Ejemplo n.º 1
0
 public static function GetInstance()
 {
     if (!isset(self::$_zbp)) {
         self::$_zbp = new ZBlogPHP();
     }
     return self::$_zbp;
 }
Ejemplo n.º 2
0
 function ExistTable($tablename)
 {
     $zbp = ZBlogPHP::GetInstance();
     $a = $this->Query($this->sql->ExistTable($tablename));
     if (!is_array($a)) {
         return false;
     }
     $b = current($a);
     if (!is_array($b)) {
         return false;
     }
     $c = (int) current($b);
     if ($c > 0) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
 */
$actions = array('login' => 6, 'logout' => 6, 'verify' => 6, 'admin' => 5, 'search' => 6, 'misc' => 6, 'feed' => 6, 'cmt' => 6, 'getcmt' => 6, 'ajax' => 6, 'ArticleEdt' => 4, 'ArticlePst' => 4, 'ArticleDel' => 4, 'ArticlePub' => 3, 'PageEdt' => 2, 'PagePst' => 2, 'PageDel' => 2, 'CategoryEdt' => 2, 'CategoryPst' => 2, 'CategoryDel' => 2, 'CommentEdt' => 5, 'CommentSav' => 5, 'CommentDel' => 5, 'CommentChk' => 5, 'CommentBat' => 5, 'MemberEdt' => 5, 'MemberPst' => 5, 'MemberDel' => 1, 'MemberNew' => 1, 'TagEdt' => 2, 'TagPst' => 2, 'TagDel' => 2, 'TagNew' => 2, 'PluginEnb' => 1, 'PluginDis' => 1, 'UploadPst' => 3, 'UploadDel' => 3, 'ModuleEdt' => 3, 'ModulePst' => 3, 'ModuleDel' => 3, 'ThemeSet' => 1, 'SidebarSet' => 1, 'SettingSav' => 1, 'ArticleMng' => 4, 'PageMng' => 2, 'CategoryMng' => 2, 'SettingMng' => 1, 'TagMng' => 2, 'CommentMng' => 5, 'UploadMng' => 3, 'MemberMng' => 5, 'ThemeMng' => 1, 'PluginMng' => 1, 'ModuleMng' => 1, 'ArticleAll' => 2, 'PageAll' => 2, 'CategoryAll' => 2, 'CommentAll' => 2, 'MemberAll' => 1, 'TagAll' => 2, 'UploadAll' => 2, 'root' => 1);
/**
 *定义数据表
 */
$table = array('Post' => '%pre%post', 'Category' => '%pre%category', 'Comment' => '%pre%comment', 'Tag' => '%pre%tag', 'Upload' => '%pre%upload', 'Counter' => '%pre%counter', 'Module' => '%pre%module', 'Member' => '%pre%member', 'Config' => '%pre%config');
/**
 *定义数据结构
 */
$datainfo = array('Config' => array('ID' => array('conf_ID', 'integer', '', 0), 'Name' => array('conf_Name', 'string', 50, ''), 'Value' => array('conf_Value', 'string', '', '')), 'Post' => array('ID' => array('log_ID', 'integer', '', 0), 'CateID' => array('log_CateID', 'integer', '', 0), 'AuthorID' => array('log_AuthorID', 'integer', '', 0), 'Tag' => array('log_Tag', 'string', 250, ''), 'Status' => array('log_Status', 'integer', '', 0), 'Type' => array('log_Type', 'integer', '', 0), 'Alias' => array('log_Alias', 'string', 250, ''), 'IsTop' => array('log_IsTop', 'boolean', '', false), 'IsLock' => array('log_IsLock', 'boolean', '', false), 'Title' => array('log_Title', 'string', 250, ''), 'Intro' => array('log_Intro', 'string', '', ''), 'Content' => array('log_Content', 'string', '', ''), 'PostTime' => array('log_PostTime', 'integer', '', 0), 'CommNums' => array('log_CommNums', 'integer', '', 0), 'ViewNums' => array('log_ViewNums', 'integer', '', 0), 'Template' => array('log_Template', 'string', 50, ''), 'Meta' => array('log_Meta', 'string', '', '')), 'Category' => array('ID' => array('cate_ID', 'integer', '', 0), 'Name' => array('cate_Name', 'string', 50, ''), 'Order' => array('cate_Order', 'integer', '', 0), 'Count' => array('cate_Count', 'integer', '', 0), 'Alias' => array('cate_Alias', 'string', 50, ''), 'Intro' => array('cate_Intro', 'string', '', ''), 'RootID' => array('cate_RootID', 'integer', '', 0), 'ParentID' => array('cate_ParentID', 'integer', '', 0), 'Template' => array('cate_Template', 'string', 50, ''), 'LogTemplate' => array('cate_LogTemplate', 'string', 50, ''), 'Meta' => array('cate_Meta', 'string', '', '')), 'Comment' => array('ID' => array('comm_ID', 'integer', '', 0), 'LogID' => array('comm_LogID', 'integer', '', 0), 'IsChecking' => array('comm_IsChecking', 'boolean', '', false), 'RootID' => array('comm_RootID', 'integer', '', 0), 'ParentID' => array('comm_ParentID', 'integer', '', 0), 'AuthorID' => array('comm_AuthorID', 'integer', '', 0), 'Name' => array('comm_Name', 'string', 20, ''), 'Content' => array('comm_Content', 'string', '', ''), 'Email' => array('comm_Email', 'string', 50, ''), 'HomePage' => array('comm_HomePage', 'string', 250, ''), 'PostTime' => array('comm_PostTime', 'integer', '', 0), 'IP' => array('comm_IP', 'string', 15, ''), 'Agent' => array('comm_Agent', 'string', '', ''), 'Meta' => array('comm_Meta', 'string', '', '')), 'Counter' => array('ID' => array('coun_ID', 'integer', '', 0), 'MemID' => array('coun_MemID', 'integer', '', 0), 'IP' => array('coun_IP', 'string', 15, ''), 'Agent' => array('coun_Agent', 'string', '', ''), 'Refer' => array('coun_Refer', 'string', 250, ''), 'Title' => array('coun_Title', 'string', 250, ''), 'PostTime' => array('coun_PostTime', 'integer', '', 0), 'Description' => array('coun_Description', 'string', '', ''), 'PostData' => array('coun_PostData', 'string', '', ''), 'AllRequestHeader' => array('coun_AllRequestHeader', 'string', '', '')), 'Module' => array('ID' => array('mod_ID', 'integer', '', 0), 'Name' => array('mod_Name', 'string', 100, ''), 'FileName' => array('mod_FileName', 'string', 50, ''), 'Content' => array('mod_Content', 'string', '', ''), 'HtmlID' => array('mod_HtmlID', 'string', 50, ''), 'Type' => array('mod_Type', 'string', 5, 'div'), 'MaxLi' => array('mod_MaxLi', 'integer', '', 0), 'Source' => array('mod_Source', 'string', 50, 'user'), 'IsHideTitle' => array('mod_IsHideTitle', 'boolean', '', false), 'Meta' => array('mod_Meta', 'string', '', '')), 'Member' => array('ID' => array('mem_ID', 'integer', '', 0), 'Guid' => array('mem_Guid', 'string', 36, ''), 'Level' => array('mem_Level', 'integer', '', 6), 'Status' => array('mem_Status', 'integer', '', 0), 'Name' => array('mem_Name', 'string', 50, ''), 'Password' => array('mem_Password', 'string', 32, ''), 'Email' => array('mem_Email', 'string', 50, ''), 'HomePage' => array('mem_HomePage', 'string', 250, ''), 'IP' => array('mem_IP', 'string', 15, ''), 'PostTime' => array('mem_PostTime', 'integer', '', 0), 'Alias' => array('mem_Alias', 'string', 50, ''), 'Intro' => array('mem_Intro', 'string', '', ''), 'Articles' => array('mem_Articles', 'integer', '', 0), 'Pages' => array('mem_Pages', 'integer', '', 0), 'Comments' => array('mem_Comments', 'integer', '', 0), 'Uploads' => array('mem_Uploads', 'integer', '', 0), 'Template' => array('mem_Template', 'string', 50, ''), 'Meta' => array('mem_Meta', 'string', '', '')), 'Tag' => array('ID' => array('tag_ID', 'integer', '', 0), 'Name' => array('tag_Name', 'string', 250, ''), 'Order' => array('tag_Order', 'integer', '', 0), 'Count' => array('tag_Count', 'integer', '', 0), 'Alias' => array('tag_Alias', 'string', 250, ''), 'Intro' => array('tag_Intro', 'string', '', ''), 'Template' => array('tag_Template', 'string', 50, ''), 'Meta' => array('tag_Meta', 'string', '', '')), 'Upload' => array('ID' => array('ul_ID', 'integer', '', 0), 'AuthorID' => array('ul_AuthorID', 'integer', '', 0), 'Size' => array('ul_Size', 'integer', '', 0), 'Name' => array('ul_Name', 'string', 250, ''), 'SourceName' => array('ul_SourceName', 'string', 250, ''), 'MimeType' => array('ul_MimeType', 'string', 50, ''), 'PostTime' => array('ul_PostTime', 'integer', '', 0), 'DownNums' => array('ul_DownNums', 'integer', '', 0), 'LogID' => array('ul_LogID', 'integer', '', 0), 'Intro' => array('ul_Intro', 'string', '', ''), 'Meta' => array('ul_Meta', 'string', '', '')));
#加载ZBP类 数据库类 配置类
AutoloadClass('ZBlogPHP');
AutoloadClass('DbSql');
AutoloadClass('Config');
#实例化zbp
$zbp = ZBlogPHP::GetInstance();
$zbp->Initialize();
#已激活应用列表
$activeapps = array();
#加载主题内置的插件
if (is_readable($filename = $usersdir . 'theme/' . $blogtheme . '/theme.xml')) {
    $activeapps[] = $blogtheme;
}
if (is_readable($filename = $usersdir . 'theme/' . $blogtheme . '/include.php')) {
    require $filename;
}
#加载插件
$ap = $zbp->GetActivePlugin();
foreach ($ap as $plugin) {
    if (is_readable($filename = $usersdir . 'plugin/' . $plugin . '/plugin.xml')) {
        $activeapps[] = $plugin;
Ejemplo n.º 4
0
 function ShowError($idortext, $file = null, $line = null)
 {
     if ((int) $idortext == 2) {
         Http404();
     }
     self::$error_id = (int) $idortext;
     self::$error_file = $file;
     self::$error_line = $line;
     if (is_numeric($idortext)) {
         $idortext = $this->lang['error'][$idortext];
     }
     foreach ($GLOBALS['Filter_Plugin_Zbp_ShowError'] as $fpname => &$fpsignal) {
         $fpreturn = $fpname($idortext, $file, $line);
         if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
             return $fpreturn;
         }
     }
     throw new Exception($idortext);
 }
Ejemplo n.º 5
0
}
$GLOBALS['blogtitle'] = $GLOBALS['option']['ZC_BLOG_SUBNAME'];
// 不是漏写!
$GLOBALS['blogname'] =& $GLOBALS['option']['ZC_BLOG_NAME'];
$GLOBALS['blogsubname'] =& $GLOBALS['option']['ZC_BLOG_SUBNAME'];
$GLOBALS['blogtheme'] =& $GLOBALS['option']['ZC_BLOG_THEME'];
$GLOBALS['blogstyle'] =& $GLOBALS['option']['ZC_BLOG_CSS'];
$GLOBALS['cookiespath'] = null;
$GLOBALS['bloghost'] = GetCurrentHost($GLOBALS['blogpath'], $GLOBALS['cookiespath']);
/**
 * 系统实例化
 */
AutoloadClass('ZBlogPHP');
AutoloadClass('DbSql');
AutoloadClass('Config');
$GLOBALS['zbp'] = ZBlogPHP::GetInstance();
$GLOBALS['zbp']->Initialize();
/**
 * 加载主题和插件APP
 */
if (is_readable($file_base = $GLOBALS['usersdir'] . 'theme/' . $GLOBALS['blogtheme'] . '/theme.xml')) {
    $GLOBALS['activedapps'][] = $GLOBALS['blogtheme'];
}
if (is_readable($file_base = $GLOBALS['usersdir'] . 'theme/' . $GLOBALS['blogtheme'] . '/include.php')) {
    require $file_base;
}
$aps = $GLOBALS['zbp']->GetPreActivePlugin();
foreach ($aps as $ap) {
    if (is_readable($file_base = $GLOBALS['usersdir'] . 'plugin/' . $ap . '/plugin.xml')) {
        $GLOBALS['activedapps'][] = $ap;
    }
Ejemplo n.º 6
0
function Setup4()
{
    global $zbp;
    ?>
<dl>
  <dt></dt>
  <dd id="ddleft"><div id="headerimg"><img src="../zb_system/image/admin/install.png" alt="Z-BlogPHP" />
  <strong><?php 
    echo $zbp->lang['zb_install']['install_program'];
    ?>
</strong></div>
    <div class="left"><?php 
    echo $zbp->lang['zb_install']['install_progress'];
    ?>
&nbsp;</div>
    <div id="setup4"  class="left"></div>
    <p><b><?php 
    echo $zbp->lang['zb_install']['install_license'];
    ?>
</b> » <b><?php 
    echo $zbp->lang['zb_install']['environment_check'];
    ?>
</b> » <b><?php 
    echo $zbp->lang['zb_install']['db_build_set'];
    ?>
</b> » <b><?php 
    echo $zbp->lang['zb_install']['install_result'];
    ?>
</b></p>
  </dd>
  <dd id="ddright">
    <div id="title"><?php 
    echo $zbp->lang['zb_install']['install_result'];
    ?>
</div>
    <div id="content">
      <?php 
    $isInstallFlag = true;
    $zbp->option['ZC_DATABASE_TYPE'] = GetVars('dbtype', 'POST');
    $cts = '';
    switch ($zbp->option['ZC_DATABASE_TYPE']) {
        case 'mysql':
        case 'mysqli':
        case 'pdo_mysql':
            $cts = file_get_contents($GLOBALS['blogpath'] . 'zb_system/defend/createtable/mysql.sql');
            if ($zbp->option['ZC_YUN_SITE'] != '') {
                break;
            }
            $zbp->option['ZC_MYSQL_SERVER'] = GetVars('dbmysql_server', 'POST');
            if (strpos($zbp->option['ZC_MYSQL_SERVER'], ':') !== false) {
                $servers = explode(':', $zbp->option['ZC_MYSQL_SERVER']);
                $zbp->option['ZC_MYSQL_SERVER'] = trim($servers[0]);
                $zbp->option['ZC_MYSQL_PORT'] = (int) $servers[1];
                if ($zbp->option['ZC_MYSQL_PORT'] == 0) {
                    $zbp->option['ZC_MYSQL_PORT'] = 3306;
                }
                unset($servers);
            }
            $zbp->option['ZC_MYSQL_USERNAME'] = trim(GetVars('dbmysql_username', 'POST'));
            $zbp->option['ZC_MYSQL_PASSWORD'] = trim(GetVars('dbmysql_password', 'POST'));
            $zbp->option['ZC_MYSQL_NAME'] = trim(str_replace(array('\'', '"'), array('', ''), GetVars('dbmysql_name', 'POST')));
            $zbp->option['ZC_MYSQL_PRE'] = trim(str_replace(array('\'', '"'), array('', ''), GetVars('dbmysql_pre', 'POST')));
            if ($zbp->option['ZC_MYSQL_PRE'] == '') {
                $zbp->option['ZC_MYSQL_PRE'] == 'zbp_';
            }
            $zbp->option['ZC_MYSQL_ENGINE'] = GetVars('dbengine', 'POST');
            $cts = str_replace('MyISAM', $zbp->option['ZC_MYSQL_ENGINE'], $cts);
            $zbp->db = ZBlogPHP::InitializeDB($zbp->option['ZC_DATABASE_TYPE']);
            if ($zbp->db->CreateDB($zbp->option['ZC_MYSQL_SERVER'], $zbp->option['ZC_MYSQL_PORT'], $zbp->option['ZC_MYSQL_USERNAME'], $zbp->option['ZC_MYSQL_PASSWORD'], $zbp->option['ZC_MYSQL_NAME']) == true) {
                echo $zbp->lang['zb_install']['create_db'] . $zbp->option['ZC_MYSQL_NAME'] . "<br/>";
            }
            $zbp->db->dbpre = $zbp->option['ZC_MYSQL_PRE'];
            $zbp->db->Close();
            break;
        case 'sqlite':
            $cts = file_get_contents($GLOBALS['blogpath'] . 'zb_system/defend/createtable/sqlite.sql');
            $cts = str_replace(' autoincrement', '', $cts);
            $zbp->option['ZC_SQLITE_NAME'] = trim(GetVars('dbsqlite_name', 'POST'));
            $zbp->option['ZC_SQLITE_PRE'] = trim(GetVars('dbsqlite_pre', 'POST'));
            break;
        case 'sqlite3':
        case 'pdo_sqlite':
            $cts = file_get_contents($GLOBALS['blogpath'] . 'zb_system/defend/createtable/sqlite.sql');
            $zbp->option['ZC_SQLITE_NAME'] = trim(GetVars('dbsqlite_name', 'POST'));
            $zbp->option['ZC_SQLITE_PRE'] = trim(GetVars('dbsqlite_pre', 'POST'));
            break;
        default:
            $isInstallFlag = false;
            break;
    }
    if ($isInstallFlag) {
        $zbp->OpenConnect();
        $zbp->ConvertTableAndDatainfo();
        if (CreateTable($cts)) {
            InsertInfo();
            SaveConfig();
        }
        $zbp->CloseConnect();
    } else {
        echo '<p>还没有选择数据库类型,请后退重试。</p><p><a href="javascript:history.go(-1)">点击这里后退</a></p>';
    }
    ?>

    </div>
    <div id="bottom">
      <input type="button" name="next" onClick="window.location.href='../'" id="netx" value="<?php 
    echo $zbp->lang['zb_install']['ok'];
    ?>
" />
    </div>
  </dd>
</dl>
<?php 
}
Ejemplo n.º 7
0
 /**
  * 连接数据库
  * @return bool
  * @throws Exception
  */
 public function OpenConnect()
 {
     if ($this->isconnected) {
         return false;
     }
     if (!$this->option['ZC_DATABASE_TYPE']) {
         return false;
     }
     switch ($this->option['ZC_DATABASE_TYPE']) {
         case 'sqlite':
         case 'sqlite3':
         case 'pdo_sqlite':
             $this->db = ZBlogPHP::InitializeDB($this->option['ZC_DATABASE_TYPE']);
             if ($this->db->Open(array($this->usersdir . 'data/' . $this->option['ZC_SQLITE_NAME'], $this->option['ZC_SQLITE_PRE'])) == false) {
                 $this->ShowError(69, __FILE__, __LINE__);
             }
             break;
         case 'pgsql':
         case 'pdo_pgsql':
             $this->db = ZBlogPHP::InitializeDB($this->option['ZC_DATABASE_TYPE']);
             if ($this->db->Open(array($this->option['ZC_PGSQL_SERVER'], $this->option['ZC_PGSQL_USERNAME'], $this->option['ZC_PGSQL_PASSWORD'], $this->option['ZC_PGSQL_NAME'], $this->option['ZC_PGSQL_PRE'], $this->option['ZC_PGSQL_PORT'], $this->option['ZC_PGSQL_PERSISTENT'])) == false) {
                 $this->ShowError(67, __FILE__, __LINE__);
             }
             break;
         case 'mysql':
         case 'mysqli':
         case 'pdo_mysql':
         default:
             $this->db = ZBlogPHP::InitializeDB($this->option['ZC_DATABASE_TYPE']);
             if ($this->db->Open(array($this->option['ZC_MYSQL_SERVER'], $this->option['ZC_MYSQL_USERNAME'], $this->option['ZC_MYSQL_PASSWORD'], $this->option['ZC_MYSQL_NAME'], $this->option['ZC_MYSQL_PRE'], $this->option['ZC_MYSQL_PORT'], $this->option['ZC_MYSQL_PERSISTENT'], $this->option['ZC_MYSQL_ENGINE'])) == false) {
                 $this->ShowError(67, __FILE__, __LINE__);
             }
             break;
     }
     $this->isconnected = true;
     return true;
 }
Ejemplo n.º 8
0
 function Display()
 {
     Http500();
     ob_end_clean();
     $zbp = ZBlogPHP::GetInstance();
     $zbp->StartGzip();
     require $GLOBALS['blogpath'] . 'zb_system/defend/error.html';
 }
Ejemplo n.º 9
0
 /**
  * 连接数据库
  * @return bool
  * @throws Exception
  */
 public function OpenConnect()
 {
     if ($this->isconnected) {
         return false;
     }
     if (!$this->option['ZC_DATABASE_TYPE']) {
         return false;
     }
     switch ($this->option['ZC_DATABASE_TYPE']) {
         case 'sqlite':
         case 'sqlite3':
         case 'pdo_sqlite':
             $this->db = ZBlogPHP::InitializeDB($this->option['ZC_DATABASE_TYPE']);
             if ($this->db->Open(array($this->usersdir . 'data/' . $this->option['ZC_SQLITE_NAME'], $this->option['ZC_SQLITE_PRE'])) == false) {
                 $this->ShowError(69, __FILE__, __LINE__);
             }
             break;
         case 'pgsql':
         case 'pdo_pgsql':
             $this->db = ZBlogPHP::InitializeDB($this->option['ZC_DATABASE_TYPE']);
             if ($this->db->Open(array($this->option['ZC_PGSQL_SERVER'], $this->option['ZC_PGSQL_USERNAME'], $this->option['ZC_PGSQL_PASSWORD'], $this->option['ZC_PGSQL_NAME'], $this->option['ZC_PGSQL_PRE'], $this->option['ZC_PGSQL_PORT'], $this->option['ZC_PGSQL_PERSISTENT'])) == false) {
                 $this->ShowError(67, __FILE__, __LINE__);
             }
             break;
         case 'mysql':
         case 'mysqli':
         case 'pdo_mysql':
         default:
             $this->db = ZBlogPHP::InitializeDB($this->option['ZC_DATABASE_TYPE']);
             if ($this->db->Open(array($this->option['ZC_MYSQL_SERVER'], $this->option['ZC_MYSQL_USERNAME'], $this->option['ZC_MYSQL_PASSWORD'], $this->option['ZC_MYSQL_NAME'], $this->option['ZC_MYSQL_PRE'], $this->option['ZC_MYSQL_PORT'], $this->option['ZC_MYSQL_PERSISTENT'], $this->option['ZC_MYSQL_ENGINE'])) == false) {
                 $this->ShowError(67, __FILE__, __LINE__);
             }
             break;
     }
     //add utf8mb4
     if ($this->db->type == 'mysql' && version_compare($this->db->version, '5.5.3') < 0) {
         Add_Filter_Plugin('Filter_Plugin_DbSql_Filter', 'utf84mb_filter');
         Add_Filter_Plugin('Filter_Plugin_Edit_Begin', 'utf84mb_fixHtmlSpecialChars');
     }
     $this->isconnected = true;
     return true;
 }