public function login() { if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') { if (strtolower($_SESSION['validCode']) != strtolower(trim($_POST['validCode']))) { //记录日志 $logInfo['success'] = 0; $logInfo['password'] = ''; $user_loginlog_db->insert($logInfo); //echo SITE_NAME.':验证码输入错误,<a href="login.php?user='******'email'].'">返回重新登录</a>'; echo '<script>window.location.href=\'?user='******'email'] . '&error=errorcode\';</script>'; exit; } else { $userObj = bpBase::loadAppCLass('userObj', 'user'); $rt = $userObj->adminLoginWithEmail($_POST['email'], $_POST['password']); if ($rt > 0) { //记录日志 $logInfo['success'] = 1; $logInfo['password'] = ''; $user_loginlog_db->insert($logInfo); // if (!isah()) { $thisUser = $userObj->getUserByUID($rt); setcookie('jsusername', escape($thisUser->username), SYS_TIME + 2592000, '/', DOMAIN_ROOT); $r = setcookie('autousername', $thisUser->username, SYS_TIME + 2592000, '/', DOMAIN_ROOT); } else { if (isset($_COOKIE['jsusername'])) { setcookie('jsusername', '', 0); setcookie('jsusername', '', 0, '/', DOMAIN_ROOT); setcookie('jsusername', '', 0, '/', $_SERVER['HTTP_HOST']); } } delCache('rigthsOf' . $rt); delCache('citysOf' . $rt); $_SESSION['autoAdminUid'] = $rt; //session_regenerate_id(); $_SESSION['cmsuid'] = $rt; //session_regenerate_id(); //echo '<span style="font-size:12px;">登录成功,正在转向...如果您的浏览器不能自动跳转,<a href="index.php" style="font-size:12px;">请点击</a>'; echo '<script>window.location.href=\'index.php\';</script></span>'; exit; } else { //记录日志 $logInfo['success'] = 0; $user_loginlog_db->insert($logInfo); // $_SESSION['autoAdminUid'] = null; unset($_SESSION['autoAdminUid']); //echo SITE_NAME.':登录失败,<a href="login.php?user='******'email'].'">返回重新登录</a>'; echo '<script>window.location.href=\'?user='******'email'] . '&error=notmatch\';</script>'; exit; } } } else { $m = empty($m) ? ROUTE_MODEL : $m; if (empty($m)) { return false; } include ABS_PATH . MANAGE_DIR . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $m . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'login.tpl.php'; } }
/** * 加载缓存驱动 * @param $cache_type 缓存类型 * @return object */ public function load($cache_type) { $object = null; if (isset($cache_type)) { switch ($cache_type) { default: case 'zendfile': $object = bpBase::loadSysClass('cache_zendfile'); break; case 'file': $object = bpBase::loadSysClass('cache_file'); break; case 'memcache': define('MEMCACHE_HOST', $this->cache_config['hostname']); define('MEMCACHE_PORT', $this->cache_config['port']); define('MEMCACHE_TIMEOUT', $this->cache_config['timeout']); define('MEMCACHE_DEBUG', $this->cache_config['debug']); $object = bpBase::loadSysClass('cache_memcache'); break; case 'apc': $object = bpBase::loadSysClass('cache_apc'); break; } } else { $object = bpBase::loadSysClass('cache_zendfile'); } return $object; }
function createSitemap($type, $showMessage = 1) { $sitemapConfig = loadConfig('sitemap'); $articleCount = $sitemapConfig['articleCount'] ? $sitemapConfig['articleCount'] : 500; $ucarCount = $sitemapConfig['ucarCount'] ? $sitemapConfig['ucarCount'] : 500; $datas = array(); switch ($type) { default: case 'news': $article_db = bpBase::loadModel('article_model'); $articles = $article_db->select(array('ex' => 0), 'link,time,title,keywords', '0,' . $articleCount, 'time DESC'); if ($articles) { foreach ($articles as $a) { if (!strExists($a['link'], 'http://')) { $a['link'] = MAIN_URL_ROOT . $a['link']; } if ($a['keywords'] == ',') { $a['keywords'] = ''; } array_push($datas, array('url' => $a['link'], 'time' => $a['time'], 'keywords' => $a['keywords'])); } } break; } $this->_createSitemap($type, $datas, $showMessage); }
function getValue($str = '', $avs, $siteID = 0, $channelID = 0, $contentID = 0) { //<stl:***></stl:***> $channelObj = bpBase::loadAppClass('channelObj', 'channel', 1); // $siteID = $avs['site'] == null ? $siteID : $avs['site']; // $upLevel = $avs['upLevel'] == null ? 0 : intval($avs['upLevel']); if ($avs['channelIndex']) { $thisChannel = $channelObj->getChannelByIndex($avs['channelIndex'], $siteID); $channels = $channelObj->getChannelsByParentID($thisChannel->id); } else { switch ($upLevel) { case 0: break; case 1: $currentChannel = $channelObj->getChannelByIndex($avs['channelIndex'], $siteID); $channels = $channelObj->getChannelsByParentID($currentChannel->parentid); break; } } // $returnStr = ''; if ($channels) { $middleStr = parent::getMiddleBody($str, 'channels', $this->gTag); $i = 0; foreach ($channels as $c) { $start = intval($avs['startNum']) - 1; $count = intval($avs['totalNum']); if (!$count) { $count = count($channels); } if ($i == $start || $i > $start) { if ($i < $count) { $rs = str_replace(array('[stl.channel.id]', '[stl.channel.name]', '[stl.channel.link]', '[stl.channel.num]', '<stl:contents'), array($c->id, $c->name, $c->link, $i + intval($avs['numStart']), '<stl:contents channelIndex="' . $c->cindex . '"'), $middleStr); //current class if ($channelID == $c->id) { $rs = str_replace('[stl.channel.currentItemClass]', $avs['currentItemClass'], $rs); } else { $rs = str_replace('[stl.channel.currentItemClass]', '', $rs); } $returnStr .= $rs; } } $i++; } } //处理stl:contents if (strExists($returnStr, '<stl:contents')) { $template = bpBase::loadAppClass('template', 'template'); $now = SYS_TIME; $returnStr = $template->parseStr($returnStr, $now); @unlink(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $now . '.parsed.tpl.php'); @unlink(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $now . '.tags.tpl.php'); } // return $returnStr; }
function __construct() { //$this->update_log_db = bpBase::loadModel('update_log_model'); parent::__construct(); $checkAccess = $this->exitWithoutAccess('system', 'manage'); $this->dbConfig = array('default' => array('hostname' => DB_HOSTNAME, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'tablepre' => TABLE_PREFIX, 'charset' => DB_CHARSET, 'type' => 'mysql', 'debug' => DEBUG, 'pconnect' => 0, 'autoconnect' => 0)); bpBase::loadSysClass('db_factory'); $this->db = db_factory::get_instance($this->dbConfig)->get_database('default'); }
function getValue($str = '', $avs, $siteID = 0, $channelID = 0, $contentID = 0) { //<stl:***></stl:***> $siteID = $avs['siteID'] == null ? $siteID : $avs['siteID']; $site = bpBase::loadAppClass('siteObj', 'site', 1); $thisSite = $site->getSiteByID($siteID); // $type = strtolower($avs['type']); return $thisSite->{$type}; }
function getValue($str = '', $avs, $siteID = 0, $channelID = 0, $contentID = 0, $pagination = array('pageSize' => 20, 'totalCount' => 0, 'currentPage' => 1, 'urlPrefix' => '', 'urlSuffix' => '')) { //<stl:***></stl:***> $articleObj = bpBase::loadAppClass('articleObj', 'article'); $thisContent = $articleObj->getContentByID($contentID); if ($thisContent->pagecount > 1) { $currentPage = intval($pagination['currentPage']); if (!$thisContent->title) { $sep = ''; for ($i = 0; $i < $thisContent->pagecount; $i++) { $thisContent->titles .= $sep . ''; $sep = '|'; } } $titles = explode('|', $thisContent->titles); $str = ''; $ah_str_l = ''; $ah_str_r = ''; if ($titles) { $i = 0; foreach ($titles as $t) { $nextI = $i + 1; if ($i == 0) { $link = $pagination['urlPrefix'] . $pagination['urlSuffix']; } else { $link = $pagination['urlPrefix'] . '-' . $nextI . $pagination['urlSuffix']; } if ($pagination['currentPage'] != $nextI) { $style = ''; } else { $style = ' style="color:red"'; } if (!isah()) { $str .= '<li><a title="' . $t . '" href="' . $link . '"' . $style . '>第' . $nextI . '页:' . $t . '</a></li>'; } else { $s = '<a title="' . $t . '" href="' . $link . '"' . $style . '>第' . $nextI . '页:' . $t . '</a><br>'; if ($i % 2 == 0) { $ah_str_l .= $s; } else { $ah_str_r .= $s; } } $i++; } } } if ($titles) { if (!isah()) { return '<div class="contentTitleNav"><h2>“' . $thisContent->title . '”导航</h2><div id="titles"><ul>' . $str . '<div class="clear"></div></ul><div class="clear" style="width:100%;height:1px"></div></div></div>'; } else { return '<dl class="article_nav"><dt>文章导航条</dt><dd>' . $ah_str_l . '</dd><dd class="last">' . $ah_str_r . '</dd></dl>'; } } }
function currentCityInfo() { $geoObj = bpBase::loadAppClass('geoObj', 'geo', 1); $ipGeo = $geoObj->getGeoByIP(ip()); if (!$ipGeo) { $geo_db = bpBase::loadModel('geo_model'); $defaultChildLocation = $geo_db->getDefaultChildLocation(); $ipGeo = $defaultChildLocation; } echo '{"city":[{"name":"' . $ipGeo->name . '","id":"' . $ipGeo->id . '","geoindex":"' . $ipGeo->geoindex . '"}]}'; }
public function __construct() { parent::__construct(); /***********uid*******************/ $uid = isset($_GET['uid']) && intval($_GET['uid']) > 0 ? intval($_GET['uid']) : 0; //设置uid为request的数值 $uid = $uid > 0 ? $uid : $this->uid; $this->assign('uid', $uid); if (!$uid) { header('Location:/'); exit; } $thisUser = $this->user; $this->assign('user', $thisUser); /**********************************************************/ if ($this->uid == $uid) { $sub = '我'; $my = 1; } else { $sub = '他(她)'; $my = 0; } $this->uid = $uid; $this->assign('sub', $sub); $this->assign('my', $my); /*********************判断是不是各种经销商***************************/ $storeUserIndependent = 0; //经销商用户是否单独建表存储 if (intval(loadConfig('store', 'storeUserIndependent'))) { $storeUserIndependent = 1; //经销商用户是否单独建表存储 } if ($uid == $this->uid) { $this->assign('canManage', 1); } if ($uid == $this->uid && !$storeUserIndependent) { $store_db = bpBase::loadModel('store_model'); $is4sStore = 0; if ($store_db->select(array('storetype' => 1, 'uid' => $this->uid))) { $is4sStore = 1; } $this->assign('is4sStore', $is4sStore); //carRental $isRentalStore = 0; if ($store_db->select(array('storetype' => 3, 'uid' => $this->uid))) { $isRentalStore = 1; } $this->assign('isRentalStore', $isRentalStore); //ucar $ucar_store_db = bpBase::loadModel('usedcar_store_model'); $thisUcarStore = $ucar_store_db->select(array('uid' => $this->uid)); $this->assign('isUcarStore', $thisUcarStore ? 1 : 0); } }
function getValue($str = '', $avs, $siteID = 0, $channelID = 0, $contentID = 0) { //<stl:***></stl:***> //properties $id = $avs['ID']; $sindex = $avs['index']; // $geoid = intval($avs['cityid']); if (!$site) { $site = 1; } // $adset_db = bpBase::loadModel('adset_model'); if ($id) { $thisAdSet = $adset_db->singleADSet($id); } elseif ($sindex) { $thisAdSet = $adset_db->singleADSetByIndex($sindex, $site); $id = $thisAdSet->set_id; } // $str = ''; $ad_db = bpBase::loadModel('ad_model'); $ads = $ad_db->adsOfSet($id, 1, $site, 1, $geoid); switch ($avs['type']) { case 'couplet': $bianju = 26; //距离浏览器边的宽度 $mtop = 50; //上边距 //左侧广告 switch ($ads[0]->type) { case 'flash': $str .= '<div id="couplet_l" style="position:fixed;top:' . $mtop . 'px;_position:absolute;left:' . $bianju . 'px"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' . $ads[0]->width . '" height="' . $ads[0]->height . '"><param name="movie" value="' . $ads[0]->path . '"><param name="quality" value="high"><embed src="' . $ads[0]->path . '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' . $ads[0]->width . '" height="' . $ads[0]->height . '"></embed></object><div style="cursor:pointer;margin:5px 0 0 0;text-align:right;" onclick="$(\'couplet_l\').dispose()">关闭</div></div>'; break; case 'image': $str .= '<div id="couplet_l" style="position:fixed;top:' . $mtop . 'px;_position:absolute;left:' . $bianju . 'px"><a href="' . $ads[0]->link . '" target="_blank"><img src="' . $ads[0]->path . '" width="' . $ads[0]->width . '" height="' . $ads[0]->height . '" border="0" /></a><div style="cursor:pointer;margin:5px 0 0 0;text-align:right;" onclick="$(\'couplet_l\').dispose()">关闭</div></div>'; break; } //右侧广告 switch ($ads[1]->type) { case 'flash': $str .= '<div id="couplet_r" style="position:fixed;top:' . $mtop . 'px;_position:absolute;right:' . $bianju . 'px"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' . $ads[1]->width . '" height="' . $ads[1]->height . '"><param name="movie" value="' . $ads[1]->path . '"><param name="quality" value="high"><embed src="' . $ads[1]->path . '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' . $ads[1]->width . '" height="' . $ads[1]->height . '"></embed></object><div style="cursor:pointer;margin:5px 0 0 0;text-align:right;" onclick="$(\'couplet_r\').dispose()">关闭</div></div>'; break; case 'image': $str .= '<div id="couplet_r" style="position:fixed;top:' . $mtop . 'px;_position:absolute;right:' . $bianju . 'px"><a href="' . $ads[1]->link . '" target="_blank"><img src="' . $ads[1]->path . '" width="' . $ads[1]->width . '" height="' . $ads[1]->height . '" border="0" /></a><div style="cursor:pointer;margin:5px 0 0 0;text-align:right;" onclick="$(\'couplet_r\').dispose()">关闭</div></div>'; break; } $str .= ''; break; } return $str; }
function parse($siteid, $str = '') { //<stl:include></stl:include> $siteid = intval($siteid); $siteClass = bpBase::loadAppClass('siteObj', 'site', 1); $thisSite = $siteClass->getSiteByID($siteid); $filePath = ABS_PATH . str_replace('@', '', parent::getAttributeValue($str, $this->attributes[0])); $filePath = str_replace('{siteIndex}', $thisSite->siteindex, $filePath); if (file_exists($filePath)) { return file_get_contents($filePath); } else { return ''; } }
public function __construct() { bpBase::loadAppFunc('global', 'manage'); //access //$_SESSION['token']='tokenvalue'; if (!isset($_SESSION['token']) || !strlen($_SESSION['token'])) { header('Location:/index.php?g=User&m=Index&a=index'); } $this->token = $_SESSION['token']; // $site_db = M('site'); $this->site = $site_db->getSiteByToken($this->token); $this->siteid = intval($this->site['id']); }
/** * 构造函数 * */ public function __construct($dbObj = null) { if (!$dbObj) { $this->db = bpBase::loadModel('session_model'); } else { //autoDB; $this->db = $dbObj; $this->oldSys = 1; $this->table = TABLE_PREFIX . 'session'; } $this->lifetime = loadConfig('site', 'session_ttl'); $this->lifetime = $this->lifetime == '' ? 3600 : $this->lifetime; session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc')); session_start(); }
function getValue($str = '', $avs, $siteID = 0, $channelID = 0, $contentID = 0) { //<stl:***></stl:***> $str = parent::removeProperties($str, $this->attributes); $middleStr = parent::getMiddleBody($str, 'a', $this->gTag); if (isset($avs['contentID']) && $avs['contentID']) { $articleObj = bpBase::loadAppClass('articleObj', 'article', 1); $thisContent = $articleObj->getContentByID($avs['contentID']); $valueStr = str_replace('[stl.content.title]', $thisContent->title, $middleStr); $link = $thisContent->link; } elseif (isset($avs['channelIndex']) && $avs['channelIndex']) { $channelObj = bpBase::loadAppClass('channelObj', 'channel', 1); if ($avs['site']) { //指定了站点 $siteID = intval($avs['site']); } $thisChannel = $channelObj->getChannelByIndex($avs['channelIndex'], $siteID); // $valueStr = str_replace('[stl.channel.name]', $thisChannel->name, $middleStr); if ($avs['site'] || $siteID > 0) { //指定了站点 $siteObj = bpBase::loadAppClass('siteObj', 'site', 1); $thisSite = $siteObj->getSiteByID($avs['site']); if (strExists($link, 'http://') || $thisChannel->externallink) { $link = $thisChannel->link; } else { $link = $thisSite->url . $thisChannel->link; } } else { if (strExists($link, 'http://') || $thisChannel->externallink) { $link = $thisChannel->link; } else { $link = MAIN_URL_ROOT . $thisChannel->link; } } } elseif (isset($avs['siteID']) && $avs['siteID']) { $siteObj = bpBase::loadAppClass('siteObj', 'site', 1); $thisSite = $siteObj->getSiteByID($avs['siteID']); // $valueStr = str_replace('[stl.site.name]', $thisSite->name, $middleStr); $link = $thisSite->url; } $str = str_replace('<stl:a', '<a href="' . $link . '"', $str); $str = str_replace('</stl:a', '</a', $str); $str = str_replace($middleStr, $valueStr, $str); return $str; }
function getValue($str = '', $avs, $csiteID = 0, $thisChannelID = 0, $contentID = 0) { //<stl:***></stl:***> $articleObj = bpBase::loadAppClass('articleObj', 'article'); $site = bpBase::loadAppClass('siteObj', 'site'); $content_db = bpBase::loadModel('article_model'); $totalNum = $avs['totalNum'] ? $avs['totalNum'] : 10; $cat = $avs['cat'] ? $avs['cat'] : 'news'; $cats = array('video', 'news', 'guide', 'comment', 'market'); if (!in_array($cat, $cats)) { $cat = 'news'; } $startNum = $avs['startNum'] ? intval($avs['startNum']) : 1; $startI = $startNum - 1; $totalNum = $startI + $totalNum; $orderBy = $avs['orderBy'] ? $avs['orderBy'] : 'viewcount'; $contents = $articleObj->viewRanksByCat($cat, $totalNum, $orderBy); $returnStr = ''; if ($contents) { $i = 0; $middleStr = parent::getMiddleBody($str, 'articleRanks', $this->gTag); $tags = array('[stl.content.link]', '[stl.content.title]', '[stl.content.thumb]'); $count = 0; foreach ($contents as $c) { if ($i > $startI - 1 && $count < $totalNum) { $replaces = array($c->link, $c->title, $c->thumb); $valueStr = str_replace($tags, $replaces, $middleStr); //time $valueStr = str_replace('[stl.content.time]', date($avs['dateFormat'], $c->time), $valueStr); //other thumb $valueStr = str_replace('[stl.content.thumb2]', str_replace('.jpg', '_small.jpg', $c->thumb), $valueStr); $valueStr = str_replace('[stl.content.thumb3]', str_replace('.jpg', '_middle.jpg', $c->thumb), $valueStr); $valueStr = str_replace('[stl.content.thumb4]', str_replace('.jpg', '_big.jpg', $c->thumb), $valueStr); //num $valueStr = str_replace('[stl.content.num]', $count + $startNum, $valueStr); // $returnStr .= $valueStr; $count++; } $i++; } } return $returnStr; }
/** * 加载数据库驱动 * @param $db_config_name 数据库配置名称 * @return object */ public function connect($db_config_name) { $object = null; switch ($this->db_config[$db_config_name]['type']) { case 'mysql': bpBase::loadSysClass('mysql', '', 0); $object = new mysql(); break; case 'mysqli': $object = bpBase::loadSysClass('mysqli'); break; case 'access': $object = bpBase::loadSysClass('db_access'); break; default: bpBase::load_sys_class('mysql', '', 0); $object = new mysql(); } $object->open($this->db_config[$db_config_name]); return $object; }
/** * 加载控制器 * @param string $filename * @param string $m * @return obj */ private function load_controller($filename = '', $m = '') { if (empty($filename)) { $filename = ROUTE_CONTROL; } if (empty($m)) { $m = ROUTE_MODEL; } $filepath = ABS_PATH . MANAGE_DIR . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $m . DIRECTORY_SEPARATOR . $filename . '.php'; if (file_exists($filepath)) { $classname = $filename; include $filepath; if ($mypath = bpBase::my_path($filepath)) { //加载用户的扩展 $classname = 'MY_' . $filename; include $mypath; } return new $classname(); } else { exit('Controller doesn\'t exist.'); } }
function getValue($str = '', $avs, $siteID = 0, $channelID = 0, $contentID = 0) { //<stl:***></stl:***> // $site = $avs['site'] == null ? $siteID : $avs['site']; $site = intval($site); //instance $channelObj = bpBase::loadAppClass('channelObj', 'channel'); $upLevel = $avs['upLevel'] == null ? 0 : intval($avs['upLevel']); if ($avs['channelIndex'] != null) { $thisChannel = $channelObj->getChannelByIndex($avs['channelIndex'], $site); } else { switch ($upLevel) { case 0: $thisChannel = $channelObj->getChannelByID($channelID); break; case 1: $currentChannel = $channelObj->getChannelByID($channelID); $thisChannel = $channelObj->getChannelByID($currentChannel->parentid); break; } } // $type = strtolower($avs['type']); if ($type == 'title') { $type = 'name'; } if ($type == 'content') { $type = 'des'; } if ($type == 'imageurl') { $type = 'thumb'; } if ($type) { return $thisChannel->{$type}; } else { return $thisChannel->name; } }
function handleStag($str) { preg_match_all($this->regex, $str, $varArray); $checkArr = array(); if ($varArray[1]) { $i = 0; foreach ($varArray[1] as $k => $tagName) { $tagValue = $varArray[2][$i]; $tag = '[stl.' . $tagName . ':' . $tagValue . ']'; if (!in_array($tag, $checkArr)) { //start if ($tagClass = bpBase::loadSmallTagClass('stag_' . $tagName)) { $returnStr = $tagClass->getValue($tagValue); $str = str_replace($tag, $returnStr, $str); } //end array_push($checkArr, $tag); } $i++; } } return $str; }
function getValue($str = '', $avs, $siteID = 0, $channelID = 0, $contentID = 0) { //<stl:***></stl:***> //properties $seperator = $avs['separator']; $linkClass = $avs['linkClass']; $target = $avs['target'] == null ? '_self' : $avs['target']; // $channel = bpBase::loadAppClass('channelObj', 'channel', 1); $crumbArr = $channel->crumbArr($channelID); $arrCount = count($crumbArr); // $site = bpBase::loadAppClass('siteObj', 'site', 1); if ($siteID < 100) { $thisSite = $site->getSiteByID($siteID); } else { $special_db = bpBase::loadModel('special_model'); $thisSpecial = $special_db->get($siteID); $thisSite->main = false; $thisSite->url = $thisSpecial['url']; $crumbArr[0]['name'] = '专题:' . $thisSpecial['name']; } $currentChannel = $channel->getChannelByID($channelID); $returnStr = ''; if (intval($thisSite->main)) { $returnStr .= '<a href="/" class="' . $linkClass . '" target="' . $target . '">' . $crumbArr[0]['name'] . '</a>' . $seperator; } else { $returnStr .= '<a href="' . $thisSite->url . '" class="' . $linkClass . '" target="' . $target . '">' . $crumbArr[0]['name'] . '</a>' . $seperator; } for ($i = 1; $i < $arrCount; $i++) { if (strlen($crumbArr[$i]['name'])) { $returnStr .= '<a href="' . $crumbArr[$i]['link'] . '" class="' . $linkClass . '" target="' . $target . '">' . $crumbArr[$i]['name'] . '</a>' . $seperator; } } $returnStr .= '<a href="' . $currentChannel->link . '" class="' . $linkClass . '" target="' . $target . '">' . $currentChannel->name . '</a>'; return $returnStr; }
function vc() { $session_storage = getSessionStorageType(); bpBase::loadSysClass($session_storage); $captcha = bpBase::loadSysClass('checkCode'); //width if (isset($_GET['width']) && intval($_GET['width'])) { $captcha->width = intval($_GET['width']); } if ($captcha->width <= 0) { $captcha->width = 70; } //height if (isset($_GET['height']) && intval($_GET['height'])) { $captcha->height = intval($_GET['height']); } if ($captcha->height <= 0) { $captcha->height = 25; } //codeNum if (isset($_GET['codeNum']) && intval($_GET['codeNum'])) { $captcha->code_len = intval($_GET['codeNum']); } if ($captcha->codeNum > 8 || $captcha->codeNum < 2) { $captcha->codeNum = 4; } //backGround if (isset($_GET['backGround']) && trim(urldecode($_GET['backGround'])) && preg_match('/(^[a-z0-9]{6}$)/im', trim(urldecode($_GET['backGround'])))) { $captcha->backGround = '#' . trim(urldecode($_GET['backGround'])); } //fontColor if (isset($_GET['fontColor']) && trim(urldecode($_GET['fontColor'])) && preg_match('/(^[a-z0-9]{6}$)/im', trim(urldecode($_GET['fontColor'])))) { $captcha->fontColor = '#' . trim(urldecode($_GET['fontColor'])); } $captcha->showImg(); $_SESSION['validCode'] = $captcha->getCaptcha(); }
public function action_picUpload() { if (!isset($_SESSION['canupload'])) { exit; } $error = 0; if (isset($_FILES['thumb'])) { $photo = $_FILES['thumb']; if (substr($photo['type'], 0, 5) == 'image') { switch ($photo['type']) { case 'image/jpeg': case 'image/jpg': case 'image/pjpeg': $ext = '.jpg'; break; case 'image/gif': $ext = '.gif'; break; case 'image/png': case 'image/x-png': $ext = '.png'; break; default: $error = -1; break; } if ($error == 0) { $time = SYS_TIME; $year = date('Y', $time); $month = date('m', $time); $day = date('d', $time); $pathInfo = upFileFolders($time); $dstFolder = $pathInfo['path']; $dstFile = ABS_PATH . 'upload' . DIRECTORY_SEPARATOR . 'temp' . $ext; //the size of file uploaded must under 1M if ($photo['size'] > 2000000) { $error = -2; return $error; } } else { return $error; } //if no error if ($error == 0) { $rand = randStr(4); //delete primary files if (file_exists($dstFolder . $time . $rand . $ext)) { unlink($dstFolder . $time . $rand . $ext); } if ($ext != '.gif') { //save the temporary file move_uploaded_file($photo['tmp_name'], $dstFile); $imgInfo = getimagesize($dstFile); //generate new files $imageWidth = intval($_POST['width']) != 0 ? intval($_POST['width']) : $imgInfo[0]; $imageHeight = intval($_POST['height']) != 0 ? intval($_POST['height']) : $imgInfo[1]; bpBase::loadSysClass('image'); image::zfResize($dstFile, $dstFolder . $time . $rand . '.jpg', $imageWidth, $imageHeight, 1 | 4, 2); $ext = '.jpg'; // } else { move_uploaded_file($photo['tmp_name'], $dstFolder . $time . $rand . '.gif'); } if (isset($_POST['channelid'])) { //内容缩略图 $channelObj = bpBase::loadAppClass('channelObj', 'channel'); $thisChannel = $channelObj->getChannelByID($_POST['channelid']); $articleObj = bpBase::loadAppClass('articleObj', 'article'); $articleObj->setOtherThumb($thisChannel, $dstFile, $dstFolder, $time . $rand, 'jpg'); } if ($ext != '.gif') { @unlink($dstFile); } $location = MAIN_URL_ROOT . '/upload/images/' . $year . '/' . $month . '/' . $day . '/' . $time . $rand . $ext; $error = 0; } } else { $error = -1; } } else { $error = -1; } if ($error == 0) { echo $location; } else { $errors = array(-1 => '你上传的不是图片', -2 => '文件不能超过2M', -3 => '图片地址不正确'); echo $errors[intval($error)]; } }
<?php bpBase::loadSysClass('model', '', 0); class site_model extends model { public function __construct() { $this->table_name = TABLE_PREFIX . 'moopha_site'; parent::__construct(); } function sites() { $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'site ORDER BY taxis ASC'; $sites = $this->get_resultsBySql($sql); return $sites; } function getSiteByToken($token) { $cacheName = 'siteByToken' . $token; $cache = getCache($cacheName); if ($cache) { return unserialize($cache); } else { $site = $this->get_one(array('token' => $token)); setCache($cacheName, serialize($site)); return $site; } } }
<?php /** * background access * */ //root dir define('ABS_PATH', dirname(__FILE__) . '/'); include './config/config.inc.php'; include './config/safe3.php'; include './' . MANAGE_DIR . '/base.php'; if (!isset($_GET['m'])) { define('ROUTE_MODEL', 'site'); define('ROUTE_CONTROL', 'home'); define('ROUTE_ACTION', 'home'); } bpBase::creatApp();
<?php bpBase::loadAppClass('manage', 'manage', 0); class m_user extends manage { function __construct() { parent::__construct(); } public function users() { include $this->showManageTpl('users'); } }
function setTemplate() { $templateIndex = $_GET['templateindex']; if (!$templateIndex || !file_exists(ABS_PATH . 'smarty' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'tpls' . DIRECTORY_SEPARATOR . $templateIndex) || !is_dir(ABS_PATH . 'smarty' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'tpls' . DIRECTORY_SEPARATOR . $templateIndex)) { exit('不是合法的模板'); } // $ys = intval($this->siteid % 10); //1.创建smarty文件夹 if (!is_dir(ABS_PATH . 'smarty' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $ys)) { mkdir(ABS_PATH . 'smarty' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $ys, 0777); } if (!is_dir(ABS_PATH . 'smarty' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $ys . DIRECTORY_SEPARATOR . $this->site['token'])) { mkdir(ABS_PATH . 'smarty' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $ys . DIRECTORY_SEPARATOR . $this->site['token'], 0777); } //2.拷贝模板文件到smarty目录中 $sourceDir = ABS_PATH . 'smarty' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'tpls' . DIRECTORY_SEPARATOR . $templateIndex . DIRECTORY_SEPARATOR; $dstDir = ABS_PATH . 'smarty' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $ys . DIRECTORY_SEPARATOR . $this->site['token'] . DIRECTORY_SEPARATOR; @copy($sourceDir . 'index.html', $dstDir . 'index.html'); @copy($sourceDir . 'channel_picture.html', $dstDir . 'channel_picture.html'); @copy($sourceDir . 'channel_text.html', $dstDir . 'channel_text.html'); @copy($sourceDir . 'content.html', $dstDir . 'content.html'); @copy($sourceDir . 'style.css', $dstDir . 'style.css'); @copy($sourceDir . 'footer.html', $dstDir . 'footer.html'); @copy($sourceDir . 'header.html', $dstDir . 'header.html'); //3.插入模板数据 $template_db = M('template'); $template_db->delete(array('site' => $this->siteid)); //删除原有模板 $templateRows = array(array('name' => '首页', 'path' => '@/smarty/templates/' . $ys . '/' . $this->site['token'] . '/index.html', 'generate_path' => '', 'type' => '1', 'isdefault' => '1', 'createhtml' => '0', 'site' => $this->siteid, 'time' => SYS_TIME), array('name' => '文字列表', 'path' => '@/smarty/templates/' . $ys . '/' . $this->site['token'] . '/channel_text.html', 'generate_path' => '?m=site&c=home&a=channel&channelid={channelID}', 'type' => '2', 'isdefault' => '1', 'createhtml' => '0', 'site' => $this->siteid, 'time' => SYS_TIME), array('name' => '图片列表', 'path' => '@/smarty/templates/' . $ys . '/' . $this->site['token'] . '/channel_picture.html', 'generate_path' => '?m=site&c=home&a=channel&channelid={channelID}', 'type' => '2', 'isdefault' => '0', 'createhtml' => '0', 'site' => $this->siteid, 'time' => SYS_TIME), array('name' => '内容', 'path' => '@/smarty/templates/' . $ys . '/' . $this->site['token'] . '/content.html', 'generate_path' => '?m=site&c=home&a=content&contentid={contentID}', 'type' => '3', 'isdefault' => '1', 'createhtml' => '0', 'site' => $this->siteid, 'time' => SYS_TIME), array('name' => '样式css', 'path' => '@/smarty/templates/' . $ys . '/' . $this->site['token'] . '/style.css', 'generate_path' => '', 'type' => '4', 'isdefault' => '0', 'createhtml' => '0', 'site' => $this->siteid, 'time' => SYS_TIME), array('name' => '顶部', 'path' => '@/smarty/templates/' . $ys . '/' . $this->site['token'] . '/header.html', 'generate_path' => '', 'type' => '4', 'isdefault' => '0', 'createhtml' => '0', 'site' => $this->siteid, 'time' => SYS_TIME), array('name' => '底部', 'path' => '@/smarty/templates/' . $ys . '/' . $this->site['token'] . '/footer.html', 'generate_path' => '', 'type' => '4', 'isdefault' => '0', 'createhtml' => '0', 'site' => $this->siteid, 'time' => SYS_TIME)); $defaultChannelTemplateID = 0; $defaultContentTemplateID = 0; $pictureChanenlTemplateID = 0; foreach ($templateRows as $trow) { $templateid = $template_db->insert($trow, 1); if ($trow['type'] == '2' && $trow['isdefault'] == '1') { $defaultChannelTemplateID = $templateid; } if ($trow['type'] == '3' && $trow['isdefault'] == '1') { $defaultContentTemplateID = $templateid; } if ($trow['type'] == '2' && $trow['isdefault'] == '0') { $pictureChanenlTemplateID = $templateid; } } //5.栏目匹配模板 $channel_db = M('channel'); $channel_db->update(array('channeltemplate' => $defaultChannelTemplateID, 'contenttemplate' => $defaultContentTemplateID), array('site' => $this->siteid)); $channel_db->update(array('channeltemplate' => $pictureChanenlTemplateID), array('site' => $this->siteid, 'cindex' => 'products')); //6.设置home数据 $home_db = M('home'); $home_db->update(array('advancetpl' => 1), array('token' => $this->token)); // $site_db = M('site'); $site_db->update(array('template' => $templateIndex), array('token' => $this->token)); delCache('siteByToken' . $this->token); //7.生成页面 $allChannels = $channel_db->select(array('site' => $this->siteid)); if ($allChannels) { $tpl = bpBase::loadAppClass('template', 'template'); foreach ($allChannels as $c) { @$tpl->createChannelPageR($c['id']); } } // unset($_SESSION['previewSkin']); showMessage(L('setSuccess') . ',请在网站内容管理里设置栏目和内容,<a href="../index.php?token=' . $this->token . '" target="_blank">点击这里预览首页</a>', $_POST['referer']); }
function __construct() { $this->site_db = bpBase::loadModel('site_model'); }
<?php /** * 数据模型基类 */ bpBase::loadSysClass('db_factory', '', 0); class model { //数据库配置 protected $db_config = ''; //调用数据库的配置项 protected $db_setting = 'default'; //数据库连接 protected $db = ''; //数据表名 protected $table_name = ''; //表前缀 public $db_tablepre = ''; public function __construct() { if (!isset($this->db_config[$this->db_setting])) { $this->db_setting = 'default'; } //$this->table_name = $this->table_name; $this->db = db_factory::get_instance($this->db_config)->get_database($this->db_setting); } /** * 执行sql查询 * @param $where 查询条件[例`name`='$name'] * @param $data 需要查询的字段值[例`name`,`gender`,`birthday`] * @param $limit 返回结果范围[例:10或10,10 默认为空]
function getValue($str = '', $avs, $siteID = 0, $channelID = 0, $contentID = 0, $pagination = array(), $thisContent = null) { //<stl:***></stl:***> //type $type = $avs['type'] == null ? 'title' : strtolower($avs['type']); if ($type == 'imageurl') { $type = 'thumb'; } elseif ($type == 'adddate') { $type = 'time'; } elseif ($type == 'summary') { $type = 'intro'; } $contentID = $avs['ID'] ? $avs['ID'] : $contentID; $articleObj = bpBase::loadAppClass('articleObj', 'article'); //instance if (intval($avs['ID']) || intval($avs['id'])) { if (!intval($avs['ID'])) { $contentID = intval($avs['id']); } $thisContent = $articleObj->getContentByID($contentID); } if (!$thisContent) { $thisContent = $articleObj->getContentByID($contentID); } // $autoids = explode(',', $thisContent->autoid); $firstAutoid = 0; if ($autoids) { foreach ($autoids as $autoid) { if (intval($autoid)) { $firstAutoid = $autoid; break; } } } $autoclassification_db = bpBase::loadModel('autoclassification_model'); $autoObj = bpBase::loadAppClass('autoObj', 'auto'); $firstAuto = $autoclassification_db->getCfByID($firstAutoid); // switch ($type) { default: return $thisContent->{$type}; break; case 'keywords': return substr($thisContent->keywords, 1); break; case 'content': $thisContent->{$type} = stripslashes($thisContent->{$type}); $stag = bpBase::loadAppClass('stag', 'template'); $thisContent->{$type} = $stag->handleStag($thisContent->{$type}); return $thisContent->{$type}; break; case 'sourcetypeValue': if ($thisContent->sourcetype) { $articleConstant = bpBase::loadAppClass('articleConstant', 'article'); $sourceTypes = $articleConstant->sourceTypes(); return $sourceTypes[$thisContent->sourcetype]; } else { return '-'; } break; case 'time': return date($avs['formatString'], $thisContent->time); break; case 'autotabs': if ($thisContent->autograde) { //文章类别 $cat = $articleObj->getArticleCat($thisContent->id); if ($cat == 'other' || $cat == '') { $cat = 'none'; } $smallLogo = $autoObj->getLogo($firstAuto->id, $firstAuto->logo, 's', $firstAuto->grade); if ($thisContent->autograde == 3) { $parentAuto = $autoclassification_db->getCfByID($firstAuto->parentid); if (!function_exists('autoTabs')) { include_once ABS_PATH . CAR_DIR . DIRECTORY_SEPARATOR . 'include.php'; } $autoTabs = autoTabs($cat, $firstAutoid, $firstAutoid, 3, $firstAuto); if (AUTO_SKIN != 'ahauto') { return '<div class="g3nautonav"><div class="bnav_t"><a href="' . CAR_URL_ROOT . '/library_brand.html" class="twpp_morea">车型大全>></a><div class="tit"><h1><a href="' . CAR_URL_ROOT . '/' . $firstAutoid . '" class="twpp_tia">' . $parentAuto->name . ' ' . $firstAuto->name . '</a></h1> <a href="' . STORE_URL_ROOT . '/stores.php?autoid=' . $firstAutoid . '" target="_blank">' . $firstAuto->name . '经销商</a></div></div></div><div class="childChannelNav" style="margin-bottom:8px">' . $autoTabs . '</div>'; } else { return '<div id="newcar_title_01" style="margin-bottom:10px"><span><ul>{$autoTabs}</ul></span><b>' . $parentAuto->name . ' ' . $firstAuto->name . '</b></div>'; } } elseif ($thisContent->autograde == 1) { if (!function_exists('brandTabs')) { include_once ABS_PATH . CAR_DIR . DIRECTORY_SEPARATOR . 'include.php'; } if (AUTO_SKIN != 'ahauto') { $autoTabs = brandTabs($cat, $firstAuto->id, $firstAuto); return '<div class="twpp_bnav" style="margin-bottom:8px"><div class="bnav_t"><a href="' . CAR_URL_ROOT . '/library_brand.html" class="twpp_morea">品牌大全>></a><div class="tit"><img src="' . $smallLogo . '" width="40" height="30" /><h1><a href="' . CAR_URL_ROOT . '/brand-' . $firstAutoid . '.html" class="twpp_tia">' . $firstAuto->name . '</a></h1> <a href="' . CAR_URL_ROOT . '/price/' . $firstAutoid . '.html" title="' . $firstAuto->name . '车系" target="_blank">车系</a> <a href="' . CAR_URL_ROOT . '/picture/' . $firstAutoid . '.html" title="' . $firstAuto->name . '图片">图片</a> <a href="' . STORE_URL_ROOT . '/stores.php?autoid=' . $firstAutoid . '" title="' . $firstAuto->name . '4S店" target="_blank">经销商</a></div></div><div class="bnav_b">' . $autoTabs . '</div></div>'; } else { return '<div class="btop contentt" style="margin-bottom:10px"><img src="' . $smallLogo . '" width="40" height="30" /><h1>' . $firstAuto->name . '</h1></div>'; } } } break; case 'relateautoinfo': $articlePage = bpBase::loadAppClass('articlePage', 'article'); $str = $articlePage->relateAutosInContentPage($thisContent->id, $thisContent); $strs = explode('<span style="display:none" id="relateAutoStores">,', $str); return $strs[0]; break; case 'autoid': return $firstAutoid; break; case 'serieid': if ($thisContent->autograde) { if ($thisContent->autograde == 3) { return $firstAutoid; } elseif ($thisContent->autograde == 1) { return 0; } } break; case 'brandid': if ($thisContent->autograde) { if ($thisContent->autograde == 3) { return $firstAuto->g1id; } elseif ($thisContent->autograde == 1) { return $firstAutoid; } } break; case 'autoname': return $thisContent->autoname; break; } }
<?php $session_storage = getSessionStorageType(); bpBase::loadSysClass($session_storage); bpBase::loadSysFunc('front'); class front { public $uid; public $username; public $email; public $realname; public $mp; public $qq; public $credits; public $isAdmin; public static $user; // public static $smarty; public function __construct() { //smarty if (front::$smarty == '') { //smarty ini_set('include_path', ABS_PATH . 'library' . DIRECTORY_SEPARATOR . 'smarty' . PATH_SEPARATOR . ini_get('include_path')); require_once 'Smarty.class.php'; // $smartyInstance = new smarty(); if (!isset($_GET['preview']) || !intval($_GET['preview'])) { $smartyInstance->template_dir = ABS_PATH . 'smarty' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; } else { $smartyInstance->template_dir = ABS_PATH . 'templates' . DIRECTORY_SEPARATOR;