Ejemplo n.º 1
0
 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';
     }
 }
Ejemplo n.º 2
0
 function clearCache()
 {
     set_time_limit(0);
     $i = intval($_REQUEST['id']);
     if (!$i) {
         $this->error('操作失败');
     } else {
         import("ORG.Io.Dir");
         $dir = new Dir();
         switch ($i) {
             case 1:
                 //更新全站缓存
                 is_dir(CACHE_PATH) && $dir->del(CACHE_PATH);
                 is_dir(DATA_PATH . '_fields/') && $dir->del(DATA_PATH . '_fields/');
                 is_dir(TEMP_PATH) && $dir->del(TEMP_PATH);
                 if (is_dir("./index/Runtime")) {
                     deleteCacheData("./index/Runtime");
                 }
                 if (is_dir("./admin/Runtime")) {
                     deleteCacheData("./admin/Runtime");
                 }
                 //Api缓存
                 is_dir('./Apicache/') && delCache('./Apicache/');
                 break;
             case 2:
                 //后台模版缓存
                 is_dir(CACHE_PATH) && $dir->del(CACHE_PATH);
                 break;
             case 3:
                 //前台模版缓存
                 is_dir("./index/Runtime/Cache/") && $dir->del("./index/Runtime/Cache/");
                 is_dir("./index/Html/") && $dir->del("./index/Html/");
                 break;
             case 4:
                 //数据库缓存
                 is_dir(DATA_PATH . '_fields/') && $dir->del(DATA_PATH . '_fields/');
                 is_dir("./index/Runtime/Data/_fields/") && $dir->del("./index/Runtime/Data/_fields/");
                 break;
             case 5:
                 //Api缓存
                 is_dir('./Apicache/') && delCache('./Apicache/');
                 break;
             default:
                 break;
         }
         $runtime = defined('MODE_NAME') ? '~' . strtolower(MODE_NAME) . '_runtime.php' : '~runtime.php';
         $runtime_file_admin = RUNTIME_PATH . $runtime;
         $runtime_file_front = ROOT_PATH . '/index/Runtime/' . $runtime;
         is_file($runtime_file_admin) && @unlink($runtime_file_admin);
         is_file($runtime_file_front) && @unlink($runtime_file_front);
         $this->success('更新完成', U('Cache/index'));
     }
 }
Ejemplo n.º 3
0
function delCache($dir)
{
    //删除目录
    $handle = @opendir($dir);
    while ($file = @readdir($handle)) {
        $bdir = $dir . '/' . $file;
        if (filetype($bdir) == 'dir') {
            if ($file != '.' && $file != '..') {
                delCache($bdir);
            }
        } else {
            @unlink($bdir);
        }
    }
    closedir($handle);
    @rmdir($dir);
    return true;
}
Ejemplo n.º 4
0
 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']);
 }
Ejemplo n.º 5
0
 public function clearCrumbCache($id)
 {
     delCache('channelCrumb' . $id);
     delCache('channelsOf' . $id . 'oOBJECT');
     delCache('channelsOf' . $id . 'oARRAY');
     delCache('channel' . $id);
     $thisChannel = $this->getChannelByID($id);
     delCache('channelOfIndex' . $thisChannel->cindex . 'Site' . $thisChannel->site);
     delCache('channelsOf' . $thisChannel->parentid . 'oOBJECT');
     delCache('channelsOf' . $id . 'oOBJECT');
 }
Ejemplo n.º 6
0
 public function recoveryarticle20121113()
 {
     $taskName = 'recoveryarticle20121113';
     $thisTask = $this->update_log_db->get_one(array('file' => $taskName));
     $this->_executedCheck($taskName, $thisTask);
     //
     $content_db = bpBase::loadModel('content_model');
     if (getCache('c_function_contenttimeis0')) {
         $contents = unserialize(getCache('c_function_contenttimeis0'));
     } else {
         $contents = $content_db->select(array('time' => 0), 'contentid');
         setCache('c_function_contenttimeis0', serialize($contents));
     }
     $count = count($contents);
     $i = intval($_GET['i']);
     if ($i < $count) {
         //start
         $article_db = bpBase::loadModel('article_model');
         $thisArticle = $article_db->get_one(array('id' => $contents[$i]['contentid']));
         $content_db->update(array('time' => $thisArticle['time']), array('contentid' => $contents[$i]['contentid']));
         //end
         $i++;
         showMessage($thisTask['des'] . ':' . $i . '/' . $count, '?m=update&c=updateTask&a=' . $taskName . '&i=' . $i, 0);
     } else {
         //删除缓存
         delCache('c_function_contenttimeis0');
         $this->_finishTask($taskName);
     }
 }
Ejemplo n.º 7
0
 public function channels()
 {
     if (isset($_POST['taxis'])) {
         foreach ($_POST['taxis'] as $id => $value) {
             $this->channel_db->update(array('taxis' => $value), array('id' => $id));
         }
         delCache('navChannels' . $this->siteid);
         showMessage('排序成功', $_SERVER['HTTP_REFERER']);
     } else {
         $parentChannelID = intval($_GET['id']);
         $siteid = intval($_GET['siteid']);
         $channels = $this->channel_db->select(array('site' => $siteid, 'parentid' => $parentChannelID), '*', $limit = '', $order = '`taxis` ASC');
         delCache('navChannels' . $this->siteid);
         include $this->showManageTpl('channels');
     }
 }
Ejemplo n.º 8
0
 public function site()
 {
     $this->exitWithoutAccess('system', 'manage');
     //判断是否有相关站点
     $thisSite = $this->site;
     $site_db = M('site');
     //读取softphs首页回复配置
     $home_db = M('home');
     $homeConfig = $home_db->get_one(array('token' => $this->token));
     //
     if (IS_POST) {
         $row = $_POST['info'];
         $row['statisticcode'] = base64_encode($row['statisticcode']);
         if (!$thisSite) {
             $siteid = $site_db->insert($row, 1);
             //添加默认分类
             if ($siteid) {
                 $channel_db = M('channel');
                 $homeChannelRow = array('name' => '首页', 'shortname' => '首页', 'channeltype' => 1, 'cindex' => 'homepage', 'thumbwidth' => 0, 'thumbheight' => 0, 'parentid' => 0, 'site' => $siteid, 'time' => SYS_TIME, 'token' => $this->token, 'isnav' => 0);
                 $homeChannelID = $channel_db->insert($homeChannelRow, 1);
                 $channelArrs = array(array('name' => '关于我们', 'shortname' => '简介', 'cindex' => 'aboutus', 'channeltype' => 1, 'isnav' => 1), array('name' => '最新动态', 'shortname' => '动态', 'cindex' => 'news', 'channeltype' => 1, 'isnav' => 1), array('name' => '产品展示', 'shortname' => '产品', 'cindex' => 'products', 'channeltype' => 1, 'isnav' => 1), array('name' => '精彩案例', 'shortname' => '案例', 'cindex' => 'case', 'channeltype' => 1, 'isnav' => 1), array('name' => '联系我们', 'shortname' => '联系', 'cindex' => 'contact', 'channeltype' => 1, 'isnav' => 1), array('name' => '幻灯片', 'shortname' => '幻灯片', 'cindex' => 'focus', 'channeltype' => 1, 'isnav' => 0));
                 $baseChannelArr = array('thumbwidth' => 0, 'thumbheight' => 0, 'parentid' => $homeChannelID, 'site' => $siteid, 'time' => SYS_TIME, 'token' => $this->token);
                 $focusChannelID = 0;
                 if ($homeChannelID) {
                     $tpl = bpBase::loadAppClass('template', 'template');
                     foreach ($channelArrs as $c) {
                         $crow = $baseChannelArr;
                         $crow['name'] = $c['name'];
                         $crow['cindex'] = $c['cindex'];
                         $crow['channeltype'] = $c['channeltype'];
                         $crow['isnav'] = $c['isnav'];
                         $crow['shortname'] = $c['shortname'];
                         $channelid = $channel_db->insert($crow, 1);
                         if ($c['cindex'] == 'focus') {
                             $focusChannelID = $channelid;
                         }
                         $tpl->createChannelPageR($channelid);
                     }
                 }
             }
             //导入pigcms幻灯片
             $flash_db = M('flash');
             $article_db = M('article');
             $flashPics = $flash_db->select(array('token' => $this->token));
             if ($flashPics) {
                 foreach ($flashPics as $fp) {
                     $article_db->insert(array('channel_id' => $focusChannelID, 'token' => $this->token, 'site' => $siteid, 'title' => $fp['info'], 'link' => $fp['url'], 'thumb' => $fp['img'], 'time' => SYS_TIME, 'content' => $fp['info']));
                 }
             }
             //
         } else {
             $site_db->update($row, array('token' => $this->token));
         }
         delCache('siteByToken' . $row['token']);
         if ($this->site['template']) {
             showMessage('设置成功', '?m=' . ROUTE_MODEL . '&c=' . ROUTE_CONTROL . '&a=' . ROUTE_ACTION);
         } else {
             showMessage('设置成功,请选择网站模板', '?m=template&c=m_template&a=selectTemplate');
         }
     } else {
         include $this->showManageTpl('site');
     }
 }
Ejemplo n.º 9
0
 function keywordSet()
 {
     $keywords_db = bpBase::loadModel('keywords_model');
     if (isset($_POST['doSubmit'])) {
         $info = $_POST['info'];
         $info['keyword'] = htmlspecialchars($info['keyword'], ENT_COMPAT, 'GB2312');
         $info['title'] = htmlspecialchars($info['title'], ENT_COMPAT, 'GB2312');
         $info['link'] = htmlspecialchars($info['link'], ENT_COMPAT, 'GB2312');
         $info['target'] = htmlspecialchars($info['target'], ENT_COMPAT, 'GB2312');
         if (!isset($_POST['id']) || !intval($_POST['id'])) {
             //add
             $info['time'] = SYS_TIME;
             $keywords_db->insert($info);
         } else {
             $keywords_db->update($info, array('id' => intval($_POST['id'])));
         }
         delCache('c_keywords');
         showMessage(L('setSuccess'), '?m=seo&a=keywords&c=seo');
     } else {
         $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
         $adus = bpBase::loadAppClass('adus', 'manage');
         $adus->title = '设置关键词';
         $adus->opers = array(array('text' => '返回', 'href' => $_SERVER['HTTP_REFERER'], 'class' => 'back'));
         $adus->formAction = '?m=seo&c=seo&a=keywordSet';
         $adus->jss = array('');
         $adus->headerHtml = '';
         /********************输入项*************************/
         $inputs = array();
         if (!$id) {
             $linkValue = 'http://';
             $targetValue = '_blank';
         } else {
             $thisKeyWord = $keywords_db->get_one(array('id' => $id));
             $linkValue = $thisKeyWord['link'];
             $titleValue = $thisKeyWord['title'];
             $targetValue = $thisKeyWord['target'];
             $keywordValue = $thisKeyWord['keyword'];
         }
         array_push($inputs, array('name' => '关键词', 'type' => 'text', 'validate' => "'required'", 'style' => 'width:180px;', 'field' => 'info[keyword]', 'value' => $keywordValue));
         array_push($inputs, array('name' => '链接地址', 'type' => 'text', 'validate' => "'required'", 'style' => 'width:180px;', 'field' => 'info[link]', 'value' => $linkValue));
         array_push($inputs, array('name' => '链接title', 'type' => 'hidden', 'validate' => "'required'", 'style' => 'width:180px;', 'field' => 'info[title]', 'value' => $titleValue));
         array_push($inputs, array('name' => '链接target', 'type' => 'text', 'validate' => "'required'", 'style' => 'width:180px;', 'field' => 'info[target]', 'value' => $targetValue));
         array_push($inputs, array('name' => '', 'type' => 'hidden', 'validate' => "", 'field' => 'id', 'value' => $id));
         $adus->inputs = $inputs;
         $adus->outputPage();
     }
 }
Ejemplo n.º 10
0
 function updateLastCreateTime($id)
 {
     $id = intval($id);
     $rt = $this->article_db->update(array('lastcreate' => SYS_TIME), array('id' => $id));
     if ($rt) {
         delCache('content' . $id);
     }
     return $rt;
 }
Ejemplo n.º 11
0
 function createIndexPage($siteid = 1)
 {
     $siteid = intval($siteid);
     if (!ABS_PATH . 'templatesCache' && !is_dir(ABS_PATH . 'templatesCache')) {
         mkdir(ABS_PATH . 'templatesCache', 777);
     }
     if ($siteid < 100) {
         //站点
         $template = $this->getDefaultTemplate($siteid, 1);
         //获取首页模板的数据库信息
         if (!$template) {
             showMessage('没有默认的模板,请在模板管理里面设置', '?m=template&c=m_template&a=templates&siteid=' . $siteid, 2000);
             exit;
         }
         //如果缓存不存在则分析模板
         if (!file_exists(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $template['id'] . '.parsed.tpl.php')) {
             $templateInfo = $this->getTemplateInfoByPath($template['path']);
             //parse first layer tags
             $this->addIDtoFirstLayerTagInTemplate($siteid, $template['id'], $templateInfo['absPath']);
         }
         $this->parseFirstLayerTag($template['id'], $siteid, 0, 0);
         //生成静态首页
         if (defined('NEW_INDEX') && NEW_INDEX && !loadConfig('index', 'notToHtml')) {
             $sitePage = bpBase::loadAppClass('sitePage', 'site');
             $sitePage->index(0);
         } else {
             if ((loadConfig('site', 'tohtml') || !loadConfig('index', 'notToHtml')) && $siteid == 1) {
                 $snoopy = bpBase::loadSysClass('Snoopy', '', 1);
                 if (!strpos(MAIN_URL_ROOT, 'localhost')) {
                     //echo 'st';
                     $snoopy->fetch('http://' . $_SERVER['HTTP_HOST'] . '/index.php');
                 } else {
                     $snoopyRt = $snoopy->fetch('http://127.0.0.1/index.php');
                 }
                 //file_put_contents(ABS_PATH.'/index.html',$snoopy->result);
             }
         }
         if (isah()) {
             $this->createSinglePage(193);
         }
         if ($siteid > 1) {
             //ah子站
             $site = bpBase::loadAppClass('siteObj', 'site');
             $thisSite = $site->getSiteByID($siteid);
             $child_siteMoudleClass = bpBase::loadAppClass('sitePage', 'site');
             $geo_db = bpBase::loadModel('geo_model');
             $thisGeo = $geo_db->get_one(array('geoindex' => $thisSite->siteindex));
             if ($thisGeo) {
                 $child_siteMoudleClass->childSiteIndex($thisGeo['id']);
             }
         }
     } else {
         //专题
         $special_db = bpBase::loadModel('special_model');
         $thisSpecial = $special_db->get_one(array('id' => $siteid));
         if (!$thisSpecial['templateid']) {
             showMessage('没有选择模板,请设置模板后再操作', '?m=special&c=m_special&a=specialSet&id=' . $siteid, 2000);
             exit;
         }
         $template_db = bpBase::loadModel('template_model');
         $template = $template_db->get_one(array('id' => $thisSpecial['templateid']));
         if (!$template) {
             showMessage('模板不存在,请在模板管理里面设置', '?m=template&c=m_template&a=templates&siteid=' . $siteid . '&type=5', 2000);
             exit;
         }
         //如果缓存不存在则分析模板
         //if (!file_exists(ABS_PATH.'templatesCache'.DIRECTORY_SEPARATOR.$template['id'].'.parsed.tpl.php')){
         $templateInfo = $this->getTemplateInfoByPath($template['path']);
         //parse first layer tags
         $this->addIDtoFirstLayerTagInTemplate($siteid, $template['id'], $templateInfo['absPath']);
         //}
         $this->parseFirstLayerTag($template['id'], $siteid, 0, 0);
         //更新专题url
         $specialConfig = loadConfig('special');
         $thisSpecial['urlformat'] = $thisSpecial['urlformat'] ? $thisSpecial['urlformat'] : $specialConfig['urlFormate'];
         $url = $this->specialPathReplace($thisSpecial['urlformat'], $thisSpecial['catid'], $thisSpecial);
         $special_db->update(array('url' => $url), array('id' => $siteid));
         delCache('c_special_' . $siteid);
     }
 }
Ejemplo n.º 12
0
 /**
  * 数据库导出方法
  * @param unknown_type $tables 数据表数据组
  * @param unknown_type $sqlcompat 数据库兼容类型
  * @param unknown_type $sqlcharset 数据库字符
  * @param unknown_type $sizelimit 卷大小
  * @param unknown_type $action 操作
  * @param unknown_type $fileid 卷标
  * @param unknown_type $random 随机字段
  * @param unknown_type $tableid 
  * @param unknown_type $startfrom 
  */
 private function export_database($tables, $sqlcompat, $sqlcharset, $sizelimit, $action, $fileid, $random, $tableid, $startfrom)
 {
     $dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', DB_CHARSET);
     $fileid = $fileid != '' ? $fileid : 1;
     if ($fileid == 1 && $tables) {
         if (!isset($tables) || !is_array($tables)) {
             showMessage('请选择要备份的表');
         }
         $random = mt_rand(1000, 9999);
         setCache('backupTables', serialize($tables));
     } else {
         if (!($tables = unserialize(getCache('backupTables')))) {
             showMessage('请选择要备份的表');
         }
     }
     if ($sqlcharset) {
         $this->db->query("SET NAMES '" . $sqlcharset . "';\n\n");
     }
     $tabledump = '';
     $tableid = $tableid != '' ? $tableid - 1 : 0;
     $startfrom = $startfrom != '' ? intval($startfrom) : 0;
     for ($i = $tableid; $i < count($tables) && strlen($tabledump) < $sizelimit * 1000; $i++) {
         global $startrow;
         $offset = 100;
         if (!$startfrom) {
             if ($tables[$i] != AUTO_TABLE_PREFIX . 'session') {
                 $tabledump .= "DROP TABLE IF EXISTS `{$tables[$i]}`;\n";
             }
             $createtable = $this->db->query("SHOW CREATE TABLE `{$tables[$i]}` ");
             $create = $this->db->fetch_next();
             $tabledump .= $create['Create Table'] . ";\n\n";
             $this->db->free_result($createtable);
             if ($sqlcompat == 'MYSQL41' && $this->db->version() < '4.1') {
                 $tabledump = preg_replace("/TYPE\\=([a-zA-Z0-9]+)/", "ENGINE=\\1 DEFAULT CHARSET=" . $dumpcharset, $tabledump);
             }
             if ($this->db->version() > '4.1' && $sqlcharset) {
                 $tabledump = preg_replace("/(DEFAULT)*\\s*CHARSET=[a-zA-Z0-9]+/", "DEFAULT CHARSET=" . $sqlcharset, $tabledump);
             }
             if ($tables[$i] == AUTO_TABLE_PREFIX . 'session') {
                 $tabledump = str_replace("CREATE TABLE `" . DB_PRE . "session`", "CREATE TABLE IF NOT EXISTS `" . DB_PRE . "session`", $tabledump);
             }
         }
         $numrows = $offset;
         while (strlen($tabledump) < $sizelimit * 1000 && $numrows == $offset) {
             if ($tables[$i] == AUTO_TABLE_PREFIX . 'session') {
                 break;
             }
             $sql = "SELECT * FROM `{$tables[$i]}` LIMIT {$startfrom}, {$offset}";
             $numfields = $this->db->num_fields($sql);
             $numrows = $this->db->num_rows($sql);
             $fields_name = $this->db->get_fields($tables[$i]);
             $rows = $this->db->query($sql);
             $name = array_keys($fields_name);
             $r = array();
             while ($row = $this->db->fetch_next()) {
                 $r[] = $row;
                 $comma = "";
                 $tabledump .= "INSERT INTO `{$tables[$i]}` VALUES(";
                 for ($j = 0; $j < $numfields; $j++) {
                     $tabledump .= $comma . "'" . mysql_real_escape_string($row[$name[$j]]) . "'";
                     $comma = ",";
                 }
                 $tabledump .= ");\n";
             }
             $this->db->free_result($rows);
             $startfrom += $offset;
         }
         $tabledump .= "\n";
         $startrow = $startfrom;
         $startfrom = 0;
     }
     if (trim($tabledump)) {
         $tabledump = "# time:" . date('Y-m-d H:i:s') . "\n# bupu auto system:http://www.bupu.net\n# --------------------------------------------------------\n\n\n" . $tabledump;
         $tableid = $i;
         $filename = date('Ymd') . '_' . $random . '_' . $fileid . '.sql';
         $altid = $fileid;
         $fileid++;
         $backUpFolder = ABS_PATH . DIRECTORY_SEPARATOR . 'backup';
         if (!file_exists($backUpFolder) && !is_dir($backUpFolder)) {
             mkdir($backUpFolder, 0777);
         }
         $bakfile_path = ABS_PATH . 'backup' . DIRECTORY_SEPARATOR . 'data' . date('Y-m-d', SYS_TIME);
         if (!file_exists($bakfile_path) && !is_dir($bakfile_path)) {
             mkdir($bakfile_path, 0777);
         }
         $bakfile = $bakfile_path . DIRECTORY_SEPARATOR . $filename;
         if (!is_writable($bakfile_path)) {
             showMessage('backup文件夹不可写');
         }
         file_put_contents($bakfile, $tabledump);
         @chmod($bakfile, 0777);
         showmessage('正在备份,请不要关闭浏览器' . " {$filename} ", '?m=manage&c=database&a=action_export&sizelimit=' . $sizelimit . '&sqlcompat=' . $sqlcompat . '&sqlcharset=' . $sqlcharset . '&tableid=' . $tableid . '&fileid=' . $fileid . '&startfrom=' . $startrow . '&random=' . $random . '&allow=' . $allow);
     } else {
         $bakfile_path = ABS_PATH . 'backup' . DIRECTORY_SEPARATOR . 'database';
         //file_put_contents($bakfile_path.DIRECTORY_SEPARATOR.'index.html','');
         delCache('backupTables');
         showmessage('备份成功,数据备份在了“/backup/data' . date('Y-m-d', SYS_TIME) . '”文件夹中');
     }
 }
 private function delRequestCache($request, $login, $optionsArray)
 {
     delCache(makeRequestPath($request, $login, $optionsArray));
 }
Ejemplo n.º 14
0
 /**
  * 删除某地的文章
  *
  */
 function deleteContentInLocation()
 {
     $geoid = intval($_GET['geoid']);
     if ($geoid > 0) {
         if (getCache('deleteContentInLocation' . $geoid)) {
             $articles = unserialize(getCache('deleteContentInLocation' . $geoid));
         } else {
             $articles = $this->article_db->get_results('*', '', array('geoid' => $geoid), 'time DESC');
             setCache('deleteContentInLocation' . $geoid, serialize($articles));
         }
         $count = count($articles);
         $i = isset($_GET['i']) ? intval($_GET['i']) : 0;
         $channelObj = bpBase::loadAppClass('channelObj', 'channel');
         if ($i < $count) {
             $thisChannel = $channelObj->getChannelByID($articles[$i]->channel_id);
             if ($thisChannel->iscity) {
                 $rt = $this->_delete($articles[$i], 0);
                 $this->_deleteContentInAllGroup($articles[$i]->id);
                 $i++;
                 $rt = $this->_delete($articles[$i], 0);
                 $this->_deleteContentInAllGroup($articles[$i]->id);
             }
             $i++;
             showMessage($articles[$i]->geoid . ':' . $articles[$i]->title . ' ' . $i . '/' . $count, '?m=article&c=m_article&a=deleteContentInLocation&geoid=' . $geoid . '&i=' . $i, 1);
         } else {
             delCache('deleteContentInLocation' . $geoid);
             echo 'complete';
         }
     }
 }
Ejemplo n.º 15
0
 public function catChannelSet()
 {
     if (isset($_GET['specialid']) || isset($_POST['info']['specialid'])) {
         //专题栏目
         $infoType = 'special';
         $channel_db = bpBase::loadModel('channel_model');
         $thisSpecial = $this->special_db->get($_GET['specialid']);
     } elseif (isset($_GET['catid']) || isset($_POST['info']['catid'])) {
         //每个专题分类的默认文章分类
         $infoType = 'specialCat';
         $channel_db = bpBase::loadModel('special_defaultchannel_model');
         $thisCat = $this->special_cat_db->get($_GET['catid']);
     }
     if (isset($_POST['doSubmit'])) {
         $tpl = bpBase::loadAppClass('template', 'template');
         $info = $_POST['info'];
         if (!isset($_POST['id'])) {
             $info['time'] = SYS_TIME;
             $info['site'] = $info['specialid'];
             $channelid = $channel_db->insert($info, 1);
             $channel_db->update(array('taxis' => $channelid), array('id' => $channelid));
             if ($infoType == 'specialCat') {
                 delCache('c_specialCatChannels' . $_POST['info']['catid']);
             } else {
                 $tpl->createChannelPageR($channelid);
             }
             showMessage(L('addSuccess'), $_POST['referer']);
         } else {
             //update
             $thisChannel = $channel_db->get_one(array('id' => $_POST['id']));
             if (!isset($info['externallink'])) {
                 $info['externallink'] = 0;
             }
             $channel_db->update($info, array('id' => $_POST['id']));
             if ($infoType == 'specialCat') {
                 delCache('c_specialCatChannels' . $_POST['info']['catid']);
                 delCache('c_special_catChannel' . $_POST['id']);
             } else {
                 $tpl->createChannelPageR($thisChannel['id']);
                 delCache('channelOfIndex' . $thisChannel['cindex'] . 'Site' . $thisChannel['site']);
             }
             showMessage(L('updateSuccess'), $_POST['referer']);
         }
     } else {
         $template_db = bpBase::loadModel('template_model');
         $channelTemplates = $template_db->select(array('site' => 1, 'type' => 2), '*', '', 'id ASC');
         $contentTemplates = $template_db->select(array('site' => 1, 'type' => 3), '*', '', 'id ASC');
         if ($_GET['id']) {
             $thisChannel = $channel_db->get_one(array('id' => $_GET['id']));
         } else {
             $thisChannel = array();
             $thisChannel['pagesize'] = 20;
             $thisChannel['thumbwidth'] = 0;
             $thisChannel['thumb2width'] = 0;
             $thisChannel['thumb3width'] = 0;
             $thisChannel['thumb4width'] = 0;
             $thisChannel['thumbheight'] = 0;
             $thisChannel['thumb2height'] = 0;
             $thisChannel['thumb3height'] = 0;
             $thisChannel['thumb4height'] = 0;
         }
         include $this->showManageTpl('catChannelSet');
     }
 }