Use use
instead of \
This commit is contained in:
parent
bc724f2b68
commit
39f894bd4a
5 changed files with 97 additions and 71 deletions
|
@ -1,8 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use DDDBL;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
require_once('include/datetime.php');
|
require_once('include/datetime.php');
|
||||||
|
|
||||||
$objDDDBLResultHandler = new \DDDBL\DataObjectPool('Result-Handler');
|
$objDDDBLResultHandler = new DDDBL\DataObjectPool('Result-Handler');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create handler, which returns just the PDOStatement object
|
* create handler, which returns just the PDOStatement object
|
||||||
|
@ -10,7 +14,7 @@ $objDDDBLResultHandler = new \DDDBL\DataObjectPool('Result-Handler');
|
||||||
* big result-sets
|
* big result-sets
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
$cloPDOStatementResultHandler = function(\DDDBL\Queue $objQueue) {
|
$cloPDOStatementResultHandler = function(DDDBL\Queue $objQueue) {
|
||||||
|
|
||||||
$objPDO = $objQueue->getState()->get('PDOStatement');
|
$objPDO = $objQueue->getState()->get('PDOStatement');
|
||||||
$objQueue->getState()->update(array('result' => $objPDO));
|
$objQueue->getState()->update(array('result' => $objPDO));
|
||||||
|
@ -47,7 +51,7 @@ class dba {
|
||||||
$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 DDDBL\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,10 +82,10 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +110,7 @@ class dba {
|
||||||
$strQueryAlias = md5($sql);
|
$strQueryAlias = md5($sql);
|
||||||
$strSQLType = strtoupper(strstr($sql, ' ', true));
|
$strSQLType = strtoupper(strstr($sql, ' ', true));
|
||||||
|
|
||||||
$objPreparedQueryPool = new \DDDBL\DataObjectPool('Query-Definition');
|
$objPreparedQueryPool = new DDDBL\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))
|
||||||
|
@ -121,14 +125,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();
|
||||||
}
|
}
|
||||||
|
@ -234,7 +238,7 @@ class dba {
|
||||||
|
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
if ($this->db)
|
if ($this->db)
|
||||||
\DDDBL\disconnect();
|
DDDBL\disconnect();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ use Friendica\App;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
|
|
||||||
|
use DomXPath;
|
||||||
|
use DOMDocument;
|
||||||
|
|
||||||
require_once 'include/datetime.php';
|
require_once 'include/datetime.php';
|
||||||
require_once 'include/probe.php';
|
require_once 'include/probe.php';
|
||||||
require_once 'include/network.php';
|
require_once 'include/network.php';
|
||||||
|
@ -890,9 +893,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