예제 #1
0
<?php

require "inc.php";
$method = $req->getGet("method");
if (empty($method)) {
    $method = "list";
}
$id = $req->getGet("id");
$log_info = "";
$setting_sub = getSubSetting($web_id);
if ($setting['db']['name'] == $setting_sub['db']['name']) {
    $setting['db']['pre_sub'] = $setting_sub['db']['pre'];
} else {
    $setting['db']['pre_sub'] = $setting_sub['db']['name'] . "." . $setting_sub['db']['pre'];
}
switch ($method) {
    case "list":
        build_page($method);
        break;
    case "delete":
        $log_info = $setting['language']['admin_art_tag_delete'];
        $tag = $db->result($setting['db']['pre_sub'] . "news_tag", "tag", array("id", "n=", $id));
        $db->update($setting['db']['pre_sub'] . "news_show", array("tag" => ''), array("id", "n=", $id));
        $db->update($setting['db']['pre_sub'] . "news_show", array("tag" => "REPLACE(tag, '" . $tag . ",', '')"), array("tag", "like", $tag));
        $db->update($setting['db']['pre_sub'] . "news_show", array("tag" => "REPLACE(tag, '," . $tag . "', '')"), array("tag", "like", $tag));
        $db->delete($setting['db']['pre_sub'] . "news_tag", array("id", "n=", $id));
        break;
    case "rebuild":
        set_time_limit(0);
        $log_info = $setting['language']['admin_art_tag_rebuild'];
        $db_tmp = new MySQL();
예제 #2
0
 public static function ajax_rank($news_id, $web_id, $value)
 {
     global $db, $setting;
     $sql = $db->buildSel($setting['db']['pre'] . "news_mark", "*", array(array("news_id", "n=", $news_id), array("web_id", "n=", $web_id)));
     $record = getData($sql, "record", 3600 * 24);
     if ($record === false) {
         $webInfo = getSubSetting($web_id);
         $newInfo = $db->record($webInfo['db']['name'] . "." . $webInfo['db']['pre'] . "news_show", "cat_id, subject", array("news_id", "n=", $news_id));
         if ($newInfo === false) {
             return array();
         }
         $subject = mysql_real_escape_string($newInfo['subject']);
         $cat_id = $newInfo['cat_id'];
         $db->insert($setting['db']['pre'] . "news_mark", array($web_id, $news_id, $cat_id, $subject, 0, 0, 0, 0, 0));
     }
     if (strpos($value, "-") === false) {
         $value = "+" . $value;
     }
     $db->update($setting['db']['pre'] . "news_mark", array("rank_total" => $value, "rank_times" => "+1", "rank_time" => "UNIX_TIMESTAMP()"), array(array("web_id", "n=", $web_id), array("news_id", "n=", $news_id, "and")));
     $sql = $db->buildSel($setting['db']['pre'] . "news_mark", "*", array(array("web_id", "n=", $web_id), array("news_id", "n=", $news_id, "and")));
     getData($sql, "remove");
     return getData($sql, "record", 3600 * 24);
 }
예제 #3
0
$order = $req->getGet("order");
$order_type = $req->getGet("order_type");
if (empty($order_type)) {
    $order_type = "desc";
}
$keyword = $req->getGet("keyword");
$tpl->Set_Variable('keyword', $keyword);
$page = $req->getGet("page");
$condition = array();
if (!empty($keyword)) {
    $condition[] = array("comment", "like", $keyword);
}
$counter = $db->result($setting['db']['pre'] . "comment", "count(*)", array("web_id", "n=", $web_id));
list($page_arr, $page_start, $page_size) = GetPageList($counter, "?keyword={$keyword}&order={$order}&order_type={$order_type}", $page);
$tpl->Set_Variables($page_arr);
$webInfo = getSubSetting($web_id);
$pre_sub = $webInfo['db']['name'] . "." . $webInfo['db']['pre'];
$condition[] = array("web_id", "n=", $web_id, "and");
$the_order = array();
if (empty($order)) {
    $order = "id";
}
$the_order[] = "{$order} {$order_type}";
$db->select(array(array("name" => $setting['db']['pre'] . "comment", "idx" => "a", "col" => "*", "condition" => $condition, "order" => $the_order), array("name" => $pre_sub . "news_show", "idx" => "b", "col" => "subject, cat_id", "join" => "news_id")), "", array("limit" => "{$page_start}, {$page_size}"));
while ($record = $db->GetRS()) {
    HtmlTrans(&$record);
    $record['link'] = getUrl("read", array($record['news_id'], $record['cat_id']), 1, $record['web_id']);
    $tpl->Set_Loop('record', $record);
}
$db->Free();
$tpl->Set_Variable('order_type_org', $order_type);
예제 #4
0
 public function pageStart($setPlugin = false)
 {
     global $setting, $db, $req, $cache;
     ob_start();
     ob_implicit_flush(false);
     $setting['cookie']['prefix'] .= substr(md5($_SERVER["USERNAME"] . $_SERVER["COMPUTERNAME"] . $_SERVER["OS"]), 0, 4) . "_";
     if ($setting['session']['mode'] == "sess_file") {
         $setting['session']['path'] = ROOT_PATH . "/" . $setting['path']['cache'] . "/session/" . date("Ymd") . "/";
     }
     $req = $this->getInstance("MyReq", $setting['cookie'], $setting['session']);
     $db = $this->getInstance("MySQL", $setting['db']['host'], $setting['db']['user'], $setting['db']['pass'], $setting['db']['charset']);
     $cache = $this->getInstance("MyCache", $setting['web']['cache_mode']);
     includeCache("website");
     includeCache("user_group");
     includeCache("user_type");
     $setting['info'] = array();
     $setting['info']['time'] = $_SERVER['REQUEST_TIME'];
     $setting['info']['time_start'] = GetMicrotime();
     $setting['info']['self'] = strtolower(basename($req->getServer("PHP_SELF")));
     $setting['info']['web'] = null;
     $host = $req->getServer("HTTP_HOST");
     for ($i = 0, $m = count($GLOBALS['website']); $i < $m; $i++) {
         if (strpos("," . $GLOBALS['website'][$i]['host'] . ",", "," . $host . ",") !== false) {
             $GLOBALS['website'][$i]['host'] = $host;
             $setting['web']['url'] = "http://" . $host;
             $setting['info']['web'] = $GLOBALS['website'][$i];
             break;
         }
     }
     if (is_null($setting['info']['web'])) {
         $setting['info']['web'] = $GLOBALS['website'][0];
     }
     if ($setting['info']['web'] === false) {
         $setting['info']['web'] = getParaInfo("website", "web_id", 1);
     }
     $setting_sub = getSubSetting($setting['info']['web']['web_id']);
     $setting_sub['web']['url'] = $setting['web']['url'];
     $setting['db_sub'] = $setting_sub['db'];
     if ($setting['db']['name'] == $setting_sub['db']['name']) {
         $setting['db']['pre_sub'] = $setting_sub['db']['pre'];
     } else {
         $setting['db']['pre_sub'] = $setting_sub['db']['name'] . "." . $setting_sub['db']['pre'];
     }
     unset($setting_sub['db']);
     $setting = arrayMerge($setting, $setting_sub);
     $req->init($setting['cookie'], $setting['session']);
     if ($setPlugin) {
         $this->setPlugin();
     }
     $this->getLanguage(ROOT_PATH . "/source/language/");
     $setting['language'] = $this->language;
     $req->SessionStart($GLOBALS['sess_handle']);
     $max_count = count($this->func_start);
     for ($i = 0; $i < $max_count; $i++) {
         call_user_func($this->func_start[$i]);
     }
     if (checkSign(1)) {
         return;
     }
     $username = $req->getSession("username");
     if (empty($username) || $username == "Guest") {
         $this->logcheck();
     }
     $req->setSession("url", "http://" . $req->getServer("HTTP_HOST") . $req->getServer("URL"));
     $req->setSession("ip", GetIp());
     $setting['info']['user'] = array();
     $setting['info']['user']['name'] = $req->getSession("username");
     $setting['info']['user']['group'] = getParaInfo("user_group", "group_id", $req->getSession('usergroup'));
     $setting['info']['user']['type'] = getParaInfo("user_type", "type_id", $req->getSession('usertype'));
     if ($setting['info']['user']['type'] === false) {
         $setting['info']['user']['type'] = array('type_id' => '1', 'type_name' => 'Guest', 'view_lvl' => '0');
     }
     $this->regAjax("reset_psw", "MyStep::ajax_reset_psw");
 }
예제 #5
0
function build_page($method = "")
{
    global $mystep, $req, $tpl, $tpl_info, $setting, $idx, $tpl_path, $method;
    $fso = $mystep->getInstance("MyFSO");
    $tpl_info['idx'] = "web_template";
    if ($method != "show") {
        $tpl_info['idx'] .= $method == "list" ? "_list" : "_input";
    }
    $tpl_tmp = $mystep->getInstance("MyTpl", $tpl_info);
    if ($method == "show") {
        $tpl_tmp->Set_Variable('title', $setting['language']['admin_web_template_title']);
        $tpl_tmp->Set_Variable('tpl_idx', $idx);
        $tpl_list = $fso->Get_List($tpl_path);
        $max_count = count($tpl_list['dir']);
        $the_list = array();
        for ($i = 0; $i < $max_count; $i++) {
            $tpl_list['dir'][$i] = basename($tpl_list['dir'][$i]);
            if ($tpl_list['dir'][$i] == "cache" || strpos($tpl_list['dir'][$i], "admin") !== false) {
                continue;
            }
            $tpl_tmp->Set_Loop("tpl_list", array("idx" => $tpl_list['dir'][$i], "img" => is_file($tpl_path . $tpl_list['dir'][$i] . "/sample.jpg") ? "/" . $setting['path']['template'] . "/" . $tpl_list['dir'][$i] . "/sample.jpg" : "/images/noimage.gif"));
            $the_list[] = $tpl_list['dir'][$i];
        }
        $tpl_tmp->Set_Variable('tpl_list', toJson($the_list, $setting['gen']['charset']));
        $max_count = count($GLOBALS['website']);
        for ($i = 0; $i < $max_count; $i++) {
            $setting_sub = getSubSetting($GLOBALS['website'][$i]['web_id']);
            $GLOBALS['website'][$i]['tpl'] = $setting_sub['gen']['template'];
            $tpl_tmp->Set_Loop("website", $GLOBALS['website'][$i]);
        }
    } elseif ($method == "list") {
        $tpl_tmp->Set_Variable('title', $setting['language']['admin_web_template_title']);
        $tpl_tmp->Set_Variable('tpl_idx', $idx);
        $tpl_list = $fso->Get_List($tpl_path);
        $max_count = count($tpl_list['dir']);
        for ($i = 0; $i < $max_count; $i++) {
            $tpl_list['dir'][$i] = basename($tpl_list['dir'][$i]);
            if ($tpl_list['dir'][$i] == "cache") {
                continue;
            }
            $tpl_tmp->Set_Loop("tpl_list", array("idx" => $tpl_list['dir'][$i], "selected" => $tpl_list['dir'][$i] == $idx ? "selected" : ""));
        }
        $css_file = ROOT_PATH . "/images/" . $idx . "/style.css";
        if (is_file($css_file)) {
            $tpl_tmp->Set_Loop("file", array("name" => "style.css", "size" => GetFileSize(filesize($css_file)), "attr" => $fso->Get_Attrib(substr(DecOct(fileperms($css_file)), -3)), "time" => date("Y/m/d H:i:s", filemtime($css_file))));
        }
        $file_list = $fso->Get_Tree($tpl_path . $idx, false, ".tpl");
        foreach ($file_list as $key => $value) {
            $curFile = $value;
            $curFile['name'] = $key;
            $tpl_tmp->Set_Loop("file", $curFile);
        }
    } else {
        $file = array();
        $file['idx'] = $idx;
        $file['content'] = "";
        if ($method == "edit") {
            $file['name'] = $req->getGet("file");
            if ($file['name'] == "style.css") {
                $the_file = ROOT_PATH . "/images/" . $idx . "/style.css";
                $file['type'] = "css";
            } else {
                $the_file = $tpl_path . $idx . "/" . $file['name'];
                $file['type'] = "htmlmixed";
            }
            if (is_file($the_file)) {
                $file['content'] = file_get_contents($the_file);
                $file['content'] = htmlspecialchars($file['content']);
                $file['content'] = str_replace("\t", "  ", $file['content']);
            }
            $tpl_tmp->Set_Variable('title', $setting['language']['admin_web_template_edit']);
        } else {
            $file['name'] = "";
            $tpl_tmp->Set_Variable('title', $setting['language']['admin_web_template_add']);
        }
        $tpl_tmp->Set_Variable('readonly', $method == "edit" ? "readonly" : "");
        $tpl_tmp->Set_Variables($file, "file");
    }
    $tpl_tmp->Set_Variable('back_url', $req->getServer("HTTP_REFERER"));
    $tpl_tmp->Set_Variable('method', $method);
    $tpl->Set_Variable('main', $tpl_tmp->Get_Content('$db, $setting'));
    unset($tpl_tmp);
    $mystep->show($tpl);
    return;
}
예제 #6
0
    public static function parse_news(MyTPL $tpl, $att_list = array())
    {
        global $setting, $db;
        $result = "";
        /*
        foreach($att_list as $key => $value) {
        	eval("\$att_list['".$key."'] = \"".$value."\";");
        }
        */
        if (!isset($att_list['template'])) {
            $att_list['template'] = "classic";
        }
        if (!isset($att_list['web_id'])) {
            $att_list['web_id'] = "";
        }
        if (!isset($att_list['cat_id'])) {
            $att_list['cat_id'] = "";
        }
        if (!isset($att_list['order'])) {
            if (empty($att_list['cat_id'])) {
                $att_list['order'] = " news_id desc";
            } else {
                $att_list['order'] = " `order` desc, news_id desc";
            }
        }
        if (!isset($att_list['setop'])) {
            $att_list['setop'] = "";
        }
        if (!empty($att_list['setop'])) {
            $show_list = array("index.php" => 1, "list.php" => 2, "read.php" => 4);
            $att_list['setop'] = $show_list[$setting['info']['self']] + ($att_list['setop'] == "img" ? 2 : 1) * 1024;
        }
        if (!isset($att_list['show_image'])) {
            $att_list['show_image'] = "";
        }
        if (!isset($att_list['xid'])) {
            $att_list['xid'] = "";
        }
        if (!isset($att_list['css1'])) {
            $att_list['css1'] = "";
        }
        if (!isset($att_list['css2'])) {
            $att_list['css2'] = $att_list['css1'];
        }
        if (!isset($att_list['limit'])) {
            $att_list['limit'] = 0;
        }
        if (!isset($att_list['loop'])) {
            $att_list['loop'] = 0;
        }
        if (!isset($att_list['expire'])) {
            $att_list['expire'] = "";
        }
        if (!isset($att_list['condition'])) {
            $att_list['condition'] = "";
        }
        if (!isset($att_list['show_catalog'])) {
            $att_list['show_catalog'] = "";
        }
        if (!isset($att_list['show_date'])) {
            $att_list['show_date'] = "";
        }
        if (!empty($att_list['show_date']) && date($att_list['show_date']) == $att_list['show_date']) {
            $att_list['show_date'] = "Y-m-d";
        }
        if (!isset($att_list['tag'])) {
            $att_list['tag'] = "";
        }
        if (!empty($att_list['cat_id'])) {
            if ($cat_info = getParaInfo("news_cat", "cat_id", $att_list['cat_id'])) {
                $att_list['web_id'] = $cat_info['web_id'];
            }
        }
        $pre = "{db_pre}";
        if (!empty($att_list['web_id'])) {
            $setting_sub = getSubSetting($att_list['web_id']);
            $pre = $setting_sub['db']['name'] . "." . $setting_sub['db']['pre'];
        }
        $condition = array();
        if (!empty($att_list['expire'])) {
            $condition[] = array(array("a.expire", "is", null), array("expire", "f>", "now()", "or"));
        }
        if (!empty($att_list['web_id'])) {
            $condition[] = array("a.web_id", "n=", $att_list['web_id'], "and");
        }
        if (!empty($att_list['cat_id'])) {
            if (is_numeric($att_list['cat_id'])) {
                $condition[] = array(array("a.cat_id", "=", $att_list['cat_id']), array("b.cat_main", "=", $att_list['cat_id'], "or"), "and");
            } else {
                $condition[] = array(array("a.cat_id", "in", $att_list['cat_id']), array("b.cat_main", "in", $att_list['cat_id'], "or"), "and");
            }
        }
        if (!empty($att_list['show_image'])) {
            $condition[] = array("a.image", "!=", "", "and");
        }
        if (!empty($att_list['setop'])) {
            $condition[] = array("(a.setop & {$att_list['setop']})", "n=", $att_list['setop'], "and");
        }
        if (!empty($att_list['xid'])) {
            $condition[] = array("a.news_id", "not in", $att_list['xid'], "and");
        }
        $tag = "";
        if (!empty($att_list['tag'])) {
            if (strpos($att_list['tag'], '$GLOBALS') === false) {
                $tag = explode(",", trim($att_list['tag']));
                $att_list['tag'] = "";
            } else {
                $tag = array("{tag}");
            }
            $tag_list = array();
            for ($i = 0, $m = count($tag); $i < $m; $i++) {
                $att_list['tag'][$i] = trim($tag[$i]);
                if (strlen($tag[$i]) < 2) {
                    continue;
                }
                $tag_list[] = array("a.tag", "like", $tag[$i], "or");
            }
            $tag_list[] = "and";
            $condition[] = $tag_list;
        }
        $opt = array();
        $opt["order"] = $att_list['order'];
        if (!empty($att_list['limit'])) {
            $opt["limit"] = $att_list['limit'];
        }
        if (!empty($att_list['condition'])) {
            $opt["condition"] = $att_list['condition'];
        }
        $sql = $db->buildSel(array(array("name" => $pre . "news_show", "idx" => "a", "col" => "*"), array("name" => $setting['db']['pre'] . "news_cat", "idx" => "b", "join" => "cat_id")), $condition, $opt);
        $cur_content = $tpl->Get_TPL($tpl->tpl_info["path"] . "/" . $tpl->tpl_info["style"] . "/block_news_{$att_list['template']}.tpl", $tpl->tpl_info["path"] . "/" . $tpl->tpl_info["style"] . "/block_news_classic.tpl");
        preg_match("/" . preg_quote($tpl->delimiter_l) . "loop:start" . preg_quote($tpl->delimiter_r) . "(.*)" . preg_quote($tpl->delimiter_l) . "loop:end" . preg_quote($tpl->delimiter_r) . "/isU", $cur_content, $block_all);
        $block = $block_all[0];
        $unit = $block_all[1];
        $unit_blank = preg_replace("/" . preg_quote($tpl->delimiter_l) . ".*?" . preg_quote($tpl->delimiter_r) . "/is", "", $unit);
        $unit_blank = preg_replace("/<(td|li|p|dd|dt)([^>]*?)>.*?<\\/\\1>/is", "<\\1\\2>&nbsp;</\\1>", $unit_blank);
        $unit_blank = addslashes($unit_blank);
        $unit = preg_replace("/" . preg_quote($tpl->delimiter_l) . "news_(\\w+)" . preg_quote($tpl->delimiter_r) . "/i", "{\$record['\\1']}", $unit);
        $tag = $att_list['tag'];
        $result = <<<mytpl
<?php
global \$plugin_setting;
\$n = 0;
\$sql = str_replace("{db_pre}", \$setting['db']['pre_sub'], "{$sql}");
\$sql = str_replace("and  order", "order", \$sql);
\$tag = "{$att_list['tag']}";
if(!empty(\$tag)) {
\t\$tag = str_replace("'", "", \$tag);
\t\$tag = str_replace("£¬", ",", \$tag);
\t\$tag = str_replace(" ", ",", \$tag);
\t\$tag = preg_replace("/,+/", ",", \$tag);
\t\$tag = trim(\$tag, ",");
\t\$tag = str_replace(",", "%' or a.tag like '%", \$tag);
\t\$sql = str_replace("{tag}", \$tag, \$sql);
} else {
\t\$sql = str_replace("(`a`.`tag` like '%{tag}%')", "true", \$sql);
}
\$result = getData(\$sql, "all", \$plugin_setting['offical']['ct_news']);
for(\$num=0,\$m=count(\$result); \$num<\$m; \$num++) {
\t\$record = \$result[\$num];
\tHtmlTrans(&\$record);
\t\$theStyle = explode(",", \$record['style']);
\t\$style = "";
\tfor(\$i=0;\$i<count(\$theStyle);\$i++) {
\t\t\$record['subject_org'] = htmlspecialchars(\$record['subject']);
\t\tif(\$theStyle[\$i]=="i") {
\t\t\t\$style .= "font-style:italic;";
\t\t} elseif((\$theStyle[\$i]=="b")) {
\t\t\t\$style .= "font-weight:bold;";
\t\t} else {
\t\t\t\$style .= "color:".\$theStyle[\$i].";";
\t\t}
\t}
\tif(!empty(\$style)) \$record['subject'] = "<span style=\\"".\$style."\\">".\$record['subject']."</span>";
\tif("{$att_list['template']}"=="classic" && \$setting['info']['time_start']/1000-strtotime(\$record['add_date'])<86400) \$record['subject'] .= ' <img src="images/new.gif" />';
\t\$record['style'] = \$n++%2 ? "{$att_list['css1']}" : "{$att_list['css2']}";
\t\$cat_info = getParaInfo("news_cat", "cat_id", \$record['cat_id']);
\tif(empty(\$record['link'])) \$record['link'] = getUrl("read", array(\$record['news_id'], (\$cat_info?\$cat_info['cat_idx']:"")), 1, \$record['web_id']);
\t\$record['add_date'] = ("{$att_list['show_date']}"!="") ? date("{$att_list['show_date']}", strtotime(\$record['add_date'])) : "";
\t\$record['catalog'] = "";
\tif("{$att_list['show_catalog']}"!="") {
\t\t\$cat_info = getParaInfo("news_cat", "cat_id", \$record['cat_id']);
\t\tif(\$cat_info) {
\t\t\t\$record['catalog'] = "<a href=\\"".getUrl("list", \$cat_info['cat_idx'], 1, \$record['web_id'])."\\" target=\\"_blank\\">[".\$cat_info['cat_name']."]</a>";
\t\t}
\t}
\techo <<<content
{$unit}
content;
\techo "\\n";
\tunset(\$record);
}
unset(\$result);
for(; \$n<{$att_list['loop']}; \$n++) {
\t\$unit = str_replace("style=\\"\\"", "style=\\"".(\$n%2?"{$att_list['css1']}":"{$att_list['css2']}")."\\"", "{$unit_blank}");
\techo \$unit;
\techo "\\n";
}
?>
mytpl;
        $result = str_replace($block, $result, $cur_content);
        return $result;
    }
예제 #7
0
 MultiDel($path_rollback);
 WriteFile($path_rollback . "include/config.php", GetFile(ROOT_PATH . "/include/config.php"), "wb");
 if (count($update_info['setting']) > 0) {
     $setting_org = $setting;
     require ROOT_PATH . "/include/config.php";
     $update_info['setting']['gen']['etag'] = date("Ymd");
     $content = changeSetting($update_info['setting'], array(), false);
     if ($method == "update") {
         WriteFile(ROOT_PATH . "/include/config.php", $content, "wb");
     }
     $setting = $setting_org;
     WriteFile($path_rollback . $ms_version['ver'] . "_config.php", $content, "wb");
 }
 $pre_list = array();
 foreach ($website as $cur_web) {
     $cur_setting = getSubSetting($cur_web['web_id']);
     $pre_list[] = $cur_setting['db']['name'] . "`.`" . $cur_setting['db']['pre'];
 }
 $strFind = array("{db_name}", "{pre}", "{charset}");
 $strReplace = array($setting['db']['name'], $setting['db']['pre'], $setting['db']['charset']);
 $sql_list = array();
 for ($i = 0, $m = count($update_info['sql']); $i < $m; $i++) {
     if (count($pre_list) > 1 && (strpos($update_info['sql'][$i], "{pre}news_show") || strpos($update_info['sql'][$i], "{pre}news_detail") || strpos($update_info['sql'][$i], "{pre}news_tag"))) {
         foreach ($pre_list as $cur_pre) {
             $cur_sql = str_replace("{pre}", $cur_pre, $update_info['sql'][$i]);
             $cur_sql = str_replace($strFind, $strReplace, $cur_sql);
             $sql_list[] = $cur_sql;
         }
     } else {
         $sql_list[] = str_replace($strFind, $strReplace, $update_info['sql'][$i]);
     }
예제 #8
0
    public static function news_comment(MyTPL $tpl, $att_list = array())
    {
        global $setting;
        $result = "";
        if (!isset($att_list['template'])) {
            $att_list['template'] = "classic";
        }
        if (!isset($att_list['web_id'])) {
            $att_list['web_id'] = $setting['info']['web']['web_id'];
        }
        if (!isset($att_list['news_id'])) {
            $att_list['news_id'] = "";
        }
        if (!isset($att_list['css1'])) {
            $att_list['css1'] = "";
        }
        if (!isset($att_list['css2'])) {
            $att_list['css2'] = $att_list['css1'];
        }
        if (!isset($att_list['limit'])) {
            $att_list['limit'] = 10;
        }
        if (!isset($att_list['loop'])) {
            $att_list['loop'] = 0;
        }
        if (!isset($att_list['order'])) {
            $att_list['order'] = "id desc";
        }
        if (!isset($att_list['count'])) {
            $att_list['count'] = false;
        }
        $webInfo = getSubSetting($att_list['web_id']);
        $pre_sub = $webInfo['db']['name'] . "." . $webInfo['db']['pre'];
        if ($att_list['count']) {
            $sql = $db->buildSel($setting['db']['pre'] . "comment", "news_id, count(*) as counter", array("web_id", "n=", $att_list['web_id']), array("group" => "news_id", "limit" => $att_list['limit']));
            $sql = $db->buildSel(array(array("query" => $sql, "idx" => "a", "col" => "counter", "order" => "counter desc, news_id desc"), array("name" => $pre_sub . "news_show", "idx" => "b", "col" => "news_id, subject, web_id, cat_id", "join" => "news_id")));
        } else {
            $condition = array();
            $condition[] = array("web_id", "n=", $att_list['web_id']);
            if (!empty($att_list['news_id'])) {
                $condition[] = array("news_id", "n=", $att_list['news_id']);
            }
            $sql = $db->buildSel(array(array("name" => $setting['db']['pre'] . "comment", "idx" => "a", "col" => array("*", "comment as describe"), "condition" => $condition), array("name" => $pre_sub . "news_show", "idx" => "b", "col" => "subject, cat_id", "join" => "news_id")), "", $att_list);
        }
        $cur_content = $tpl->Get_TPL($tpl->tpl_info["path"] . "/" . $tpl->tpl_info["style"] . "/block_news_{$att_list['template']}.tpl", $tpl->tpl_info["path"] . "/" . $tpl->tpl_info["style"] . "/block_news_classic.tpl");
        preg_match("/" . preg_quote($tpl->delimiter_l) . "loop:start" . preg_quote($tpl->delimiter_r) . "(.*)" . preg_quote($tpl->delimiter_l) . "loop:end" . preg_quote($tpl->delimiter_r) . "/isU", $cur_content, $block_all);
        $block = $block_all[0];
        $unit = $block_all[1];
        $unit_blank = preg_replace("/" . preg_quote($tpl->delimiter_l) . ".*?" . preg_quote($tpl->delimiter_r) . "/is", "", $unit);
        $unit_blank = preg_replace("/<(td|li|p|dd|dt)([^>]*?)>.*?<\\/\\1>/is", "<\\1\\2>&nbsp;</\\1>", $unit_blank);
        $unit_blank = addslashes($unit_blank);
        $unit = preg_replace("/" . preg_quote($tpl->delimiter_l) . "news_(\\w+)" . preg_quote($tpl->delimiter_r) . "/i", "{\$record['\\1']}", $unit);
        $result = <<<mytpl
<?php
global \$plugin_setting;
\$n = 0;
\$result = getData("{$sql}", "all", \$plugin_setting['offical']['ct_news']);
\$max_count = count(\$result);
for(\$num=0; \$num<\$max_count; \$num++) {
\t\$record = \$result[\$num];
\tHtmlTrans(&\$record);
\t\$record['style'] = \$n++%2 ? "{$att_list['css1']}" : "{$att_list['css2']}";
\t\$record['subject_org'] = \$record['subject'];
\t\$record['describe'] = \$record['comment'];
\tif(empty(\$record['link'])) \$record['link'] = getUrl("read", array(\$record['news_id'], \$record['cat_id']), 1, \$record['web_id']);
\t\$record['add_date'] = "";
\t\$record['catalog'] = "";
\techo <<<content
{$unit}
content;
\techo "\\n";
\tunset(\$record);
}
unset(\$result);
for(; \$n<{$att_list['loop']}; \$n++) {
\t\$unit = str_replace("style=\\"\\"", "style=\\"".(\$n%2?"{$att_list['css1']}":"{$att_list['css2']}")."\\"", "{$unit_blank}");
\techo \$unit;
\techo "\\n";
}
?>
mytpl;
        $result = str_replace($block, $result, $cur_content);
        return $result;
    }
예제 #9
0
<?php

require "../inc.php";
$method = $req->getReq("method");
includeCache("news_cat");
$log_info = "";
switch ($method) {
    case "trans":
        $cat_id = $req->getReq("cat_id");
        $org_id = $_POST['web_id_org'];
        $dst_id = $_POST['web_id_dst'];
        $log_info = $setting['language']['plugin_data_trans_title'];
        $setting_org = getSubSetting($org_id);
        $setting_dst = getSubSetting($dst_id);
        $pre_org = "{$setting_org['db']['name']}.{$setting_org['db']['pre']}";
        $pre_dst = "{$setting_dst['db']['name']}.{$setting_dst['db']['pre']}";
        if ($pre_org == $pre_dst) {
            showInfo($setting['language']['plugin_data_trans_error']);
        }
        $db2 = new MySQL();
        $db2->init($setting['db']['host'], $setting['db']['user'], $setting['db']['pass'], $setting['db']['charset']);
        $db2->Connect(false, $setting['db']['name']);
        $db->ReConnect(true);
        if ($cat_id == 0) {
            foreach ($GLOBALS['news_cat'] as $cur_cat) {
                if ($cur_cat['web_id'] != $org_id) {
                    continue;
                }
                if ($org_id != $dst_id) {
                    $db->update($setting['db']['pre'] . "news_cat", array("web_id" => $dst_id), array("cat_id", "n=", $cur_cat['cat_id']));
                }
예제 #10
0
파일: rss.php 프로젝트: laiello/mystep-cms
<?php

$ms_sign = 1;
require "inc.php";
$cat_idx = strtolower($req->getGet("cat"));
if ($cat_info = getParaInfo("news_cat", "cat_idx", $cat_idx)) {
    $web_info = getSubSetting($cat_info['web_id']);
} else {
    $cat_idx = "";
    $web_info = getSubSetting($setting['info']['web']['web_id']);
}
$tpl_info['idx'] = "rss";
if ($setting['gen']['cache']) {
    $cache_info = array('idx' => "rss_" . $web_info["info"]["web_id"] . (empty($cat_idx) ? "" : "_{$cat_info[cat_id]}"), 'path' => $cache_path . "/rss/", 'expire' => getCacheExpire());
} else {
    $cache_info = false;
}
$tpl = $mystep->getInstance("MyTpl", $tpl_info, $cache_info);
if ($tpl->Is_Cached()) {
    echo $tpl->Get_Content();
    $mystep->pageEnd(false);
}
if (empty($cat_idx)) {
    $cat_txt = $setting['language']['page_all_news'];
} else {
    $cat_txt = $cat_info['cat_name'];
    $setting['web']['description'] .= ", " . $cat_info['cat_comment'];
}
$cat_txt .= sprintf($setting['language']['page_update_lastest'], $setting['list']['rss']);
$charset_tag = '<?xml version="1.0" encoding="' . $setting['gen']['charset'] . '"?>' . "\n";
$tpl->Set_Variable('charset_tag', $charset_tag);
예제 #11
0
             }
             $db->update($setting['db']['pre'] . "news_cat", array("cat_layer" => $layer), array("cat_id", "n=", $catid));
             $catid_list = array();
             $db->select($setting['db']['pre'] . "news_cat", "cat_id", array("cat_main", "n=", $catid));
             while ($record = $db->GetRS()) {
                 $catid_list[] = $record['cat_id'];
             }
             $db->free();
             for ($i = 0, $m = count($catid_list); $i < $m; $i++) {
                 multiChange($catid_list[$i], $layer + 1);
             }
             return;
         }
         multiChange($cat_id, $_POST['cat_layer']);
         $db->update($setting['db']['pre'] . "news_cat", $_POST, array("cat_id", "n=", $cat_id));
         $setting_sub = getSubSetting($webInfo['web_id']);
         if ($setting['db']['name'] == $setting_sub['db']['name']) {
             $setting['db']['pre_sub'] = $setting_sub['db']['pre'];
         } else {
             $setting['db']['pre_sub'] = $setting_sub['db']['name'] . "." . $setting_sub['db']['pre'];
         }
         if ($view_lvl_org != $_POST['view_lvl'] && is_numeric($_POST['view_lvl'])) {
             $db->update($setting['db']['pre_sub'] . "news_show", array("view_lvl", $_POST['view_lvl']), array(array("cat_id", "n=", $cat_id), array("view_lvl", "n=", $view_lvl_org, "and")));
         }
         if ($notice_org != $_POST['notice']) {
             $db->update($setting['db']['pre_sub'] . "news_show", array("notice", $_POST['notice']), array(array("cat_id", "n=", $cat_id), array("notice", "=", $notice_org, "and")));
         }
     }
 }
 if ($method == "add_ok") {
     $cat_id = $db->GetInsertId();