示例#1
0
 /**
  * Set controller, action, [parameter, app_dir] for future calls to dispatch().
  * @see    dispatch
  * @access public
  * @return null
  */
 function setParams()
 {
     // since we got this far, we need to rewrite $_SERVER['PHP_SELF'] to a pared down $_SERVER['REQUEST_URI']
     $query_string = array_key_exists('QUERY_STRING', $_SERVER) ? $_SERVER['QUERY_STRING'] : '';
     $_SERVER['PHP_SELF'] = str_replace('?' . $query_string, '', $_SERVER['REQUEST_URI']);
     NDebug::debug('' . $_SERVER['REMOTE_ADDR'] . ' requested ' . $_SERVER['PHP_SELF'], N_DEBUGTYPE_PAGE);
     // normalize the url
     $url = $this->url;
     $url = preg_replace("|index\\..*\$|i", "", $url);
     $url = preg_replace("|\\." . DEFAULT_PAGE_EXTENSION . "\$|i", "", $url);
     $url = preg_replace("|/\$|", "", $url);
     $url = preg_replace('|^/|', '', $url);
     // explode into an array
     $parts = explode('/', $url);
     // check if it's an nterchange specific controller
     if (isset($parts[0]) && $parts[0] == APP_DIR) {
         $this->app_dir = true;
         $app = array_shift($parts);
         if (empty($parts)) {
             $loc = '/' . APP_DIR . '/dashboard';
             $qs = '';
             foreach ($_GET as $k => $v) {
                 $qs .= ($qs ? '&' : '?') . $k . '=' . urlencode($v);
             }
             $loc .= $qs;
             header('Location:' . $loc);
             exit;
         }
     }
     // set the controller, method and parameter and invoke
     $this->controller = isset($parts[0]) ? $parts[0] : null;
     $this->action = isset($parts[1]) ? $parts[1] : null;
     $this->parameter = isset($parts[2]) ? $parts[2] : null;
 }
示例#2
0
 public function __construct(array $config)
 {
     if (is_callable('Nette\\Debug::addPanel')) {
         call_user_func('Nette\\Debug::addPanel', $this);
     } elseif (is_callable('NDebug::addPanel')) {
         NDebug::addPanel($this);
     } elseif (is_callable('Debug::addPanel')) {
         Debug::addPanel($this);
     }
     $this->useFirebug = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'FirePHP/');
     if (isset($config['file'])) {
         $this->setFile($config['file']);
     }
     if (isset($config['filter'])) {
         $this->setFilter($config['filter']);
     }
     if (isset($config['explain'])) {
         $this->explainQuery = (bool) $config['explain'];
     }
 }
 function login()
 {
     NDebug::debug('Redirecting ' . $_SERVER['REMOTE_ADDR'] . ' to login to nterchange.', N_DEBUGTYPE_AUTH);
     $auth = new NAuth();
     $auth->start();
     $username = $auth->username;
     $status = $auth->status;
     $form = new NQuickForm('login_form', 'post', preg_replace('/logout=1[\\&]?/', '', $_SERVER['REQUEST_URI']));
     $form->setDefaults(array('username' => $username));
     if (isset($_GET['logout']) && $_GET['logout'] == 1) {
         $form->addElement('cmsalert', 'logout_header', 'You have signed out. Sign back in to continue.');
     } else {
         if ($status < 0 && !empty($username)) {
             $form->addElement('cmserror', 'login_status', $auth->statusMessage($status));
         } else {
             $form->addElement('cmsalert', 'login_status', 'Please sign in and you will be sent right along.');
         }
     }
     $form->addElement('text', 'username', 'Username', array('maxlength' => 32, 'style' => 'width:300px;'));
     $form->addElement('password', 'password', 'Password', array('maxlength' => 32, 'style' => 'width:150px;'));
     // $form->addElement('checkbox', 'remember', null, 'Remember me for 2 weeks.');
     $form->addElement('submit', 'login', 'Sign In');
     $referer = isset($_GET['_referer']) ? urlencode($_GET['_referer']) : urlencode('/' . $this->base_dir);
     $form->addElement('hidden', '_referer', $referer);
     if ($auth->checkAuth()) {
         NDebug::debug('Logged ' . $_POST['username'] . ' from ' . $_SERVER['REMOTE_ADDR'] . ' in to nterchange.', N_DEBUGTYPE_AUTH);
         // Log this in the audit trail.
         $user_id = $auth->currentUserID();
         $audit_trail =& NController::factory('audit_trail');
         $audit_trail->insert(array('asset' => 'users', 'asset_id' => $user_id, 'action_taken' => AUDIT_ACTION_LOGIN));
         unset($audit_trail);
         // Redirect to the page requested.
         header('Location:' . urldecode($referer));
         exit;
     }
     $content = $form->toHTML();
     $this->set(array('MAIN_CONTENT' => $content, 'username' => $username, 'status' => $status));
     $this->auto_render = false;
     $this->render(array('layout' => 'login'));
 }
示例#4
0
 static function debug($message, $debug_type = N_DEBUGTYPE_INFO, $log_level = PEAR_LOG_DEBUG, $ident = false)
 {
     $debug_level = defined('DEBUG_LEVEL') ? constant('DEBUG_LEVEL') : 0;
     if (empty($debug_level) || is_numeric($debug_level) && $debug_level < $log_level) {
         return;
     }
     $debug_type_setting = defined('DEBUG_TYPE') ? constant('DEBUG_TYPE') : 0;
     if (empty($debug_type_setting) || !is_numeric($debug_type_setting) || !($debug_type_setting & $debug_type)) {
         return;
     }
     // make message intelligible
     if (!is_string($message)) {
         $message = print_r($message, true);
     }
     $filename = NDebug::getFilename($debug_type);
     if ($ident == false) {
         $ident = ucwords(APP_NAME);
     }
     $log = Log::singleton('file', NDebug::getDir() . $filename, $ident);
     $log->log($message, $log_level);
     unset($log);
 }
示例#5
0
<?php

/**
 * My NApplication bootstrap file.
 *
 * @copyright  Copyright (c) 2010 John Doe
 * @package    MyApplication
 */
// Step 1: Load Nette Framework
// this allows load Nette Framework classes automatically so that
// you don't have to litter your code with 'require' statements
require LIBS_DIR . '/Nette/loader.php';
// Step 2: Configure environment
// 2a) enable NDebug for better exception and error visualisation
NDebug::enable(NDebug::DETECT, APP_DIR . '/log/php_error.log', '*****@*****.**');
NEnvironment::getHttpResponse()->enableCompression();
// Load dibi
dibi::connect(NEnvironment::getConfig('database'));
dibi::addSubst('graweb', 'gw2010__');
// Step 3: Configure application
NEnvironment::setVariable("sizes", array(0 => array(880, 330), 1 => array(263, 174), 2 => array(600, 510)));
// 3a) get and setup a front controller
$application = NEnvironment::getApplication();
$application->errorPresenter = 'Front:Error';
$application->catchExceptions = TRUE;
// Step 4: Setup application router
$router = $application->getRouter();
$router[] = new NRoute('index.php', array('module' => 'Front', 'presenter' => 'Default'), NRoute::ONE_WAY);
$router[] = new NRoute('', array('module' => 'Front', 'presenter' => 'Default', 'action' => 'default'));
// Presmerovani starych URL
$router[] = new NRoute('internet/<? ceny|postup|sluzby|vyroba>', array('module' => 'Front', 'presenter' => 'Page', 'action' => 'webdesign'), NRoute::ONE_WAY);
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

<h1>Nette\Debug & Variables | dibi</h1>

<p>Dibi can dump variables via Nette\Debug, part of Nette Framework.</p>

<ul>
	<li>Nette Framework: http://nette.org
</ul>

<?php 
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
// enable NDebug
NDebug::enable();
dibi::connect(array('driver' => 'sqlite', 'database' => 'data/sample.sdb', 'profiler' => array('run' => TRUE)));
NDebug::barDump(dibi::fetchAll('SELECT * FROM customers WHERE customer_id < %i', 38), '[customers]');
示例#7
0
<?php

define('CONSOLE', php_sapi_name() == 'cli');
define('LF', CONSOLE ? "\n" : "<br>");
include_once dirname(__FILE__) . '/nette.php';
NDebug::enable();
date_default_timezone_set('Europe/Prague');
$app = new FakturoidPairing('config.ini');
$app->run();
// autoload
function __autoload($class)
{
    if (is_file(dirname(__FILE__) . '/app/' . $class . '.php')) {
        include_once dirname(__FILE__) . '/app/' . $class . '.php';
    } else {
        include_once dirname(__FILE__) . '/app/Statement/' . $class . '.php';
    }
}
// helpers
if (!function_exists('dump')) {
    function dump($var)
    {
        if (!CONSOLE) {
            echo "<pre>";
        }
        var_dump($var);
        if (!CONSOLE) {
            echo "</pre>";
        }
        return $var;
    }
 function page($parameter)
 {
     $page_id = $parameter;
     $this->_auth = new NAuth();
     $this->auto_render = false;
     // set up the search form
     include_once 'n_quickform.php';
     // search for the date
     /* @var $model cmsAuditTrail */
     $model =& $this->getDefaultModel();
     $model->page_id = $page_id;
     if ($model->find(array('order_by' => 'cms_created DESC'))) {
         $html = '';
         while ($model->fetch()) {
             // Actually turn the id's into something readable.
             $info = $this->humanizeAuditTrailRecord($model);
             $this->set($info);
             $html .= $this->render(array('action' => 'page_audit_trail_record', 'return' => true));
         }
         $this->set('audit_trail', $html);
         $this->set('result_count', $model->numRows());
     } else {
         $this->set('result_count', 'no');
         $this->set('audit_trail', '<p>There were no results found for the specified page.</p>');
     }
     // Exposes an RSS feed link to Admin or higher users.
     if (defined('RSS_AUDIT_TRAIL') && RSS_AUDIT_TRAIL) {
         NDebug::debug('We are checking to see if we can display the RSS feed.', N_DEBUGTYPE_INFO);
         $this->checkRSSFeed();
     }
     $this->loadSubnav($parameter);
     $this->render(array('layout' => 'default'));
 }
示例#9
0
 function deleteFile($filename)
 {
     if (!$this->connection || !$this->login_result) {
         $this->connect();
     }
     // Take off the leading /
     $filename = eregi_replace('^/', '', $filename);
     // Change into MIRROR_REMOTE_DIR.
     ftp_chdir($this->connection, MIRROR_REMOTE_DIR);
     if (ftp_delete($this->connection, $filename)) {
         NDebug::debug("FTP Mirror: {$filename} WAS deleted successfully", N_DEBUGTYPE_INFO);
     } else {
         NDebug::debug("FTP Mirror: {$filename} was NOT deleted successfully", N_DEBUGTYPE_INFO);
     }
 }
示例#10
0
static$fireTable=array(array('Time','SQL Statement','Rows','Connection'));function
__construct(array$config){if(is_callable('Nette\Debug::addPanel')){call_user_func('Nette\Debug::addPanel',$this);}elseif(is_callable('NDebug::addPanel')){NDebug::addPanel($this);}elseif(is_callable('Debug::addPanel')){Debug::addPanel($this);}$this->useFirebug=isset($_SERVER['HTTP_USER_AGENT'])&&strpos($_SERVER['HTTP_USER_AGENT'],'FirePHP/');if(isset($config['file'])){$this->setFile($config['file']);}if(isset($config['filter'])){$this->setFilter($config['filter']);}if(isset($config['explain'])){$this->explainQuery=(bool)$config['explain'];}}function
示例#11
0
 /**
  * deleteSmartyCache - Delete the entire cache when you make a page change.
  * If you're including the navigation in the page as ul/li's - this keeps the
  * navigation always consistent.
  *
  * @return void
  **/
 function deleteSmartyCache()
 {
     // Only delete the entire cache if the NAV_IN_PAGE is true and we're in production.
     if (defined('NAV_IN_PAGE') && NAV_IN_PAGE && ENVIRONMENT == 'production' && !isset($this->smarty_cache_cleared)) {
         NDebug::debug('We are clearing the smarty caches because of a page edit.', N_DEBUGTYPE_INFO);
         $view =& NView::singleton($this);
         $view->clear_all_cache();
         $site_admin = NController::factory('site_admin');
         $site_admin->rmDirFiles(CACHE_DIR . '/smarty_cache');
         $site_admin->rmDirFiles(CACHE_DIR . '/templates_c');
         $this->smarty_cache_cleared = true;
     }
 }
示例#12
0
 public static function copyTo($id_file_node, $type_module, $id_module)
 {
     $old_module = self::getTypeModuleIdModule($id_file_node);
     $old_files = self::getAllFiles($old_module['type_module'], $old_module['id_module']);
     NDebug::fireLog('type_module:' . $type_module);
     NDebug::fireLog('id_module:' . $id_module);
     foreach ($old_files as $f) {
         $new_file = Files::duplicateFile($f['id_file']);
         NDebug::fireLog('Stary subor: ' . $f['id_file']);
         NDebug::fireLog('Meno noveho suboru: ');
         NDebug::fireLog($new_file);
         $id_file_node = self::getFileNode($type_module, $id_module);
         if (!$id_file_node) {
             $id_file_node = self::addFileNode($type_module, $id_module);
         }
         $new_file['id_file_node'] = $id_file_node;
         Files::insert($new_file);
     }
 }
示例#13
0
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

<h1>Result Set Data Types  | dibi</h1>

<?php 
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array('driver' => 'sqlite', 'database' => 'data/sample.sdb'));
// using manual hints
$res = dibi::query('SELECT * FROM [customers]');
$res->setType('customer_id', Dibi::INTEGER)->setType('added', Dibi::DATETIME, 'H:i j.n.Y');
NDebug::dump($res->fetch());
// outputs:
// object(DibiRow)#3 (3) {
//     customer_id => int(1)
//     name =>  string(11) "Dave Lister"
//     added =>  object(DateTime53) {}
// }
// using auto-detection (works well with MySQL or other strictly typed databases)
$res = dibi::query('SELECT * FROM [customers]');
$res->detectTypes();
NDebug::dump($res->fetch());
// outputs:
// object(DibiRow)#3 (3) {
//     customer_id => int(1)
//     name =>  string(11) "Dave Lister"
//     added =>  string(15) "17:20 11.3.2007"
// }
示例#14
0
文件: loader.php 项目: GE3/GE3
 function __toString()
 {
     try {
         return $this->toString();
     } catch (Exception $e) {
         NDebug::toStringException($e);
     }
 }
示例#15
0
 function removeJavascript($id = 0)
 {
     $page =& NController::singleton('page');
     $page->base_view_dir = ROOT_DIR;
     $page->view_caching = (bool) PAGE_CACHING;
     $page->view_cache_lifetime = JS_CACHE_LIFETIME;
     $view_options = array('action' => 'blank');
     // REMOVE JAVASCRIPT CACHES
     $javascript_caches = array('javascript', 'javascript_secure', 'javascript_qualified', 'admin_javascript', 'admin_edit_javascript');
     foreach ($javascript_caches as $javascript_cache) {
         $page->view_cache_name = $javascript_cache;
         $view =& NView::singleton($page);
         $title = ucfirst(str_replace('_', ' ', $javascript_cache));
         if ($view->isCached($view_options)) {
             $cache_cleared = $view->clearCache($view_options);
             if ($cache_cleared) {
                 NDebug::debug($title . ' cache removed due to page edit on Page ID ' . $id . '.', N_DEBUGTYPE_CACHE);
             } else {
                 NDebug::debug($title . ' cache failed attempted removal due to page edit on Page ID ' . $id . '.', N_DEBUGTYPE_CACHE);
             }
         } else {
             NDebug::debug($title . ' cache failed attempted removal due to page edit on Page ID ' . $id . ' but cache does not exist.', N_DEBUGTYPE_CACHE);
         }
     }
     unset($view);
 }
示例#16
0
 public static function debug($message, $t = N_DEBUGTYPE_INFO, $p = PEAR_LOG_DEBUG, $z = false)
 {
     NDebug::debug($message, $t, $p, $z);
 }
 /**
  * dashboardVersionCheck - This runs for ADMIN users or higher and lets them know
  *		if there is an upgrade available for nterchange. Called from the dashboard
  *		helper and displays on the dashboard.
  *
  * @return void
  **/
 function dashboardVersionCheck()
 {
     // Check the user level - this only shows up for admins or higher.
     $auth = new NAuth();
     $current_user_level = $auth->getAuthData('user_level');
     unset($auth);
     if ($current_user_level >= N_USER_ADMIN) {
         $newest = $this->versionCheck();
         if (is_array($newest)) {
             $upgrade = $this->compareVersions(NTERCHANGE_VERSION, $newest['version']);
             if ($upgrade == true) {
                 $this->set('upgrade', $newest);
                 $this->set('nterchange_version', NTERCHANGE_VERSION);
             } else {
                 $this->set('uptodate', true);
             }
             $this->render(array('action' => 'dashboard_version_check', 'return' => false));
         } else {
             NDebug::debug('There was an error with the version check.', N_DEBUGTYPE_INFO);
         }
     }
 }
示例#18
0
 function debug($message, $debug_type = N_DEBUGTYPE_INFO, $log_level = PEAR_LOG_DEBUG, $ident = false)
 {
     if (!$ident) {
         $ident = isset($this) && is_a($this, __CLASS__) ? get_class($this) : __CLASS__;
     }
     NDebug::debug($message, $debug_type, $log_level, $ident);
 }
示例#19
0
 public static function log($message, $priority = self::INFO)
 {
     if (!self::$logFile) {
         return;
     }
     if ($message instanceof Exception) {
         $exception = $message;
         $message = "PHP Fatal error: " . ($message instanceof FatalErrorException ? $exception->getMessage() : "Uncaught exception " . get_class($exception) . " with message '" . $exception->getMessage() . "'") . " in " . $exception->getFile() . ":" . $exception->getLine();
     }
     error_log(@date('[Y-m-d H-i-s] ') . trim($message) . (self::$source ? '  @  ' . self::$source : '') . PHP_EOL, 3, self::$logFile);
     if ($priority === self::ERROR && self::$sendEmails && @filemtime(self::$logFile . '.email-sent') + self::$emailSnooze < time() && @file_put_contents(self::$logFile . '.email-sent', 'sent')) {
         call_user_func(self::$mailer, $message);
     }
     if (isset($exception)) {
         $hash = md5($exception . (method_exists($exception, 'getPrevious') ? $exception->getPrevious() : (isset($exception->previous) ? $exception->previous : '')));
         foreach (new DirectoryIterator(dirname(self::$logFile)) as $entry) {
             if (strpos($entry, $hash)) {
                 $skip = TRUE;
                 break;
             }
         }
         if (empty($skip) && (self::$logHandle = @fopen(dirname(self::$logFile) . "/exception " . @date('Y-m-d H-i-s') . " {$hash}.html", 'w'))) {
             ob_start();
             ob_start(array(__CLASS__, '_writeFile'), 1);
             self::paintBlueScreen($exception);
             ob_end_flush();
             ob_end_clean();
             fclose(self::$logHandle);
         }
     }
 }
示例#20
0
文件: dibi.php 项目: GE3/GE3
 public function __construct(array $config)
 {
     if (class_exists('Debug', FALSE) && is_callable('Debug::addPanel')) {
         NDebug::addPanel($this);
     }
     $this->useFirebug = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'FirePHP/');
     if (isset($config['filter'])) {
         $this->setFilter($config['filter']);
     }
     if (isset($config['explain'])) {
         $this->explainQuery = (bool) $config['explain'];
     }
 }
示例#21
0
 /**
  * deletePathRecursive - Deletes a file/folder and all it's contents
  *
  * @param   string   The file or folder to delete
  * @return  boolean  True if successfully deleted
  */
 function deletePathRecursive($path)
 {
     $path = str_replace(DOCUMENT_ROOT, '', $path);
     $path = DOCUMENT_ROOT . $path;
     if (is_dir($path)) {
         if (substr($path, -1) != '/') {
             $path = $path . '/';
         }
         $files = glob($path . '*', GLOB_MARK);
         $empty = true;
         foreach ($files as $file) {
             if (!self::deletePathRecursive($file)) {
                 $empty = false;
             }
         }
         if ($empty) {
             return rmdir($path);
         } else {
             return false;
         }
     }
     if (is_file($path)) {
         return unlink($path);
     }
     // Not a file or a directory?
     NDebug::debug("Unable to remove: " . $path, N_DEBUGTYPE_INFO);
     return false;
 }
 /**
  * deleteEverything - Delete all old versions of everything. Used just before
  * website launch or when somebody just wants to clean up.
  * NOTE: Not linked to from anywhere or really heavily tested. Use with caution.
  *
  * @return void
  **/
 function deleteEverything($parameter)
 {
     if ($model =& $this->getDefaultModel()) {
         if ($model->find()) {
             while ($model->fetch()) {
                 $arr = $model->toArray();
                 $content = unserialize($arr['version']);
                 $success = $this->fileDelete($content, $arr['asset'], $arr['asset_id']);
                 $this->deleteEmptyFolders($arr['asset'], $arr['asset_id']);
                 $model->delete();
             }
             // Let's empty out the entire table as well.
             $sql = 'TRUNCATE cms_nterchange_versions';
             $db = NDB::connect();
             $res = $db->query($sql);
         } else {
             NDebug::debug('There were no old versions of anything to delete.', N_DEBUGTYPE_INFO);
         }
         header('Location:/nterchange/');
     }
 }
示例#23
0
 function deletePageCache($id)
 {
     if (!empty($id)) {
         // load the model
         $model =& NModel::singleton($this->name);
         $model->reset();
         if ($model->get($id)) {
             $pk = $model->primaryKey();
             // find the action
             $action = $this->getTemplate($model->page_template_id);
             $action = $action ? $action : 'default';
             $action = $this->getTemplate($model->page_template_id);
             $action = $action ? $action : 'default';
             // set up caching values
             $this->base_view_dir = ROOT_DIR;
             $this->view_caching = true;
             $this->view_cache_lifetime = $model->cache_lifetime;
             $this->view_cache_name = 'page' . $id;
             $view =& NView::singleton($this);
             if ($this->isCached($action)) {
                 $cleared = $view->clearCache($action);
                 $this->debug('Page cache for Page ID ' . $id . ($cleared ? ' removed' : ' failed attempted removal') . '.', N_DEBUGTYPE_CACHE);
             } else {
                 $this->debug('Page cache for Page ID ' . $id . ' failed attempted removal since cache does not exist.', N_DEBUGTYPE_CACHE);
             }
             // Check the smarty_cache folder for additional caches from query string pages.
             $query_string_caches = CACHE_DIR . '/smarty_cache/page' . $id . '%*';
             if (count(glob($query_string_caches)) != 0) {
                 $files = glob($query_string_caches);
                 foreach ($files as $file) {
                     unlink($file);
                 }
                 NDebug::debug('Deleted query string cache files for page id ' . $id, N_DEBUGTYPE_INFO);
             }
         }
         unset($model);
         unset($view);
     }
     return;
 }
示例#24
0
 function start()
 {
     if (self::$started) {
         return;
     } elseif (self::$started === NULL && defined('SID')) {
         throw new InvalidStateException('A session had already been started by session.auto-start or session_start().');
     }
     $this->configure($this->options);
     NDebug::tryError();
     session_start();
     if (NDebug::catchError($e)) {
         @session_write_close();
         throw new InvalidStateException($e->getMessage());
     }
     self::$started = TRUE;
     if ($this->regenerationNeeded) {
         session_regenerate_id(TRUE);
         $this->regenerationNeeded = FALSE;
     }
     unset($_SESSION['__NT'], $_SESSION['__NS'], $_SESSION['__NM']);
     $nf =& $_SESSION['__NF'];
     if (empty($nf)) {
         $nf = array('C' => 0);
     } else {
         $nf['C']++;
     }
     $browserKey = $this->getHttpRequest()->getCookie('nette-browser');
     if (!$browserKey) {
         $browserKey = (string) lcg_value();
     }
     $browserClosed = !isset($nf['B']) || $nf['B'] !== $browserKey;
     $nf['B'] = $browserKey;
     $this->sendCookie();
     if (isset($nf['META'])) {
         $now = time();
         foreach ($nf['META'] as $namespace => $metadata) {
             if (is_array($metadata)) {
                 foreach ($metadata as $variable => $value) {
                     if (!empty($value['B']) && $browserClosed || !empty($value['T']) && $now > $value['T'] || $variable !== '' && is_object($nf['DATA'][$namespace][$variable]) && (isset($value['V']) ? $value['V'] : NULL) !== NClassReflection::from($nf['DATA'][$namespace][$variable])->getAnnotation('serializationVersion')) {
                         if ($variable === '') {
                             unset($nf['META'][$namespace], $nf['DATA'][$namespace]);
                             continue 2;
                         }
                         unset($nf['META'][$namespace][$variable], $nf['DATA'][$namespace][$variable]);
                     }
                 }
             }
         }
     }
     register_shutdown_function(array($this, 'clean'));
 }
示例#25
0
文件: index.php 项目: GE3/GE3
<?php

/**
 * GE3 Installer 
 * 
 * @author  Michal Mikoláš
 * @version 0.0.1   
 **/
// Nette
require_once '../Nette/loader.php';
NDebug::enable(NDebug::DEVELOPMENT);
define('APP_DIR', '../Nette');
require_once '../Nette/dibi.php';
// Config
if (file_exists("../config.php/default.conf.php")) {
    include "../config.php/default.conf.php";
}
$CONF =& $GLOBALS["config"];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  
  <link rel="stylesheet" type="text/css" media="screen" href="style.css" />
  <link rel="stylesheet" type="text/css" href="nifty.css">
  <script type="text/javascript" src="nifty2.js"></script>   
  
  <title>GE3 Installer</title>
</head>
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

<h1>Using Extension Methods | dibi</h1>

<?php 
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
dibi::connect(array('driver' => 'sqlite', 'database' => 'data/sample.sdb'));
// using the "prototype" to add custom method to class DibiResult
function DibiResult_prototype_fetchShuffle(DibiResult $obj)
{
    $all = $obj->fetchAll();
    shuffle($all);
    return $all;
}
// fetch complete result set shuffled
$res = dibi::query('SELECT * FROM [customers]');
$all = $res->fetchShuffle();
NDebug::dump($all);
示例#27
0
// key
NDebug::dump($assoc);
// fetch complete result set like pairs key => value
echo "<h2>fetchPairs('product_id', 'title')</h2>\n";
$pairs = $res->fetchPairs('product_id', 'title');
NDebug::dump($pairs);
// fetch row by row
echo "<h2>using foreach</h2>\n";
foreach ($res as $n => $row) {
    NDebug::dump($row);
}
// more complex association array
$res = dibi::query('
	SELECT *
	FROM products
	INNER JOIN orders USING (product_id)
	INNER JOIN customers USING (customer_id)
');
echo "<h2>fetchAssoc('customers.name|products.title')</h2>\n";
$assoc = $res->fetchAssoc('customers.name|products.title');
// key
NDebug::dump($assoc);
echo "<h2>fetchAssoc('customers.name[]products.title')</h2>\n";
$assoc = $res->fetchAssoc('customers.name[]products.title');
// key
NDebug::dump($assoc);
echo "<h2>fetchAssoc('customers.name->products.title')</h2>\n";
$assoc = $res->fetchAssoc('customers.name->products.title');
// key
NDebug::dump($assoc);
示例#28
0
文件: Setting.php 项目: oaki/demoshop
 function show()
 {
     MT::addTemplate(dirname(__FILE__) . '/menu.phtml', 'leftHolder');
     MT::addVar('leftHolder', 'dir', '/require_modules/Setting');
     MT::addCss('/require_modules/Setting/css/setting.css', 'settingCss');
     MT::addContent(MT::renderCurrentTemplate('leftHolder'), 'leftHolder');
     MT::addTemplate(dirname(__FILE__) . '/setting.phtml', 'setting');
     NDebug::fireLog('start Duplicate Tree');
     switch (@$_GET['setting_action']) {
         case 'lang':
             if (isset($_GET['ajax_action'])) {
                 switch ($_GET['ajax_action']) {
                     case "active_lang":
                         $active = dibi::fetchSingle("SELECT active FROM [lang] WHERE id_lang=%i", $_GET['id_lang']);
                         dibi::query("UPDATE [lang] SET active=%i", (bool) (!$active), "WHERE id_lang=%i", $_GET['id_lang']);
                         break;
                     case 'edit_name':
                         dibi::query("UPDATE [lang] SET name=%s", $_GET['name'], "WHERE id_lang=%i", $_GET['id_lang']);
                         break;
                     case 'edit_rate':
                         dibi::query("UPDATE [lang] SET rate=%s", $_GET['rate'], "WHERE id_lang=%i", $_GET['id_lang']);
                         break;
                     case 'edit_currency':
                         dibi::query("UPDATE [lang] SET currency=%s", $_GET['currency'], "WHERE id_lang=%i", $_GET['id_lang']);
                         break;
                 }
                 exit;
             }
             if (isset($_GET['id_lang_delete'])) {
                 dibi::query("DELETE FROM lang WHERE id_lang=%i", $_GET['id_lang_delete']);
                 header('Location: admin.php?setting_action=lang');
                 exit;
             }
             MT::addTemplate(dirname(__FILE__) . '/lang.phtml', 'lang');
             MT::addVar('lang', 'langs', dibi::fetchAll("SELECT * FROM lang"));
             $form = new NForm();
             $renderer = $form->getRenderer();
             //
             $renderer->wrappers['controls']['container'] = 'div';
             $renderer->wrappers['pair']['container'] = 'div';
             $renderer->wrappers['label']['container'] = 'span';
             $renderer->wrappers['control']['container'] = '';
             $form->addText('lang', 'Pridanie nového jazyka')->addRule(NForm::FILLED, 'Názov jazyka musí byť vyplnený.');
             $form->addText('iso', 'ISO')->addRule(NForm::FILLED, 'ISO jazyka musí byť vyplnený.');
             $form->addSubmit('add_lang', 'Pridať');
             $form->onSubmit[] = array($this, 'addLang');
             $form->fireEvents();
             MT::addVar('lang', 'lang_form', $form);
             break;
             /*
              * Duplicate
              */
         /*
          * Duplicate
          */
         case 'duplicate':
             MT::addTemplate(dirname(__FILE__) . '/duplicate/duplicate.phtml', 'duplicate');
             $form = new NForm();
             $form->addSelect('sourceLang', 'Zdrojový jazyk', dibi::query("SELECT iso,name FROM [lang]")->fetchPairs('iso', 'name'));
             $form->addSelect('destLang', 'Jazyk, do ktorého prekopírujeme všetky položky.', dibi::query("SELECT iso,name FROM [lang]")->fetchPairs('iso', 'name'));
             $form->addSubmit('duplicate_submit', 'Kopírovať');
             $form->onSubmit[] = array($this, 'duplicate');
             $form->fireEvents();
             MT::addVar('duplicate', 'duplicate_form', $form);
             break;
     }
 }
示例#29
0
 function m($matches, $file, $sourcePath)
 {
     //		NDebug::dump($file);
     NDebug::dump($matches);
     //		NDebug::dump($sourcePath);
     return "url('" . CssUrlsFilter::absolutizeUrl($matches[2], $matches[1], $file, $sourcePath) . "')";
 }