Esempio n. 1
0
 public function __construct()
 {
     // construct controller
     parent::__construct();
     // set urls
     $this->data['project_url'] = Router::getProjectUrl();
     $this->data['current_url'] = Router::getUrl();
     // set date format
     $this->data['date_format'] = App::load()->date_format;
     //set admin nav
     App::load()->register('nav', array(" \n  <div class='list-group panel'> \n    <a href='#post' class='list-group-item list-group-item-info' data-toggle='collapse'>" . i18n::get('POST_HEADER', 'post') . "</a> \n    <div class='collapse' id='post'> \n       <a href='" . $this->data['project_url'] . "admin/read/post/article/' class='list-group-item'>" . i18n::get('POST_SUB_HEADER', 'post') . "</a> \n      <a href='" . $this->data['project_url'] . "admin/create/post/article/' class='list-group-item'>" . i18n::get('POST_CREATE', 'post') . "</a> \n    </div> \n  </div>"));
     // set default includes
     $this->header = PATH_APP_VIEWS . 'admin/default/assets/inc/_header';
     $this->sidebar = PATH_APP_VIEWS . 'admin/default/assets/inc/_sidebar';
     $this->footer = PATH_APP_VIEWS . 'admin/default/assets/inc/_footer';
 }
Esempio n. 2
0
 /**
  * Loop through active controllers and generate sitemap data.
  */
 public function index()
 {
     $controllers = App::objects('Controller');
     $sitemap = array();
     // Fetch sitemap data
     foreach ($controllers as $controller) {
         App::uses($controller, 'Controller');
         // Don't load AppController's, SitemapController or Controller's who can't be found
         if (strpos($controller, 'AppController') !== false || $controller === 'SitemapController' || !App::load($controller)) {
             continue;
         }
         $instance = new $controller($this->request, $this->response);
         $instance->constructClasses();
         if (method_exists($instance, '_generateSitemap')) {
             if ($data = $instance->_generateSitemap()) {
                 $sitemap = array_merge($sitemap, $data);
             }
         }
     }
     // Cleanup sitemap
     if ($sitemap) {
         foreach ($sitemap as &$item) {
             if (is_array($item['loc'])) {
                 if (!isset($item['loc']['plugin'])) {
                     $item['loc']['plugin'] = false;
                 }
                 $item['loc'] = h(Router::url($item['loc'], true));
             }
             if (array_key_exists('lastmod', $item)) {
                 if (!$item['lastmod']) {
                     unset($item['lastmod']);
                 } else {
                     $item['lastmod'] = CakeTime::format(DateTime::W3C, $item['lastmod']);
                 }
             }
         }
     }
     // Disable direct linking
     if (empty($this->request->params['ext'])) {
         throw new NotFoundException();
     }
     // Render view and don't use specific view engines
     $this->RequestHandler->respondAs($this->request->params['ext']);
     $this->set('sitemap', $sitemap);
 }
Esempio n. 3
0
 /**
  * Attaches $adapter and inits it
  *
  * @param string $adapter
  * @param array $config
  * @return boolean
  */
 function attach($adapter, $config)
 {
     $class = $adapter . 'MediaAdapter';
     $file = 'media' . DS . 'adapter' . DS . Inflector::underscore($adapter) . '.php';
     App::uses($class, 'Media.Libs/Media/Adapter');
     if (!class_exists($class)) {
         App::load($class);
         $message = "MediaAdapterCollection::attach() - Adapter `{$adapter}` not found!";
         $this->__errors[] = $message;
         return false;
     }
     $this->{$adapter} = new $class();
     $this->_attached[] = $adapter;
     return true;
 }
 */
App::uses('FixtureInjector', 'Environment.TestSuite/Fixture');
if (!class_exists('FixtureInjector', false)) {
    App::load('FixtureInjector');
}
App::uses('CakeTestRunner', 'Environment.TestSuite');
if (!class_exists('CakeTestRunner', false)) {
    App::load('CakeTestRunner');
}
App::uses('CakeTestSuiteCommand', 'Environment.TestSuite');
if (!class_exists('CakeTestSuiteCommand', false)) {
    App::load('CakeTestSuiteCommand');
}
App::uses('HHVMTestSuiteDispatcher', 'Environment.TestSuite');
if (!class_exists('HHVMTestSuiteDispatcher', false)) {
    App::load('HHVMTestSuiteDispatcher');
}
App::uses('CakeBaseReporter', 'Environment.TestSuite/Reporter');
if (!class_exists('CakeBaseReporter', false)) {
    App::load('CakeBaseReporter');
}
App::uses('CakeHtmlReporter', 'Environment.TestSuite/Reporter');
if (!class_exists('CakeHtmlReporter', false)) {
    App::load('CakeHtmlReporter');
}
if (!class_exists('Hash')) {
    $merge = array('Set', 'merge');
} else {
    $merge = array('Hash', 'mergeDiff');
}
Configure::write('Environment', call_user_func($merge, array('console' => array('handler' => 'hhvm'), 'xhprof' => array('host' => 'http://xhprof.dev/', 'utils' => '/var/www/xhprof.dev/xhprof_lib/utils/', 'storage' => '/var/www/profiler/xhprof/', 'tag' => 'xhprof'), 'scripts' => array('webroot' => array('index.php', 'test.php'), 'console' => array('cake.php', 'cakehhvm', 'cakephp', 'cakeprofiler', 'caketrace', 'cakexhprof', 'cakexhprof.php'))), Configure::read('Environment')));
Esempio n. 5
0
<?php

ob_start();
//session_set_cookie_params(172800);
include_once MAIN_DIR . DS . ENGINE_DIR_PREFIX . 'core/defines.php';
include_once CLASS_DIR . DS . 'Load.class.php';
Load::file(array('Temp.class.php', 'File.class.php'), CLASS_DIR);
spl_autoload_register('Load::autoLoadClasses');
register_shutdown_function('Core::shutDown');
//Debug::start();
//$GLOBALS['_SESSION'] = new SessionArray();
Load::getClasses();
Route::init();
App::load(Request::get('app'));
 /**
  * Set as the default error handler by CakePHP. Use Configure::write('Error.handler', $callback), to use your own
  * error handling methods. This function will use Debugger to display errors when debug > 0. And
  * will log errors to CakeLog, when debug == 0.
  *
  * You can use Configure::write('Error.level', $value); to set what type of errors will be handled here.
  * Stack traces for errors can be enabled with Configure::write('Error.trace', true);
  *
  * @param int $code Code of error
  * @param string $description Error description
  * @param string $file File on which error occurred
  * @param int $line Line that triggered the error
  * @param array $context Context
  * @return bool true if error was handled
  */
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     if (error_reporting() === 0) {
         return false;
     }
     $errorConfig = Configure::read('Error');
     list($error, $log) = static::mapErrorCode($code);
     if ($log === LOG_ERR) {
         return static::handleFatalError($code, $description, $file, $line);
     }
     $debug = Configure::read('debug');
     if ($debug) {
         $data = array('level' => $log, 'code' => $code, 'error' => $error, 'description' => $description, 'file' => $file, 'line' => $line, 'context' => $context, 'start' => 2, 'path' => Debugger::trimPath($file));
         return Debugger::getInstance()->outputError($data);
     }
     $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
     if (!empty($errorConfig['trace'])) {
         // https://bugs.php.net/bug.php?id=65322
         if (version_compare(PHP_VERSION, '5.4.21', '<')) {
             if (!class_exists('Debugger')) {
                 App::load('Debugger');
             }
             if (!class_exists('CakeText')) {
                 App::uses('CakeText', 'Utility');
                 App::load('CakeText');
             }
         }
         $trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
         $message .= "\nTrace:\n" . $trace . "\n";
     }
     return CakeLog::write($log, $message);
 }
<?php

/**
 * This file is loaded automatically by the app/webroot/bancha.php file after core.php
 *
 * This file should load/create any application wide configuration settings.
 *
 * Bancha Project : Combining Ext JS and CakePHP (http://banchaproject.org)
 * Copyright 2011-2012 StudioQ OG
 *
 * @package       Bancha.Config
 * @copyright     Copyright 2011-2012 StudioQ OG
 * @link          http://banchaproject.org Bancha Project
 * @since         Bancha v 0.9.0
 * @author        Roland Schuetz <*****@*****.**>
 */
// load exceptionhandler
App::uses('BanchaExceptionHandler', 'Bancha.Bancha/ExceptionHandler');
App::load('BanchaExceptionHandler');
// register exceptionhandler
Configure::write('Exception.handler', array('BanchaExceptionHandler', 'handleException'));
// load helper classes for the dispatcher
App::uses('BanchaDispatcher', 'Bancha.Bancha/Routing');
App::uses('BanchaRequestCollection', 'Bancha.Bancha/Network');
// this shouldn't be necessary, but sometime it is.. maybe becaue of the caching?!
App::import('Controller', 'Bancha.Bancha');
Esempio n. 8
0
 /**
  * Generate the string to use to describe the error.
  *
  * @param string $error The error type (e.g. "Warning")
  * @param int $code Code of error
  * @param string $description Error description
  * @param string $file File on which error occurred
  * @param int $line Line that triggered the error
  * @return string
  */
 protected static function _getErrorMessage($error, $code, $description, $file, $line)
 {
     $errorConfig = Configure::read('Error');
     $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
     if (!empty($errorConfig['trace'])) {
         // https://bugs.php.net/bug.php?id=65322
         if (version_compare(PHP_VERSION, '5.4.21', '<')) {
             if (!class_exists('Debugger')) {
                 App::load('Debugger');
             }
             if (!class_exists('CakeText')) {
                 App::uses('CakeText', 'Utility');
                 App::load('CakeText');
             }
         }
         $trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
         $message .= "\nTrace:\n" . $trace . "\n";
     }
     return $message;
 }
Esempio n. 9
0
<?php

require_once "classes/App.php";
define('HOME_DIR', dirname(__FILE__));
if (file_exists('config.json')) {
    $config = json_decode(file_get_contents('config.json'));
    foreach ($config->constants as $constant => $value) {
        define($constant, $value);
    }
    App::load($config->app);
    unset($config);
    date_default_timezone_set(App::get('timezone'));
} else {
    throw new Exception("Config file doesn't exist!");
}
Esempio n. 10
0
<?php

App::uses('Resize', 'Lib');
App::load("Resize");
class DashboardController extends AppController
{
    function beforeFilter()
    {
        $this->layout = 'admin';
        if (!$this->Session->read('admin')) {
            $this->redirect('/admin');
        }
    }
    function index()
    {
    }
    function news()
    {
        $this->loadModel('Categorymanager');
        $q = $this->Categorymanager->find('all', array('order' => array('display_order' => 'asc')));
        $this->set('order', $q);
        $this->loadModel('Newsmanager');
        $a = $this->Newsmanager->find('all');
        $this->set('list', $a);
    }
    function addNews()
    {
        // debug($_POST);die();
        $error = 0;
        if (isset($_POST)) {
            $dateObject = new DateTime(date('Y-m-d G:i:s'));
<?php

require_once dirname(__FILE__) . DS . 'models.php';
App::uses('LikeableBehavior', 'Like.Model/Behavior');
App::load('LikeableBehavior');
class LikeableBehaviorTest extends CakeTestCase
{
    public $fixtures = array('plugin.like.like', 'plugin.like.post', 'plugin.like.user');
    /**
     * Method executed before each test
     *
     */
    public function setUp()
    {
        parent::setUp();
        $this->User = ClassRegistry::init('User');
        $this->Post = ClassRegistry::init('Post');
        $this->User->bindModel(array('hasMany' => array('Post')), false);
        $this->Post->bindModel(array('belongsTo' => array('User')), false);
        $this->Post->Behaviors->attach('Likeable');
    }
    /**
     * Method executed after each test
     *
     */
    public function tearDown()
    {
        unset($this->Post);
        unset($this->User);
        parent::tearDown();
    }
 public function setupAdminMenus()
 {
     if (Auth::load()->role('broker')) {
         //set posts menu
         App::load()->register('nav', array(" \n  <div class='list-group panel'> \n    <a href='#posts' class='list-group-item list-group-item-info' data-toggle='collapse'>" . I18n::get('POSTS_HEADER') . "</a> \n    <div class='collapse' id='posts'> \n       <a href='" . $this->data['project_url'] . "admin/read/posts/house/' class='list-group-item'>" . I18n::get('POSTS_SUB_HEADER') . "</a> \n      <a href='" . $this->data['project_url'] . "admin/create/posts/house/' class='list-group-item'>" . I18n::get('POSTS_CREATE') . "</a> \n    </div> \n  </div>"));
     }
     //set uplo
 }
Esempio n. 13
0
<?php

App::uses('Rsize', 'Lib');
App::load("Rsize");
class DashboardController extends AppController
{
    function beforeFilter()
    {
        $this->layout = 'admin';
        if (!$this->Session->read('admin')) {
            $this->redirect('/admin');
        }
    }
    function index()
    {
    }
    function logout()
    {
        $this->Session->delete('admin');
        $this->redirect('/admin');
    }
    function pages()
    {
        $this->loadModel('Page');
        $q = $this->Page->find('all', array('conditions' => array('parent' => 0)));
        $this->set('pages', $q);
    }
    function getChild($id)
    {
        $this->loadModel('Page');
        return $this->Page->find('all', array('conditions' => array('parent' => $id)));
Esempio n. 14
0
<!-- Sidebar --> 
<div id="sidebar-wrapper"> 
    <ul class="sidebar-nav"> 
        <li class="sidebar-brand"> 
            <a href="<?php 
echo $this->project_url;
?>
"> 
                MVC CMS
            </a> 
        </li> 
        <?php 
App::load()->get('nav');
?>
 
    </ul> 
</div> 
<!-- /#sidebar-wrapper --> 
<!-- Page Content --> 
<div id="page-content-wrapper"> 
    <div class="container-fluid"> 
        <div class="row"> 
            <div class="col-lg-12"> 
                <a href="#menu-toggle" class="btn btn-default" id="menu-toggle"> 
                    Menu 
                </a> 
                <?php 
$this->renderFeedback(PATH_APP_VIEWS . 'templates/system/feedback.php');
Esempio n. 15
0
<?php

define('APP_ROOT', realpath(__DIR__ . '/../'));
include '../core/helpers.php';
include '../core/autoload.php';
App::load();
Esempio n. 16
0
 /**
  * Autoload classes.
  *
  * @param string $className Autoload class name
  * @access public
  * @static
  * @return void
  */
 public static function __autoload($className)
 {
     \App::uses($className, 'Vendor');
     \App::load($className);
 }
Esempio n. 17
0
 /**
  * Step 3, Database
  *
  * @param bool $skip
  * @return void
  */
 public function database($skip = false)
 {
     $_step = 3;
     Configure::write('installStep', $_step);
     Configure::write('installPercentage', $_step / $this->totalInstallSteps * 100);
     if (!$this->__stepSuccess(array('license', 'server_test'), true)) {
         $this->redirect(array('action' => 'index'));
     }
     $configExists = file_exists(APP . 'Config' . DS . 'database.php');
     $this->set('configExists', $configExists);
     if (!empty($this->data) || $configExists && $skip) {
         App::uses('ConnectionManager', 'Model');
         $this->__clearCache();
         $continueEmail = true;
         $continueDb = true;
         if (!$configExists) {
             $data = $this->data;
             $data['datasource'] = 'Database/Mysql';
             $data['persistent'] = false;
             $data = Hash::merge($this->__defaultDbConfig, $data);
             $continueEmail = $this->__writeEmailFile($data);
             $continueDb = $this->__writeDatabaseFile($data);
         }
         if (!$continueEmail) {
             $this->Session->setFlash(__('Could not write email.php file! You will not be able to send user verification emails.'), null, null, 'error');
         }
         if ($continueDb) {
             try {
                 $db = ConnectionManager::getDataSource('default');
                 $data = $db->config;
             } catch (Exception $e) {
                 $this->Session->setFlash(__('Could not connect to database.'), null, null, 'error');
                 if (!$configExists) {
                     $this->__removeDatabaseFile();
                 }
                 return;
             }
             App::uses('Model', 'Model');
             App::uses('CakeSchema', 'Model');
             $schema = new CakeSchema(array('name' => 'Xlrstats', 'file' => 'xlrstats.php'));
             $schema = $schema->load();
             $execute = array();
             $sources = $db->listSources();
             foreach (array_keys($schema->tables) as $table) {
                 if (in_array($data['prefix'] . $table, $sources)) {
                     $this->Session->setFlash(__('A previous installation of XLRstats already exists, please empty your database!'), null, null, 'error');
                     if (!$configExists) {
                         $this->__removeDatabaseFile();
                         $this->__removeEmailFile();
                     }
                     return;
                 }
             }
             foreach ($schema->tables as $table => $fields) {
                 $create = $db->createSchema($schema, $table);
                 $execute[] = $db->execute($create);
                 $db->reconnect();
             }
             $dataPath = APP . 'Config' . DS . 'Schema' . DS . 'data' . DS;
             $modelDataObjects = App::objects('class', $dataPath, false);
             foreach ($modelDataObjects as $model) {
                 /** @noinspection PhpIncludeInspection */
                 include_once $dataPath . $model . '.php';
                 $model = new $model();
                 $Model = new Model(array('name' => get_class($model), 'table' => $model->table, 'ds' => 'default'));
                 $Model->cacheSources = false;
                 if (isset($model->records) && !empty($model->records)) {
                     foreach ($model->records as $record) {
                         $Model->create($record);
                         $execute[] = $Model->save();
                     }
                 }
             }
             if (!in_array(false, array_values($execute), true)) {
                 App::uses('Security', 'Utility');
                 App::load('Security');
                 $salt = Security::generateAuthKey();
                 $seed = mt_rand() . mt_rand();
                 $file = APP . DS . 'Config' . DS . 'security.php';
                 $contents = "<?php\n";
                 $contents .= "Configure::write('Security.salt', '" . $salt . "');\n";
                 $contents .= "Configure::write('Security.cipherSeed', '" . $seed . "');\n";
                 file_put_contents($file, $contents);
                 Cache::write('XlrInstallDatabase', 'success');
                 // fix: Security keys change
                 //$this->Session->write('XlrInstallDatabase', 'success');
                 $this->__stepSuccess('database');
                 $this->redirect(array('action' => 'user_account'));
             } else {
                 $this->Session->setFlash(__('Could not dump database.'), null, null, 'error');
             }
         } else {
             $this->Session->setFlash(__('Could not write database.php file.'), null, null, 'error');
         }
     }
 }
Esempio n. 18
0
<?php

/**
 * 
 * 
 * @copyright Copyright 2012 Francois Deschenes (http://francoisdeschenes.com)
 * @since CakePHP(tm) v 2.0
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
App::uses('PdfView', 'Dompdf.View');
if (version_compare(Configure::version(), '2.1.1', '<')) {
    App::load('PdfView');
}
try {
    Configure::load('dompdf');
} catch (Exception $e) {
    Configure::load('Dompdf.dompdf');
}
Esempio n. 19
0
define('PATH_APP_CONTROLLERS', PATH_APP . 'controller' . DIRECTORY_SEPARATOR);
define('PATH_APP_VIEWS', PATH_APP . 'view' . DIRECTORY_SEPARATOR);
define('PATH_APP_MODELS', PATH_APP . 'model' . DIRECTORY_SEPARATOR);
// set public uploads folders
define('PATH_PUBLIC_UPLOADS_SOURCE', PATH_ROOT . 'public/uploads/source' . DIRECTORY_SEPARATOR);
define('PATH_PUBLIC_UPLOADS_THUMBS', PATH_ROOT . 'public/uploads/thumbs' . DIRECTORY_SEPARATOR);
// set vendor folder dependencies
define('PATH_VENDOR', PATH_ROOT . 'vendor' . DIRECTORY_SEPARATOR);
// this is the (totally optional) auto-loader for Composer-dependencies (to load tools into your project).
// If you have no idea what this means: Don't worry, you don't need it, simply leave it like it is. The
// default will be used instead.
if (file_exists(PATH_VENDOR . 'autoload.php')) {
    require_once PATH_VENDOR . 'autoload.php';
} else {
    //Define the paths to the directories holding class files
    require_once PATH_VENDOR . 'thom855j/PHPAutoloader/Autoload.php';
    thom855j\PHPAutoloader\Autoload::load(array(PATH_APP, PATH_VENDOR))->namespaces();
}
// load application config (error reporting etc.)
require_once PATH_APP . 'config.php';
// load app class for setting app up
require_once PATH_APP . 'App.php';
// set env
App::load()->set('env', DEBUG);
App::load()->set('date_format', 'd/m/Y H:i');
use thom855j\PHPI18n\I18n;
// set locale
I18n::set('da_DK');
// register i18n
i18n::register(PATH_LANG . 'system', 'system');
i18n::register(PATH_LANG . 'post', 'post');
Esempio n. 20
0
<?php

/**
 * If you want to run the unit test:
 * 
 * - Replace the two lines below with a require statement for your sqs_queue.php file
 * - Replace all App::config('aws') occurences with array('key' => ..., 'secretKey' => ...)
 * - Run 'phpunit SqsQueueTest.php' in your shell
 */
require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/app/config/bootstrap.php';
App::load('Vendor', 'sqs_queue.php');
class SqsQueueTest extends PHPUnit_Framework_TestCase
{
    public $testQueue;
    public function setUp()
    {
        if (!defined('TEST_QUEUE')) {
            define('TEST_QUEUE', 'test_' . sha1((string) microtime(true)));
        }
        $this->testQueue = new SqsQueue(TEST_QUEUE, App::config('aws'));
    }
    public function testNotExists()
    {
        $this->assertFalse($this->testQueue->exists());
    }
    public function testCreate()
    {
        $expected = SqsQueue::url(TEST_QUEUE);
        $r = $this->testQueue->create(array('timeout' => 23));
        $this->assertEquals($expected, $r);
    }