pbootcms是與aspcms一家公司開發的企業網站系統,很是完美的企業網站系統,功能齊全,方便靈活,支持sqlite/mysql數據庫php
{php}echo 111+222;{/php}
引入命名空間
use corebasicModel;
use corebasicDb;html
$a = Db::table('ay_content')->where('id=1')->find(); var_dump($a); $model = new Model(); $r = $model->table('ay_content')->where('id=1')->find(); var_dump($r);
以上兩種是等價的,第一種Db經過__callstatic靜態魔術方法來調用Model類的方法mysql
public function importold() { exit('已經導入新聞'); set_time_limit(0); $data = json_decode('{"acode":"cn","scode":"16","subscode":"","title":"\u6807\u9898","titlecolor":"#333333","subtitle":"","filename":"","author":"admin","source":"\u672c\u7ad9","outlink":"","date":"2018-12-30 10:45:46","ico":"\/static\/upload\/image\/20181230\/1546137994102175.png","pics":"\/static\/upload\/image\/20181230\/1546138005227320.png,\/static\/upload\/image\/20181230\/1546138006814526.png","content":"<p>\u5185\u5bb9<\/p>","enclosure":"","keywords":"","description":"\u5185\u5bb9","sorting":255,"status":"1","istop":0,"isrecommend":0,"isheadline":0,"visits":0,"likes":0,"oppose":0,"create_user":"admin","update_user":"admin"}',true); //var_dump($data);die(); //對應關係數組 文章 產品 單頁 $relation = array( 1 => 16, 3 => 12, 6 => 38, 8 => 35, 10 => 18, 13 => 25, 15 => 31, 18 => 13, 20 => 14, 31 => 22, 33 => 27, 34 => 33 ); $i = 0; //php訪問mdb 數據庫 //成功導入數據1611條 $connstr = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=#Database#.mdb"; $connid = @odbc_connect($connstr,"","",SQL_CUR_USE_ODBC ) or die ("數據庫鏈接錯誤!"); $sql = "select * from jtbc_articles"; $exec = odbc_exec($connid,$sql); while($row = odbc_fetch_array($exec)) { //重置這些內容 以避免下一個 $data['ico'] = ''; $data['pics'] = ''; if(isset($relation[$row['a_class']]) && $row['a_id'] != 540) { //有相應的欄目對應關係的話 $data['scode'] = $relation[$row['a_class']]; $data['title'] = escape_string(iconv('gb2312', 'utf-8', $row['a_topic'])); $data['content'] = iconv('gb2312', 'utf-8', $row['a_content']); $data['content'] = escape_string(str_replace('{$->>repath}articles/common/upload/', '/static/upload/', $data['content'])); $data['description'] = mb_substr(strip_tags($data['content']), 0, 150, 'utf-8'); $data['date'] = $row['a_time']; $data['visits'] = $row['a_count']; if ($row['a_content_images'] != '') { if (strpos($row['a_content_images'], '|') !== false) { $data['pics'] = str_replace('|', ',', $row['a_content_images']); $data['pics'] = str_replace('common/upload/', '/static/upload/', $data['pics']); $data['ico'] = explode(',', $data['pics'])[0]; } else { $data['ico'] = $row['a_content_images']; } } //var_dump($data); //exit(); if (! ! $id = $this->model->addContent($data)) { $i++; } } } echo "成功導入數據" . $i . '條'; }
先斷點獲取到輸入文章時的數組,每條導入數據只須要賦值須要變動的部分,注意每次重置數據項爲空sql
碰到的大坑
php odbc鏈接 查詢顯示不完整問題
在php.ini裏找到[ODBC] 下面有odbc.defaultlrl = 4096 你改正你想要設置 的大小就ok數據庫
<?php /** * @copyright (C)2016-2099 Hnaoyun Inc. * @license This is not a freeware, use is subject to license terms * @author XingMeng * @email hnxsh@foxmail.com * @date 2018-08-09 16:03:55 * 翱雲科技版權全部,除本受權文件其他代碼均開源,未經許可擅自破解本文件將依法追究法律責任。 */ namespace core\basic; class Kernel { private static $controllerPath; public static function run() { //self::license(); self::loadCache(); $path_info = self::getPathInfo(); $path_info = self::urlBlind($path_info); $path_info = self::urlRoute($path_info); $access_path = self::getAccessPath($path_info); self::regAppPath($access_path); self::loadComm(); self::loadController(); } private static function getPathInfo() { if (isset($_SERVER['PATH_INFO']) && !mb_check_encoding($_SERVER['PATH_INFO'], 'utf-8')) { $_SERVER['PATH_INFO'] = mb_convert_encoding($_SERVER['PATH_INFO'], 'UTF-8', 'GBK'); } if (isset($_SERVER['PATH_INFO'])) { $path_info = $_SERVER['PATH_INFO']; } elseif (isset($_SERVER["REDIRECT_URL"])) { $path_info = str_replace('/' . basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['REDIRECT_URL']); $path_info = str_replace(SITE_DIR, '', $path_info); $_SERVER['PATH_INFO'] = $path_info; } elseif (isset($_GET['s'])) { $path_info = $_GET['s']; } else { $path_info = ''; } if ($path_info) { $pattern = '{^\/?([\x{4e00}-\x{9fa5}\w-\/\.' . Config::get('url_allow_char') . ']+?)?\/?$}u'; if (preg_match($pattern, $path_info)) { $path_info = preg_replace($pattern, '$1', $path_info); $url_html_suffix = Config::get('url_suffix'); if (substr($path_info, -strlen($url_html_suffix)) == $url_html_suffix) { $path_info = substr($path_info, 0, -strlen($url_html_suffix)); } } else { error('您訪問路徑含有非法字符,防注入系統提醒您請勿嘗試非法操做!'); } } return $path_info; } private static function urlBlind($pathInfo) { $path = ''; if (!!$domains = Config::get('app_domain_blind')) { $server_name = str_replace(':' . $_SERVER['SERVER_PORT'], '', $_SERVER['HTTP_HOST']); if (isset($domains[$server_name])) { $path = $domains[$server_name]; } } if (defined('URL_BLIND')) { if ($path) { if (strpos($path, URL_BLIND) === false && strpos(URL_BLIND, $path) === false) { error('系統配置的域名地址綁定與入口文件地址綁定衝突,請覈對!'); } elseif (strpos($path, URL_BLIND) === false && strpos(URL_BLIND, $path) !== false) { $path = URL_BLIND; } } else { $path = URL_BLIND; } } if ($path) { $path = trim_slash($path) . '/' . $pathInfo; } else { $path = $pathInfo; } return $path; } private static function urlRoute($pathInfo) { if (!!$route = Config::get('url_route')) { if (!$pathInfo && isset($route['/'])) { return $route['/']; } foreach ($route as $key => $value) { $key = str_replace('/', '\\/', trim_slash($key)); $reg = "{(.*\/|^)" . $key . "(\/.*|$)}Ui"; if (preg_match($reg, $pathInfo)) { $value = trim_slash($value); $pathInfo = preg_replace($reg, "$1$value$2", $pathInfo); break; } } } return $pathInfo; } private static function getAccessPath($pathInfo) { $apps = Config::get('public_app', true); if ($pathInfo) { $path_info = trim_slash($pathInfo); $path_array = explode('/', $path_info); $path_count = count($path_array); if ($path_count >= 3) { $access_path['m'] = $path_array[0]; $access_path['c'] = $path_array[1]; $access_path['f'] = $path_array[2]; for ($i = 3; $i < $path_count; $i = $i + 2) { if (isset($path_array[$i + 1])) { $_GET[$path_array[$i]] = $path_array[$i + 1]; } else { $_GET[$path_array[$i]] = null; } } } elseif ($path_count == 2) { $access_path['m'] = $path_array[0]; $access_path['c'] = $path_array[1]; } elseif ($path_count == 1) { $access_path['m'] = $path_array[0]; } } if (!isset($access_path['m'])) { $access_path['m'] = $apps[0]; } if (!isset($access_path['c'])) { $access_path['c'] = 'Index'; } if (!isset($access_path['f'])) { $access_path['f'] = 'index'; } if (!in_array(strtolower($access_path['m']), $apps)) { error('您訪問的模塊' . $access_path['m'] . '未開放,請覈對後重試!'); } return $access_path; } private static function regAppPath($accessPath) { define('M', strtolower($accessPath['m'])); self::$controllerPath = self::adjustController($accessPath['c']); if (!!$pos = strrpos(self::$controllerPath, '/')) { define('C', ucfirst(substr(self::$controllerPath, $pos + 1))); self::$controllerPath = substr(self::$controllerPath, 0, $pos + 1) . ucfirst(substr(self::$controllerPath, $pos + 1)); } else { define('C', ucfirst(self::$controllerPath)); self::$controllerPath = ucfirst(self::$controllerPath); } define('F', $accessPath['f']); if (isset($_SERVER["REQUEST_URI"])) { define('URL', $_SERVER["REQUEST_URI"]); } else { define('URL', $_SERVER["ORIG_PATH_INFO"] . '?' . $_SERVER["QUERY_STRING"]); } define('CORE_VERSION', Config::get('core_version')); define('APP_CONTROLLER_PATH', APP_PATH . '/' . M . '/controller'); define('APP_MODEL_PATH', APP_PATH . '/' . M . '/model'); if (($tpl_dir = Config::get('tpl_dir')) && array_key_exists(M, $tpl_dir)) { if (strpos($tpl_dir[M], ROOT_PATH) === false) { define('APP_VIEW_PATH', ROOT_PATH . $tpl_dir[M]); } else { define('APP_VIEW_PATH', $tpl_dir[M]); } } else { define('APP_VIEW_PATH', APP_PATH . '/' . M . '/view'); } } private static function adjustController($string) { $string = str_replace('.', '/', $string); $string_arr = explode('_', $string); if (count($string_arr) > 1) { $count = count($string_arr); for ($i = 1; $i < $count; $i++) { $string_arr[$i] = ucfirst($string_arr[$i]); } $string = implode($string_arr); } return $string; } private static function loadComm() { Config::get('debug') ? Check::checkAppFile() : ''; $app_config = APP_PATH . '/' . M . '/config/config.php'; if (file_exists($app_config)) { Config::assign($app_config); } define('APP_VERSION', Config::get('app_version')); define('RELEASE_TIME', Config::get('release_time')); if (M == 'api') { if (!!$sid = request('sid')) { session_id($sid); session_start(); } header("Access-Control-Allow-Origin: *"); } else { if (!ini_get('session.auto_start') && !isset($_SESSION)) { session_start(); } Check::checkBs(); Check::checkOs(); } } private static function loadController() { $class_file = self::$controllerPath . 'Controller.php'; $class_file_path = APP_CONTROLLER_PATH . '/' . $class_file; $class_name = '\\app\\' . M . '\\controller\\' . str_replace('/', '\\', self::$controllerPath) . 'Controller'; $function = F; if (!file_exists($class_file_path)) { header('HTTP/1.1 404 Not Found'); header('status: 404 Not Found'); $file_404 = ROOT_PATH . '/404.html'; if (file_exists($file_404)) { require $file_404; exit(); } else { error('對不起,您訪問的頁面不存在,請覈對後再試!'); } } if (!class_exists($class_name)) { error('類' . $class_name . '不存在!類文件' . $class_file_path . '中沒法找到!'); } $app_function = APP_PATH . '/' . M . '/function/function.php'; if (file_exists($app_function)) { require $app_function; } if (file_exists(APP_PATH . '/common/function.php')) { require APP_PATH . '/common/function.php'; } if (file_exists(APP_PATH . '/common/' . ucfirst(M) . 'Controller.php')) { $comm_class_name = '\\app\\common\\' . ucfirst(M) . 'Controller'; $comm_class = new $comm_class_name(); } $controller = new $class_name(); if (method_exists($class_name, $function)) { if (strtolower($class_name) != strtolower($function)) { $return = $controller->$function(); } else { $return = $controller; } } else { if (method_exists($class_name, '_empty')) { $return = $controller->_empty(); } else { error('方法不存在!' . M . '模塊下控制器文件' . $class_file . '中不存在您調用的方法' . $function . ',可能正在開發中,請耐心等待!'); } } if ($return !== null) { Response::handle($return); } } private static function loadCache() { if (!Config::get('tpl_html_cache') || URL_BLIND == 'api') { return; } $lg = isset($_COOKIE['lg']) ? cookie('lg') : ''; Config::get(); $config_file = RUN_PATH . '/config/' . md5('config' . $lg) . '.php'; if (!Config::assign($config_file)) { return; } $lg = $lg ?: Config::get('lgs.0.acode'); if (Config::get('open_wap') && (is_mobile() || Config::get('wap_domain') == get_http_host())) { $wap = 'wap'; } else { $wap = ''; } $cache_file = RUN_PATH . '/cache/' . md5($_SERVER["REQUEST_URI"] . $lg . $wap) . '.html'; if (file_exists($cache_file) && time() - filemtime($cache_file) < Config::get('tpl_html_cache_time')) { ob_start(); include $cache_file; $content = ob_get_contents(); ob_end_clean(); if (Config::get('gzip') && !headers_sent() && extension_loaded("zlib") && strstr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip")) { $content = gzencode($content, 6); header("Content-Encoding: gzip"); header("Vary: Accept-Encoding"); header("Content-Length: " . strlen($content)); } echo $content; exit(); } } private static function license() { if (URL_BLIND == 'admin') { return; } if (!!$sn = Config::get('sn', true)) { $host = $_SERVER['HTTP_HOST']; $key = strtoupper(substr(md5(substr(sha1($host), 0, 10)), 10, 10)); $sip = isset($_SERVER['LOCAL_ADDR']) ? $_SERVER['LOCAL_ADDR'] : $_SERVER['SERVER_ADDR']; if ($sip != '::1' && substr($sip, 0, 6) != '127.0.' && !in_array($key, $sn)) { error('未匹配到本域名有效受權碼,請到<a href="http://www.pbootcms.com" target="_blank">PbootCMS</a>官網獲取,並填寫到後臺"全局配置>>配置參數"中。'); } } else { error('配置文件中受權碼爲空,請到<a href="http://www.pbootcms.com" target="_blank">PbootCMS</a>官網獲取,並填寫到後臺"全局配置>>配置參數"中。'); } } }
有子分類調用子分類 沒有子分類顯示同級分類json
修改標籤解析控制器方法 ParserController.php中的 paseSortLabel,添加case分支api
case 'soncount': $content = str_replace($matches[0][$i], count($this->model->getSubScodes($sort->scode)), $content); break;
將appshomemodelParserModel.php中的getSubScodes方法改成public數組
public function getSubScodes($scode)
模板標籤寫法cookie
<!--沒有子類--> {pboot:if({sort:soncount} == 1)} <div class="module-inner"> <div class="t3_nav1_t nav1_color1"> <dl> <dt>{sort:parentname}</dt> <dd>Zibo Central Hospital</dd> </dl> </div> <div class="module-ct t3_nav1_b"> <ul> {pboot:nav num=100 parent={sort:pcode}} <li class="item-399 {pboot:2if('[nav:scode]'=='{sort:scode}')}current active{/pboot:2if}"><a href="[nav:link]">[nav:name]</a> </li> {/pboot:nav} </ul> </div> </div> {else} <div class="module-inner"> <div class="t3_nav1_t nav1_color1"> <dl> <dt>{sort:name}</dt> <dd>Zibo Central Hospital</dd> </dl> </div> <div class="module-ct t3_nav1_b"> <ul> {pboot:nav num=100 parent={sort:scode}} <li class="item-399"><a href="[nav:link]">[nav:name]</a> </li> {/pboot:nav} </ul> </div> </div> {/pboot:if}
{page:bar} /* 分頁樣式 */ .paging { margin-top: 32px; font-size: 14px; } .paging > span { margin: auto 16px; } .paging .page-numbar { margin: auto 0; } .paging .page-numbar .page-num, .paging .page-index, .paging .page-pre, .paging .page-next, .paging .page-last { display: inline-block; margin: auto 4px; padding: 2px 12px; border: 1px solid #EEE; border-radius: 2px; } .paging .page-numbar .page-num-current, .paging .page-numbar .page-num:hover { border-color: #8667F7; color: #8667F7; }