Merge pull request #3459 from Hypolite/improvement/class-autoloading-use
Use `use` instead of `\`
This commit is contained in:
commit
abc924bc8f
|
@ -1,8 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use DDDBL\DataObjectPool;
|
||||||
|
use DDDBL\Queue;
|
||||||
|
|
||||||
require_once('include/datetime.php');
|
require_once('include/datetime.php');
|
||||||
|
|
||||||
$objDDDBLResultHandler = new \DDDBL\DataObjectPool('Result-Handler');
|
$objDDDBLResultHandler = new DataObjectPool('Result-Handler');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create handler, which returns just the PDOStatement object
|
* create handler, which returns just the PDOStatement object
|
||||||
|
@ -10,11 +13,11 @@ $objDDDBLResultHandler = new \DDDBL\DataObjectPool('Result-Handler');
|
||||||
* big result-sets
|
* big result-sets
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
$cloPDOStatementResultHandler = function(\DDDBL\Queue $objQueue) {
|
$cloPDOStatementResultHandler = function(Queue $objQueue) {
|
||||||
|
|
||||||
$objPDO = $objQueue->getState()->get('PDOStatement');
|
$objPDO = $objQueue->getState()->get('PDOStatement');
|
||||||
$objQueue->getState()->update(array('result' => $objPDO));
|
$objQueue->getState()->update(array('result' => $objPDO));
|
||||||
|
|
||||||
# delete handler which closes the PDOStatement-cursor
|
# delete handler which closes the PDOStatement-cursor
|
||||||
# this will be done manual if using this handler
|
# this will be done manual if using this handler
|
||||||
$objQueue->deleteHandler(QUEUE_CLOSE_CURSOR_POSITION);
|
$objQueue->deleteHandler(QUEUE_CLOSE_CURSOR_POSITION);
|
||||||
|
@ -29,12 +32,12 @@ $objDDDBLResultHandler->add('PDOStatement', array('HANDLER' => $cloPDOStatementR
|
||||||
*
|
*
|
||||||
* For debugging, insert 'dbg(1);' anywhere in the program flow.
|
* For debugging, insert 'dbg(1);' anywhere in the program flow.
|
||||||
* dbg(0); will turn it off. Logging is performed at LOGGER_DATA level.
|
* dbg(0); will turn it off. Logging is performed at LOGGER_DATA level.
|
||||||
* When logging, all binary info is converted to text and html entities are escaped so that
|
* When logging, all binary info is converted to text and html entities are escaped so that
|
||||||
* the debugging stream is safe to view within both terminals and web pages.
|
* the debugging stream is safe to view within both terminals and web pages.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! class_exists('dba')) {
|
if (! class_exists('dba')) {
|
||||||
class dba {
|
class dba {
|
||||||
|
|
||||||
private $debug = 0;
|
private $debug = 0;
|
||||||
|
@ -45,9 +48,9 @@ class dba {
|
||||||
|
|
||||||
function __construct($server,$user,$pass,$db,$install = false) {
|
function __construct($server,$user,$pass,$db,$install = false) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
# work around, to store the database - configuration in DDDBL
|
# work around, to store the database - configuration in DDDBL
|
||||||
$objDataObjectPool = new \DDDBL\DataObjectPool('Database-Definition');
|
$objDataObjectPool = new DataObjectPool('Database-Definition');
|
||||||
$objDataObjectPool->add('DEFAULT', array('CONNECTION' => "mysql:host=$server;dbname=$db",
|
$objDataObjectPool->add('DEFAULT', array('CONNECTION' => "mysql:host=$server;dbname=$db",
|
||||||
'USER' => $user,
|
'USER' => $user,
|
||||||
'PASS' => $pass,
|
'PASS' => $pass,
|
||||||
|
@ -78,13 +81,13 @@ class dba {
|
||||||
}
|
}
|
||||||
|
|
||||||
# etablish connection to database and store PDO object
|
# etablish connection to database and store PDO object
|
||||||
\DDDBL\connect();
|
DDDBL\connect();
|
||||||
$this->db = \DDDBL\getDB();
|
$this->db = DDDBL\getDB();
|
||||||
|
|
||||||
if (\DDDBL\isConnected()) {
|
if (DDDBL\isConnected()) {
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->connected) {
|
if (! $this->connected) {
|
||||||
$this->db = null;
|
$this->db = null;
|
||||||
if (! $install)
|
if (! $install)
|
||||||
|
@ -102,12 +105,12 @@ class dba {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';
|
$strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';
|
||||||
|
|
||||||
$strQueryAlias = md5($sql);
|
$strQueryAlias = md5($sql);
|
||||||
$strSQLType = strtoupper(strstr($sql, ' ', true));
|
$strSQLType = strtoupper(strstr($sql, ' ', true));
|
||||||
|
|
||||||
$objPreparedQueryPool = new \DDDBL\DataObjectPool('Query-Definition');
|
$objPreparedQueryPool = new DataObjectPool('Query-Definition');
|
||||||
|
|
||||||
# check if query do not exists till now, if so create its definition
|
# check if query do not exists till now, if so create its definition
|
||||||
if (!$objPreparedQueryPool->exists($strQueryAlias))
|
if (!$objPreparedQueryPool->exists($strQueryAlias))
|
||||||
$objPreparedQueryPool->add($strQueryAlias, array('QUERY' => $sql,
|
$objPreparedQueryPool->add($strQueryAlias, array('QUERY' => $sql,
|
||||||
|
@ -121,14 +124,14 @@ class dba {
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$r = \DDDBL\get($strQueryAlias);
|
$r = DDDBL\get($strQueryAlias);
|
||||||
|
|
||||||
# bad workaround to emulate the bizzare behavior of mysql_query
|
# bad workaround to emulate the bizzare behavior of mysql_query
|
||||||
if (in_array($strSQLType, array('INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'SET')))
|
if (in_array($strSQLType, array('INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'SET')))
|
||||||
$result = true;
|
$result = true;
|
||||||
$intErrorCode = false;
|
$intErrorCode = false;
|
||||||
|
|
||||||
} catch (\Exception $objException) {
|
} catch (Exception $objException) {
|
||||||
$result = false;
|
$result = false;
|
||||||
$intErrorCode = $objPreparedQueryPool->get($strQueryAlias)->get('PDOStatement')->errorCode();
|
$intErrorCode = $objPreparedQueryPool->get($strQueryAlias)->get('PDOStatement')->errorCode();
|
||||||
}
|
}
|
||||||
|
@ -166,7 +169,7 @@ class dba {
|
||||||
$mesg = 'true';
|
$mesg = 'true';
|
||||||
else {
|
else {
|
||||||
# this needs fixing, but is a bug itself
|
# this needs fixing, but is a bug itself
|
||||||
#$mesg = mysql_num_rows($result) . ' results' . EOL;
|
#$mesg = mysql_num_rows($result) . ' results' . EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg
|
$str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg
|
||||||
|
@ -190,13 +193,13 @@ class dba {
|
||||||
|
|
||||||
if (isset($result) AND (($result === true) || ($result === false)))
|
if (isset($result) AND (($result === true) || ($result === false)))
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
if ($onlyquery) {
|
if ($onlyquery) {
|
||||||
$this->result = $r; # this will store an PDOStatement Object in result
|
$this->result = $r; # this will store an PDOStatement Object in result
|
||||||
$this->result->execute(); # execute the Statement, to get its result
|
$this->result->execute(); # execute the Statement, to get its result
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$a->save_timestamp($stamp1, "database");
|
//$a->save_timestamp($stamp1, "database");
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
|
@ -212,7 +215,7 @@ class dba {
|
||||||
return $this->result->fetch();
|
return $this->result->fetch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function qclose() {
|
public function qclose() {
|
||||||
if ($this->result)
|
if ($this->result)
|
||||||
return $this->result->closeCursor();
|
return $this->result->closeCursor();
|
||||||
|
@ -228,13 +231,13 @@ class dba {
|
||||||
# this workaround is needed, because quote creates "'" and the beginning and the end
|
# this workaround is needed, because quote creates "'" and the beginning and the end
|
||||||
# of the string, which is correct. but until now the queries set this delimiter manually,
|
# of the string, which is correct. but until now the queries set this delimiter manually,
|
||||||
# so we must remove them from here and wait until everything uses prepared statements
|
# so we must remove them from here and wait until everything uses prepared statements
|
||||||
return mb_substr($strQuoted, 1, mb_strlen($strQuoted) - 2);
|
return mb_substr($strQuoted, 1, mb_strlen($strQuoted) - 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
if ($this->db)
|
if ($this->db)
|
||||||
\DDDBL\disconnect();
|
DDDBL\disconnect();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -248,14 +251,14 @@ function printable($s) {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// Procedural functions
|
// Procedural functions
|
||||||
if (! function_exists('dbg')) {
|
if (! function_exists('dbg')) {
|
||||||
function dbg($state) {
|
function dbg($state) {
|
||||||
global $db;
|
global $db;
|
||||||
if ($db)
|
if ($db)
|
||||||
$db->dbg($state);
|
$db->dbg($state);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
if (! function_exists('dbesc')) {
|
if (! function_exists('dbesc')) {
|
||||||
function dbesc($str) {
|
function dbesc($str) {
|
||||||
global $db;
|
global $db;
|
||||||
if ($db && $db->connected)
|
if ($db && $db->connected)
|
||||||
|
@ -271,7 +274,7 @@ function dbesc($str) {
|
||||||
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
|
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
|
||||||
// 'user', 1);
|
// 'user', 1);
|
||||||
|
|
||||||
if (! function_exists('q')) {
|
if (! function_exists('q')) {
|
||||||
function q($sql) {
|
function q($sql) {
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -288,12 +291,12 @@ function q($sql) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This will happen occasionally trying to store the
|
* This will happen occasionally trying to store the
|
||||||
* session data after abnormal program termination
|
* session data after abnormal program termination
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
logger('dba: no database: ' . print_r($args,true));
|
logger('dba: no database: ' . print_r($args,true));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -303,7 +306,7 @@ function q($sql) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! function_exists('dbq')) {
|
if (! function_exists('dbq')) {
|
||||||
function dbq($sql) {
|
function dbq($sql) {
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -315,10 +318,10 @@ function dbq($sql) {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
// Caller is responsible for ensuring that any integer arguments to
|
// Caller is responsible for ensuring that any integer arguments to
|
||||||
// dbesc_array are actually integers and not malformed strings containing
|
// dbesc_array are actually integers and not malformed strings containing
|
||||||
// SQL injection vectors. All integer array elements should be specifically
|
// SQL injection vectors. All integer array elements should be specifically
|
||||||
// cast to int to avoid trouble.
|
// cast to int to avoid trouble.
|
||||||
|
|
||||||
|
|
||||||
if (! function_exists('dbesc_array_cb')) {
|
if (! function_exists('dbesc_array_cb')) {
|
||||||
|
|
|
@ -890,9 +890,9 @@ function poco_fetch_nodeinfo($server_url) {
|
||||||
function poco_detect_server_type($body) {
|
function poco_detect_server_type($body) {
|
||||||
$server = false;
|
$server = false;
|
||||||
|
|
||||||
$doc = new \DOMDocument();
|
$doc = new DOMDocument();
|
||||||
@$doc->loadHTML($body);
|
@$doc->loadHTML($body);
|
||||||
$xpath = new \DomXPath($doc);
|
$xpath = new DomXPath($doc);
|
||||||
|
|
||||||
$list = $xpath->query("//meta[@name]");
|
$list = $xpath->query("//meta[@name]");
|
||||||
|
|
||||||
|
|
21
src/App.php
21
src/App.php
|
@ -5,6 +5,13 @@ namespace Friendica;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
|
||||||
|
use Cache;
|
||||||
|
use dbm;
|
||||||
|
|
||||||
|
use Detection\MobileDetect;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* class: App
|
* class: App
|
||||||
|
@ -192,7 +199,7 @@ class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! static::directory_usable($basepath, false)) {
|
if (! static::directory_usable($basepath, false)) {
|
||||||
throw new \Exception('Basepath ' . $basepath . ' isn\'t usable.');
|
throw new Exception('Basepath ' . $basepath . ' isn\'t usable.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR);
|
$this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR);
|
||||||
|
@ -276,7 +283,7 @@ class App {
|
||||||
$this->pager['total'] = 0;
|
$this->pager['total'] = 0;
|
||||||
|
|
||||||
// Detect mobile devices
|
// Detect mobile devices
|
||||||
$mobile_detect = new \Mobile_Detect();
|
$mobile_detect = new MobileDetect();
|
||||||
$this->is_mobile = $mobile_detect->isMobile();
|
$this->is_mobile = $mobile_detect->isMobile();
|
||||||
$this->is_tablet = $mobile_detect->isTablet();
|
$this->is_tablet = $mobile_detect->isTablet();
|
||||||
|
|
||||||
|
@ -687,7 +694,7 @@ class App {
|
||||||
q('START TRANSACTION');
|
q('START TRANSACTION');
|
||||||
|
|
||||||
$r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
|
$r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
|
||||||
if (!\dbm::is_result($r)) {
|
if (!dbm::is_result($r)) {
|
||||||
q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')", intval(getmypid()), dbesc($command), dbesc(datetime_convert()));
|
q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')", intval(getmypid()), dbesc($command), dbesc(datetime_convert()));
|
||||||
}
|
}
|
||||||
q('COMMIT');
|
q('COMMIT');
|
||||||
|
@ -700,7 +707,7 @@ class App {
|
||||||
q('START TRANSACTION');
|
q('START TRANSACTION');
|
||||||
|
|
||||||
$r = q('SELECT `pid` FROM `process`');
|
$r = q('SELECT `pid` FROM `process`');
|
||||||
if (\dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r AS $process) {
|
foreach ($r AS $process) {
|
||||||
if (!posix_kill($process['pid'], 0)) {
|
if (!posix_kill($process['pid'], 0)) {
|
||||||
q('DELETE FROM `process` WHERE `pid` = %d', intval($process['pid']));
|
q('DELETE FROM `process` WHERE `pid` = %d', intval($process['pid']));
|
||||||
|
@ -805,7 +812,7 @@ class App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$processlist = \dbm::processlist();
|
$processlist = dbm::processlist();
|
||||||
if ($processlist['list'] != '') {
|
if ($processlist['list'] != '') {
|
||||||
logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG);
|
logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG);
|
||||||
|
|
||||||
|
@ -896,14 +903,14 @@ class App {
|
||||||
// If the last worker fork was less than 10 seconds before then don't fork another one.
|
// If the last worker fork was less than 10 seconds before then don't fork another one.
|
||||||
// This should prevent the forking of masses of workers.
|
// This should prevent the forking of masses of workers.
|
||||||
$cachekey = 'app:proc_run:started';
|
$cachekey = 'app:proc_run:started';
|
||||||
$result = \Cache::get($cachekey);
|
$result = Cache::get($cachekey);
|
||||||
|
|
||||||
if (!is_null($result) AND ( time() - $result) < 10) {
|
if (!is_null($result) AND ( time() - $result) < 10) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the timestamp of the last proc_run
|
// Set the timestamp of the last proc_run
|
||||||
\Cache::set($cachekey, time(), CACHE_MINUTE);
|
Cache::set($cachekey, time(), CACHE_MINUTE);
|
||||||
|
|
||||||
array_unshift($args, ((x($this->config, 'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));
|
array_unshift($args, ((x($this->config, 'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,13 @@ namespace Friendica\Network;
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
|
use dbm;
|
||||||
|
use Cache;
|
||||||
|
use xml;
|
||||||
|
|
||||||
|
use DomXPath;
|
||||||
|
use DOMDocument;
|
||||||
|
|
||||||
require_once 'include/feed.php';
|
require_once 'include/feed.php';
|
||||||
require_once 'include/email.php';
|
require_once 'include/email.php';
|
||||||
require_once 'include/network.php';
|
require_once 'include/network.php';
|
||||||
|
@ -92,7 +99,7 @@ class Probe {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$links = \xml::element_to_array($xrd);
|
$links = xml::element_to_array($xrd);
|
||||||
if (!isset($links["xrd"]["link"])) {
|
if (!isset($links["xrd"]["link"])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +282,7 @@ class Probe {
|
||||||
public static function uri($uri, $network = "", $uid = 0, $cache = true) {
|
public static function uri($uri, $network = "", $uid = 0, $cache = true) {
|
||||||
|
|
||||||
if ($cache) {
|
if ($cache) {
|
||||||
$result = \Cache::get("probe_url:".$network.":".$uri);
|
$result = Cache::get("probe_url:".$network.":".$uri);
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -327,7 +334,7 @@ class Probe {
|
||||||
|
|
||||||
// Only store into the cache if the value seems to be valid
|
// Only store into the cache if the value seems to be valid
|
||||||
if (!in_array($data['network'], array(NETWORK_PHANTOM, NETWORK_MAIL))) {
|
if (!in_array($data['network'], array(NETWORK_PHANTOM, NETWORK_MAIL))) {
|
||||||
\Cache::set("probe_url:".$network.":".$uri, $data, CACHE_DAY);
|
Cache::set("probe_url:".$network.":".$uri, $data, CACHE_DAY);
|
||||||
|
|
||||||
/// @todo temporary fix - we need a real contact update function that updates only changing fields
|
/// @todo temporary fix - we need a real contact update function that updates only changing fields
|
||||||
/// The biggest problem is the avatar picture that could have a reduced image size.
|
/// The biggest problem is the avatar picture that could have a reduced image size.
|
||||||
|
@ -543,7 +550,7 @@ class Probe {
|
||||||
return $webfinger;
|
return $webfinger;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xrd_arr = \xml::element_to_array($xrd);
|
$xrd_arr = xml::element_to_array($xrd);
|
||||||
if (!isset($xrd_arr["xrd"]["link"])) {
|
if (!isset($xrd_arr["xrd"]["link"])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -811,12 +818,12 @@ class Probe {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$doc = new \DOMDocument();
|
$doc = new DOMDocument();
|
||||||
if (!@$doc->loadHTML($content)) {
|
if (!@$doc->loadHTML($content)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xpath = new \DomXPath($doc);
|
$xpath = new DomXPath($doc);
|
||||||
|
|
||||||
$vcards = $xpath->query("//div[contains(concat(' ', @class, ' '), ' vcard ')]");
|
$vcards = $xpath->query("//div[contains(concat(' ', @class, ' '), ' vcard ')]");
|
||||||
if (!is_object($vcards)) {
|
if (!is_object($vcards)) {
|
||||||
|
@ -1099,12 +1106,12 @@ class Probe {
|
||||||
*/
|
*/
|
||||||
private function pumpioProfileData($profile_link) {
|
private function pumpioProfileData($profile_link) {
|
||||||
|
|
||||||
$doc = new \DOMDocument();
|
$doc = new DOMDocument();
|
||||||
if (!@$doc->loadHTMLFile($profile_link)) {
|
if (!@$doc->loadHTMLFile($profile_link)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xpath = new \DomXPath($doc);
|
$xpath = new DomXPath($doc);
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
|
@ -1186,13 +1193,13 @@ class Probe {
|
||||||
* @return string feed link
|
* @return string feed link
|
||||||
*/
|
*/
|
||||||
private function getFeedLink($url) {
|
private function getFeedLink($url) {
|
||||||
$doc = new \DOMDocument();
|
$doc = new DOMDocument();
|
||||||
|
|
||||||
if (!@$doc->loadHTMLFile($url)) {
|
if (!@$doc->loadHTMLFile($url)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xpath = new \DomXPath($doc);
|
$xpath = new DomXPath($doc);
|
||||||
|
|
||||||
//$feeds = $xpath->query("/html/head/link[@type='application/rss+xml']");
|
//$feeds = $xpath->query("/html/head/link[@type='application/rss+xml']");
|
||||||
$feeds = $xpath->query("/html/head/link[@type='application/rss+xml' and @rel='alternate']");
|
$feeds = $xpath->query("/html/head/link[@type='application/rss+xml' and @rel='alternate']");
|
||||||
|
@ -1298,7 +1305,7 @@ class Probe {
|
||||||
|
|
||||||
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
|
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
|
||||||
|
|
||||||
if (\dbm::is_result($x) && \dbm::is_result($r)) {
|
if (dbm::is_result($x) && dbm::is_result($r)) {
|
||||||
$mailbox = construct_mailbox_name($r[0]);
|
$mailbox = construct_mailbox_name($r[0]);
|
||||||
$password = '';
|
$password = '';
|
||||||
openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
|
openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
|
||||||
|
|
|
@ -9,6 +9,11 @@ namespace Friendica;
|
||||||
|
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
|
use xml;
|
||||||
|
|
||||||
|
use DomXPath;
|
||||||
|
use DOMDocument;
|
||||||
|
|
||||||
require_once("include/network.php");
|
require_once("include/network.php");
|
||||||
require_once("include/Photo.php");
|
require_once("include/Photo.php");
|
||||||
require_once("include/oembed.php");
|
require_once("include/oembed.php");
|
||||||
|
@ -223,22 +228,22 @@ class ParseUrl {
|
||||||
|
|
||||||
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
|
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
|
||||||
|
|
||||||
$doc = new \DOMDocument();
|
$doc = new DOMDocument();
|
||||||
@$doc->loadHTML($body);
|
@$doc->loadHTML($body);
|
||||||
|
|
||||||
\xml::deleteNode($doc, "style");
|
xml::deleteNode($doc, "style");
|
||||||
\xml::deleteNode($doc, "script");
|
xml::deleteNode($doc, "script");
|
||||||
\xml::deleteNode($doc, "option");
|
xml::deleteNode($doc, "option");
|
||||||
\xml::deleteNode($doc, "h1");
|
xml::deleteNode($doc, "h1");
|
||||||
\xml::deleteNode($doc, "h2");
|
xml::deleteNode($doc, "h2");
|
||||||
\xml::deleteNode($doc, "h3");
|
xml::deleteNode($doc, "h3");
|
||||||
\xml::deleteNode($doc, "h4");
|
xml::deleteNode($doc, "h4");
|
||||||
\xml::deleteNode($doc, "h5");
|
xml::deleteNode($doc, "h5");
|
||||||
\xml::deleteNode($doc, "h6");
|
xml::deleteNode($doc, "h6");
|
||||||
\xml::deleteNode($doc, "ol");
|
xml::deleteNode($doc, "ol");
|
||||||
\xml::deleteNode($doc, "ul");
|
xml::deleteNode($doc, "ul");
|
||||||
|
|
||||||
$xpath = new \DomXPath($doc);
|
$xpath = new DomXPath($doc);
|
||||||
|
|
||||||
$list = $xpath->query("//meta[@content]");
|
$list = $xpath->query("//meta[@content]");
|
||||||
foreach ($list as $node) {
|
foreach ($list as $node) {
|
||||||
|
|
Loading…
Reference in a new issue