PHP App, Examples

PHP App - 30 examples found. These are the top rated real world PHP examples of App extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public function setUp()
 {
     $this->app = Pagon::create(array('cache' => array('user' => array('type' => 'file'))));
     ob_start();
     $this->app->run();
     ob_end_clean();
 }
Example #2
0
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;
}
Example #3
0
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;
}
Example #4
0
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;
}
Example #5
0
 public static function smstorage_parseMessages($data)
 {
     $emoji = new App();
     foreach ($data['messages'] as $message) {
         $message->body = $emoji->any_to_html($message->body);
     }
 }
Example #6
0
 /**
  * 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();
         }
     }
 }
Example #7
0
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;
}
Example #8
0
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;
}
Example #9
0
 public function testPaserInput()
 {
     $input = '7:ABCDEFGabcdfXYZ';
     $test = $this->obj->parseInput($input);
     $expected = ['seatCount' => 7, 'queueStr' => 'ABCDEFGabcdfXYZ'];
     $this->assertEquals($expected, $test);
 }
Example #10
0
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;
}
Example #11
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();
 }
Example #13
0
 /**
  * @param App $app
  */
 public function __construct($app)
 {
     $this->commandConfig = $app->getCommandConfig();
     if ($this->commandConfig->isMultipleCommandMode()) {
         $this->subcommandName = $app->getSubcommandName();
     }
 }
Example #14
0
function change_theme($job)
{
    $json = $job->workload();
    $data = json_decode($json, true);
    $app = new App($data['token']);
    $app->themeWorker($data);
}
Example #15
0
function main()
{
    $app = new App();
    $app->bootstrap();
    $app->setupErrorHandling();
    $app->dispatch();
}
Example #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());
 }
Example #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));
 }
 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;
 }
Example #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]);
     }
 }
Example #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']);
 }
 /**
  * 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');
 }
Example #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;
 }
Example #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);
 }
Example #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;
 }
 /**
  * @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;
 }
Example #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);
 }
Example #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");
     }
 }
Example #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();
 }
Example #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.');
 }
Example #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
 }