function smarty_block_block($params, $content, $template, &$repeat) { global $smarty_block_stack; global $smarty_blocks; if (!$content) { $block = new Block($params['name']); apply_block_params($block, $params); $block->output(false); if (count($smarty_block_stack) > 0) { $parent = end($smarty_block_stack); $parent->add_block($block); } array_push($smarty_block_stack, $block); } else { $block = end($smarty_block_stack); if (count($smarty_block_stack) > 0) { array_pop($smarty_block_stack); } if (strpos($content, '{elements}') !== FALSE) { $count = substr_count($content, '{elements}'); $count -= 1; if ($count > 0) { $content = preg_replace('/{elements}/', "", $content, $count); } } PC::content($content); $block->html($content); str_replace('{elements}', '', $content); if (count($smarty_block_stack) == 0) { return $block->show(); } else { return '{elements}'; } } }
function myInit($f, $title = "") { // calling file, optional title if ($title == "") { $title = basename($f); } echo ' <DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <title>' . $title . '</title> </head> <body> '; echo "<h3><a href=" . basename($f) . ">{$f}</a></h3>"; PC::db('Entering ' . $f); if ($_GET) { PC::db($_GET, "_GET"); } if ($_POST) { PC::db($_POST, "_POST"); } if ($_FILES) { PC::db($_FILES, "_FILES"); } if ($_COOKIE) { PC::db($_COOKIE, "_COOKIE"); } if ($_REQUEST) { PC::db($_REQUEST, "_REQUEST"); } }
public static function fire($event, &$arg = null) { if (self::is_initializing()) { // PC::EventManager("Queuing event $event"); $queued_event['event'] = $event; $queued_event['arg'] =& $arg; array_push(self::$queue, $queued_event); return false; } if (!array_key_exists($event, self::$events)) { //PC::EventManager("Event $event not found"); return; } //PC::EventManager("Yey firing"); foreach (self::$events[$event] as $callback) { PC::EventManager("Firing event {$event} -> {$callback}"); if (function_exists($callback)) { if ($arg != null) { call_user_func($callback, $arg); } else { call_user_func($callback); } } else { if ($arg != null) { $output = Modules::run($callback, $arg); } else { $output = Modules::run($callback); } } if (isset($output) && $output != "__NO_MODULE__" && $output != "__404__") { echo $output; } } return self::$events[$event] > 0; }
public function startQuery($sql, array $params = null, array $types = null) { \PC::debug($sql, 'sql'); if ($params) { \PC::debug($params, 'params'); } }
protected function appDebug() { if (DEBUG and (!defined('ARTISAN') and !defined('TESTING'))) { $this->app->error(function (\Exception $e) { Request::ajax() and \PC::debug($e); }); } }
public static function run($config) { self::$config = $config; self::init_db(); self::init_view(); self::init_controllor(); self::init_method(); C(self::$controller, self::$method); }
public function action_index() { require_once APPPATH . "classes/Controller/Widgets/Menu.php"; $menu = new Controller_Widgets_Menu($this->request, $this->response); $menu->get_config(); PC::debug($menu->module_config); PC::debug($menu->request); PC::debug($menu->response); }
public function dispatchLoopShutdown(Yaf\Request_Abstract $request, Yaf\Response_Abstract $response) { /** * phpConsole调试(需要安装google扩展) */ PC::debug(Core\ServiceLocator::db()->log(), 'sql.trace'); PC::debug(Core\ServiceLocator::db()->error(), 'sql.error'); $performance = ['memory_usage' => memory_get_usage() - APP_MEMORY_START, 'time_usage' => microtime(true) - APP_MICROTIME_START]; PC::debug($performance, 'performance.info'); }
public static function run($config) { self::$config = $config; self::init_db(); self::init_view(); self::init_cachefile(); self::init_weixinurl(); self::init_controller(); self::init_method(); C(self::$controller, self::$method); }
/** * ChromeのJavaScript コンソールにメッセージを出力 * * @param string $message 出力する文字列 * @return void */ public static function log($message) { if (self::$debugMode) { if (is_array($message)) { $message = 'Array[' . str_replace('&', ", ", urldecode(http_build_query($message))) . ']'; } $message = strip_tags($message); $message = html_entity_decode($message); PC::db($message); global $LOGGER; $LOGGER->info($message); } }
public static function run($config) { //self::调用类本身,如第一个为调用自身类(PC)的$config静态变量,并给其赋值config.php文件里的$config变量内的值(config.php已经在index.php内被引入了,所以可以直接调用) self::$config = $config; //调用类本身的init_db()、init_view()、init_controller()、init_method()方法, self::init_db(); self::init_view(); self::init_controllor(); self::init_method(); //通过大C函数(function.php里定义好的函数),完成对控制器的实例化,以及使用控制器中的某个方法,通过控制器调用模型,调用视图,完成数据的输出 //这里大C函数的意思,C(配置1,配置2),调用自身PC类里的$controller变量指定的控制器及$method变量指定的方法 C(self::$controller, self::$method); }
public function admin_option_toggle_collapse_toggle($toggled) { $this->block->force_data_modification(true); PC::toggled($toggled); if ($toggled) { $this->block->add_css_class('minimized-section'); PC::toggled("truee"); } else { $this->block->remove_css_class('minimized-section'); PC::toggled("falsee"); } $this->block->save(); }
public function request_license() { $hostname = $_SERVER['HTTP_HOST']; PC::market("http://builderengine.com/builder_market_server/request_license?hostname=" . $hostname); $response_string = file_get_contents("http://builderengine.com/builder_market_server/request_license?hostname=" . $hostname); $response = json_decode($response_string); if ($response->status == "success") { $this->BuilderEngine->set_option('be_website_license', $response->license); } else { echo "error"; } return $response->license; }
public function admin_option_toggle_test_toggle($toggled) { $this->block->force_data_modification(true); PC::toggled($toggled); if ($toggled) { $this->block->remove_css_class('container-fluid'); $this->block->add_css_class('container'); $this->block->add_css_class('boxed-row'); } else { $this->block->remove_css_class('container'); $this->block->remove_css_class('boxed-row'); $this->block->add_css_class('container-fluid'); } $this->block->save(); }
public function install($module_folder) { PC::install("Installing module."); $this->load->module($module_folder . "/setup"); $this->module = new Module(); $this->module->where('folder', $module_folder)->get(); if (get_class($this->setup) != 'setup' || $this->module->installed == 'yes') { return $this->finish(); } $this->module->folder = $module_folder; $this->module->save(); $this->setup->module = null; $this->setup->module =& $this->module; if ($this->setup->install() !== false) { return $this->finish(); } }
public function reg($name, $pass, $role) { PC::debug(array($name, $pass, $role), "reg"); $myuser = new Model_Myuser(); $auth = Auth::instance(); $hash_pass = $auth->hash($pass); //Создаем пользователя $myuser->username = $name; $myuser->email = $name; $myuser->password = $hash_pass; try { $myuser->save(); //Узнаем id пользователя //$usertmp = ORM::factory('user', array('username'=>$name)); $adduserid = DB::select()->from('users')->where('username', '=', $name)->execute()->as_array()[0]["id"]; $adduser = new Model_Addrole(); $adduser->user_id = $adduserid; $adduser->role_id = $role; $adduser->save(); //добавляем запись для активации $token = substr($auth->hash($adduserid . $name), 0, 20); $addtoken = new Model_Addtoken(); $addtoken->user_id = $adduserid; $addtoken->token = $token; $addtoken->save(); //отправляем пользователю сообщение для авторизации $config = Kohana::$config->load('email'); $mbase = new Model_Base(); $options = $mbase->getOptions(); Email::connect($config); $to = $name; $subject = 'Добро пожаловать на сайт ' . $options['sitename']; $from = $config['options']['username']; $message = '<h2>Вы успешно зарегистрировались на сайте <a href="' . Kohana::$base_url . '">' . $options['sitename'] . '</a>!</h2><hr>'; $message .= '<p>Перед входом пожалуйста подтвердите свою учётную запись, для этого перейдите по <a href="' . Kohana::$base_url . 'user/activate?token=' . $token . '&user='******'">этой ссылке</a>.</p><hr>'; $message .= '<h3>Ваши реквизиты для входа:<h3>'; $message .= '<p><small>Логин: <input type="text" value="' . $name . '"></small></p>'; $message .= '<p><small>Пароль: <input type="text" value="' . $pass . '"></small></p>'; $message .= '<hr>Спасибо за то, что пользуетесь услугами нашего портала. По всем вопросам обращайтесь в техподдержку: ' . $config['options']['username']; Email::send($to, $from, $subject, $message, $html = true); return true; } catch (ORM_Validation_Exception $e) { $this->errors = $e->errors('validation'); return false; } }
/** * 适配默认后台样式的菜单列表 * @param $userInfo * @param $currentRequet 当前请求权限节点 * @return string */ public static function builtMenu($userInfo, $currentRequet) { //TODO::可以根据业务实现缓存菜单文件 $rbacManage = \Core\ServiceLocator::getInstance()->get('rbacManage'); $itemGroup = $rbacManage->getItemsGroup('*', null); $userPermissionIds = []; foreach ($rbacManage->userPermissions as $ps) { $userPermissionIds[] = $ps['item_id']; } $menuHtml = ''; PC::debug($itemGroup); foreach ($itemGroup as $item) { if (!isset($item['sub'])) { continue; } $shtml = ''; $liActive = ''; foreach ($item['sub'] as $subNode) { //管理员显示所有菜单 if (!$rbacManage->isAdmin($userInfo['name'])) { if (!in_array($subNode['id'], $userPermissionIds)) { continue; } } if ($subNode['show'] == RbacItemModel::ITEM_SHOW_NOT) { continue; } $subLiActive = ''; if ($currentRequet == strtolower($subNode['title'])) { $liActive = $subLiActive = 'active'; } $shtml .= "<li class='{$subLiActive}'><a href=\"{$subNode['title']}\"><i class=\"fa fa-circle-o text-aqua\"></i><span>{$subNode['desc']}</span></a></li>"; } if (!$shtml) { continue; } $menuHtml .= "<li class=\"treeview {$liActive}\">\n <a href=\"#\"><i class=\"fa fa-th\"></i><span>{$item['desc']}</span><i class=\"fa fa-angle-left pull-right\"></i></a>\n <ul class=\"treeview-menu\">" . $shtml . "</ul>\n </li>"; } return $menuHtml; }
public function _remap($method) { //echo "Method: $method <br>\n"; //echo "Params: "; PC::_remap(func_get_args()); $params = array_slice(func_get_args(), 1); if (!is_array($params)) { $val = $params; $params = array($val); } if (method_exists($this, $method)) { if (!$this->initialized) { $this->_initialize(); } return call_user_func_array(array($this, $method), $params); } $string[0] = $method; for ($i = 0; $i < count($params); $i++) { array_push($string, $params[$i]); } if (strrpos($method, '.html') === strlen($method) - 5 && method_exists($this, "seo")) { if (!$this->initialized) { $this->_initialize(); } return call_user_func_array(array($this, "seo"), $string); } if (method_exists($this, "query")) { if (!$this->initialized) { $this->_initialize(); } return call_user_func_array(array($this, "query"), $string); } if (method_exists($this, "index")) { if (!$this->initialized) { $this->_initialize(); } return call_user_func_array(array($this, "index"), $string); } return "__404__"; }
public function action_index($options = array()) { $breadcrumbs = new Model_Widgets_Breadcrumb(); $paths[] = array("title" => "Главная", "path" => "/"); $uri = Request::detect_uri(); $dirs = explode("/", $uri); array_shift($dirs); foreach ($dirs as $dir) { $path = $breadcrumbs->getPath($dir); if ($path != FALSE) { $paths[] = array("title" => $path["name"], "path" => $path["path"]); } } $cnt = count($paths) - 1; $paths[$cnt]["path"] = ""; // --- Не удалять!!! -------------------------------------------------- $node = $paths[count($paths) - 1]; $paths[0]["path"] = ""; unset($paths[count($paths) - 1]); // --- /Не удалять!!! ------------------------------------------------- $model = array("nodes" => $paths, "node" => $node); PC::debug($model, "breadcrumb"); $this->set_template("/widgets/w_breadcrumb.php", "twig")->render($model)->body(); }
public function debug($model) { $this->parse_model($model); PC::debug($this->model, 'parse model'); }
/** * 七牛操作 * @method opration * @param string $op [操作命令] * @return bool [操作结果] * @author NewFuture */ private static function opration($op, $data = null, $host = self::QINIU_RS) { $token = self::sign(is_string($data) ? $op . "\n" . $data : $op . "\n"); $url = $host . $op; $header = array('Authorization: QBox ' . $token); if ($ch = curl_init($url)) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); if ($data) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } curl_setopt($ch, CURLOPT_HEADER, 1); $response = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($status == 200) { return true; } elseif (\Config::get('isdebug')) { /*操作出错*/ \PC::debug($response, '七牛请求出错'); } } \Log::write('[QINIU]七牛错误' . $url . ':' . ($response ?: '请求失败'), 'ERROR'); return false; }
<?php //设置网页编码格式为utf-8 header("Content-type:text/html; charset=utf-8"); //设置当前时区 date_default_timezone_set('Asia/Shanghai'); //引入文件config.php、pc.php require_once 'config.php'; require_once 'framework/pc.php'; //执行PC文件内的run函数,参数为$config变量内的值 PC::run($config);
function load_options() { $this->register_admin_options(); $options = $this->block->data('admin_options'); if ($options != null) { $this->options = $options; } if (empty($this->options)) { $this->options = array(); PC::admin_options("Initialize " . $this->block->name); } }
echo $this->showDescription(); } public function showDescription() { return $this->os . " Memory;" . $this->RAM . " CPU;" . $this->CPU; } } $pc = new PC(2.5, 2000, "MAC OS", "Desctop"); $pc->showInfo(); $pc->CPU = 2.7; echo '<br><br>'; $pc->showInfo(); echo '<br><br>'; echo $pc; echo "<hr><div style='height:10px; background-color:red;'></div>"; $pc2 = new PC(3.5, 7000, "Windows XP", "Tower"); $pc3 = clone $pc2; $pc2->showInfo(); $pc2->CPU = 2.7; echo '<br><br>'; $pc2->showInfo(); echo '<br><br>'; echo $pc2; echo "<hr><div style='height:10px; background-color:red;'></div>"; $pc3->showInfo(); //$pc3->CPU = 2.7; echo '<br><br>'; $pc3->showInfo(); echo '<br><br>'; echo $pc3; echo "<hr><div style='height:10px; background-color:red;'></div>";
param("al", $al); // mira lo que hace extract(), todavía no lo uso aquí param("ca", $ca); // seria buena idea si son muchos parametros param("vi", $vi); // empezamos el query string para pasarlo a hacer_lista() $qs = "{$yo}?"; $con = db_open($db_name); echo "KEYS:", br(); foreach (["artistas", "albumes", "canciones", "videos"] as $t) { echo "{$t} PK: ", db_getPK($db_name, $t), br(); $ka = db_getFK($db_name, $t); if ($ka[0]) { echo "{$t} FK: " . $ka[1][0][0] . " ref tabla " . $ka[1][0][1] . " col " . $ka[1][0][2] . br(); } PC::db($ka, "{$t}"); $rfk = db_getrFK($db_name, $t); if ($rfk[0]) { echo "Referencias a {$t}: ", table($rfk[0], $rfk[1]); } } // empezamos por las canciones de momento, luego veremos que hacer con los videos if ($ca) { // mostrar la cancion selecionada $qs .= "vi={$vi}&"; $videos = db_query($con, "SELECT tipo_video, enlace FROM videos WHERE id_cancion={$ca} ORDER BY 1, 2")[1]; if ($videos) { foreach ($videos as $v) { echo br(), "{$v['0']}: {$v['1']}" . t("video", t("source", "", ["src" => $v[1]]), ["width" => 320, "height" => 240, "controls" => ""]); } } else {
<?php require_once __DIR__ . '/../../src/PhpConsole/__autoload.php'; \PhpConsole\OldVersionAdapter::register(); // register PhpConsole class emulator // Call old PhpConsole v1 methods as is PhpConsole::start(true, true, $_SERVER['DOCUMENT_ROOT']); PhpConsole::debug('Debug using old method PhpConsole::debug()', 'some,tags'); debug('Debug using old function debug()', 'some,tags'); echo $undefinedVar; PhpConsole::getInstance()->handleException(new Exception('test')); // Call new PhpConsole methods, if you need :) \PhpConsole\Connector::getInstance()->setServerEncoding('cp1251'); \PhpConsole\Helper::register(); PC::debug('Debug using new methods'); echo 'So there is an easy way to migrate from PhpConsole v1.x to v3.x without any code changes';
private function error($msg) { Log::write('{SQL PDO exec PRE ERROR}:' . $msg, 'ERROR'); $this->_isdebug and \PC::DB($msg, 'ERROR'); }
$f->debutTable(HORIZONTAL); $f->champTexte("", "", $ct->ct_no . " - " . $ct->ct_nom, 45, 45); $f->champValider("OUI-destruction-de-ce-compte", "action"); $f->champCache("pc_id", $pc_id); $f->fin(); print "<br /><br />"; print Imprime_titreListe("<b>S I N O N</b> => <a href=\"budgets.php?action=gestion-du-projet-choisi&pj_id={$pc->pj_id}\" style=\"color:blue;\">retour au budget du projet</a>", "ffA fs12 fwN"); print "</td></tr></table>\n"; print "<br />"; unset($pc); unset($ct); print Html3("bas"); break; case "OUI-destruction-de-ce-compte": // ====================================== d e t ru i r e $pc = new PC("pcs"); $pc->Get_pc($bd, $pc_id); $pc->Detruire($bd); $operation = "!destruction complétée"; $url = "Location: budgets.php?action=gestion-du-projet-choisi&operation={$operation}&pj_id={$pc->pj_id}"; header($url); exit; break; case "sommaire": //====================================================== s o m m a i r e $projets = array(); $dateRapport = trim($_SESSION['dateRapport']) == "" ? $aujour : $_SESSION['dateRapport']; print Html3("haut", "AAQ-Projets-Sommaire", $css); print Menu_budget("cp"); //print("<br />"); $wt = "100%";
function process_editor() { //echo "Intercepted"; global $BuilderEngine; $BuilderEngine->set_editor_active(); $argv = func_get_args(); PC::vardumps($argv, '$argv'); if (strstr($argv[0], ".html")) { $argv[0] = str_replace(".html", "", $argv[0]); $data = explode("-", $argv[0], 2); call_user_func_array(array($this, 'process'), $data); } else { call_user_func_array(array($this, 'process'), $argv); } }
function add_block($parent, $type) { $page_path = $_POST['page_path']; PC::page_paths($page_path); $this->BuilderEngine->set_page_path($page_path); //$this->blocks->set_page_path($this->blocks->get_page_path_of($parent)); $max_id = $this->blocks->get_max_block_id(); $new_id = $max_id + 1; $new_block_name = "custom-block-" . $new_id; $block = new Block($parent); $block->load(); $new_block = new Block($new_block_name); $new_block->set_type($type); if (isset($_POST['data_class']) && $_POST['data_class'] != "") { $new_block->add_css_class($_POST['data_class']); } if ($block->is_global()) { $new_block->set_global(true); } $block->add_block_first($new_block); $block->save(); $new_block->set_content("Your new block."); $new_block->show(); }