public function edit() { $id = (int) $_GET['id']; if (!empty($_POST)) { $level = $this->category->get_level($_POST['p_id']); if ($level <= 3 && $level > 0) { $data = array('id' => $id, 'name' => $_POST['name'], 'intro' => $_POST['intro'], 'sort' => $_POST['sort'], 'pid' => $_POST['p_id'], 'level' => $level); $this->category->save($data); $this->success('更新成功', '/category'); return; } else { $this->success('更新失败,最大分类不能超过三级', '/category/edit?id=' . $id); } } $p_name = '根节点'; $categories = $this->category->format_tree($this->category->get_all()); $root = array(array('id' => -1, 'pId' => 0, 'name' => $p_name)); $categories = array_merge($root, $categories); fb($categories); $category = $this->category->find($id); foreach ($categories as $value) { if ($value['id'] == $category['pid']) { $p_name = $value['name']; } } $this->assign('categories', $categories); $this->assign('category', $category); $this->assign('p_name', $p_name); $this->display(); }
/** * */ public function ajax_carga_capa() { header('Content-type: application/json'); $this->load->library("visor/capa/visor_capa_elemento"); $params = $this->input->post(null, true); $data = array("correcto" => true, "capa" => array("zona" => "", "icono" => "", "nombre" => "", "color" => "", "json" => array())); /*$regiones_usuario = explode(",",$this->session->userdata('session_regiones')); foreach($regiones_usuario as $region){ $retorno = $this->visor_capa_elemento->cargaCapasRegion($region); $data["capa"]["nombre"] = $retorno["capa"]["nombre"]; $data["capa"]["icono"] = $retorno["capa"]["icono"]; $data["capa"]["color"] = $retorno["capa"]["color"]; $data["capa"]["zona"] = $retorno["capa"]["zona"]; if(is_array($retorno["capa"]["json"])){ $data["capa"]["json"] = array_merge($retorno["capa"]["json"], $data["capa"]["json"]); } }*/ foreach ($params["emergencia"] as $id_emergencia) { fb($id_emergencia); $this->visor_capa_elemento->setEmergencia($id_emergencia); $retorno = $this->visor_capa_elemento->cargaCapa($params["id"]); $data["capa"]["nombre"] = $retorno["capa"]["nombre"]; $data["capa"]["icono"] = $retorno["capa"]["icono"]; $data["capa"]["color"] = $retorno["capa"]["color"]; $data["capa"]["zona"] = $retorno["capa"]["zona"]; if (is_array($retorno["capa"]["json"])) { $data["capa"]["json"] = array_merge($retorno["capa"]["json"], $data["capa"]["json"]); } } echo json_encode($data); }
/** +---------------------------------------------------------- * 显示页面Trace信息 +---------------------------------------------------------- * @access private +---------------------------------------------------------- */ private function showTrace() { // 系统默认显示信息 $log = Log::$log; $files = get_included_files(); $trace = array('请求时间' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']), '当前页面' => __SELF__, '请求协议' => $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'], '运行信息' => $this->showTime(), '会话ID' => session_id(), '日志记录' => !empty($log) ? $log : '无日志记录', '加载文件' => $files); // 读取项目定义的Trace文件 $traceFile = CONF_PATH . 'trace.php'; if (is_file($traceFile)) { // 定义格式 return array('当前页面'=>$_SERVER['PHP_SELF'],'通信协议'=>$_SERVER['SERVER_PROTOCOL'],...); $trace = array_merge(include $traceFile, $trace); } // 设置trace信息 trace($trace); $fire = array(array('', '')); foreach (trace() as $key => $value) { $fire[] = array($key, $value); } if (headers_sent($filename, $linenum)) { $fileInfo = !empty($filename) ? "(在{$filename}文件的第{$linenum}行)" : ''; Log::record("已经有Http Header信息头输出{$fileInfo},请在你的入口文件加入ob_start() 或通过配置output_buffering,已确保headers不被提前输出"); } else { fb(array('页面Trace信息', $fire), FirePHP::TABLE); } }
/** * 修改之前,如果没有修改权限的权力,而且又对权限进行了修改,则强制失败并提示 * @see \yii\db\BaseActiveRecord::beforeSave($insert) */ public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($insert) { //新建插入 //没有新建的权限(插入前检查) // Yii::$app->getSession()->setFlash('denger', 'You do not have permission to modify the user permissions!'); // return false; } else { //更新 $is_admin = Yii::$app->getUser()->getIdentity()->attributes['is_admin']; if (!$is_admin && !Yii::$app->getUser()->can('auth/auth')) { //无权修改 fb('ddd'); exit; //如果修改了权限则 if ($this->getAttribute('role_name') != $this->getOldAttribute('role_name')) { $this->setAttribute('role_name', $this->getOldAttribute('role_name')); //恢复并提示 Yii::$app->getSession()->setFlash('warning', 'You do not have permission to modify the user permissions!'); } } } return true; } else { return false; } }
public static function getAllNetworksByAid($aid) { $sdb = SDB::getInstance(); $domain = Network::$SDBDomain; $aaa = array(); foreach (Network::$SDBFields as $field => $meta) { $aaa[] = $field; } $where = "where `aid` = '{$aid}'"; if (!$sdb->select($domain, $aaa, $where)) { return null; } fb("aaa", $aaa); $appNetworks = array(); foreach ($aaa as $aa) { $appNetwork = new Network(); foreach (Network::$SDBFields as $field => $meta) { if (array_key_exists($field, $aa)) { $appNetwork->{$field} = $aa[$field]; } } $appNetwork->id = $aa['id']; $appNetwork->postGet(); $appNetworks[] = $appNetwork; } return $appNetworks; }
/** * Lista la capa por una propiedad del elemento * @param int $id_capa * @param string $string * @return html */ public function listaByCapaPropiedad($id_capa, $string) { $query = $this->_query->select("p.*")->from($this->_tabla . " p")->join("capas_geometria g", "g.geometria_id = p.poligono_capitem", "INNER")->whereAND("g.geometria_capa", $id_capa)->whereAND("p.poligono_propiedades", $string, "like"); fb($query->getQuery()); $result = $query->getAllResult(); return $result; }
protected function execute($query_string) { if (in_array("curl", get_loaded_extensions())) { fb($this->getNmiUrl()); fb($query_string); $ch = curl_init($this->getNmiUrl()); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); curl_setopt($ch, CURLOPT_REFERER, ""); $response = curl_exec($ch); curl_close($ch); $result = array(); $result['query_string'] = $query_string; // TO DO, PARSE RESULT AND PROCESS AVS RETURN CODES if (!$response) { $result['response'] = 2; $result['responsetext'] = 'There was an error communicating with the NMI gateway'; } else { parse_str($response, $result); } return $result; } else { throw new Exception('Could not load cURL libraries. Make sure PHP is compiled with cURL'); } }
/** * Log permission checks to the permission_checks.log file * * @param MEMBER The user checking against * @param ID_TEXT The function that was called to check a permission * @param array Parameters to this permission-checking function * @param boolean Whether the permission was held */ function _handle_permission_check_logging($member, $op, $params, $result) { global $PERMISSION_CHECK_LOGGER; if ($op == 'has_specific_permission') { require_all_lang(); $params[0] = $params[0] . ' ("' . do_lang('PT_' . $params[0]) . '")'; } $str = $op; if (count($params) != 0) { $str .= ': '; foreach ($params as $i => $p) { if ($i != 0) { $str .= ','; } $str .= is_string($p) ? $p : (is_null($p) ? '' : strval($p)); } } if ($PERMISSION_CHECK_LOGGER !== false && !$result) { fwrite($PERMISSION_CHECK_LOGGER, "\t" . $str); $username = $GLOBALS['FORUM_DRIVER']->get_username($member); if (is_null($username)) { $username = do_lang('UNKNOWN'); } if ($member != get_member()) { fwrite($PERMISSION_CHECK_LOGGER, ' -- ' . $username); } // fwrite($PERMISSION_CHECK_LOGGER,' --> '.($result?do_lang('YES'):do_lang('NO')).chr(10)); fwrite($PERMISSION_CHECK_LOGGER, chr(10)); sync_file(get_custom_file_base() . '/data_custom/permissioncheckslog.php'); } if (function_exists('fb') && get_param_integer('keep_firephp', 0) == 1 && !headers_sent()) { fb('Permission check ' . ($result ? 'PASSED' : 'FAILED') . ': ' . $str); } }
protected function write(array $record) { if (function_exists('fb')) { switch ($record['level_name']) { case 'DEBUG': $l = 'LOG'; break; case 'INFO': case 'NOTICE': $l = 'INFO'; break; case 'WARNING': $l = 'WARN'; break; case 'ERROR': case 'CRITICAL': case 'ALERT': case 'EMERGENCY': $l = 'ERROR'; break; default: $l = 'LOG'; break; } if (!empty($record['context'])) { fb($record['context'], $record['message'], $l); } else { fb($record['message'], $l); } } }
/** * replace internal katadebug-function */ function kataDebugOutput($var = null, $isTable = false) { if (!$isTable) { fb($var); } else { /* $widths = array(); foreach ($var as $line) { $cellNo = 0; foreach ($line as $cell) { if (!isset($widths[$cellNo])) { $widths[$cellNo]=0; } $widths[$cellNo] = max($widths[$cellNo],strlen($cell)); $cellNo++; } } foreach ($var as $line) { $s = ''; $cellNo = 0; foreach ($line as $cell) { $s.=$cell.str_repeat(' ',$widths[$cellNo]-strlen($cell)).' | '; $cellNo++; } fb($s); } */ fb($var, 'see below', FirePHP::TABLE); } }
public function index() { $articles = $this->articleModel->getArticles(); fb($articles); $this->assign('articles', $articles); $this->display(); }
function __construct($text1, $text2) { $this->text1 = $text1; $this->text2 = $text2; $this->get_trial1(); fb($this); }
public function js() { $row = $this->input->getInt('row'); $col = $this->input->getInt('col'); $uid = $this->input->getInt('uid'); $count = $row * $col; $sql = 'SELECT ads.* FROM ck_ads as ads JOIN ck_packages as pack ON(ads.package_id=pack.id) WHERE ads.status="approve" AND ads.clicked < pack.max_click ORDER BY RAND() LIMIT ' . $count; $query = $this->db->query($sql); $tmpl = Template::getInstance('empty.tpl'); $tmpl->loadPage('jsAds'); fb($col, 'row'); for ($i = 0; $i < $row; ++$i) { $tmp = array(); for ($j = 0; $j < $col; ++$j) { $tmp[] = $query->fetch(); } $data[] = $tmp; } fb($data); $tmpl->assign('uid', $uid); $tmpl->assign('row', $row); $tmpl->assign('col', $col); $tmpl->assign('data', $data); Response::getInstance()->setTemplate($tmpl); }
public function show() { if ($this->input->getString('traceID') || $this->input->getString('traceCode')) { $this->traceID = $this->input->getString('traceID'); $this->traceCode = $this->input->getString('traceCode'); $this->tmpl->assign('hasResult', true); $req = array(); $req[] = $this->db->SimpleSelect('sh_requests', 'status,code', array('code' => $this->traceID))->fetch(); $req[] = $this->db->SimpleSelect('sh_requests', 'status,code', array('code' => $this->traceCode))->fetch(); $req[] = $this->db->SimpleSelect('fr_requests', 'status,code', array('code' => $this->traceID))->fetch(); $req[] = $this->db->SimpleSelect('fr_requests', 'status,code', array('code' => $this->traceCode))->fetch(); for ($i = 0; $i < 4; ++$i) { if ($req[$i] != null) { if ($i < 2) { $this->tmpl->assign('shop_type', 'شخصی'); } else { $this->tmpl->assign('shop_type', 'مشارکتی'); } $this->tmpl->assign('status', $req[$i]->status); $this->tmpl->assign('trace_code', $req[$i]->code); fb($req); } } } $this->reponse->setTitle('لیست کالاها'); $this->tmpl->loadPage('traceShow'); $this->reponse->setTemplate($this->tmpl); }
protected function _send($content) { if (!function_exists('fb')) { throw new lmbException("FirePHP function 'fb' not found"); } fb($content, 'new mail'); }
/** * firephp debug * * @param string $info debug信息 */ public static function fbDebug($info = '') { if (!RThink_Config::get('app.debug')) { return; } require_once 'Debug/Firephp/Fb.php'; fb($info, FirePHP::TRACE); }
function _dump() { if (is_terminal) { print_r($message); } else { fb($message); } }
public function doWell($text) { $k = array_keys($this->data); $v = array_values($this->data); fb(array_shift($k)); fb(array_shift($v)); return str_replace(array_keys($this->data), array_values($this->data), $text); }
public function select($domain, &$aaa, $where, $showAliveOnly = true, $attempts = 2) { if ($attempts <= 0) { return; } if ($showAliveOnly) { if (empty($where)) { $where = "where deleted is null"; } else { $where .= " intersection deleted is null"; } } if (is_array($aaa)) { $select = "select `" . implode("`, `", $aaa) . "` from `" . $domain . "` " . $where; } else { $select = "select {$aaa} from `{$domain}` {$where}"; } fb($select, ""); $aaa = array(); $selectRequest = new Amazon_SimpleDB_Model_SelectRequest(); $selectRequest->setSelectExpression($select); try { do { $response = $this->service->select($selectRequest); if ($response->isSetSelectResult()) { $selectResult = $response->getSelectResult(); $itemList = $selectResult->getItem(); foreach ($itemList as $item) { $aa = array(); if ($item->isSetName()) { $aa['id'] = $item->getName(); } $attributeList = $item->getAttribute(); foreach ($attributeList as $attribute) { if ($attribute->isSetName()) { if ($attribute->isSetValue()) { $aa[$attribute->getName()] = $attribute->getValue(); } } } array_push($aaa, $aa); $selectRequest->setNextToken($selectResult->getNextToken()); } } } while ($selectResult->isSetNextToken()); return true; } catch (Amazon_SimpleDB_Exception $ex) { //select($domain, $aaa, $where, $showAliveOnly, $attempts-1); echo "Caught Exception: " . $ex->getMessage() . "<br />\n"; // echo("Response Status Code: ".$ex->getStatusCode()."<br />\n"); // echo("Error Code: ".$ex->getErrorCode()."<br />\n"); // echo("Error Type: ".$ex->getErrorType()."<br />\n"); // echo("Request ID: ".$ex->getRequestId()."<br />\n"); // echo("XML: ".$ex->getXML()."<br />\n"); // echo("Select: $select<br />\n"); } return false; }
/** * 同步指定项目的指定插件 * * @param string $project_id * 项目编号 * @param string $plugin_id * 插件编号 * @param string $collectionName * 集合名称 * @return true false */ public function syncPluginCollection($project_id, $plugin_id, $collectionName) { $pluginCollectionInfo = $this->findOne(array('plugin_id' => $plugin_id, 'alias' => $collectionName)); if ($pluginCollectionInfo == null) { fb('$pluginCollectionInfo is null', 'LOG'); return false; } // 同步数据结构 $syncPluginStructure = function ($plugin_id, $collection_id) use($pluginCollectionInfo) { if ($collection_id instanceof \MongoId) { $collection_id = $collection_id->__toString(); } $this->_structure->physicalRemove(array('collection_id' => $collection_id)); // 插入新的数据结构 $cursor = $this->_plugin_structure->find(array('plugin_id' => $plugin_id, 'plugin_collection_id' => $pluginCollectionInfo['_id']->__toString())); while ($cursor->hasNext()) { $row = $cursor->getNext(); array_unset_recursive($row, array('_id', 'collection_id', '__CREATE_TIME__', '__MODIFY_TIME__', '__REMOVED__')); $row['collection_id'] = $collection_id; $this->_structure->update(array('collection_id' => $collection_id, 'field' => $row['field']), array('$set' => $row), array('upsert' => true)); } return true; }; // 添加映射关系 $createMapping = function ($collection_id, $collectionName) use($project_id, $plugin_id) { if ($collection_id instanceof \MongoId) { $collection_id = $collection_id->__toString(); } $projectPluginInfo = $this->_project_plugin->findOne(array('project_id' => $project_id, 'plugin_id' => $plugin_id)); if ($projectPluginInfo !== null) { $source_project_id = $projectPluginInfo['source_project_id']; if (!empty($source_project_id)) { $collectionInfo = $this->_collection->findOne(array('project_id' => $source_project_id, 'plugin_id' => $plugin_id, 'alias' => $collectionName)); $this->_mapping->update(array('project_id' => $project_id, 'collection_id' => $collection_id), array('$set' => array('collection' => 'idatabase_collection_' . myMongoId($collectionInfo['_id']), 'database' => DEFAULT_DATABASE, 'cluster' => DEFAULT_CLUSTER, 'active' => true)), array('upsert' => true)); return true; } } return false; }; if ($pluginCollectionInfo != null) { unset($pluginCollectionInfo['_id']); $collectionInfo = $pluginCollectionInfo; $collectionInfo['project_id'] = array($project_id); $check = $this->_collection->findOne(array('project_id' => $project_id, 'alias' => $collectionName)); if ($check == null) { $this->_collection->insertRef($collectionInfo); $syncPluginStructure($plugin_id, $collectionInfo['_id']); $createMapping($collectionInfo['_id'], $collectionName); return $collectionInfo; } else { $this->_collection->update(array('_id' => $check['_id']), array('$set' => $collectionInfo)); $syncPluginStructure($plugin_id, $check['_id']); $createMapping($check['_id'], $collectionName); } return $check; } return false; }
* headers输出,你可以在入口文件第一行加入代码 ob_start(); 或者配置output_buffering * */ namespace Behavior; /** * 系统行为扩展 页面Trace显示输出 */ class FireShowPageTraceBehavior { protected $tracePagTabs = array('BASE' => '基本', 'FILE' => '文件', 'INFO' => '流程', 'ERR|NOTIC' => '错误', 'SQL' => 'SQL', 'DEBUG' => '调试'); // 行为扩展的执行入口必须是run public function run(&$params) { if (C('FIRE_SHOW_PAGE_TRACE', null, true)) { $this->showTrace(); } } /** * 显示页面Trace信息 * @access private */ private function showTrace() { // 系统默认显示信息 $files = get_included_files(); $info = array(); foreach ($files as $key => $file) { $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; } $trace = array(); $base = array('请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . __SELF__, '运行时间' => $this->showTime(), '内存开销' => MEMORY_LIMIT_ON ? number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024, 2) . ' kb' : '不支持', '查询信息' => N('db_query') . ' queries ' . N('db_write') . ' writes ', '文件加载' => count(get_included_files()), '缓存信息' => N('cache_read') . ' gets ' . N('cache_write') . ' writes ', '配置加载' => count(c()), '会话信息' => 'SESSION_ID=' . session_id()); // 读取应用定义的Trace文件 $traceFile = CONF_PATH . 'trace.php'; if (is_file($traceFile)) { $base = array_merge($base, include $traceFile); } $debug = trace(); $tabs = C('TRACE_PAGE_TABS', null, $this->tracePagTabs); foreach ($tabs as $name => $title) { switch (strtoupper($name)) { case 'BASE': // 基本信息 $trace[$title] = $base; break; case 'FILE': // 文件信息 $trace[$title] = $info; break; default: // 调试信息 if (strpos($name, '|')) { // 多组信息 $array = explode('|', $name); $result = array(); foreach ($array as $name) { $result += isset($debug[$name]) ? $debug[$name] : array(); } $trace[$title] = $result;
/** * * * @param unknown $safeFile * @param unknown $srid * @param unknown $file * @param unknown $pdo */ function __construct($safeFile, $srid, $file, $pdo) { parent::__construct(); $this->safeFile = $safeFile; $this->srid = $srid; $this->file = $file; $this->pdo = $pdo; fb($pdo); }
/** * Admin page and post search * * @param string $query Search term, encoded by Javascript's encodeURI() */ function wf_search($query = '') { fb($query); $query = urldecode($query); $postResults = $this->WildPost->search($query); $pageResults = $this->WildPage->search($query); $results = am($postResults, $pageResults); $this->set('results', $results); }
public function getData() { if (!isset($this->data)) { $query = "SELECT id, name, username, email FROM #__users"; $this->data = $this->_getList($query); } fb($this->data[0]->username); return $this->data; }
public function executeGzcTest() { //$log = sfLogTable::getInstance()->find; $logs = sfLogTable::getInstance()->CreateQuery()->addWhere('server_zip is null')->limit(2500)->execute(); $i_sum = 0; foreach ($logs as $log) { $i = 0; if (is_null($log->getPostZip())) { $log->setPostZip(gzcompress(json_encode(unserialize($log->getPost())), 9)); $i = 1; } if (is_null($log->getRequestZip())) { $log->setRequestZip(gzcompress(json_encode(unserialize($log->getRequest())), 9)); $i = 1; } if (is_null($log->getGetZip())) { $log->setGetZip(gzcompress(json_encode(unserialize($log->getGet())), 9)); $i = 1; } if (is_null($log->getServerZip())) { $log->setServerZip(gzcompress(json_encode(unserialize($log->getServer())), 9)); $i = 1; } $i_sum += $i; $log->save(); } fb($i_sum); /* ALTER TABLE `sf_log` DROP `post`, DROP `get`, DROP `request`, DROP `server`; vs. update sf_log set server = NULL, request = null, post=NULL, get = NULL; */ die('1'); //$log->setPostZip($log->getPost()); echo '<pre>'; fb(json_decode(gzuncompress($log->getPostZip()), true)); $log->setPostZip(gzcompress(json_encode(unserialize($log->getPost())), 9)); $log->save(); die('Ok'); /* ALTER TABLE sf_log ROW_FORMAT = COMPRESSED , KEY_BLOCK_SIZE =4 SELECT table_schema "DB Name", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" FROM information_schema.tables GROUP BY table_schema; */ }
function fb($n) { if ($n == 0) { return 0; } elseif ($n < 3 and $n !== 0) { return 1; } else { return fb($n - 1) + fb($n - 2); } }
private function __unify($list) { // najprv vyextrahuje udaje len na pole mailov $list = $this->__getMailList($list); // naslene prefiltruje podla nastaveni $list = $this->__filterList($list); // vrati zoznam zle bez opakujucich sa mailov // TODO: potrebne ? fb($list, "Mail list"); return array_unique($list); }
private function getWeblogId() { fb('ssss', FirePHP::TRACE); $ob = Factory::getDBO()->SimpleSelect('wb_weblogs', 'id', array("site_id" => ResponseRegistery::getInstance()->site_id))->fetch(); fb($ob, 'admin'); if ($ob) { return intval($ob->id); } else { return 0; } }
public function expert() { $id = (int) $_GET['id']; $expert = M('expert')->where("id={$id}")->find(); $this->assign('expert', $expert); fb($expert); $this->display(); }
protected function parse_uri() { $u = parse_url($this->uri); $u['path']; $r = explode('/', $u['path']); $r = array_filter($r); fb($r); }