当前位置: 首页>>代码示例>>PHP>>正文


PHP serendipity_rebuildCategoryTree函数代码示例

本文整理汇总了PHP中serendipity_rebuildCategoryTree函数的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_rebuildCategoryTree函数的具体用法?PHP serendipity_rebuildCategoryTree怎么用?PHP serendipity_rebuildCategoryTree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了serendipity_rebuildCategoryTree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $categories = array();
     $entries = array();
     if (!extension_loaded('mysqli')) {
         return MYSQL_REQUIRED;
     }
     $pmdb = @mysqli_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$pmdb || mysqli_connect_error()) {
         return sprintf(COULDNT_CONNECT, serendipity_specialchars($this->data['host']));
     }
     if (!@mysqli_select_db($pmdb, $this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysqli_error($pmdb));
     }
     /* Users */
     $res = @$this->nativeQuery("SELECT id         AS ID,\n                                    username   AS user_login,\n                                    `password` AS user_pass,\n                                    email      AS user_email,\n                                    status     AS user_level,\n                                    url        AS url\n                               FROM {$this->data['prefix']}members", $pmdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysqli_error($pmdb));
     }
     for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysqli_fetch_assoc($res);
         $data = array('right_publish' => $users[$x]['user_level'] >= 3 ? 1 : 0, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'password' => $users[$x]['user_pass']);
         // pMachine uses md5, too.
         if ($users[$x]['user_level'] < 12) {
             $data['userlevel'] = USERLEVEL_EDITOR;
         } else {
             $data['userlevel'] = USERLEVEL_ADMIN;
         }
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     $res = @$this->nativeQuery("SELECT id       AS cat_ID,\n                                    category AS cat_name,\n                                    category AS category_description\n                               FROM {$this->data['prefix']}categories ORDER BY id", $pmdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysqli_error($pmdb));
     }
     // Get all the info we need
     for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
         $categories[] = mysqli_fetch_assoc($res);
     }
     // Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
     for ($x = 0, $max_x = sizeof($categories); $x < $max_x; $x++) {
         $cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
         serendipity_db_insert('category', $this->strtrRecursive($cat));
         $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}weblog ORDER BY t_stamp;", $pmdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysqli_error($pmdb));
     }
     for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
         $entries[$x] = mysqli_fetch_assoc($res);
         $entry = array('title' => $this->decode($entries[$x]['title']), 'isdraft' => $entries[$x]['status'] == 'open' ? 'false' : 'true', 'allow_comments' => $entries[$x]['showcomments'] == '1' ? 'true' : 'false', 'timestamp' => $entries[$x]['t_stamp'], 'extended' => $this->strtr($entries[$x]['more']), 'body' => $this->strtr($entries[$x]['body']));
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['member_id']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['username'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
         /* Entry/category */
         foreach ($categories as $category) {
             if ($category['cat_ID'] == $entries[$x]['category']) {
                 $data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
                 serendipity_db_insert('entrycat', $this->strtrRecursive($data));
                 break;
             }
         }
     }
     /* Comments */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comments;", $pmdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_COMMENT_INFO, mysqli_error($pmdb));
     }
     while ($a = mysqli_fetch_assoc($res)) {
         foreach ($entries as $entry) {
             if ($entry['post_id'] == $a['post_id']) {
                 $author = '';
                 $mail = '';
                 $url = '';
                 if (!empty($a['member_id'])) {
//.........这里部分代码省略.........
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:101,代码来源:pmachine.inc.php

示例2: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $users = array();
     $entries = array();
     if (!extension_loaded('mysql')) {
         return MYSQL_REQUIRED;
     }
     $ltdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$ltdb) {
         return sprintf(COULDNT_CONNECT, $this->data['host']);
     }
     if (!@mysql_select_db($this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysql_error($ltdb));
     }
     /* Users */
     $res = @$this->nativeQuery("SELECT \n                                            user AS user_login,\n                                            `password` AS user_pass,\n                                            email AS user_email,\n                                            full_name AS user_name,\n                                            site_admin AS user_level,\n                                            id AS ID\n                                       FROM lt_users", $ltdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($ltdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysql_fetch_assoc($res);
         $data = array('right_publish' => true, 'realname' => $users[$x]['user_name'], 'username' => $users[$x]['user_login'], 'userlevel' => $users[$x]['user_level'] > 0 ? USERLEVEL_ADMIN : USERLEVEL_EDITOR, 'email' => $users[$x]['user_email'], 'password' => $users[$x]['user_pass']);
         // MD5 compatible
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     if (!$this->importCategories(null, 0, $ltdb)) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($ltdb));
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @$this->nativeQuery("SELECT \n                                           article_id AS ID,\n                                           UNIX_TIMESTAMP(`date`) AS tstamp, \n                                           user_id AS post_author, \n                                           status AS post_status,\n                                           text AS post_content,\n                                           topic AS post_title\n                                      FROM lt_articles \n                                      JOIN lt_articles_text\n                                        ON lt_articles_text.article_id = lt_articles.id\n                               ORDER BY ID;", $ltdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($ltdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entries[$x] = mysql_fetch_assoc($res);
         $entry = array('title' => $this->decode($entries[$x]['post_title']), 'isdraft' => $entries[$x]['post_status'] == '1' ? 'false' : 'true', 'allow_comments' => 'true', 'timestamp' => $entries[$x]['tstamp'], 'body' => $this->strtr($entries[$x]['post_content']));
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['post_author']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['user_login'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
     }
     /* Even more category stuff */
     $res = @$this->nativeQuery("SELECT article_id AS postcat_post_ID, \n                                           category_id AS postcat_cat_ID \n                                      FROM lt_article_categories_link", $ltdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($ltdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entrycat = mysql_fetch_assoc($res);
         $entryid = 0;
         $categoryid = 0;
         foreach ($entries as $entry) {
             if ($entry['ID'] == $entrycat['postcat_post_ID']) {
                 $entryid = $entry['entryid'];
                 break;
             }
         }
         foreach ($this->categories as $category) {
             if ($category['cat_ID'] == $entrycat['postcat_cat_ID']) {
                 $categoryid = $category['categoryid'];
             }
         }
         if ($entryid > 0 && $categoryid > 0) {
             $data = array('entryid' => $entryid, 'categoryid' => $categoryid);
             serendipity_db_insert('entrycat', $this->strtrRecursive($data));
         }
     }
     /* Comments */
     $res = @$this->nativeQuery("SELECT article_id AS comment_post_ID,\n                                           topic AS title,\n                                           text AS comment_content,\n                                           user_email AS comment_author_email,\n                                           user_url AS comment_author_url,\n                                           user_name AS comment_author,\n                                           user_id AS comment_author_ID,\n                                           UNIX_TIMESTAMP(`date`) AS tstamp,\n                                           client_ip AS comment_author_IP,\n                                           status AS comment_status\n                                      FROM lt_articles_comments;", $ltdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($ltdb));
     }
     while ($a = mysql_fetch_assoc($res)) {
         foreach ($entries as $entry) {
             if ($entry['ID'] == $a['comment_post_ID']) {
                 $author = '';
                 $mail = '';
                 $url = '';
                 if (!empty($a['comment_author_ID']) && $a['comment_author_ID'] > 0) {
                     foreach ($users as $user) {
//.........这里部分代码省略.........
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:lifetype.inc.php

示例3: serendipity_rebuildCategoryTree

/**
 * Rebuild the Category Nested Set tree
 *
 * @access public
 * @see Based on http://www.sitepoint.com/article/hierarchical-data-database/1
 * @param   int     The ID of the parent category to rebuild
 * @param   int     The ID of the next left category
 * @return  int     Returns the new ID
 */
function serendipity_rebuildCategoryTree($parent = 0, $left = 0)
{
    global $serendipity;
    $right = $left + 1;
    $result = serendipity_db_query("SELECT categoryid FROM {$serendipity['dbPrefix']}category WHERE parentid = '" . (int) $parent . "'");
    if (is_array($result)) {
        foreach ($result as $category) {
            $right = serendipity_rebuildCategoryTree($category['categoryid'], $right);
        }
    }
    if ($parent > 0) {
        serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET category_left='{$left}', category_right='{$right}' WHERE categoryid='{$parent}'");
    }
    return $right + 1;
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:24,代码来源:functions_entries.inc.php

示例4: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $categories = array();
     $entries = array();
     if (!extension_loaded('mysql')) {
         return MYSQL_REQUIRED;
     }
     $nucdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$nucdb) {
         return sprintf(COULDNT_CONNECT, $this->data['host']);
     }
     if (!@mysql_select_db($this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysql_error($nucdb));
     }
     /* Users */
     $res = @$this->nativeQuery("SELECT mnumber AS ID, mname AS user_login, mpassword AS user_pass, memail AS user_email, madmin AS user_level FROM {$this->data['prefix']}member;", $nucdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($nucdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysql_fetch_assoc($res);
         $data = array('right_publish' => $users[$x]['user_level'] >= 1 ? 1 : 0, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'password' => $users[$x]['user_pass']);
         // Nucleus uses md5, too.
         if ($users[$x]['user_level'] < 1) {
             $data['userlevel'] = USERLEVEL_EDITOR;
         } else {
             $data['userlevel'] = USERLEVEL_ADMIN;
         }
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     $res = @$this->nativeQuery("SELECT catid AS cat_ID, cname AS cat_name, cdesc AS category_description FROM {$this->data['prefix']}category ORDER BY catid;", $nucdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($nucdb));
     }
     // Get all the info we need
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $categories[] = mysql_fetch_assoc($res);
     }
     // Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
     for ($x = 0, $max_x = sizeof($categories); $x < $max_x; $x++) {
         $cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
         serendipity_db_insert('category', $this->strtrRecursive($cat));
         $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}item ORDER BY itime;", $nucdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($nucdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entries[$x] = mysql_fetch_assoc($res);
         $entry = array('title' => $this->decode($entries[$x]['ititle']), 'isdraft' => $entries[$x]['idraft'] != '1' ? 'false' : 'true', 'allow_comments' => $entries[$x]['iclosed'] == '1' ? 'false' : 'true', 'timestamp' => strtotime($entries[$x]['itime']), 'extended' => $this->strtr($entries[$x]['imore']), 'body' => $this->strtr($entries[$x]['ibody']));
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['iauthor']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['realname'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
         /* Entry/category */
         foreach ($categories as $category) {
             if ($category['cat_ID'] == $entries[$x]['icat']) {
                 $data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
                 serendipity_db_insert('entrycat', $this->strtrRecursive($data));
                 break;
             }
         }
     }
     /* Comments */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comment;", $nucdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($nucdb));
     }
     while ($a = mysql_fetch_assoc($res)) {
         foreach ($entries as $entry) {
             if ($entry['inumber'] == $a['citem']) {
                 $author = '';
                 $mail = '';
                 if (!empty($a['cmember'])) {
                     foreach ($users as $user) {
//.........这里部分代码省略.........
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:nucleus.inc.php

示例5: import_cat

 function import_cat(&$s9ydb)
 {
     global $serendipity;
     $this->import_table($s9ydb, 'category', array('categoryid'), ' ORDER BY parentid ASC', false, array('authorid' => array('authors' => 'authorid'), 'parentid' => array('category' => 'categoryid')));
     $this->import_table($s9ydb, 'entrycat', false, null, false, array('entryid' => array('entries' => 'id'), 'categoryid' => array('category' => 'categoryid')));
     $this->import_table($s9ydb, 'permalinks', false, ' WHERE type = "category" ', false, array('entry_id' => array('category' => 'categoryid')));
     $this->import_table($s9ydb, 'access', false, ' WHERE artifact_type = "category" ', false, array('groupid' => array('groups' => 'id'), 'artifact_id' => array('category' => 'categoryid')));
     serendipity_rebuildCategoryTree();
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:9,代码来源:serendipity.inc.php

示例6: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $users = array();
     $entries = array();
     if (!extension_loaded('mysql')) {
         return MYSQL_REQUIRED;
     }
     $b2db = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$b2db) {
         return sprintf(COULDNT_CONNECT, $this->data['host']);
     }
     if (!@mysql_select_db($this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysql_error($b2db));
     }
     /* Users */
     $res = @$this->nativeQuery("SELECT ID         AS ID,\n                                    user_login AS user_login,\n                                    user_pass  AS user_pass,\n                                    user_email AS user_email,\n                                    user_level AS user_level,\n                                    user_url   AS user_url\n                               FROM evo_users", $b2db);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($b2db));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysql_fetch_assoc($res);
         $data = array('right_publish' => $users[$x]['user_level'] >= 2 ? 1 : 0, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'password' => $users[$x]['user_pass']);
         // MD5 compatible
         if ($users[$x]['user_level'] <= 2) {
             $data['userlevel'] = USERLEVEL_EDITOR;
         } elseif ($users[$x]['user_level'] <= 9) {
             $data['userlevel'] = USERLEVEL_CHIEF;
         } else {
             $data['userlevel'] = USERLEVEL_ADMIN;
         }
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     if (!$this->importCategories(null, 0, $b2db)) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($b2db));
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @$this->nativeQuery("SELECT * FROM evo_posts ORDER BY ID;", $b2db);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($b2db));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entries[$x] = mysql_fetch_assoc($res);
         $entry = array('title' => $this->decode($entries[$x]['post_title']), 'isdraft' => $entries[$x]['post_status'] == 'published' ? 'false' : 'true', 'allow_comments' => $entries[$x]['post_comments'] == 'open' ? 'true' : 'false', 'timestamp' => strtotime(isset($entries[$x]['post_issue_date']) ? $entries[$x]['post_issue_date'] : $entries[$x]['post_date']), 'body' => $this->strtr($entries[$x]['post_content']));
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['post_author']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['user_login'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
         /* Entry/category */
         foreach ($this->categories as $category) {
             if ($category['cat_ID'] == $entries[$x]['post_category']) {
                 $data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
                 serendipity_db_insert('entrycat', $this->strtrRecursive($data));
                 break;
             }
         }
     }
     /* Even more category stuff */
     $res = @$this->nativeQuery("SELECT * FROM evo_postcats;", $b2db);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($b2db));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entrycat = mysql_fetch_assoc($res);
         $entryid = 0;
         $categoryid = 0;
         foreach ($entries as $entry) {
             if ($entry['ID'] == $entrycat['postcat_post_ID']) {
                 $entryid = $entry['entryid'];
                 break;
             }
         }
         foreach ($this->categories as $category) {
             if ($category['cat_ID'] == $entrycat['postcat_cat_ID']) {
                 $categoryid = $category['categoryid'];
             }
         }
         if ($entryid > 0 && $categoryid > 0) {
             $data = array('entryid' => $entryid, 'categoryid' => $categoryid);
             serendipity_db_insert('entrycat', $this->strtrRecursive($data));
//.........这里部分代码省略.........
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:b2evolution.inc.php

示例7: import


//.........这里部分代码省略.........
             $categories[] = mysqli_fetch_assoc($res);
         }
         // Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
         for ($x = 0, $c = sizeof($categories); $x < $c; $x++) {
             $cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
             serendipity_db_insert('category', $this->strtrRecursive($cat));
             $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
             // Set association.
             $assoc['categories'][$categories[$x]['cat_ID']] = $categories[$x]['categoryid'];
         }
         foreach ($categories as $cat) {
             if ($cat['category_parent'] != 0) {
                 // Find the parent
                 $par_id = 0;
                 foreach ($categories as $possible_par) {
                     if ($possible_par['cat_ID'] == $cat['category_parent']) {
                         $par_id = $possible_par['categoryid'];
                         break;
                     }
                 }
                 if ($par_id != 0) {
                     serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category \n                                                 SET parentid={$par_id} \n                                               WHERE categoryid={$cat['categoryid']};");
                 }
             }
         }
         // Clean memory
         unset($categories);
         if ($debug) {
             echo "<span class='block_level'>Imported categories.</span>";
         }
         if ($debug) {
             echo "<span class='block_level'>Rebuilding category tree...</span>";
         }
         serendipity_rebuildCategoryTree();
         if ($debug) {
             echo "<span class='block_level'>Rebuilt category tree.</span>";
         }
     }
     /* Categories (WP >= 2.3 style) */
     $res = @$this->nativeQuery("SELECT taxonomy.description      AS category_description, \n                                           taxonomy.parent           AS category_parent, \n                                           taxonomy.term_taxonomy_id AS cat_ID, \n                                           terms.name                AS cat_name\n\n                                      FROM {$this->data['prefix']}term_taxonomy AS taxonomy\n\n                                      JOIN {$this->data['prefix']}terms AS terms\n                                        ON taxonomy.term_id = terms.term_id\n\n                                     WHERE taxonomy.taxonomy = 'category' \n                                  ORDER BY taxonomy.parent, taxonomy.term_taxonomy_id", $wpdb);
     if (!$res && !$no_cat) {
         $no_cat = mysqli_error($wpdb);
     } elseif ($res) {
         $no_cat = false;
         if ($debug) {
             echo "<span class='block_level'>Importing categories (WP 2.3 style)...</span>";
         }
         // Get all the info we need
         for ($x = 0; $x < mysqli_num_rows($res); $x++) {
             $categories[] = mysqli_fetch_assoc($res);
         }
         // Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
         for ($x = 0, $c = sizeof($categories); $x < $c; $x++) {
             $cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
             serendipity_db_insert('category', $this->strtrRecursive($cat));
             $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
             // Set association.
             $assoc['categories'][$categories[$x]['cat_ID']] = $categories[$x]['categoryid'];
         }
         foreach ($categories as $cat) {
             if ($cat['category_parent'] != 0) {
                 // Find the parent
                 $par_id = 0;
                 foreach ($categories as $possible_par) {
                     if ($possible_par['cat_ID'] == $cat['category_parent']) {
                         $par_id = $possible_par['categoryid'];
开发者ID:jimjag,项目名称:Serendipity,代码行数:67,代码来源:wordpress.inc.php

示例8: serendipity_db_query

        if (!serendipity_checkPermission('adminCategoriesMaintainOthers') && !serendipity_ACLCheck($serendipity['authorid'], $serendipity['GET']['cid'], 'category', 'write')) {
            $data['editPermission'] = false;
        } else {
            /* Check to make sure parent is not a child of self */
            $r = serendipity_db_query("SELECT categoryid FROM {$serendipity['dbPrefix']}category c\n                                                WHERE c.categoryid = " . (int) $parentid . "\n                                                    AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange((int) $serendipity['GET']['cid'])));
            if (is_array($r)) {
                $r = serendipity_db_query("SELECT category_name FROM {$serendipity['dbPrefix']}category\n                                                        WHERE categoryid = " . (int) $parentid);
                $data['subcat'] = sprintf(ALREADY_SUBCATEGORY, serendipity_specialchars($r[0]['category_name']), serendipity_specialchars($name));
            } else {
                serendipity_updateCategory($serendipity['GET']['cid'], $name, $desc, $authorid, $icon, $parentid, $serendipity['POST']['cat']['sort_order'], $serendipity['POST']['cat']['hide_sub'], $admin_category);
                serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'read', $serendipity['POST']['cat']['read_authors']);
                serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'write', $serendipity['POST']['cat']['write_authors']);
            }
        }
    }
    serendipity_rebuildCategoryTree();
    $serendipity['GET']['adminAction'] = 'view';
}
/* Delete a category */
if ($serendipity['GET']['adminAction'] == 'doDelete' && serendipity_checkFormToken()) {
    $data['doDelete'] = true;
    if ($serendipity['GET']['cid'] != 0) {
        $remaining_cat = (int) $serendipity['POST']['cat']['remaining_catid'];
        $category_ranges = serendipity_fetchCategoryRange((int) $serendipity['GET']['cid']);
        $category_range = implode(' AND ', $category_ranges);
        if ($serendipity['dbType'] == 'postgres' || $serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'sqlite3oo' || $serendipity['dbType'] == 'pdo-sqlite') {
            $query = "UPDATE {$serendipity['dbPrefix']}entrycat\n                        SET categoryid={$remaining_cat} WHERE entryid IN\n                        (\n                          SELECT DISTINCT(e.id) FROM {$serendipity['dbPrefix']}entries e,\n                          {$serendipity['dbPrefix']}category c,\n                          {$serendipity['dbPrefix']}entrycat ec\n                          WHERE e.id=ec.entryid AND c.categoryid=ec.categoryid\n                          AND c.category_left BETWEEN {$category_range} {$admin_category}\n                        )";
        } else {
            $query = "UPDATE {$serendipity['dbPrefix']}entries e,\n                        {$serendipity['dbPrefix']}entrycat ec,\n                        {$serendipity['dbPrefix']}category c\n                      SET ec.categoryid={$remaining_cat}\n                        WHERE e.id = ec.entryid\n                          AND c.categoryid = ec.categoryid\n                          AND c.category_left BETWEEN {$category_range}\n                          {$admin_category}";
        }
        serendipity_db_query($query);
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:31,代码来源:category.inc.php

示例9: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $entries = array();
     if (!extension_loaded('mysql')) {
         return MYSQL_REQUIRED;
     }
     $gdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$gdb) {
         return sprintf(COULDNT_CONNECT, $this->data['host']);
     }
     if (!@mysql_select_db($this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysql_error($gdb));
     }
     /* Users */
     $res = @$this->nativeQuery("SELECT uid        AS ID,\n                                    username   AS user_login,\n                                    passwd     AS user_pass,\n                                    email      AS user_email,\n                                    homepage   AS user_url\n                               FROM {$this->data['prefix']}users", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($gdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysql_fetch_assoc($res);
         $data = array('right_publish' => 1, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'userlevel' => USERLEVEL_ADMIN, 'password' => $users[$x]['user_pass']);
         // MD5 compatible
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         echo mysql_error();
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     $res = @$this->nativeQuery("SELECT tid AS cat_ID, topic AS cat_name, topic AS category_description FROM {$this->data['prefix']}topics ORDER BY tid;", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($gdb));
     }
     // Get all the info we need
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $categories[] = mysql_fetch_assoc($res);
     }
     // Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
     for ($x = 0, $max_x = sizeof($categories); $x < $max_x; $x++) {
         $cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
         serendipity_db_insert('category', $this->strtrRecursive($cat));
         $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}stories ORDER BY sid;", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($gdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entries[$x] = mysql_fetch_assoc($res);
         $entry = array('title' => $this->decode($entries[$x]['title']), 'isdraft' => $entries[$x]['draft_flag'] == '0' ? 'false' : 'true', 'allow_comments' => $entries[$x]['comments'] == '1' ? 'true' : 'false', 'timestamp' => strtotime($entries[$x]['date']), 'body' => $this->strtr($entries[$x]['introtext']), 'extended' => $this->strtr($entries[$x]['bodytext']));
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['uid']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['user_login'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
         /* Entry/category */
         foreach ($categories as $category) {
             if ($category['cat_ID'] == $entries[$x]['tid']) {
                 $data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
                 serendipity_db_insert('entrycat', $this->strtrRecursive($data));
                 break;
             }
         }
     }
     /* Comments */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comments;", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($gdb));
     }
     while ($a = mysql_fetch_assoc($res)) {
         foreach ($entries as $entry) {
             if ($entry['sid'] == $a['sid']) {
                 $author = '';
                 $mail = '';
                 $url = '';
                 foreach ($users as $user) {
                     if ($user['ID'] == $a['uid']) {
                         $author = $user['user_login'];
                         $mail = $user['user_email'];
                         $url = $user['user_url'];
                         break;
//.........这里部分代码省略.........
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:geeklog.inc.php

示例10: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $entries = array();
     if (!extension_loaded('mysql')) {
         return MYSQL_REQUIRED;
     }
     $txpdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$txpdb) {
         return sprintf(COULDNT_CONNECT, $this->data['host']);
     }
     if (!@mysql_select_db($this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysql_error($txpdb));
     }
     /* Users */
     $res = @$this->nativeQuery("SELECT user_id    AS ID,\n                                    name       AS user_login,\n                                    `pass`     AS user_pass,\n                                    email      AS user_email,\n                                    privs      AS user_level\n                               FROM {$this->data['prefix']}txp_users", $txpdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($txpdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysql_fetch_assoc($res);
         $data = array('right_publish' => $users[$x]['user_level'] <= 4 ? 1 : 0, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'password' => md5('txp'));
         // blame TXP for using PASSWORD().
         if ($users[$x]['user_level'] == 1) {
             $data['userlevel'] = USERLEVEL_EDITOR;
         } elseif ($users[$x]['user_level'] == 2) {
             $data['userlevel'] = USERLEVEL_CHIEF;
         } else {
             $data['userlevel'] = USERLEVEL_ADMIN;
         }
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     if (!$this->importCategories('root', 0, $txpdb)) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($txpdb));
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     // Notice: Textpattern doesn't honor the prefix for this table. Wicked system.
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}textpattern ORDER BY Posted;", $txpdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($txpdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entries[$x] = mysql_fetch_assoc($res);
         $entry = array('title' => $this->decode($entries[$x]['Title']), 'isdraft' => $entries[$x]['Status'] == '4' ? 'false' : 'true', 'allow_comments' => $entries[$x]['Annotate'] == '1' ? 'true' : 'false', 'timestamp' => strtotime($entries[$x]['Posted']), 'extended' => $this->strtr($entries[$x]['Body_html']), 'body' => $this->strtr($entries[$x]['Excerpt']));
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['user_login'] == $entries[$x]['AuthorID']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['user_login'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
         /* Entry/category */
         foreach ($this->categories as $category) {
             if ($category['name'] == $entries[$x]['Category1'] || $category['name'] == $entries[$x]['Category2']) {
                 $data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
                 serendipity_db_insert('entrycat', $this->strtrRecursive($data));
                 break;
             }
         }
     }
     /* Comments */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}txp_discuss;", $txpdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($txpdb));
     }
     while ($a = mysql_fetch_assoc($res)) {
         foreach ($entries as $entry) {
             if ($entry['ID'] == $a['parentid']) {
                 $author = $a['name'];
                 $mail = $a['email'];
                 $url = $a['web'];
                 $comment = array('entry_id ' => $entry['entryid'], 'parent_id' => 0, 'timestamp' => strtotime($a['posted']), 'author' => $author, 'email' => $mail, 'url' => $url, 'ip' => $a['ip'], 'status' => $a['visible'] == '1' ? 'approved' : 'pending', 'body' => $a['message'], 'subscribed' => 'false', 'type' => 'NORMAL');
                 serendipity_db_insert('comments', $this->strtrRecursive($comment));
                 if ($a['visible'] == '1') {
                     $cid = serendipity_db_insert_id('comments', 'id');
                     serendipity_approveComment($cid, $entry['entryid'], true);
                 }
             }
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
//.........这里部分代码省略.........
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:textpattern.inc.php

示例11: importOPML

 function importOPML()
 {
     $tree = $this->importFeeds();
     if (!$tree) {
         return;
     }
     $this->removeFeeds();
     $this->cats = serendipity_fetchCategories();
     foreach ($tree as $xml_base) {
         if ($xml_base['tag'] != 'opml' || !is_array($xml_base['children'])) {
             continue;
         }
         foreach ($xml_base['children'] as $xml_body) {
             if ($xml_body['tag'] != 'body' || !is_array($xml_body['children'])) {
                 continue;
             }
             foreach ($xml_body['children'] as $xml_outline) {
                 $this->parseOutline($xml_outline);
             }
         }
     }
     serendipity_rebuildCategoryTree();
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:23,代码来源:serendipity_event_aggregator.php

示例12: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $entries = array();
     if (!extension_loaded('mysql')) {
         return MYSQL_REQUIRED;
     }
     $gdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$gdb) {
         return sprintf(COULDNT_CONNECT, $this->data['host']);
     }
     if (!@mysql_select_db($this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysql_error($gdb));
     }
     /* Users */
     $res = @$this->nativeQuery("SELECT ID_MEMBER       AS ID,\r\n                                    memberName      AS user_login,\r\n                                    passwd AS user_pass,\r\n                                    emailAddress    AS user_email,\r\n                                    ID_GROUP AS user_level\r\n                               FROM {$this->data['prefix']}members\r\n                              WHERE is_activated = 1", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($gdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysql_fetch_assoc($res);
         $data = array('right_publish' => 1, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'userlevel' => $users[$x]['user_level'] == 1 ? USERLEVEL_ADMIN : USERLEVEL_EDITO, 'password' => $users[$x]['user_pass']);
         // MD5 compatible
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         echo mysql_error();
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     $res = @$this->nativeQuery("SELECT ID_CAT AS cat_ID,\r\n                                    name AS cat_name\r\n                               FROM {$this->data['prefix']}categories", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($gdb));
     }
     // Get all the info we need
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $parent_categories[] = mysql_fetch_assoc($res);
     }
     for ($x = 0, $max_x = sizeof($parent_categories); $x < $max_x; $x++) {
         $cat = array('category_name' => $parent_categories[$x]['cat_name'], 'category_description' => '', 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
         serendipity_db_insert('category', $this->strtrRecursive($cat));
         $parent_categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
     }
     /* Categories */
     $res = @$this->nativeQuery("SELECT ID_BOARD AS cat_ID,\r\n                                    ID_CAT   AS parent_cat_id,\r\n                                    name AS cat_name,\r\n                                    description AS category_description\r\n                               FROM {$this->data['prefix']}boards ORDER BY boardOrder;", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($gdb));
     }
     // Get all the info we need
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $categories[] = mysql_fetch_assoc($res);
     }
     // Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
     for ($x = 0, $max_x = sizeof($categories); $x < $max_x; $x++) {
         $pcatid = 0;
         foreach ($parent_categories as $pcat) {
             if ($pcat['cat_ID'] == $categories[$x]['parent_cat_id']) {
                 $pcatid = $pcat['cat_ID'];
                 break;
             }
         }
         $cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => $pcatid, 'category_left' => 0, 'category_right' => 0);
         serendipity_db_insert('category', $this->strtrRecursive($cat));
         $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @$this->nativeQuery("SELECT\r\n\r\n        tm.subject AS post_subject,\r\n        t.ID_MEMBER_STARTED AS topic_poster,\r\n        t.ID_BOARD AS forum_id,\r\n        tm.posterTime AS post_time,\r\n        tm.body AS post_text,\r\n        t.ID_TOPIC AS topic_id,\r\n        t.ID_FIRST_MSG AS post_id,\r\n        t.numReplies AS ccount\r\n\r\n        FROM {$this->data['prefix']}topics AS t\r\n        JOIN {$this->data['prefix']}messages AS tm\r\n          ON tm.ID_MSG = t.ID_FIRST_MSG\r\n\r\n        GROUP BY t.ID_TOPIC", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($gdb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entries[$x] = mysql_fetch_assoc($res);
         $entry = array('title' => $this->decode($entries[$x]['post_subject']), 'isdraft' => 'false', 'allow_comments' => 'true', 'timestamp' => $entries[$x]['post_time'], 'body' => $this->strtr($entries[$x]['post_text']), 'extended' => '');
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['topic_poster']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['user_login'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
         /* Entry/category */
         foreach ($categories as $category) {
             if ($category['cat_ID'] == $entries[$x]['forum_id']) {
                 $data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
                 serendipity_db_insert('entrycat', $this->strtrRecursive($data));
//.........这里部分代码省略.........
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:smf.inc.php

示例13: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $users = array();
     $entries = array();
     if (!extension_loaded('mysql')) {
         return MYSQL_REQUIRED;
     }
     $nukedb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$nukedb) {
         return sprintf(COULDNT_CONNECT, $this->data['host']);
     }
     if (!@mysql_select_db($this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysql_error($nukedb));
     }
     /* Users: Authors */
     $res = @$this->nativeQuery("SELECT\n                                            aid         AS user_login,\n                                            `pwd`       AS user_pass,\n                                            email       AS user_email,\n                                            name        AS user_name,\n                                            radminsuper AS user_level,\n                                            aid         AS ID\n                                       FROM nuke_authors", $nukedb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($nukedb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysql_fetch_assoc($res);
         $data = array('right_publish' => true, 'realname' => $users[$x]['user_name'], 'username' => $users[$x]['user_login'], 'userlevel' => $users[$x]['user_level'] > 0 ? USERLEVEL_ADMIN : USERLEVEL_EDITOR, 'email' => $users[$x]['user_email'], 'password' => md5($users[$x]['user_pass']));
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Users: Users */
     $res = @$this->nativeQuery("SELECT\n                                            u.uname      AS user_login,\n                                            u.pass       AS user_pass,\n                                            u.email      AS user_email,\n                                            u.name       AS user_name,\n                                            s.user_level AS user_level,\n                                            uname        AS ID\n                                       FROM nuke_users AS u\n                                       JOIN nuke_users_status AS s\n                                         ON u.uid = s.user_id\n                                       ", $nukedb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($nukedb));
     }
     for ($x = $x, $max_x = $x + mysql_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysql_fetch_assoc($res);
         if (empty($users[$x]['user_name'])) {
             $users[$x]['user_name'] = $users[$x]['user_login'];
         }
         $data = array('right_publish' => true, 'realname' => $users[$x]['user_name'], 'username' => $users[$x]['user_login'], 'userlevel' => $users[$x]['user_level'] > 1 ? USERLEVEL_ADMIN : USERLEVEL_EDITOR, 'email' => $users[$x]['user_email'], 'password' => md5($users[$x]['user_pass']));
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     if (!$this->importCategories($nukedb)) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($nukedb));
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @$this->nativeQuery("SELECT\n                                           sid                    AS ID,\n                                           UNIX_TIMESTAMP(`time`) AS tstamp,\n                                           aid                    AS post_author,\n                                           informant              AS informant,\n                                           \n                                           title                  AS post_title,\n                                           hometext               AS post_content,\n                                           bodytext               AS extended\n                                      FROM nuke_stories", $nukedb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($nukedb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entries[$x] = mysql_fetch_assoc($res);
         if (!empty($entries[$x]['informant'])) {
             $entries[$x]['post_author'] = $entries[$x]['informant'];
         }
         $entry = array('title' => $this->decode($entries[$x]['post_title']), 'isdraft' => 'false', 'allow_comments' => 'true', 'timestamp' => $entries[$x]['tstamp'], 'body' => $this->strtr($entries[$x]['post_content']), 'extended' => $this->strtr($entries[$x]['extended']));
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['post_author']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['user_login'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
     }
     /* Even more category stuff */
     $res = @$this->nativeQuery("SELECT sid AS postcat_post_ID,\n                                           topic AS postcat_cat_ID\n                                      FROM nuke_stories", $nukedb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($nukedb));
     }
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $entrycat = mysql_fetch_assoc($res);
         $entryid = 0;
         $categoryid = 0;
         foreach ($entries as $entry) {
             if ($entry['ID'] == $entrycat['postcat_post_ID']) {
                 $entryid = $entry['entryid'];
                 break;
             }
         }
         foreach ($this->categories as $category) {
             if ($category['cat_ID'] == $entrycat['postcat_cat_ID']) {
                 $categoryid = $category['categoryid'];
             }
//.........这里部分代码省略.........
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:nuke.inc.php

示例14: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $categories = array();
     $entries = array();
     if (!extension_loaded('pgsql')) {
         return PGSQL_REQUIRED;
     }
     $wpdb = pg_connect("{$this->data}['host'], {$this->data}['port'], {$this->data}['user'], {$this->data}['pass'], {$this->data}['name']");
     if (!$wpdb) {
         return sprintf(PGSQL_COULDNT_CONNECT, $this->data['pass']);
     }
     /* Users */
     $res = pg_query($wpdb, "SELECT ID, user_login, user_pass, user_email, user_level FROM {$this->data['prefix']}users;");
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, pg_last_error($wpdb));
     }
     for ($x = 0; $x < pg_num_rows($res); $x++) {
         $users[$x] = pg_fetch_assoc($res);
         $data = array('right_publish' => $users[$x]['user_level'] >= 1 ? 1 : 0, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'password' => $users[$x]['user_pass']);
         // WP uses md5, too.
         if ($users[$x]['user_level'] <= 1) {
             $data['userlevel'] = USERLEVEL_EDITOR;
         } elseif ($users[$x]['user_level'] < 5) {
             $data['userlevel'] = USERLEVEL_CHIEF;
         } else {
             $data['userlevel'] = USERLEVEL_ADMIN;
         }
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     $res = @pg_query($wpdb, "SELECT cat_ID, cat_name, category_description, category_parent FROM {$this->data['prefix']}categories ORDER BY category_parent, cat_ID;");
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, pg_last_error($wpdb));
     }
     // Get all the info we need
     for ($x = 0; $x < pg_num_rows($res); $x++) {
         $categories[] = pg_fetch_assoc($res);
     }
     // Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
     for ($x = 0; $x < sizeof($categories); $x++) {
         $cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
         serendipity_db_insert('category', $this->strtrRecursive($cat));
         $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
     }
     // There has to be a more efficient way of doing this...
     foreach ($categories as $cat) {
         if ($cat['category_parent'] != 0) {
             // Find the parent
             $par_id = 0;
             foreach ($categories as $possible_par) {
                 if ($possible_par['cat_ID'] == $cat['category_parent']) {
                     $par_id = $possible_par['categoryid'];
                     break;
                 }
             }
             if ($par_id != 0) {
                 serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET parentid={$par_id} WHERE categoryid={$cat['categoryid']};");
             }
             // else { echo "D'oh! " . random_string_of_profanity(); }
         }
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @pg_query($wpdb, "SELECT * FROM {$this->data['prefix']}posts ORDER BY post_date;");
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, pg_last_error($wpdb));
     }
     for ($x = 0; $x < pg_num_rows($res); $x++) {
         $entries[$x] = pg_fetch_assoc($res);
         $entry = array('title' => $this->decode($entries[$x]['post_title']), 'isdraft' => $entries[$x]['post_status'] == 'publish' ? 'false' : 'true', 'allow_comments' => $entries[$x]['comment_status'] == 'open' ? 'true' : 'false', 'timestamp' => strtotime($entries[$x]['post_date']), 'body' => $this->strtr($entries[$x]['post_content']));
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['post_author']) {
                 $entry['authorid'] = $user['authorid'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
     }
     /* Entry/category */
     $res = @pg_query($wpdb, "SELECT * FROM {$this->data['prefix']}post2cat;");
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, pg_last_error($wpdb));
     }
     while ($a = pg_fetch_assoc($res)) {
         foreach ($categories as $category) {
//.........这里部分代码省略.........
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:wordpress-pg.inc.php

示例15: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $entries = array();
     if (!extension_loaded('mysqli')) {
         return MYSQL_REQUIRED;
     }
     $gdb = @mysqli_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$gdb || mysqli_connect_error()) {
         return sprintf(COULDNT_CONNECT, serendipity_specialchars($this->data['host']));
     }
     if (!@mysqli_select_db($gdb, $this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysqli_error($gdb));
     }
     /* Users */
     $res = @$this->nativeQuery("SELECT user_id       AS ID,\n                                    username      AS user_login,\n                                    user_password AS user_pass,\n                                    user_email    AS user_email,\n                                    user_website  AS user_url,\n                                    user_level\n                               FROM {$this->data['prefix']}users\n                              WHERE user_active = 1", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysqli_error($gdb));
     }
     for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysqli_fetch_assoc($res);
         $data = array('right_publish' => 1, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'userlevel' => $users[$x]['user_level'] == 0 ? USERLEVEL_EDITOR : USERLEVEL_ADMIN, 'password' => $users[$x]['user_pass']);
         // MD5 compatible
         if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
             $data['userlevel'] = $serendipity['serendipityUserlevel'];
         }
         serendipity_db_insert('authors', $this->strtrRecursive($data));
         echo mysqli_error();
         $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
     }
     /* Categories */
     $res = @$this->nativeQuery("SELECT cat_id AS cat_ID, \n                                    cat_title AS cat_name \n                               FROM {$this->data['prefix']}categories", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysqli_error($gdb));
     }
     // Get all the info we need
     for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
         $parent_categories[] = mysqli_fetch_assoc($res);
     }
     for ($x = 0, $max_x = sizeof($parent_categories); $x < $max_x; $x++) {
         $cat = array('category_name' => $parent_categories[$x]['cat_name'], 'category_description' => '', 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
         serendipity_db_insert('category', $this->strtrRecursive($cat));
         $parent_categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
     }
     /* Categories */
     $res = @$this->nativeQuery("SELECT forum_id AS cat_ID,\n                                    cat_id   AS parent_cat_id, \n                                    forum_name AS cat_name, \n                                    forum_desc AS category_description \n                               FROM {$this->data['prefix']}forums ORDER BY forum_order;", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysqli_error($gdb));
     }
     // Get all the info we need
     for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
         $categories[] = mysqli_fetch_assoc($res);
     }
     // Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
     for ($x = 0, $max_x = sizeof($categories); $x < $max_x; $x++) {
         $pcatid = 0;
         foreach ($parent_categories as $pcat) {
             if ($pcat['cat_ID'] == $categories[$x]['parent_cat_id']) {
                 $pcatid = $pcat['cat_ID'];
                 break;
             }
         }
         $cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => $pcatid, 'category_left' => 0, 'category_right' => 0);
         serendipity_db_insert('category', $this->strtrRecursive($cat));
         $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @$this->nativeQuery("SELECT t.topic_title, \n                                    t.topic_poster,\n                                    t.forum_id,\n                                    p.post_time,\n                                    pt.post_subject,\n                                    pt.post_text,\n                                    count(p.topic_id) AS ccount,\n                                    p.topic_id,\n                                    MIN(p.post_id) AS post_id\n                               FROM {$this->data['prefix']}topics AS t\n                    LEFT OUTER JOIN {$this->data['prefix']}posts  AS p\n                                 ON t.topic_id = p.topic_id\n                    LEFT OUTER JOIN {$this->data['prefix']}posts_text  AS pt\n                                 ON pt.post_id = p.post_id\n                           GROUP BY p.topic_id\n                           ", $gdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysqli_error($gdb));
     }
     for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
         $entries[$x] = mysqli_fetch_assoc($res);
         $entry = array('title' => $this->decode($entries[$x]['post_subject']), 'isdraft' => 'false', 'allow_comments' => 'true', 'timestamp' => $entries[$x]['post_time'], 'body' => $this->strtr($entries[$x]['post_text']), 'extended' => '');
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['topic_poster']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['user_login'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
         /* Entry/category */
         foreach ($categories as $category) {
             if ($category['cat_ID'] == $entries[$x]['forum_id']) {
                 $data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
                 serendipity_db_insert('entrycat', $this->strtrRecursive($data));
//.........这里部分代码省略.........
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:101,代码来源:phpbb.inc.php


注:本文中的serendipity_rebuildCategoryTree函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。