diff --git a/boot.php b/boot.php index 4dd781e1..1c869c39 100755 --- a/boot.php +++ b/boot.php @@ -1,5 +1,7 @@ config = array(); - $this->page = array(); - $this->pager = array(); - - $this->scheme = ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'])) ? 'https' : 'http'); - $this->hostname = str_replace('www.', '', $_SERVER['SERVER_NAME']); - set_include_path("include/$this->hostname" - . PATH_SEPARATOR . 'include' - . PATH_SEPARATOR . '.'); - - if (substr($_SERVER['QUERY_STRING'], 0, 2) == "q=") { - $_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'], 2); - } - - $this->query_string = $_SERVER['QUERY_STRING']; - - $q = isset($_GET['q']) ? $_GET['q'] : ''; - $this->cmd = trim($q, '/'); - - $this->argv = explode('/', $this->cmd); - $this->argc = count($this->argv); - if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) { - $this->module = $this->argv[0]; - } else { - $this->module = 'directory'; - } - - $this->pager['page'] = ((x($_GET, 'page')) ? $_GET['page'] : 1); - $this->pager['itemspage'] = 50; - $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; - $this->pager['total'] = 0; - } - - public function get_baseurl($ssl = false) - { - if (strlen($this->baseurl)) { - return $this->baseurl; - } - - $this->baseurl = (($ssl) ? 'https' : $this->scheme) . "://" . $this->hostname - . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : ''); - return $this->baseurl; - } - - public function set_baseurl($url) - { - $this->baseurl = $url; - $this->hostname = basename($url); - } - - public function get_hostname() - { - return $this->hostname; - } - - public function set_hostname($h) - { - $this->hostname = $h; - } - - public function set_path($p) - { - $this->path = ltrim(trim($p), '/'); - } - - public function get_path() - { - return $this->path; - } - - public function set_pager_total($n) - { - $this->pager['total'] = intval($n); - } - - public function set_pager_itemspage($n) - { - $this->pager['itemspage'] = intval($n); - $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; - } - - public function init_pagehead() - { - if (file_exists("view/head.tpl")) { - $s = file_get_contents("view/head.tpl"); - } - $this->page['htmlhead'] = replace_macros($s, array( - '$baseurl' => $this->get_baseurl() - )); - } -} - if (!function_exists('x')) { function x($s, $k = null) { diff --git a/include/cron_maintain.php b/include/cron_maintain.php index 40174024..960fe901 100644 --- a/include/cron_maintain.php +++ b/include/cron_maintain.php @@ -1,5 +1,10 @@ config['syncing']['max_push_items'])); } @@ -102,7 +104,7 @@ function get_push_batch($a) * @param object $a The App instance. * @return list($targets, $batch) A list of both the targets array and batch array. */ -function get_pushing_job($a) +function get_pushing_job(App $a) { //When pushing is requested... if (!!$a->config['syncing']['enable_pushing']) { @@ -221,7 +223,7 @@ function run_pushing_job($targets, $batch, $db_host, $db_user, $db_pass, $db_dat * @param object $a The App instance. * @return array Batch of URL's. */ -function get_queued_pull_batch($a) +function get_queued_pull_batch(App $a) { //Randomize this, to prevent scraping the same servers too much or dead URL's. $batch = q("SELECT * FROM `sync-pull-queue` ORDER BY RAND() LIMIT %u", intval($a->config['syncing']['max_pull_items'])); @@ -243,7 +245,7 @@ function get_pull_targets() * @param object $a The App instance. * @return array Batch of URL's. */ -function get_remote_pull_batch($a) +function get_remote_pull_batch(App $a) { //Find our targets. $targets = get_pull_targets(); @@ -305,7 +307,7 @@ function get_remote_pull_batch($a) * @param object $a The App instance. * @return array URL's to scrape. */ -function get_pulling_job($a) +function get_pulling_job(App $a) { //No pulling today... if (!$a->config['syncing']['enable_pulling']) { @@ -375,7 +377,7 @@ function pull_worker($i, $threadc, $pull_batch, $db_host, $db_user, $db_pass, $d * @param mixed $install Maybe a boolean. * @return void */ -function run_pulling_job($a, $pull_batch, $db_host, $db_user, $db_pass, $db_data, $install) +function run_pulling_job(App $a, $pull_batch, $db_host, $db_user, $db_pass, $db_data, $install) { //We need the scraper. require_once 'include/submit.php'; diff --git a/index.php b/index.php index e3568349..325d6208 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,9 @@ config = array(); + $this->page = array(); + $this->pager = array(); + + $this->scheme = ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'])) ? 'https' : 'http'); + $this->hostname = str_replace('www.', '', $_SERVER['SERVER_NAME']); + set_include_path(get_include_path() + . PATH_SEPARATOR . "include/$this->hostname" + . PATH_SEPARATOR . 'include' + . PATH_SEPARATOR . '.'); + + if (substr($_SERVER['QUERY_STRING'], 0, 2) == "q=") { + $_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'], 2); + } + + $this->query_string = $_SERVER['QUERY_STRING']; + + $q = isset($_GET['q']) ? $_GET['q'] : ''; + $this->cmd = trim($q, '/'); + + $this->argv = explode('/', $this->cmd); + $this->argc = count($this->argv); + if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) { + $this->module = $this->argv[0]; + } else { + $this->module = 'directory'; + } + + $this->pager['page'] = ((x($_GET, 'page')) ? $_GET['page'] : 1); + $this->pager['itemspage'] = 50; + $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; + $this->pager['total'] = 0; + } + + public function get_baseurl($ssl = false) + { + if (strlen($this->baseurl)) { + return $this->baseurl; + } + + $this->baseurl = (($ssl) ? 'https' : $this->scheme) . "://" . $this->hostname + . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : ''); + return $this->baseurl; + } + + public function set_baseurl($url) + { + $this->baseurl = $url; + $this->hostname = basename($url); + } + + public function get_hostname() + { + return $this->hostname; + } + + public function set_hostname($h) + { + $this->hostname = $h; + } + + public function set_path($p) + { + $this->path = ltrim(trim($p), '/'); + } + + public function get_path() + { + return $this->path; + } + + public function set_pager_total($n) + { + $this->pager['total'] = intval($n); + } + + public function set_pager_itemspage($n) + { + $this->pager['itemspage'] = intval($n); + $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; + } + + public function init_pagehead() + { + if (file_exists("view/head.tpl")) { + $s = file_get_contents("view/head.tpl"); + } + $this->page['htmlhead'] = replace_macros($s, array( + '$baseurl' => $this->get_baseurl() + )); + } +} \ No newline at end of file diff --git a/src/Helper/BaseHelper.php b/src/Helper/BaseHelper.php index 35fa0c47..f611feaa 100644 --- a/src/Helper/BaseHelper.php +++ b/src/Helper/BaseHelper.php @@ -2,6 +2,8 @@ namespace Friendica\Directory\Helper; +use Friendica\Directory\App; + use \OutOfBoundsException; use \ReflectionMethod; @@ -12,7 +14,7 @@ abstract class BaseHelper { /** * A reference to the global App. - * @var \App + * @var Friendica\Directory\App */ protected $app;