コード例 #1
0
 static function run()
 {
     if (!self::$init) {
         self::$init = true;
         self::init();
     }
     $route = Router::dispatch();
     if (!empty($route)) {
         if (is_callable($route['callback'])) {
             call_user_func_array($route['callback'], $route['params']);
         } else {
             if (strpos($route['callback'], '@') !== false) {
                 $pieces = explode('@', $route['callback']);
                 $route['action'] = $pieces[1];
                 $route['controller'] = $pieces[0];
             } else {
                 $route['action'] = 'index';
                 $route['controller'] = $route['callback'];
             }
             self::loadRoute($route);
         }
     } else {
         call_user_func(self::$error404);
     }
 }
コード例 #2
0
 /**
  * 构造函数
  *
  * @access public
  * @param String $ini
  * @return void
  */
 private function __construct($ini)
 {
     require_once __DIR__ . '/application.php';
     Application::init($ini);
     $this->config = \Myfox\Lib\Config::instance('default');
     $this->prefix = rtrim($this->config->get('url.prefix', ''), '/');
     $logurl = $this->config->get('log/default');
     if (empty($logurl)) {
         $this->log = new \Myfox\Lib\BlackHole();
     } else {
         $this->log = new \Myfox\Lib\Log($logurl);
     }
 }
コード例 #3
0
 /**
  * 构造函数
  *
  * @access private
  * @return void
  */
 private function __construct($ini, $class, $option = null)
 {
     require_once __DIR__ . '/application.php';
     Application::init($ini);
     $worker = sprintf(__NAMESPACE__ . '\\worker\\%s', ucfirst(strtolower($class)));
     $this->worker = new $worker((array) $option);
     if (!$this->worker instanceof \Myfox\App\Worker) {
         printf("Class \"%s\" is not a subclass extended from \"Worker\".\n", $worker);
         exit;
     }
     $config = new \Myfox\Lib\Config($ini);
     self::$runmode = strtolower(trim($config->get('run.mode', 'online')));
     self::$identy = sprintf('%d@%s', getmypid(), strtolower(trim(php_uname('n'))));
     $_clone =& $this;
     $this->sigaction(SIGTERM, function ($signal) use($_clone) {
         printf("[%s]\tGot signal (%d)", date('Y-m-d H:i:s'), $signal);
         if (SIGTERM == $signal) {
             echo ", about to terminal ...\n";
             $_clone->freelock();
             exit(0);
         }
     });
 }
コード例 #4
0
ファイル: Application.class.php プロジェクト: nmcteam/recess
 static function activate(Application $application)
 {
     $application->init();
     self::$runningApplication = $application;
 }
コード例 #5
0
ファイル: index.php プロジェクト: tanya61612/Pastexen
define('APPLICATION_ENTRY_POINT', true);
// http://php.net/manual/en/security.magicquotes.disabling.php
if (get_magic_quotes_gpc()) {
    $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    while (list($key, $val) = each($process)) {
        foreach ($val as $k => $v) {
            unset($process[$key][$k]);
            if (is_array($v)) {
                $process[$key][stripslashes($k)] = $v;
                $process[] =& $process[$key][stripslashes($k)];
            } else {
                $process[$key][stripslashes($k)] = stripslashes($v);
            }
        }
    }
    unset($process);
}
if (!isset($action)) {
    if (!isset($_REQUEST['action'])) {
        $action = 'index';
    } else {
        $action = $_REQUEST['action'];
    }
}
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/core/Application.php';
$application = new Application();
$application->init($applicationConfig, $action, $_REQUEST);
$application->run();
$application->send();
exit;
コード例 #6
0
ファイル: index.php プロジェクト: jwdeitch/Concessions
<?php

/**
 * Spiral Framework, SpiralScout LLC.
 *
 * @package   spiralFramework
 * @author    Anton Titov (Wolfy-J)
 * @copyright ©2009-2011
 */
define('SPIRAL_INITIAL_TIME', microtime(true));
//No comments
mb_internal_encoding('UTF-8');
//Error reporting
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', false);
//Root directory
$root = dirname(__DIR__) . '/';
//Composer
require $root . 'vendor/autoload.php';
//Forcing work directory
chdir($root);
//Let's start!
Application::init(['root' => $root, 'libraries' => $root . '/vendor/', 'application' => $root . '/application/'], true)->start();
コード例 #7
0
ファイル: index.php プロジェクト: dgilan/test
<?php

require_once __DIR__ . '/../app/bootstrap.php';
Application::init();
コード例 #8
0
ファイル: app.php プロジェクト: no22/gongo
<?php

class Application extends Gongo_App
{
    public $uses = array('root' => 'Skelton_Controller_Root');
}
$app = new Application(dirname(__FILE__));
$app->init()->run();
コード例 #9
0
ファイル: daemon.php プロジェクト: ray-dong/Myfox-load-module
 /**
  * 构造函数
  *
  * @access private
  * @return void
  */
 private function __construct($ini, $class, $option = null)
 {
     require_once __DIR__ . '/application.php';
     Application::init($ini);
     $worker = sprintf(__NAMESPACE__ . '\\worker\\%s', ucfirst(strtolower($class)));
     $this->worker = new $worker((array) $option);
     if (!$this->worker instanceof \Myfox\App\Worker) {
         printf("Class \"%s\" is not a subclass extended from \"Worker\".\n", $worker);
         exit;
     }
 }
コード例 #10
0
ファイル: index.php プロジェクト: ievgen11/going_test_1
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <h3>Zadanie 2</h3>
                    <p>Mamy plik xml zawierający listę seansów filmowych (tutaj).
                        Napisz program, który cyklicznie będzie zaczytywał dane z
                        plików z podanego źródła i zapisywał do bazy danych
                        (zaproponuj odpowiednią strukturę bazy). Informacje na
                        temat seansów w plikach mogą z biegiem czasu ulegać zmianie
                        i odpowiadające im dane powinny być aktualizowane w bazie.
                        Program powinien być w pełni przetestowany.</p>

                    <?php 
$app = new Application();
$app->init('http://nowetwarze.goingapp.pl/kina.xml');
$app->run();
class Application
{
    var $xml_file;
    public function init($xml_location)
    {
        $this->xml_file = file_get_contents(dirname(__FILE__) . '/kina.xml', FILE_USE_INCLUDE_PATH);
        //$xml_file = file_get_contents('http://nowetwarze.goingapp.pl/kina.xml', FALSE, stream_context_create( array( 'http' => array( 'user_agent' => 'php' ))));
        $db_connect = new Database();
        $db_connect->connect();
    }
    public function run()
    {
        $movies = simplexml_load_string($this->xml_file);
        if ($movies != '') {
コード例 #11
0
ファイル: index.php プロジェクト: jm-factorin/bit-php
<?php

define('__ROOT__', dirname(__DIR__));
require_once __ROOT__ . '/vendor/autoload.php';
require_once __ROOT__ . '/app/config/bootstrap.php';
Application::init()->run();
コード例 #12
0
ファイル: Application.php プロジェクト: xJakub/LCE
    public $reason;
    public $contributions;
    public $dateline;
    public $avatar;
    /**
     * @param null $userid
     * @return static
     */
    public static function exists($userid = null)
    {
        if ($userid === null) {
            if (!TwitterAuth::isLogged()) {
                return null;
            } else {
                $userid = TwitterAuth::getUserId();
            }
        }
        return Application::findOne('userid = ?', [$userid]);
    }
    public function getVotes()
    {
        return ApplicationVote::find('applicationid = ?', [$this->applicationid]);
    }
    public function getScore()
    {
        $votes = $this->getVotes();
        return array_sum(Model::pluck($votes, 'vote'));
    }
}
Application::init('applications', 'applicationid');
コード例 #13
0
ファイル: index.php プロジェクト: rail-rz/framework
<?php

/**
 * Index
 * User: R2
 * Date: 05.09.12
 * Time: 23:49
 * To change this template use File | Settings | File Templates.
 */
header("Content-Type: charset=utf-8");
require_once "ComponentManager.php";
require_once "Application.php";
require_once "db.php";
require_once "models/Fetcher.php";
require_once "models/VoteFetcher.php";
require_once "models/AnswerFetcher.php";
require_once "models/QuestionsFetcher.php";
require_once "models/PollFetcher.php";
require_once "controller/Controller.php";
require_once "controller/PollController.php";
require_once "controller/AnswerController.php";
require_once "controller/VoteController.php";
require_once "controller/ErrorController.php";
require_once "controller/AdminPollController.php";
require_once "controller/AdminAnswerController.php";
Application::init(array('components' => array('fetchers' => array('class' => 'ComponentManager', '__construct' => array(array('components' => array('answers' => array('class' => 'AnswerFetcher'), 'poll' => array('class' => 'PollFetcher'), 'questions' => array('class' => 'QuestionsFetcher'), 'vote' => array('class' => 'VoteFetcher'))))), 'db' => array('class' => 'db', '__construct' => array('localhost', 'root', '', 'poll')))));
Application::getInstance()->run();
コード例 #14
0
ファイル: bootstrap.php プロジェクト: vgrish/dvelum
 * and save a reference for it (for convenience)
 * @var Config_Simple $appConfig
 */
$appConfig = Config::factory(Config::Simple, 'main');
$appConfig->setData($config);
Registry::set('main', $appConfig, 'config');
/**
 * Convert the data of main_config file
 * in to the general form of configuration
 * and save a reference for it (for convenience)
 * @var Config_Simple $appConfig
 */
/*
 * Starting the application
 */
$app = new Application($appConfig);
$app->setAutoloader($autoloader);
$app->init();
//  build objects
$objectFiles = File::scanFiles($config['object_configs'], array('.php'), false, File::Files_Only);
foreach ($objectFiles as $file) {
    $object = substr(basename($file), 0, -4);
    echo 'build ' . $object . ' : ';
    $builder = new Db_Object_Builder($object);
    if ($builder->build()) {
        echo 'OK';
    } else {
        echo 'Error! ' . strip_tags(implode(', ', $builder->getErrors()));
    }
    echo "\n";
}
コード例 #15
0
ファイル: index.php プロジェクト: jm-factorin/bit-php
<?php

$app = Application::init();
$app->route()->get('/', function () {
    $name = Request::get('name', 'jm-factorin');
    $user = UserService::createUserByName($name);
    return View::render('default.index', array('name' => $user->name));
});
コード例 #16
0
ファイル: Controller.php プロジェクト: vgrish/dvelum
    public function setuserpassAction()
    {
        $pass = Request::post('pass', 'str', '');
        $passConfirm = Request::post('pass_confirm', 'str', '');
        $lang = Request::post('lang', 'string', 'en');
        $timezone = Request::post('timezone', 'string', '');
        $email = Request::post('adm_email', 'string', '');
        $adminpath = strtolower(Request::post('adminpath', 'string', ''));
        $user = Request::post('user', 'str', '');
        $errors = array();
        if (!strlen($user)) {
            $errors[] = $this->_dictionary['INVALID_USERNAME'];
        }
        if (empty($pass) || empty($passConfirm) || $pass != $passConfirm) {
            $errors[] = $this->_dictionary['PASS_MISMATCH'];
        }
        $timezones = timezone_identifiers_list();
        if (empty($timezone) || !in_array($timezone, $timezones, true)) {
            $errors[] = $this->_dictionary['TIMEZOME_REQUIRED'];
        }
        if (!Validator_Email::validate($email)) {
            $errors[] = $this->_dictionary['INVALID_EMAIL'];
        }
        if (!Validator_Alphanum::validate($adminpath) || is_dir($this->_docRoot . 'system/app/Backend/' . ucfirst($adminpath))) {
            $errors[] = $this->_dictionary['INVALID_ADMINPATH'];
        }
        if (!empty($errors)) {
            Response::jsonError(implode(', ', $errors));
        }
        $salt = Utils::getRandomString(4) . '_' . Utils::getRandomString(4);
        $mainCfgPath = $this->_docRoot . 'system/config/main.php';
        $encConfigPath = $this->_docRoot . 'system/config/objects/enc/config.php';
        $config = (include $mainCfgPath);
        $inlineConfig = Config::factory(Config::Simple, 'main');
        $inlineConfig->setData($config);
        $app = new Application($inlineConfig);
        $app->init();
        $mainCfg = '<?php
$docRoot = DVELUM_ROOT;

$language = \'#lang#\';

return array(
		\'docroot\' => $docRoot ,
		/*
		 * Development mode
		 * 0 - production
		 * 1 - development
		 * 2 - test (development mode + test DB)
		 */
		\'development\' =>1,
		/*
		 * Development version (used by use_orm_build_log)
		 */
		\'development_version\'=>\'0.1\',
		/*
		 * Write SQL commands when updating Database structure.
		 * It can help to determine if there have been performed any rename operations.
		 * Please note that renaming operations in ORM interface causes loss of data
		 * during server synchronization, so it\'s better to use SQL log.
		 */
		\'use_orm_build_log\'=>true,
		/*
		 * ORM SQL logs path
		 */
		\'orm_log_path\'=>$docRoot.\'/.log/orm/\',
		/*
		 * Background tasks log path
		 */
		\'task_log_path\'=>$docRoot.\'/.log/task/\',
		/*
		 * ORM system object used as links storage
		 */
		\'orm_links_object\'=>\'Links\',
		/*
		 * ORM system object used as history storage
		 */
		\'orm_history_object\'=>\'Historylog\',
		/*
		 * File uploads path
		 */
		\'uploads\' => $docRoot . \'/media/\' ,
		/*
		 * Admin panel URL
		 * For safety reasons adminPath may be changed, however,
		 * keep in mind that IDE builds full paths in the current version,
		 * thus, they would have to be manually updated in the projects.
		 */
		\'adminPath\' => \'#adminpath#\' ,
		/*
		 * Templates directory
		 */
		\'templates\' => $docRoot . \'/templates/\' ,
		/*
		 * Url paths delimiter  "_" , "-" or "/"
		 */
		\'urlDelimiter\' => \'/\',
		\'urlExtension\' => \'.html\' ,
		/*
		 * System language
		 * Please note. Changing the language will switch ORM storage settings.
		 */
		\'language\' => $language ,
		\'system\' => $docRoot . \'/system/\',
		\'lang_path\' => $docRoot . \'/system/lang/\' ,
		\'js_lang_path\' => $docRoot. \'/js/lang/\',
		\'salt\' => \'#salt#\' ,
		\'timezone\' => \'#timezone#\' ,
		\'jsCacheUrl\' => \'js/cache/\' ,
		\'jsCachePath\' => $docRoot . \'/js/cache/\' ,

		\'jsCacheSysUrl\' => \'js/syscache/\',
		\'jsCacheSysPath\' => \'./js/syscache/\',
		 /*
		  * Сlear the object version history when deleting an object.
		  * The recommended setting is “false”.  Thus, even though the object has been deleted,
		  * it can be restored from the previous control system revision.
		  * If set to "true", the object and its history will be  totally removed. However,
		  * this allows you to get rid of redundant records in the database.
		  */
		\'vc_clear_on_delete\' => false,
		/*
		 * Main directory for config files
		 */
		\'configs\' => $docRoot . \'/system/config/\' ,  // configs path
		/*
		 * ORM configs directory
		 */
		\'object_configs\' => $docRoot . \'/system/config/objects/\' ,
		/*
		 * Report configs directory
		 */
		\'report_configs\' => $docRoot . \'/system/config/reports/\' ,
		/*
		 * Modules directory
		 */
		\'modules\'=> $docRoot . \'/system/config/modules/\',
		/*
		 * Backend modules config file
		 */
		\'backend_modules\'=> $docRoot . \'/system/config/modules/\'.$language.\'/backend_modules.php\',
		/*
		 * Backend controllers path
		 */
		\'backend_controllers\'=>$docRoot . \'/system/app/Backend/\',
		/*
		 * Frontend controllers path
		 */
		\'frontend_controllers\'=>$docRoot . \'/system/app/Frontend/\',
		/*
		 * Frontend modules config file
		 */
		\'frontend_modules\'=>$docRoot . \'/system/config/modules/\'.$language.\'/frontend_modules.php\',
		/*
		 * Application path
		 */
		\'application_path\'=>$docRoot . \'/system/app/\',
		/*
		 * Blocks path
		 */
		\'blocks\'=>$docRoot . \'/system/app/Block/\',
		 /*
		  * Dictionary configs directory depending on localization
		  */
		\'dictionary\'=>$docRoot . \'/system/config/dictionary/\'.$language.\'/\',
		/*
		 * Dictionary directory
		 */
		\'dictionary_folder\'=>$docRoot . \'/system/config/dictionary/\',
		 /*
		  * Backups directory
		  */
		\'backups\' => $docRoot . \'/.backups/\' ,
		\'tmp\' => $docRoot . \'/.tmp/\' ,
		\'mysqlExecPath\' => \'mysql\',
		\'mysqlDumpExecPath\' => \'mysqldump\',
		/*
		 * the type of frontend router with two possible values:
		 * \'module\' — using tree-like page structure  (‘Pages’ section of the administrative panel);
		 * \'path\' — the router based on the file structure of client controllers.
		 */
		\'frontend_router_type\'=>\'module\',// \'module\',\'path\',\'config\'
		/*
		 * Use memcached
		 */
		\'use_cache\' => false,
		/*
		 * Hard caching time (without validation) for frondend , seconds
		 */
		\'frontend_hardcache\'=>30,
		\'themes\' => $docRoot . \'/templates/public/\' ,
		\'usersOnline\' => false, //Collect users online info,
		// Autoloader config
		\'autoloader\' => array(
			 // Paths for autoloading
			 \'paths\'=> array(
			    \'./system/rewrite\',
				\'./system/app\',
				\'./system/library\',
			 ),
		  /*
		   * Use class map
		   */
		  \'useMap\'=>true,
			 /*
			  *	Use precompiled code packages
			  *	requires useMap property to be set to true
			  */
			 \'usePackages\' => false,
		   // Use class map (Reduce IO load during autoload)
			 // Class map file path (string / false)
			 \'map\' => $docRoot . \'/system/config/class_map.php\',
			 // Class map file path (with packages)
			 \'mapPackaged\'=> $docRoot . \'/system/config/class_map_packaged.php\',
			 // Packages config path
			 \'packagesConfig\'=>	$docRoot . \'/system/config/packages.php\',
		),
		/*
		 * Stop the site with message "Essential maintenance in progress. Please check back later."
		 */
		\'maintenance\' => false,
		/*
		 * Show debug panel (development mode)
		 */
		\'debug_panel\'=> false,
		/*
		 * HTML WYSIWYG Editor
		 * default  - ckeditor
		 */
		\'html_editor\' =>\'ckeditor\',
		/*
		 * Use the console command to compile the file system map
		 * (accelerates the compilation process; works only on Linux systems;
		 * execution of the system function should be allowed).
		 */
		\'deploy_use_console\'=>false,
		/*
		 *  Use hard cache expiration time defined in frontend_hardcache for caching blocks;
		 *  allows to reduce the cache time of dynamic blocks;
		 *  is used if there are not enough triggers for cache invalidation
		 */
		\'blockmanager_use_hardcache_time\'=>false,
		/*
		 * Use foreign keys
		 */
		\'foreign_keys\' => false,
		/*
		 * Allow external modules
		 */
		\'allow_externals\' => false,
		/*
		 * www root
		 */
		\'wwwroot\' =>\'#wwwroot#\',
		/*
		 * External modules path (Experimental)
		 */
		\'external_modules\' => \'./system/external/\',
		/*
		 * Log Db_Object errors
		 */
		\'db_object_error_log\' =>true,
		\'db_object_error_log_path\'=>$docRoot.\'/.log/error/db_object.error.log\',
		/*
		* Get real rows count for innodb tables (COUNT(*))
		* Set it "false" for large data volumes
		*/
		\'orm_innodb_real_rows_count\'=>false,
		/*
		* Directories for storing data base connection settings as per the system mode
		*/
		\'db_configs\' => array(
		      /* key as development mode code */
		      0 => array(
			      \'title\'=>\'PRODUCTION\',
			      \'dir\'=> $docRoot . \'/system/config/db/prod/\'
		      ),
		      1 => array(
			      \'title\'=>\'DEVELOPMENT\',
			      \'dir\'=> $docRoot . \'/system/config/db/dev/\'
		      ),
		      2=> array(
			      \'title\'=>\'TEST\',
			      \'dir\'=> $docRoot . \'/system/config/db/test/\'
		      ),
		),
		/*
         * Check modification time for template file. Invalidate cache
         */
        \'template_check_mtime\' => true,
    	/*
    	 * ORM system object used as version storage
    	 */
    	\'orm_version_object\' => \'Vc\',
		/*
         * Db_Object for error log 
         */
        \'erorr_log_object\'=>\'error_log\'
);';
        $mainCfg = str_replace(array('#salt#', '#timezone#', '#lang#', '#adminpath#', '#wwwroot#'), array($salt, $timezone, $lang, $adminpath, $this->_wwwRoot), $mainCfg);
        if (!@file_put_contents($mainCfgPath, $mainCfg)) {
            Response::jsonError($this->_dictionary['CANT_WRITE_FS']);
        }
        $key = md5(uniqid(md5(time())));
        $encConfig = '
		<?php
			return array(
				\'key\'=>\'' . $key . '\',
				\'iv_field\'=>\'enc_key\'
			);
		';
        if (!@file_put_contents($encConfigPath, $encConfig)) {
            Response::jsonError($this->_dictionary['CANT_WRITE_FS'] . ' ' . $encConfigPath);
        }
        Utils::setSalt($salt);
        $mainCfgPath = $this->_docRoot . 'system/config/main.php';
        $config = (include $mainCfgPath);
        $inlineConfig = Config::factory(Config::Simple, 'main');
        $inlineConfig->setData($config);
        Registry::set('main', $inlineConfig, 'config');
        if (!$this->_prepareRecords($pass, $email, $user)) {
            Response::jsonError($this->_dictionary['CANT_WRITE_TO_DB']);
        }
        ob_start();
        File::rmdirRecursive($this->_docRoot . 'install', true);
        ob_end_clean();
        Response::jsonSuccess(array('link' => Registry::get('main', 'config')->get('adminPath')));
    }