Ejemplo n.º 1
0
function convert_article_table($_prefix)
{
    global $zbp;
    $list = array("`ID`" => "log_ID", "`post_title`" => "log_Title", "unix_timestamp(`post_date`)" => "log_PostTime", "`post_excerpt`" => "log_Intro", "`post_content`" => "log_Content", "`post_name`" => "log_Alias", "`post_author`" => "log_AuthorID", '0' => "log_CateID", 'IF(`post_type` =  "post", 0, 1 )' => "log_Type", "0" => "log_ViewNums", "`comment_count`" => "log_CommNums", '0' => "log_IsTop", 'IF(`post_status` =  "publish", 0, 1 )' => "log_Status", '""' => "log_Meta");
    $ary1 = array();
    $ary2 = array();
    foreach ($list as $name => $value) {
        $ary1[] = $value;
        $ary2[] = $name . ' AS ' . $value;
    }
    $sql = build_sql('Post', $_prefix . 'posts', $ary1, $ary2, ' WHERE (((`post_type`="page") OR (`post_type`="post")) AND (`post_status`<>"auto-draft"))');
    $zbp->db->QueryMulit($sql);
    $array = $zbp->GetArticleList(null, null, null, null, null, false);
    foreach ($array as $a) {
        if ($a->Intro == '') {
            if (strpos($a->Content, '<!--more-->') !== false) {
                $a->Intro = GetValueInArray(explode('<!--more-->', $a->Content), 0);
            } else {
                if ($a->Intro == '') {
                    $a->Intro = SubStrUTF8($a->Content, $zbp->option['ZC_ARTICLE_EXCERPT_MAX']);
                    if (strpos($a->Intro, '<') !== false) {
                        $a->Intro = CloseTags($a->Intro);
                    }
                }
            }
        }
        $a->Save();
    }
    return;
}
Ejemplo n.º 2
0
function GetValueInArrayByCurrent($array, $name)
{
    if (is_array($array)) {
        $array = current($array);
        return GetValueInArray($array, $name);
    }
}
Ejemplo n.º 3
0
function misc_statistic()
{
    global $zbp;
    $r = null;
    $zbp->BuildTemplate();
    $xmlrpc_address = $zbp->host . 'zb_system/xml-rpc/';
    $current_member = $zbp->user->Name;
    $current_version = $zbp->option['ZC_BLOG_VERSION'];
    $all_artiles = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(*) AS num FROM ' . $GLOBALS['table']['Post'] . ' WHERE log_Type=0'), 'num');
    $all_pages = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(*) AS num FROM ' . $GLOBALS['table']['Post'] . ' WHERE log_Type=1'), 'num');
    $all_categorys = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(*) AS num FROM ' . $GLOBALS['table']['Category']), 'num');
    $all_comments = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(*) AS num FROM ' . $GLOBALS['table']['Comment']), 'num');
    $all_views = $zbp->option['ZC_VIEWNUMS_TURNOFF'] == true ? 0 : GetValueInArrayByCurrent($zbp->db->Query('SELECT SUM(log_ViewNums) AS num FROM ' . $GLOBALS['table']['Post']), 'num');
    $all_tags = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(*) as num FROM ' . $GLOBALS['table']['Tag']), 'num');
    $all_members = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(*) AS num FROM ' . $GLOBALS['table']['Member']), 'num');
    $current_theme = $zbp->theme;
    $current_style = $zbp->style;
    $current_member = '{$zbp->user->Name}';
    $ajax = Network::Create();
    if ($ajax) {
        $ajax = substr(get_class($ajax), 7);
    }
    $system_environment = PHP_OS . ';' . GetValueInArray(explode(' ', str_replace(array('Microsoft-', '/'), array('', ''), GetVars('SERVER_SOFTWARE', 'SERVER'))), 0) . ';' . 'PHP' . phpversion() . ';' . $zbp->option['ZC_DATABASE_TYPE'] . ';' . $ajax;
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['current_member']}</td><td class='td30'>{$current_member}</td><td class='td20'>{$zbp->lang['msg']['current_version']}</td><td class='td30'>{$current_version}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['all_artiles']}</td><td>{$all_artiles}</td><td>{$zbp->lang['msg']['all_categorys']}</td><td>{$all_categorys}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['all_pages']}</td><td>{$all_pages}</td><td>{$zbp->lang['msg']['all_tags']}</td><td>{$all_tags}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['all_comments']}</td><td>{$all_comments}</td><td>{$zbp->lang['msg']['all_views']}</td><td>{$all_views}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['current_theme']}/{$zbp->lang['msg']['current_style']}</td><td>{$current_theme}/{$current_style}</td><td>{$zbp->lang['msg']['all_members']}</td><td>{$all_members}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['xmlrpc_address']}</td><td>{$xmlrpc_address}</td><td>{$zbp->lang['msg']['system_environment']}</td><td>{$system_environment}</td></tr>";
    $zbp->cache->reload_statistic = $r;
    $zbp->cache->reload_statistic_time = time();
    $zbp->cache->system_environment = $system_environment;
    //$zbp->SaveCache();
    CountNormalArticleNums();
    $zbp->AddBuildModule('statistics', array($all_artiles, $all_pages, $all_categorys, $all_tags, $all_views, $all_comments));
    $zbp->BuildModule();
    $r = str_replace('{#ZC_BLOG_HOST#}', $zbp->host, $r);
    $r = str_replace('{$zbp->user->Name}', $zbp->user->Name, $r);
    echo $r;
}
Ejemplo n.º 4
0
function misc_statistic()
{
    global $zbp;
    $r = null;
    $zbp->BuildTemplate();
    $xmlrpc_address = $zbp->host . 'zb_system/xml-rpc/';
    $current_member = $zbp->user->Name;
    $current_version = $zbp->option['ZC_BLOG_VERSION'];
    $all_artiles = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(log_ID) AS num FROM ' . $GLOBALS['table']['Post'] . ' WHERE log_Type=0'), 'num');
    $all_pages = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(log_ID) AS num FROM ' . $GLOBALS['table']['Post'] . ' WHERE log_Type=1'), 'num');
    $all_categorys = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(cate_ID) AS num FROM ' . $GLOBALS['table']['Category']), 'num');
    $all_comments = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(comm_ID) AS num FROM ' . $GLOBALS['table']['Comment']), 'num');
    $all_views = GetValueInArrayByCurrent($zbp->db->Query('SELECT SUM(log_ViewNums) AS num FROM ' . $GLOBALS['table']['Post']), 'num');
    $all_tags = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(tag_ID) as num FROM ' . $GLOBALS['table']['Tag']), 'num');
    $all_members = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(mem_ID) AS num FROM ' . $GLOBALS['table']['Member']), 'num');
    $current_theme = $zbp->theme;
    $current_style = $zbp->style;
    $current_member = '{$zbp->user->Name}';
    $system_environment = PHP_OS . ';' . GetValueInArray(explode('/', GetVars('SERVER_SOFTWARE', 'SERVER')), 0) . ';' . 'PHP ' . phpversion() . ';' . $zbp->option['ZC_DATABASE_TYPE'];
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['current_member']}</td><td class='td30'>{$current_member}</td><td class='td20'>{$zbp->lang['msg']['current_version']}</td><td class='td30'>{$current_version}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['all_artiles']}</td><td>{$all_artiles}</td><td>{$zbp->lang['msg']['all_categorys']}</td><td>{$all_categorys}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['all_pages']}</td><td>{$all_pages}</td><td>{$zbp->lang['msg']['all_tags']}</td><td>{$all_tags}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['all_comments']}</td><td>{$all_comments}</td><td>{$zbp->lang['msg']['all_views']}</td><td>{$all_views}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['current_theme']}/{$zbp->lang['msg']['current_style']}</td><td>{$current_theme}/{$current_style}</td><td>{$zbp->lang['msg']['all_members']}</td><td>{$all_members}</td></tr>";
    $r .= "<tr><td class='td20'>{$zbp->lang['msg']['xmlrpc_address']}</td><td>{$xmlrpc_address}</td><td>{$zbp->lang['msg']['system_environment']}</td><td>{$system_environment}</td></tr>";
    $s = $zbp->db->sql->Count($zbp->table['Post'], array(array('COUNT', '*', 'num')), array(array('=', 'log_Type', 0), array('=', 'log_IsTop', 0), array('=', 'log_Status', 0)));
    $num = GetValueInArrayByCurrent($zbp->db->Query($s), 'num');
    $zbp->LoadConfigs();
    $zbp->LoadCache();
    $zbp->cache->reload_statistic = $r;
    $zbp->cache->reload_statistic_time = time();
    $zbp->cache->normal_article_nums = $num;
    $zbp->SaveCache();
    $zbp->AddBuildModule('statistics', array($all_artiles, $all_pages, $all_categorys, $all_tags, $all_views, $all_comments));
    $zbp->BuildModule();
    $r = str_replace('{$zbp->user->Name}', $zbp->user->Name, $r);
    echo $r;
}
Ejemplo n.º 5
0
function HeartVote_Main(&$post, $method, $args)
{
    global $zbp;
    if ($method != 'HeartVote') {
        return null;
    }
    //$id=$template->GetTags('article')->ID;
    $id = $post->ID;
    $s = "<!--hvbegin--><div class=\"heart-vote\" id=\"HeartVote_{$id}\">";
    $s .= "<ul class=\"unit-rating\">";
    $s .= "<li class='current-rating' style=\"width:0px;\"></li>";
    $s .= "<li><a href=\"javascript:heartVote('1','{$id}')\" title=\"打1分\" class=\"r1-unit\">1</a></li>";
    $s .= "<li><a href=\"javascript:heartVote('2','{$id}')\" title=\"打2分\" class=\"r2-unit\">2</a></li>";
    $s .= "<li><a href=\"javascript:heartVote('3','{$id}')\" title=\"打3分\" class=\"r3-unit\">3</a></li>";
    $s .= "<li><a href=\"javascript:heartVote('4','{$id}')\" title=\"打4分\" class=\"r4-unit\">4</a></li>";
    $s .= "<li><a href=\"javascript:heartVote('5','{$id}')\" title=\"打5分\" class=\"r5-unit\">5</a></li>";
    $s .= "<li><a href=\"javascript:heartVote('6','{$id}')\" title=\"打6分\" class=\"r6-unit\">6</a></li>";
    $s .= "<li><a href=\"javascript:heartVote('7','{$id}')\" title=\"打7分\" class=\"r7-unit\">7</a></li>";
    $s .= "<li><a href=\"javascript:heartVote('8','{$id}')\" title=\"打8分\" class=\"r8-unit\">8</a></li>";
    $s .= "<li><a href=\"javascript:heartVote('9','{$id}')\" title=\"打9分\" class=\"r9-unit\">9</a></li>";
    $s .= "<li><a href=\"javascript:heartVote('10','{$id}')\" title=\"打10分\" class=\"r10-unit\">10</a></li>";
    $s .= "</ul><b>0</b><i>分/0个投票</i></div>";
    $sql = $zbp->db->sql->Count($zbp->table['HeartVote'], array(array('SUM', 'vote_Score', 'allvote'), array('COUNT', '*', 'alluser')), array(array('=', 'vote_LogID', $id)));
    $array = $zbp->db->Query($sql);
    $array = current($array);
    $alluser = GetValueInArray($array, 'alluser');
    $allvote = GetValueInArray($array, 'allvote');
    if ($alluser == 0) {
        $allvote = 0;
    } else {
        $allvote = substr($allvote / $alluser, 0, 3);
    }
    $s .= "<script type=\"text/javascript\">showVote('{$allvote}','{$alluser}')</script><!--hvend-->";
    //$s.="<script src=\"{$zbp->host}zb_users/plugin/HeartVote/getvote.php?id={$id}\" type=\"text/javascript\"></script>";
    //$template->SetTags('HeartVote',$s);
    echo $s;
    $GLOBALS['Filter_Plugin_Post_Call']['HeartVote_Main'] = PLUGIN_EXITSIGNAL_RETURN;
}
Ejemplo n.º 6
0
 public function __get($name)
 {
     global $zbp;
     switch ($name) {
         case 'Category':
             return $zbp->GetCategoryByID($this->CateID);
             break;
         case 'Author':
             return $zbp->GetMemberByID($this->AuthorID);
             break;
         case 'StatusName':
             return $zbp->lang['post_status_name'][$this->Status];
             break;
         case 'Url':
             if ($this->Type == ZC_POST_TYPE_ARTICLE) {
                 $u = new UrlRule($zbp->option['ZC_ARTICLE_REGEX']);
             } else {
                 $u = new UrlRule($zbp->option['ZC_PAGE_REGEX']);
             }
             $u->Rules['{%id%}'] = $this->ID;
             if ($this->Alias) {
                 $u->Rules['{%alias%}'] = $this->Alias;
             } else {
                 $u->Rules['{%alias%}'] = urlencode($this->Title);
             }
             $u->Rules['{%year%}'] = $this->Time('Y');
             $u->Rules['{%month%}'] = $this->Time('m');
             $u->Rules['{%day%}'] = $this->Time('d');
             if ($this->Category->Alias) {
                 $u->Rules['{%category%}'] = $this->Category->Alias;
             } else {
                 $u->Rules['{%category%}'] = urlencode($this->Category->Name);
             }
             if ($this->Author->Alias) {
                 $u->Rules['{%author%}'] = $this->Author->Alias;
             } else {
                 $u->Rules['{%author%}'] = urlencode($this->Author->Name);
             }
             return $u->Make();
             break;
         case 'Tags':
             return $zbp->LoadTagsByIDString($this->Tag);
             break;
         case 'TagsCount':
             return substr_count($this->Tag, '{');
             break;
         case 'TagsName':
             return $this->TagsToNameString;
         case 'Template':
             $value = $this->Data[$name];
             if ($value == '') {
                 $value = GetValueInArray($this->Category->GetDataArray(), 'LogTemplate');
                 if ($value == '') {
                     $value = $zbp->option['ZC_POST_DEFAULT_TEMPLATE'];
                 }
             }
             return $value;
         case 'CommentPostUrl':
             foreach ($GLOBALS['Filter_Plugin_Post_CommentPostUrl'] as $fpname => &$fpsignal) {
                 $fpreturn = $fpname($this);
                 if ($fpreturn) {
                     return $fpreturn;
                 }
             }
             $key = '&amp;key=' . md5($zbp->guid . $this->ID . date('Y-m-d'));
             return $zbp->host . 'zb_system/cmd.php?act=cmt&amp;postid=' . $this->ID . $key;
             break;
         case 'ValidCodeUrl':
             return $zbp->validcodeurl . '?id=cmt';
             break;
         case 'Prev':
             static $_prev = null;
             if ($_prev !== null) {
                 return $_prev;
             }
             $articles = $zbp->GetPostList(array('*'), array(array('=', 'log_Type', 0), array('=', 'log_Status', 0), array('<', 'log_PostTime', $this->PostTime)), array('log_PostTime' => 'DESC'), array(1), null);
             if (count($articles) == 1) {
                 $_prev = $articles[0];
             } else {
                 $_prev = '';
             }
             return $_prev;
             break;
         case 'Next':
             static $_next = null;
             if ($_next !== null) {
                 return $_next;
             }
             $articles = $zbp->GetPostList(array('*'), array(array('=', 'log_Type', 0), array('=', 'log_Status', 0), array('>', 'log_PostTime', $this->PostTime)), array('log_PostTime' => 'ASC'), array(1), null);
             if (count($articles) == 1) {
                 $_next = $articles[0];
             } else {
                 $_next = '';
             }
             return $_next;
             break;
         default:
             return parent::__get($name);
             break;
     }
 }
Ejemplo n.º 7
0
function PostArticle()
{
    global $zbp;
    if (!isset($_POST['ID'])) {
        return;
    }
    if (isset($_POST['Tag'])) {
        $_POST['Tag'] = TransferHTML($_POST['Tag'], '[noscript]');
        $_POST['Tag'] = PostArticle_CheckTagAndConvertIDtoString($_POST['Tag']);
    }
    if (isset($_POST['Content'])) {
        $_POST['Content'] = str_replace('<hr class="more" />', '<!--more-->', $_POST['Content']);
        $_POST['Content'] = str_replace('<hr class="more"/>', '<!--more-->', $_POST['Content']);
        if (strpos($_POST['Content'], '<!--more-->') !== false) {
            if (isset($_POST['Intro'])) {
                $_POST['Intro'] = GetValueInArray(explode('<!--more-->', $_POST['Content']), 0);
            }
        } else {
            if (isset($_POST['Intro'])) {
                if ($_POST['Intro'] == '') {
                    $_POST['Intro'] = SubStrUTF8($_POST['Content'], $zbp->option['ZC_ARTICLE_EXCERPT_MAX']);
                    if (strpos($_POST['Intro'], '<') !== false) {
                        $_POST['Intro'] = CloseTags($_POST['Intro']);
                    }
                }
            }
        }
    }
    if (!isset($_POST['AuthorID'])) {
        $_POST['AuthorID'] = $zbp->user->ID;
    } else {
        if ($_POST['AuthorID'] != $zbp->user->ID && !$zbp->CheckRights('ArticleAll')) {
            $_POST['AuthorID'] = $zbp->user->ID;
        }
        if ($_POST['AuthorID'] == 0) {
            $_POST['AuthorID'] = $zbp->user->ID;
        }
    }
    if (isset($_POST['Alias'])) {
        $_POST['Alias'] = TransferHTML($_POST['Alias'], '[noscript]');
    }
    if (isset($_POST['PostTime'])) {
        $_POST['PostTime'] = strtotime($_POST['PostTime']);
    }
    if (!$zbp->CheckRights('ArticleAll')) {
        unset($_POST['IsTop']);
    }
    $article = new Post();
    $pre_author = null;
    $pre_tag = null;
    $pre_category = null;
    if (GetVars('ID', 'POST') == 0) {
        if (!$zbp->CheckRights('ArticlePub')) {
            $_POST['Status'] = ZC_POST_STATUS_AUDITING;
        }
    } else {
        $article->LoadInfoByID(GetVars('ID', 'POST'));
        if ($article->AuthorID != $zbp->user->ID && !$zbp->CheckRights('ArticleAll')) {
            $zbp->ShowError(6);
        }
        if (!$zbp->CheckRights('ArticlePub') && $article->Status == ZC_POST_STATUS_AUDITING) {
            $_POST['Status'] = ZC_POST_STATUS_AUDITING;
        }
        $pre_author = $article->AuthorID;
        $pre_tag = $article->Tag;
        $pre_category = $article->CateID;
    }
    foreach ($zbp->datainfo['Post'] as $key => $value) {
        if ($key == 'ID') {
            continue;
        }
        if ($key == 'Meta') {
            continue;
        }
        if (isset($_POST[$key])) {
            $article->{$key} = GetVars($key, 'POST');
        }
    }
    $article->Type = ZC_POST_TYPE_ARTICLE;
    foreach ($GLOBALS['Filter_Plugin_PostArticle_Core'] as $fpname => &$fpsignal) {
        $fpname($article);
    }
    FilterPost($article);
    FilterMeta($article);
    $article->Save();
    CountTagArrayString($pre_tag . $article->Tag);
    CountMemberArray(array($pre_author, $article->AuthorID));
    CountCategoryArray(array($pre_category, $article->CateID));
    CountPostArray(array($article->ID));
    CountNormalArticleNums();
    $zbp->AddBuildModule('previous');
    $zbp->AddBuildModule('calendar');
    $zbp->AddBuildModule('comments');
    $zbp->AddBuildModule('archives');
    $zbp->AddBuildModule('tags');
    $zbp->AddBuildModule('authors');
    foreach ($GLOBALS['Filter_Plugin_PostArticle_Succeed'] as $fpname => &$fpsignal) {
        $fpname($article);
    }
    return true;
}
Ejemplo n.º 8
0
function zbp_editPost($id, $xmlstring, $publish)
{
    global $zbp;
    $xml = simplexml_load_string($xmlstring);
    if ($xml) {
        $post = array();
        foreach ($xml->children() as $x) {
            $a = (string) $x->name;
            if ($a == 'categories') {
                $b = $x->value->children()->asXML();
            } else {
                $b = $x->value->children();
            }
            $b = str_replace(array('<array>', '</array>', '<data>', '</data>', '<string>', '</string>'), array(''), $b);
            $post[$a] = $b;
        }
        $_POST['ID'] = $id;
        $_POST['Title'] = $post['title'];
        if ($publish) {
            $_POST['Status'] = 0;
        } else {
            $_POST['Status'] = 1;
        }
        if (isset($post['mt_basename'])) {
            $_POST['Alias'] = $post['mt_basename'];
        }
        if (isset($post['dateCreated'])) {
            date_default_timezone_set('GMT');
            $_POST['PostTime'] = strtotime($post['dateCreated']);
            date_default_timezone_set($zbp->option['ZC_TIME_ZONE_NAME']);
            $_POST['PostTime'] = date('c', $_POST['PostTime']);
        }
        if (isset($post['wp_author_id'])) {
            $_POST['AuthorID'] = $post['wp_author_id'];
        } else {
            $_POST['AuthorID'] = $zbp->user->ID;
        }
        if (isset($post['mt_keywords'])) {
            $_POST['Tag'] = $post['mt_keywords'];
        }
        if (isset($post['mt_allow_comments'])) {
            if ($post['mt_allow_comments'] > 0) {
                $_POST['IsLock'] = $post['mt_allow_comments'] - 1;
            } else {
                $_POST['IsLock'] = $post['mt_allow_comments'];
            }
        }
        if (isset($post['categories'])) {
            $post['categories'] = str_replace('<value>', '', $post['categories']);
            $catename = trim(GetValueInArray(explode('</value>', $post['categories']), 0));
            $_POST['CateID'] = $zbp->GetCategoryByName($catename)->ID;
        }
        if (isset($post['mt_excerpt'])) {
            $_POST['Intro'] = $post['mt_excerpt'];
        }
        if (isset($post['mt_text_more']) || isset($post['description'])) {
            if (isset($post['mt_text_more'])) {
                if ($post['mt_text_more'] != '') {
                    $_POST['Content'] = $post['description'] . '<!--more-->' . $post['mt_text_more'];
                } else {
                    $_POST['Content'] = $post['description'];
                }
            } else {
                $_POST['Content'] = $post['description'];
            }
        }
        $strXML = '<methodResponse><params><param><value><boolean>$%#1#%$</boolean></value></param></params></methodResponse>';
        if (PostArticle() == true) {
            $strXML = str_replace("\$%#1#%\$", 1, $strXML);
            echo $strXML;
        } else {
            $zbp->ShowError(0, __FILE__, __LINE_);
        }
    }
}
Ejemplo n.º 9
0
/**
 * 获取请求来源URL
 * @return string  返回URL
 */
function GetRequestUri()
{
    $url = '';
    if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
        $url = $_SERVER['HTTP_X_ORIGINAL_URL'];
    } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
        $url = $_SERVER['HTTP_X_REWRITE_URL'];
        if (strpos($url, '?') !== false) {
            $querys = GetValueInArray(explode('?', $url), '1');
            foreach (explode('&', $querys) as $query) {
                $name = GetValueInArray(explode('=', $query), '0');
                $value = GetValueInArray(explode('=', $query), '1');
                $name = urldecode($name);
                $value = urldecode($value);
                if (!isset($_GET[$name])) {
                    $_GET[$name] = $value;
                }
                if (!isset($_GET[$name])) {
                    $_REQUEST[$name] = $value;
                }
                $name = '';
                $value = '';
            }
        }
    } elseif (isset($_SERVER['REQUEST_URI'])) {
        $url = $_SERVER['REQUEST_URI'];
    } elseif (isset($_SERVER['REDIRECT_URL'])) {
        $url = $_SERVER['REDIRECT_URL'];
        if (isset($_SERVER['REDIRECT_QUERY_STRIN'])) {
            $url .= '?' . $_SERVER['REDIRECT_QUERY_STRIN'];
        }
    } else {
        $url = $_SERVER['PHP_SELF'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '');
    }
    return $url;
}
Ejemplo n.º 10
0
 /**
  * @return bool
  */
 public function Save()
 {
     global $zbp;
     if ($this->Type == ZC_POST_TYPE_ARTICLE) {
         if ($this->Template == GetValueInArray($this->Category->GetData(), 'LogTemplate')) {
             $this->data['Template'] = '';
         }
     }
     if ($this->Template == $zbp->GetPostType_Template($this->Type)) {
         $this->data['Template'] = '';
     }
     foreach ($GLOBALS['hooks']['Filter_Plugin_Post_Save'] as $fpname => &$fpsignal) {
         $fpsignal = PLUGIN_EXITSIGNAL_NONE;
         $fpreturn = $fpname($this);
         if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
             return $fpreturn;
         }
     }
     return parent::Save();
 }
Ejemplo n.º 11
0
/**
 * 提交文章数据
 * @api Filter_Plugin_PostArticle_Core
 * @api Filter_Plugin_PostArticle_Succeed
 * @return bool
 */
function PostArticle()
{
    global $zbp;
    if (!isset($_POST['ID'])) {
        return;
    }
    if (isset($_COOKIE['timezone'])) {
        $tz = GetVars('timezone', 'COOKIE');
        if (is_numeric($tz)) {
            date_default_timezone_set('Etc/GMT' . sprintf('%+d', -$tz));
        }
        unset($tz);
    }
    if (isset($_POST['Tag'])) {
        $_POST['Tag'] = TransferHTML($_POST['Tag'], '[noscript]');
        $_POST['Tag'] = PostArticle_CheckTagAndConvertIDtoString($_POST['Tag']);
    }
    if (isset($_POST['Content'])) {
        $_POST['Content'] = str_replace('<hr class="more" />', '<!--more-->', $_POST['Content']);
        $_POST['Content'] = str_replace('<hr class="more"/>', '<!--more-->', $_POST['Content']);
        if (strpos($_POST['Content'], '<!--more-->') !== false) {
            if (isset($_POST['Intro'])) {
                $_POST['Intro'] = GetValueInArray(explode('<!--more-->', $_POST['Content']), 0);
            }
        } else {
            if (isset($_POST['Intro'])) {
                if ($_POST['Intro'] == '') {
                    $_POST['Intro'] = SubStrUTF8($_POST['Content'], $zbp->option['ZC_ARTICLE_EXCERPT_MAX']);
                    $_POST['Intro'] .= '<!--autointro-->';
                }
                $_POST['Intro'] = CloseTags($_POST['Intro']);
            }
        }
    }
    if (!isset($_POST['AuthorID'])) {
        $_POST['AuthorID'] = $zbp->user->ID;
    } else {
        if ($_POST['AuthorID'] != $zbp->user->ID && !$zbp->CheckRights('ArticleAll')) {
            $_POST['AuthorID'] = $zbp->user->ID;
        }
        if ($_POST['AuthorID'] == 0) {
            $_POST['AuthorID'] = $zbp->user->ID;
        }
    }
    if (isset($_POST['Alias'])) {
        $_POST['Alias'] = TransferHTML($_POST['Alias'], '[noscript]');
    }
    if (isset($_POST['PostTime'])) {
        $_POST['PostTime'] = strtotime($_POST['PostTime']);
    }
    if (!$zbp->CheckRights('ArticleAll')) {
        unset($_POST['IsTop']);
    }
    $article = new Post();
    $pre_author = null;
    $pre_tag = null;
    $pre_category = null;
    $pre_istop = null;
    $pre_status = null;
    $orig_id = 0;
    if (GetVars('ID', 'POST') == 0) {
        if (!$zbp->CheckRights('ArticlePub')) {
            $_POST['Status'] = ZC_POST_STATUS_AUDITING;
        }
    } else {
        $article->LoadInfoByID(GetVars('ID', 'POST'));
        if ($article->AuthorID != $zbp->user->ID && !$zbp->CheckRights('ArticleAll')) {
            $zbp->ShowError(6, __FILE__, __LINE__);
        }
        if (!$zbp->CheckRights('ArticlePub') && $article->Status == ZC_POST_STATUS_AUDITING) {
            $_POST['Status'] = ZC_POST_STATUS_AUDITING;
        }
        $orig_id = $article->ID;
        $pre_author = $article->AuthorID;
        $pre_tag = $article->Tag;
        $pre_category = $article->CateID;
        $pre_istop = $article->IsTop;
        $pre_status = $article->Status;
    }
    foreach ($zbp->datainfo['Post'] as $key => $value) {
        if ($key == 'ID' || $key == 'Meta') {
            continue;
        }
        if (isset($_POST[$key])) {
            $article->{$key} = GetVars($key, 'POST');
        }
    }
    $article->Type = ZC_POST_TYPE_ARTICLE;
    if (isset($_POST['IsTop'])) {
        if (1 == $_POST['IsTop']) {
            $article->TopType = $_POST['IstopType'];
        }
        if (0 == $_POST['IsTop']) {
            $article->TopType = null;
        }
    }
    foreach ($GLOBALS['Filter_Plugin_PostArticle_Core'] as $fpname => &$fpsignal) {
        $fpname($article);
    }
    FilterPost($article);
    FilterMeta($article);
    $article->Save();
    //更新统计信息
    $pre_arrayTag = $zbp->LoadTagsByIDString($pre_tag);
    $now_arrayTag = $zbp->LoadTagsByIDString($article->Tag);
    $pre_array = $now_array = array();
    foreach ($pre_arrayTag as $tag) {
        $pre_array[] = $tag->ID;
    }
    foreach ($now_arrayTag as $tag) {
        $now_array[] = $tag->ID;
    }
    $del_array = array_diff($pre_array, $now_array);
    $add_array = array_diff($now_array, $pre_array);
    $del_string = $zbp->ConvertTagIDtoString($del_array);
    $add_string = $zbp->ConvertTagIDtoString($add_array);
    if ($del_string) {
        CountTagArrayString($del_string, -1, $article->ID);
    }
    if ($add_string) {
        CountTagArrayString($add_string, +1, $article->ID);
    }
    if ($pre_author != $article->AuthorID) {
        if ($pre_author > 0) {
            CountMemberArray(array($pre_author), array(-1, 0, 0, 0));
        }
        CountMemberArray(array($article->AuthorID), array(+1, 0, 0, 0));
    }
    if ($pre_category != $article->CateID) {
        if ($pre_category > 0) {
            CountCategoryArray(array($pre_category), -1);
        }
        CountCategoryArray(array($article->CateID), +1);
    }
    if ($zbp->option['ZC_LARGE_DATA'] == false) {
        CountPostArray(array($article->ID));
    }
    if ($orig_id == 0 && $article->IsTop == 0 && $article->Status == ZC_POST_STATUS_PUBLIC) {
        CountNormalArticleNums(+1);
    } elseif ($orig_id > 0) {
        if ($pre_istop == 0 && $pre_status == 0 && ($article->IsTop != 0 || $article->Status != 0)) {
            CountNormalArticleNums(-1);
        }
        if (($pre_istop != 0 || $pre_status != 0) && ($article->IsTop == 0 && $article->Status == 0)) {
            CountNormalArticleNums(+1);
        }
    }
    if ($article->IsTop == true && $article->Status == ZC_POST_STATUS_PUBLIC) {
        CountTopArticle($article->ID, null);
    } else {
        CountTopArticle(null, $article->ID);
    }
    $zbp->AddBuildModule('previous');
    $zbp->AddBuildModule('calendar');
    $zbp->AddBuildModule('comments');
    $zbp->AddBuildModule('archives');
    $zbp->AddBuildModule('tags');
    $zbp->AddBuildModule('authors');
    foreach ($GLOBALS['Filter_Plugin_PostArticle_Succeed'] as $fpname => &$fpsignal) {
        $fpname($article);
    }
    return true;
}
Ejemplo n.º 12
0
 public function CreateTable($tablename, $datainfo)
 {
     $s = '';
     if ($this->type == 'Dbpdo_MySQL' || $this->type == 'DbMySQL') {
         $s .= 'CREATE TABLE IF NOT EXISTS ' . $tablename . ' (';
         $i = 0;
         foreach ($datainfo as $key => $value) {
             if ($value[1] == 'integer') {
                 if ($i == 0) {
                     $s .= $value[0] . ' int(11) NOT NULL AUTO_INCREMENT' . ',';
                 } else {
                     if ($value[2] == '') {
                         $s .= $value[0] . ' int(11) NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } elseif ($value[2] == 'tinyint') {
                         $s .= $value[0] . ' tinyint(4) NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } elseif ($value[2] == 'smallint') {
                         $s .= $value[0] . ' smallint(6) NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } elseif ($value[2] == 'mediumint') {
                         $s .= $value[0] . ' mediumint(9) NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } elseif ($value[2] == 'int') {
                         $s .= $value[0] . ' int(11) NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } elseif ($value[2] == 'bigint') {
                         $s .= $value[0] . ' bigint(20) NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     }
                 }
             }
             if ($value[1] == 'boolean') {
                 $s .= $value[0] . ' tinyint(1) NOT NULL DEFAULT \'' . (int) $value[3] . '\'' . ',';
             }
             if ($value[1] == 'string') {
                 if ($value[2] != '') {
                     if (strpos($value[2], 'char') !== false) {
                         $s .= $value[0] . ' char(' . str_replace('char', '', $value[2]) . ') NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } elseif (is_int($value[2])) {
                         $s .= $value[0] . ' varchar(' . $value[2] . ') NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } elseif ($value[2] == 'tinytext') {
                         $s .= $value[0] . ' tinytext NOT NULL ' . ',';
                     } elseif ($value[2] == 'text') {
                         $s .= $value[0] . ' text NOT NULL ' . ',';
                     } elseif ($value[2] == 'mediumtext') {
                         $s .= $value[0] . ' mediumtext NOT NULL ' . ',';
                     } elseif ($value[2] == 'longtext') {
                         $s .= $value[0] . ' longtext NOT NULL ' . ',';
                     }
                 } else {
                     $s .= $value[0] . ' longtext NOT NULL ' . ',';
                 }
             }
             if ($value[1] == 'double' || $value[1] == 'float') {
                 $s .= $value[0] . ' $value[1] NOT NULL DEFAULT \'0\'' . ',';
             }
             $i += 1;
         }
         reset($datainfo);
         $s .= 'PRIMARY KEY (' . GetValueInArrayByCurrent($datainfo, 0) . '),';
         $s = substr($s, 0, strlen($s) - 1);
         $s .= ') ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
     }
     if ($this->type == 'DbSQLite') {
         $s .= 'CREATE TABLE ' . $tablename . ' (';
         $i = 0;
         foreach ($datainfo as $key => $value) {
             if ($value[1] == 'integer') {
                 if ($i == 0) {
                     $s .= $value[0] . ' integer primary key' . ',';
                 } else {
                     $s .= $value[0] . ' integer NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                 }
             }
             if ($value[1] == 'boolean') {
                 $s .= $value[0] . ' bit NOT NULL DEFAULT \'' . (int) $value[3] . '\'' . ',';
             }
             if ($value[1] == 'string') {
                 if ($value[2] != '') {
                     if (strpos($value[2], 'char') !== false) {
                         $s .= $value[0] . ' char(' . str_replace('char', '', $value[2]) . ') NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } elseif (is_int($value[2])) {
                         $s .= $value[0] . ' varchar(' . $value[2] . ') NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } else {
                         $s .= $value[0] . ' text NOT NULL DEFAULT \'\',';
                     }
                 } else {
                     $s .= $value[0] . ' text NOT NULL DEFAULT \'\',';
                 }
             }
             if ($value[1] == 'double' || $value[1] == 'float') {
                 $s .= $value[0] . ' $value[1] NOT NULL DEFAULT \'0\'' . ',';
             }
             $i += 1;
         }
         $s = substr($s, 0, strlen($s) - 1);
         $s .= ');';
         reset($datainfo);
         $s .= 'CREATE UNIQUE INDEX %pre%' . GetValueInArrayByCurrent($datainfo, 0) . ' on ' . $tablename . ' (' . GetValueInArrayByCurrent($datainfo, 0) . ');';
     }
     if ($this->type == 'DbSQLite3') {
         $s .= 'CREATE TABLE ' . $tablename . ' (';
         $i = 0;
         foreach ($datainfo as $key => $value) {
             if ($value[1] == 'integer') {
                 if ($i == 0) {
                     $s .= $value[0] . ' integer primary key autoincrement' . ',';
                 } else {
                     $s .= $value[0] . ' integer NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                 }
             }
             if ($value[1] == 'boolean') {
                 $s .= $value[0] . ' bit NOT NULL DEFAULT \'' . (int) $value[3] . '\'' . ',';
             }
             if ($value[1] == 'string') {
                 if ($value[2] != '') {
                     if (strpos($value[2], 'char') !== false) {
                         $s .= $value[0] . ' char(' . str_replace('char', '', $value[2]) . ') NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } elseif (is_int($value[2])) {
                         $s .= $value[0] . ' varchar(' . $value[2] . ') NOT NULL DEFAULT \'' . $value[3] . '\'' . ',';
                     } else {
                         $s .= $value[0] . ' text NOT NULL DEFAULT \'\',';
                     }
                 } else {
                     $s .= $value[0] . ' text NOT NULL DEFAULT \'\',';
                 }
             }
             if ($value[1] == 'double' || $value[1] == 'float') {
                 $s .= $value[0] . ' $value[1] NOT NULL DEFAULT \'0\'' . ',';
             }
             $i += 1;
         }
         $s = substr($s, 0, strlen($s) - 1);
         $s .= ');';
         reset($datainfo);
         $s .= 'CREATE UNIQUE INDEX %pre%' . GetValueInArray($datainfo, 0) . ' on ' . $tablename . ' (' . GetValueInArray($datainfo, 0) . ');';
     }
     return $s;
 }
Ejemplo n.º 13
0
$vote = GetVars("vote");
$id = GetVars("id");
$ip = GetGuestIP();
$sql = $zbp->db->sql->Select($zbp->table['HeartVote'], '*', array(array('=', 'vote_LogID', $id), array('=', 'vote_IP', $ip)), null, null, null);
$array = $zbp->db->Query($sql);
if (count($array) == 0) {
    $vh = new HeartVote();
    $vh->LogID = $id;
    $vh->Score = $vote;
    $vh->IP = $ip;
    $vh->Save();
    $sql = $zbp->db->sql->Count($zbp->table['HeartVote'], array(array('SUM', 'vote_Score', 'allvote'), array('COUNT', '*', 'alluser')), array(array('=', 'vote_LogID', $id)));
    $array = $zbp->db->Query($sql);
    $array = current($array);
    $alluser = GetValueInArray($array, 'alluser');
    $allvote = GetValueInArray($array, 'allvote');
    if ($alluser == 0) {
        $allvote = 0;
    } else {
        $allvote = substr($allvote / $alluser, 0, 3);
    }
    if ($mode == 'script') {
        echo "showVote({$allvote},{$alluser});";
    } else {
        echo "{$allvote}|{$alluser}";
    }
} else {
    if ($mode == 'script') {
        echo "alert('你已经投过一次了,还想投么( ̄口 ̄)!!!');showVote(0,0);";
    } else {
        echo '你已经投过一次了,还想投么( ̄口 ̄)!!!';