Пример #1
1
 public function setUp()
 {
     $this->app = Pagon::create(array('cache' => array('user' => array('type' => 'file'))));
     ob_start();
     $this->app->run();
     ob_end_clean();
 }
Пример #2
1
function expire_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    require_once 'library/simplepie/simplepie.inc';
    require_once 'include/items.php';
    require_once 'include/Contact.php';
    load_config('config');
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    logger('expire: start');
    $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
    if (count($r)) {
        foreach ($r as $rr) {
            logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
            item_expire($rr['uid'], $rr['expire']);
        }
    }
    return;
}
Пример #3
1
function expire_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    require_once 'library/simplepie/simplepie.inc';
    require_once 'include/items.php';
    require_once 'include/Contact.php';
    load_config('config');
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    // physically remove anything that has been deleted for more than two months
    $r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
    q("optimize table item");
    logger('expire: start');
    $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
    if (count($r)) {
        foreach ($r as $rr) {
            logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
            item_expire($rr['uid'], $rr['expire']);
        }
    }
    return;
}
Пример #4
1
function gprobe_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    load_config('config');
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    load_hooks();
    if ($argc != 2) {
        return;
    }
    $url = hex2bin($argv[1]);
    $r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
    if (!count($r)) {
        $arr = probe_url($url);
        if (count($arr) && x($arr, 'network') && $arr['network'] === NETWORK_DFRN) {
            q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)\n\t\t\t\tvalues ( '%s', '%s', '%s', '%s') ", dbesc($arr['name']), dbesc($arr['url']), dbesc(normalise_link($arr['url'])), dbesc($arr['photo']));
        }
        $r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
    }
    if (count($r)) {
        poco_load(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
    }
    return;
}
Пример #5
1
 public static function smstorage_parseMessages($data)
 {
     $emoji = new App();
     foreach ($data['messages'] as $message) {
         $message->body = $emoji->any_to_html($message->body);
     }
 }
Пример #6
1
 /**
  * The route method calls a specefic controller
  * then apply the action and passing the arguments passed in URL
  * @param App $app
  * @return mixte 
  */
 public function route(App $app)
 {
     $urls = $this->cleanUrl();
     $controller = !empty($urls) ? array_shift($urls) : 'index';
     $action = !empty($urls) ? array_shift($urls) : '';
     $params = !empty($urls) ? $urls : '';
     if ($controller === 'index') {
         return $app->controller->index();
     } else {
         if ($app->exists($app->{$controller})) {
             if ($action !== '') {
                 if (method_exists($app->{$controller}, $action)) {
                     call_user_func_array([$app->{$controller}, $action], [$params]);
                     return;
                 } else {
                     return $app->controller->e404();
                 }
             } else {
                 return $app->{$controller}->index();
             }
         } else {
             return $app->controller->e404();
         }
     }
 }
Пример #7
1
function directory_run(&$argv, &$argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "include/dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    load_config('config');
    load_config('system');
    if ($argc != 2) {
        return;
    }
    load_config('system');
    load_hooks();
    $a->set_baseurl(get_config('system', 'url'));
    $dir = get_config('system', 'directory_submit_url');
    if (!strlen($dir)) {
        return;
    }
    $arr = array('url' => $argv[1]);
    call_hooks('globaldir_update', $arr);
    logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
    if (strlen($arr['url'])) {
        fetch_url($dir . '?url=' . bin2hex($arr['url']));
    }
    return;
}
Пример #8
1
function getAppDetails($appID, $connection)
{
    $appQuerySQL = "SELECT id, appID, averageUserRating, currency";
    $appQuerySQL .= ", price, releaseDate, sellerName, sellerURL";
    $appQuerySQL .= ", userRatingCount, version";
    $appQuerySQL .= " FROM craft_demo.`app`";
    $appQuerySQL .= " WHERE appID = '" . $appID . "';";
    $appResult = $connection->query($appQuerySQL);
    $app = null;
    $rating_floor = 4;
    if ($row = $appResult->fetch_assoc()) {
        $app = new App($appID, $row['averageUserRating'], $row['userRatingCount'], $row['currency'], $row['price'], $row['sellerName'], $row['releaseDate']);
        if ($row['version']) {
            $app->setVersion($row['version']);
        }
        if ($row['sellerURL']) {
            $app->setSellerUrl($row['sellerURL']);
        }
        $reviews = array();
        $reviewQuerySQL = "SELECT author, title, content, rating";
        $reviewQuerySQL .= " FROM craft_demo.`reviews`";
        $reviewQuerySQL .= " WHERE app_id = " . $row['id'];
        $reviewQuerySQL .= " AND rating > " . $rating_floor . ";";
        $reviewResult = $connection->query($reviewQuerySQL);
        while ($reviewRow = $reviewResult->fetch_assoc()) {
            $review = new Review($reviewRow['author'], $reviewRow['title'], $reviewRow['content'], $reviewRow['rating']);
            $reviews[] = $review;
        }
        $app->setReviews($reviews);
    }
    return $app;
}
Пример #9
1
 public function testPaserInput()
 {
     $input = '7:ABCDEFGabcdfXYZ';
     $test = $this->obj->parseInput($input);
     $expected = ['seatCount' => 7, 'queueStr' => 'ABCDEFGabcdfXYZ'];
     $this->assertEquals($expected, $test);
 }
Пример #10
1
function directory_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    load_config('config');
    load_config('system');
    if ($argc != 2) {
        return;
    }
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    $dir = get_config('system', 'directory_submit_url');
    if (!strlen($dir)) {
        return;
    }
    fetch_url($dir . '?url=' . bin2hex($argv[1]));
    return;
}
Пример #11
1
 /**
  * @param App $app
  */
 public function __construct($app)
 {
     $this->commandConfig = $app->getCommandConfig();
     if ($this->commandConfig->isMultipleCommandMode()) {
         $this->subcommandName = $app->getSubcommandName();
     }
 }
Пример #12
0
 function getAdv_list($params)
 {
     $getOption = strip_tags(JRequest::getVar('option'));
     $app = new App();
     $getAdvs = $app->getAdv();
     $getUrl = JURI::base();
     if (strpos($getUrl, 'local') !== false) {
         $prefix = 'local_';
     } elseif (strpos($getUrl, 'staging2') !== false) {
         $prefix = 'staging_';
     } elseif (strpos($getUrl, 'live') !== false) {
         $prefix = '';
     } else {
         $prefix = '';
     }
     if ($params->get("layout") == "_:default") {
         if ($getOption == "com_video" || $getOption == "com_gallery") {
             return $getAdvs[$prefix . 'gpt_adv_id_gallery_video'];
         }
         return $getAdvs[$prefix . 'gpt_adv_id_topbanner'];
     } elseif ($params->get("layout") == "_:right") {
         if ($getOption == "com_video" || $getOption == "com_gallery") {
             return $getAdvs[$prefix . 'gpt_adv_id_gallery'];
         }
         return $getAdvs[$prefix . 'gpt_adv_id_right'];
     }
 }
 public function __construct()
 {
     $this->app = App::getInstance();
     $this->view = View::getInstance();
     $this->config = $this->app->getConfig();
     $this->input = InputData::getInstance();
 }
Пример #14
0
function change_theme($job)
{
    $json = $job->workload();
    $data = json_decode($json, true);
    $app = new App($data['token']);
    $app->themeWorker($data);
}
Пример #15
0
function main()
{
    $app = new App();
    $app->bootstrap();
    $app->setupErrorHandling();
    $app->dispatch();
}
Пример #16
0
 /**
  * Returns the raw xargs call as a string
  *
  * @return string
  */
 public function getRaw()
 {
     $args = '';
     foreach ($this->args as $arg) {
         $args = sprintf('%s %s', $args, $arg->getRaw());
     }
     return sprintf('%s | %s %s %s', $this->app1->getRaw(), $this->name, $args, $this->app2->getRaw());
 }
Пример #17
0
 public function testRenderWithStatusCode()
 {
     $mock = $this->getMock('View\\TemplateEngineInterface');
     $mock->expects($this->once())->method('render')->will($this->returnValue('Heya'));
     $app = new \App($mock);
     $this->assertEquals('Heya', $app->render('a/template.php', array(), 201));
     $this->assertEquals(201, $this->readStatusCode($app));
 }
Пример #18
0
 public function makeModel()
 {
     $model = $this->_app->getFacadeApplication()->make($this->model());
     if (!$model instanceof Model) {
         throw new \Exception("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model");
     }
     return $this->model = $model;
 }
Пример #19
0
 /**
  * @return callable|mixed|null|object
  */
 function __invoke()
 {
     try {
         return $this->app->call(Arg::WEB);
     } catch (\Exception $exception) {
         return $this->app->call(Arg::EXCEPTION_RESPONSE, [Arg::EXCEPTION => $exception]);
     }
 }
Пример #20
0
 public function __construct(App $app)
 {
     $this->app = $app;
     $dbConfig = $app->getConfig()['db'];
     $provider = strtolower($dbConfig['provider']);
     $provider[0] = strtoupper($provider[0]);
     $connectionClass = __NAMESPACE__ . '\\' . $provider . 'Connection';
     $this->conn = new $connectionClass($dbConfig['host'], $dbConfig['user'], $dbConfig['password'], $dbConfig['name']);
 }
Пример #21
0
 /**
  * Register the GitHub class.
  *
  * @param  App  $app
  * @return null
  */
 protected function registerGithub($app)
 {
     $app->singleton('github', function ($app) {
         $config = $app['config'];
         $factory = $app['github.factory'];
         return new Github($config, $factory);
     });
     $app->alias('github', 'Caffeinated\\Github\\Github');
 }
Пример #22
0
 /**
  * Build an api client
  * @param sring $endpoint
  * @param string $username
  * @param string $password
  * @param string $cacheDirectory
  */
 public static function start($endpoint, $username, $password, $cacheDirectory)
 {
     if (self::$app == null) {
         self::$app = new self();
         self::$app->setAuth($username, $password)->setEndpoint($endpoint)->setCacheDirectory($cacheDirectory);
         self::$app->client->authorize();
     }
     return self::$app;
 }
Пример #23
0
 public function testStringEscape()
 {
     // Arrange
     $app = new App();
     $string = "<a>some string</a>";
     // Act
     $result = $app->escape($string);
     // Assert
     $this->assertEquals("&lt;a&gt;some string&lt;/a&gt;", $result);
 }
Пример #24
0
 /**
  * Make an HTTP request.
  *
  * @param string       $url
  * @param string|array $content
  * @param array        $headers
  * @param string       $method
  *
  * @return string
  */
 public function makeRequest($url, $content = null, $headers = [], $method = 'GET')
 {
     $context_options = array_replace_recursive($this->contextOptionDefaults, ['http' => ['method' => $method, 'header' => $headers, 'content' => $content]]);
     $this->app->debug('Sending report to {url}: {context_options}', compact('url', 'context_options'));
     $response = file_get_contents($url, false, stream_context_create($context_options));
     $this->app->debug('Response from {url}: {response} [headers: {headers}]', ['url' => $url, 'response' => $response, 'headers' => $http_response_header]);
     $http_header = $http_response_header[0];
     Ensure::matches('#HTTP/\\d+\\.\\d+\\s+2\\d{2}#Ai', $http_header, sprintf('Bad response from server: "%s"', $http_header));
     return $response;
 }
Пример #25
0
 /**
  * @return Model
  */
 public function get()
 {
     $class = $this->meta['targetClass'];
     $id = $this->meta['mappedByValue'];
     $em = $this->app->getEntityManager($class);
     $r = new \ReflectionProperty(get_class($this->context), $this->meta['property']);
     $r->setAccessible(true);
     $model = $em->find($id);
     $r->setValue($this->context, $model);
     return $model;
 }
Пример #26
0
 public function show()
 {
     include_once "views/app.php";
     $app = new App();
     $result = $app->show();
     $this->user = unserialize($_SESSION["user"]);
     $this->vars = array();
     $this->vars["user"] = $this->user;
     $this->vars["result"] = $result;
     AppView::show($this->vars);
 }
Пример #27
0
 public static function run()
 {
     Bootstrap::setup();
     $app = new App();
     if (Util::has_request_param("action")) {
         $api = new Api($app);
         $api->apply();
     } else {
         define("FALLBACK", $app->get_fallback());
         normalized_require_once("page");
     }
 }
Пример #28
0
 /**
  *	Bootstrap
  *	@return NULL
  **/
 public static function execute()
 {
     if (file_exists('vendor/autoload.php')) {
         require 'vendor/autoload.php';
     }
     $fw = new App();
     if (!file_exists('index.php')) {
         $fw->error(self::E_Index);
     } else {
         require 'index.php';
     }
     $fw->run();
 }
Пример #29
0
 public function testCorrectReader()
 {
     require_once __DIR__ . '/D/CorrectReader.php';
     $throwException = false;
     try {
         new App(new CorrectReader());
     } catch (Exception $e) {
         $throwException = true;
     }
     $this->assertFalse($throwException, 'Passed IReader type to App and catch exception');
     $app = new App($reader = new CorrectReader());
     $this->assertEquals($reader->read(), $app->parse(), 'App parse must return reader result.');
 }
Пример #30
0
 /**
  * Set up this new Controller object for an app with render data
  *
  * @param App $app the application
  * @param Object $render the render data
  */
 public function setup_for_app($app, $render)
 {
     $this->view = $app->get_file();
     // "faq" from "www.yawf.org/project/faq"
     $this->path = $app->get_path();
     // e.g. "project/faq"
     $this->render = $render;
     // data to be rendered in views
     $this->setup_request($app);
     // inherited from Request class
     $this->flash = $this->flash_object();
     // uses a request session
 }