<?php
+use DDDBL;
+
+use Exception;
+
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
* big result-sets
*
**/
-$cloPDOStatementResultHandler = function(\DDDBL\Queue $objQueue) {
+$cloPDOStatementResultHandler = function(DDDBL\Queue $objQueue) {
$objPDO = $objQueue->getState()->get('PDOStatement');
$objQueue->getState()->update(array('result' => $objPDO));
-
+
# delete handler which closes the PDOStatement-cursor
# this will be done manual if using this handler
$objQueue->deleteHandler(QUEUE_CLOSE_CURSOR_POSITION);
*
* For debugging, insert 'dbg(1);' anywhere in the program flow.
* 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.
*
*/
-
-if (! class_exists('dba')) {
+
+if (! class_exists('dba')) {
class dba {
private $debug = 0;
function __construct($server,$user,$pass,$db,$install = false) {
$a = get_app();
-
+
# 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",
'USER' => $user,
'PASS' => $pass,
}
# etablish connection to database and store PDO object
- \DDDBL\connect();
- $this->db = \DDDBL\getDB();
-
- if (\DDDBL\isConnected()) {
+ DDDBL\connect();
+ $this->db = DDDBL\getDB();
+
+ if (DDDBL\isConnected()) {
$this->connected = true;
}
-
+
if (! $this->connected) {
$this->db = null;
if (! $install)
$a = get_app();
$strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';
-
+
$strQueryAlias = md5($sql);
$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
if (!$objPreparedQueryPool->exists($strQueryAlias))
$objPreparedQueryPool->add($strQueryAlias, array('QUERY' => $sql,
$stamp1 = microtime(true);
try {
- $r = \DDDBL\get($strQueryAlias);
-
+ $r = DDDBL\get($strQueryAlias);
+
# bad workaround to emulate the bizzare behavior of mysql_query
if (in_array($strSQLType, array('INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'SET')))
$result = true;
$intErrorCode = false;
-
- } catch (\Exception $objException) {
+
+ } catch (Exception $objException) {
$result = false;
$intErrorCode = $objPreparedQueryPool->get($strQueryAlias)->get('PDOStatement')->errorCode();
}
$mesg = 'true';
else {
# 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
if (isset($result) AND (($result === true) || ($result === false)))
return $result;
-
+
if ($onlyquery) {
$this->result = $r; # this will store an PDOStatement Object in result
$this->result->execute(); # execute the Statement, to get its result
return true;
}
-
+
//$a->save_timestamp($stamp1, "database");
if ($this->debug)
return $this->result->fetch();
}
-
+
public function qclose() {
if ($this->result)
return $this->result->closeCursor();
# 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,
# 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() {
- if ($this->db)
- \DDDBL\disconnect();
+ if ($this->db)
+ DDDBL\disconnect();
}
}}
}}
// Procedural functions
-if (! function_exists('dbg')) {
+if (! function_exists('dbg')) {
function dbg($state) {
global $db;
if ($db)
$db->dbg($state);
}}
-if (! function_exists('dbesc')) {
+if (! function_exists('dbesc')) {
function dbesc($str) {
global $db;
if ($db && $db->connected)
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
// 'user', 1);
-if (! function_exists('q')) {
+if (! function_exists('q')) {
function q($sql) {
global $db;
/**
*
- * This will happen occasionally trying to store the
- * session data after abnormal program termination
+ * This will happen occasionally trying to store the
+ * session data after abnormal program termination
*
*/
logger('dba: no database: ' . print_r($args,true));
- return false;
+ return false;
}}
*
*/
-if (! function_exists('dbq')) {
+if (! function_exists('dbq')) {
function dbq($sql) {
global $db;
}}
-// 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
-// SQL injection vectors. All integer array elements should be specifically
-// cast to int to avoid trouble.
+// SQL injection vectors. All integer array elements should be specifically
+// cast to int to avoid trouble.
if (! function_exists('dbesc_array_cb')) {
use Friendica\Core\Config;
use Friendica\Network\Probe;
+use DomXPath;
+use DOMDocument;
+
require_once 'include/datetime.php';
require_once 'include/probe.php';
require_once 'include/network.php';
function poco_detect_server_type($body) {
$server = false;
- $doc = new \DOMDocument();
+ $doc = new DOMDocument();
@$doc->loadHTML($body);
- $xpath = new \DomXPath($doc);
+ $xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@name]");
use Friendica\Core\Config;
use Friendica\Core\PConfig;
+use Cache;
+use dbm;
+
+use Detection\MobileDetect;
+
+use Exception;
+
/**
*
* class: App
}
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->pager['total'] = 0;
// Detect mobile devices
- $mobile_detect = new \Mobile_Detect();
+ $mobile_detect = new MobileDetect();
$this->is_mobile = $mobile_detect->isMobile();
$this->is_tablet = $mobile_detect->isTablet();
q('START TRANSACTION');
$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('COMMIT');
q('START TRANSACTION');
$r = q('SELECT `pid` FROM `process`');
- if (\dbm::is_result($r)) {
+ if (dbm::is_result($r)) {
foreach ($r AS $process) {
if (!posix_kill($process['pid'], 0)) {
q('DELETE FROM `process` WHERE `pid` = %d', intval($process['pid']));
}
}
- $processlist = \dbm::processlist();
+ $processlist = dbm::processlist();
if ($processlist['list'] != '') {
logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG);
// 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.
$cachekey = 'app:proc_run:started';
- $result = \Cache::get($cachekey);
+ $result = Cache::get($cachekey);
if (!is_null($result) AND ( time() - $result) < 10) {
return;
}
// 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'));
use Friendica\App;
use Friendica\Core\Config;
+use dbm;
+use Cache;
+use xml;
+
+use DomXPath;
+use DOMDocument;
+
require_once 'include/feed.php';
require_once 'include/email.php';
require_once 'include/network.php';
return false;
}
- $links = \xml::element_to_array($xrd);
+ $links = xml::element_to_array($xrd);
if (!isset($links["xrd"]["link"])) {
return false;
}
public static function uri($uri, $network = "", $uid = 0, $cache = true) {
if ($cache) {
- $result = \Cache::get("probe_url:".$network.":".$uri);
+ $result = Cache::get("probe_url:".$network.":".$uri);
if (!is_null($result)) {
return $result;
}
// Only store into the cache if the value seems to be valid
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
/// The biggest problem is the avatar picture that could have a reduced image size.
return $webfinger;
}
- $xrd_arr = \xml::element_to_array($xrd);
+ $xrd_arr = xml::element_to_array($xrd);
if (!isset($xrd_arr["xrd"]["link"])) {
return false;
}
return false;
}
- $doc = new \DOMDocument();
+ $doc = new DOMDocument();
if (!@$doc->loadHTML($content)) {
return false;
}
- $xpath = new \DomXPath($doc);
+ $xpath = new DomXPath($doc);
$vcards = $xpath->query("//div[contains(concat(' ', @class, ' '), ' vcard ')]");
if (!is_object($vcards)) {
*/
private function pumpioProfileData($profile_link) {
- $doc = new \DOMDocument();
+ $doc = new DOMDocument();
if (!@$doc->loadHTMLFile($profile_link)) {
return false;
}
- $xpath = new \DomXPath($doc);
+ $xpath = new DomXPath($doc);
$data = array();
* @return string feed link
*/
private function getFeedLink($url) {
- $doc = new \DOMDocument();
+ $doc = new DOMDocument();
if (!@$doc->loadHTMLFile($url)) {
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' and @rel='alternate']");
$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]);
$password = '';
openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
use Friendica\Core\Config;
+use xml;
+
+use DomXPath;
+use DOMDocument;
+
require_once("include/network.php");
require_once("include/Photo.php");
require_once("include/oembed.php");
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
- $doc = new \DOMDocument();
+ $doc = new DOMDocument();
@$doc->loadHTML($body);
- \xml::deleteNode($doc, "style");
- \xml::deleteNode($doc, "script");
- \xml::deleteNode($doc, "option");
- \xml::deleteNode($doc, "h1");
- \xml::deleteNode($doc, "h2");
- \xml::deleteNode($doc, "h3");
- \xml::deleteNode($doc, "h4");
- \xml::deleteNode($doc, "h5");
- \xml::deleteNode($doc, "h6");
- \xml::deleteNode($doc, "ol");
- \xml::deleteNode($doc, "ul");
-
- $xpath = new \DomXPath($doc);
+ xml::deleteNode($doc, "style");
+ xml::deleteNode($doc, "script");
+ xml::deleteNode($doc, "option");
+ xml::deleteNode($doc, "h1");
+ xml::deleteNode($doc, "h2");
+ xml::deleteNode($doc, "h3");
+ xml::deleteNode($doc, "h4");
+ xml::deleteNode($doc, "h5");
+ xml::deleteNode($doc, "h6");
+ xml::deleteNode($doc, "ol");
+ xml::deleteNode($doc, "ul");
+
+ $xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@content]");
foreach ($list as $node) {