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


PHP serendipity_approveComment函数代码示例

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


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

示例1: import


//.........这里部分代码省略.........
         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));
                 break;
             }
         }
         /* Comments */
         $topic_id = $entries[$x]['topic_id'];
         $c_res = @$this->nativeQuery("SELECT t.topic_title, \n                                        t.topic_poster,\n                                        p.poster_id,\n                                        t.forum_id,\n                                        p.post_time,\n                                        pt.post_subject,\n                                        pt.post_text,\n                                        pt.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                                  WHERE p.topic_id = {$topic_id} \n                               ", $gdb);
         if (!$c_res) {
             return sprintf(COULDNT_SELECT_COMMENT_INFO, mysqli_error($gdb));
         }
         while ($a = mysqli_fetch_assoc($c_res)) {
             if ($a['post_id'] == $entries[$x]['post_id']) {
                 continue;
             }
             $author = '';
             $mail = '';
             $url = '';
             foreach ($users as $user) {
                 if ($user['ID'] == $a['poster_id']) {
                     $author = $user['user_login'];
                     $mail = $user['user_email'];
                     $url = $user['user_url'];
                     break;
                 }
             }
             $comment = array('entry_id ' => $entries[$x]['entryid'], 'parent_id' => 0, 'timestamp' => $a['post_time'], 'author' => $author, 'email' => $mail, 'url' => $url, 'ip' => '', 'status' => 'approved', 'body' => $a['post_text'], 'subscribed' => 'false', 'type' => 'NORMAL');
             serendipity_db_insert('comments', $this->strtrRecursive($comment));
             $cid = serendipity_db_insert_id('comments', 'id');
             serendipity_approveComment($cid, $entries[$x]['entryid'], true);
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
     // That was fun.
     return true;
 }
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:101,代码来源:phpbb.inc.php

示例2: import


//.........这里部分代码省略.........
         $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));
         }
     }
     /* Comments */
     $res = @$this->nativeQuery("SELECT * FROM evo_comments;", $b2db);
     if (!$res) {
         return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($b2db));
     }
     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'])) {
                     foreach ($users as $user) {
                         if ($user['ID'] == $a['comment_author_ID']) {
                             $author = $user['user_login'];
                             $mail = $user['user_email'];
                             $url = $user['user_url'];
                             break;
                         }
                     }
                 }
                 if (empty($author) && empty($mail)) {
                     $author = $a['comment_author'];
                     $mail = $a['comment_author_email'];
                     $url = $a['comment_author_url'];
                 }
                 $comment = array('entry_id ' => $entry['entryid'], 'parent_id' => 0, 'timestamp' => strtotime($a['comment_date']), 'author' => $author, 'email' => $mail, 'url' => $url, 'ip' => $a['comment_author_IP'], 'status' => $a['comment_status'] == 'published' ? 'approved' : 'pending', 'body' => $a['comment_content'], 'subscribed' => 'false', 'type' => 'NORMAL');
                 serendipity_db_insert('comments', $this->strtrRecursive($comment));
                 if ($a['comment_status'] == 'published') {
                     $cid = serendipity_db_insert_id('comments', 'id');
                     serendipity_approveComment($cid, $entry['entryid'], true);
                 }
             }
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
     // That was fun.
     return true;
 }
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:b2evolution.inc.php

示例3: 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

示例4: import


//.........这里部分代码省略.........
         if ($debug) {
             echo "<span class='block_level'>Rebuilt category tree.</span>";
         }
     }
     if ($no_cat) {
         printf(COULDNT_SELECT_CATEGORY_INFO, $no_cat);
     }
     /* Entries */
     if (serendipity_db_bool($this->data['import_all'])) {
         $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}posts WHERE post_status IN ('publish', 'draft') ORDER BY post_date;", $wpdb);
     } else {
         $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}posts ORDER BY post_date;", $wpdb);
     }
     if (!$res) {
         printf(COULDNT_SELECT_ENTRY_INFO, mysqli_error($wpdb));
     } else {
         if ($debug) {
             echo "<span class='block_level'>Importing entries...</span>";
         }
         for ($x = 0, $c = mysqli_num_rows($res); $x < $c; $x++) {
             $entries[$x] = mysqli_fetch_assoc($res);
             $content = explode('<!--more-->', $entries[$x]['post_content'], 2);
             $body = $content[0];
             $extended = $content[1];
             $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($body), 'extended' => $this->strtr($extended), 'authorid' => $assoc['users'][$entries[$x]['post_author']]);
             if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
                 printf(COULDNT_SELECT_ENTRY_INFO, mysqli_error($wpdb));
                 echo "<span class='block_level'>ID: {$entries[$x]['ID']} - {$entry['title']}</span>";
                 return $entries[$x]['entryid'];
             }
             $assoc['entries'][$entries[$x]['ID']] = $entries[$x]['entryid'];
         }
         if ($debug) {
             echo "<span class='msg_success'>Imported entries...</span>";
         }
         // Clean memory
         unset($entries);
     }
     /* Entry/category (WP < 2.3 style)*/
     $no_entrycat = false;
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}post2cat;", $wpdb);
     if (!$res) {
         $no_entrycat = mysqli_error($wpdb);
     } else {
         if ($debug) {
             echo "<span class='block_level'>Importing category associations (WP 2.2 style)...</span>";
         }
         while ($a = mysqli_fetch_assoc($res)) {
             $data = array('entryid' => $assoc['entries'][$a['post_id']], 'categoryid' => $assoc['categories'][$a['category_id']]);
             serendipity_db_insert('entrycat', $this->strtrRecursive($data));
         }
         if ($debug) {
             echo "<span class='msg_success'>Imported category associations.</span>";
         }
     }
     /* Entry/category (WP > 2.3 style)*/
     $res = @$this->nativeQuery("SELECT rel.object_id        AS post_id, \n                                           rel.term_taxonomy_id AS category_id \n                                      FROM {$this->data['prefix']}term_relationships AS rel;", $wpdb);
     if (!$res && !$no_entrycat) {
         $no_entrycat = mysqli_error($wpdb);
     } elseif ($res) {
         $no_entrycat = false;
         if ($debug) {
             echo "<span class='block_level'>Importing category associations (WP 2.3 style)...</span>";
         }
         while ($a = mysqli_fetch_assoc($res)) {
             $data = array('entryid' => $assoc['entries'][$a['post_id']], 'categoryid' => $assoc['categories'][$a['category_id']]);
             serendipity_db_insert('entrycat', $this->strtrRecursive($data));
         }
         if ($debug) {
             echo "<span class='msg_success'>Imported category associations.</span>";
         }
     }
     if ($no_entrycat) {
         printf(COULDNT_SELECT_ENTRY_INFO, $no_entrycat);
     }
     /* Comments */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comments;", $wpdb);
     if (!$res) {
         printf(COULDNT_SELECT_COMMENT_INFO, mysqli_error($wpdb));
     } else {
         $serendipity['allowSubscriptions'] = false;
         if ($debug) {
             echo "<span class='block_level'>Importing comments...</span>";
         }
         while ($a = mysqli_fetch_assoc($res)) {
             $comment = array('entry_id ' => $assoc['entries'][$a['comment_post_ID']], 'parent_id' => 0, 'timestamp' => strtotime($a['comment_date']), 'author' => $a['comment_author'], 'email' => $a['comment_author_email'], 'url' => $a['comment_author_url'], 'ip' => $a['comment_author_IP'], 'status' => empty($a['comment_approved']) || $a['comment_approved'] == '1' ? 'approved' : 'pending', 'subscribed' => 'false', 'body' => $a['comment_content'], 'type' => 'NORMAL');
             serendipity_db_insert('comments', $this->strtrRecursive($comment));
             if ($comment['status'] == 'approved') {
                 $cid = serendipity_db_insert_id('comments', 'id');
                 serendipity_approveComment($cid, $assoc['entries'][$a['comment_post_ID']], true);
             }
         }
         if ($debug) {
             echo "<span class='msg_success'>Imported comments.</span>";
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
     // That was fun.
     return true;
 }
开发者ID:jimjag,项目名称:Serendipity,代码行数:101,代码来源:wordpress.inc.php

示例5: import


//.........这里部分代码省略.........
         } 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) {
             if ($category['cat_ID'] == $a['category_id']) {
                 foreach ($entries as $entry) {
                     if ($a['post_id'] == $entry['ID']) {
                         $data = array('entryid' => $entry['entryid'], 'categoryid' => $category['categoryid']);
                         serendipity_db_insert('entrycat', $this->strtrRecursive($data));
                         break;
                     }
                 }
                 break;
             }
         }
     }
     /* Comments */
     $res = @pg_query($wpdb, "SELECT * FROM {$this->data['prefix']}comments;");
     if (!$res) {
         return sprintf(COULDNT_SELECT_COMMENT_INFO, pg_last_error($wpdb));
     }
     while ($a = pg_fetch_assoc($res)) {
         foreach ($entries as $entry) {
             if ($entry['ID'] == $a['comment_post_ID']) {
                 $comment = array('entry_id ' => $entry['entryid'], 'parent_id' => 0, 'timestamp' => strtotime($a['comment_date']), 'author' => $a['comment_author'], 'email' => $a['comment_author_email'], 'url' => $a['comment_author_url'], 'ip' => $a['comment_author_IP'], 'status' => empty($a['comment_approved']) || $a['comment_approved'] == '1' ? 'approved' : 'pending', 'subscribed' => 'false', 'body' => $a['comment_content'], 'type' => 'NORMAL');
                 serendipity_db_insert('comments', $this->strtrRecursive($comment));
                 if ($comment['status'] == 'approved') {
                     $cid = serendipity_db_insert_id('comments', 'id');
                     serendipity_approveComment($cid, $entry['entryid'], true);
                 }
             }
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
     // That was fun.
     return true;
 }
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:wordpress-pg.inc.php

示例6: import


//.........这里部分代码省略.........
                         $this->debug("Marking COMMENT.");
                         $is_comment = true;
                         $is_trackback = false;
                         $comment = array();
                         $skip = false;
                     } elseif ($matches[1] == 'PING') {
                         $this->debug("Marking TRACKBACK");
                         $is_comment = false;
                         $is_trackback = true;
                         $comment = array();
                         $skip = false;
                     }
                     $this->debug("Setting EL to {$matches[1]}");
                     $el = $matches[1];
                     $c_el = "";
                 } else {
                     $this->debug("Could not parse next line. Keeping it for next cycle.");
                     $nofetch = true;
                 }
             } else {
                 $this->debug("Resetting EL to an empty string");
                 $el = $c_el = "";
             }
         } elseif (empty($el)) {
             $this->debug("EL is empty. Line is '{$line}'");
             $content = "";
             if (preg_match('/^([A-Z\\s]+):\\s+(.*)$/s', $line, $matches)) {
                 $this->debug("Section match {$matches[1]} found, input: {$matches[2]}");
                 $c_el = $matches[1];
                 $content = $matches[2];
             } elseif (!empty($c_el)) {
                 $this->debug("Still in subsection of previous run: {$c_el}.");
                 $content = trim($line);
             }
             if (!empty($content)) {
                 if ($is_comment || $is_trackback) {
                     $this->debug("Appending to comments: {$line}");
                     $comment[$c_el] = $content;
                 } else {
                     $this->debug("Appending to entry: {$line}");
                     if (isset($entry[$c_el])) {
                         $entry[$c_el] .= "" . $content;
                     } else {
                         $entry[$c_el] = $content;
                     }
                 }
             }
         } elseif ($is_comment || $is_trackback) {
             $this->debug("Appending Line in current Element {$el} to comments: {$line}");
             $comment[$el] .= $line;
         } else {
             $this->debug("Appending Line in current Element {$el} to entries: {$line}");
             $entry[$el] .= $line;
         }
     }
     fclose($fh);
     if (!sizeof($tasks) || $force == true) {
         serendipity_db_begin_transaction();
         foreach ($entries as $entry) {
             #echo '<pre>' . printR_($entry, true) . '</pre><br />';
             #continue;
             if (empty($entry['authorid'])) {
                 $entry['authorid'] = $serendipity['authorid'];
                 $entry['author'] = $serendipity['realname'];
             }
             if (!isset($entry['isdraft'])) {
                 $entry['isdraft'] = 'false';
             }
             if (!isset($entry['allow_comments'])) {
                 $entry['allow_comments'] = 'true';
             }
             $comments = $entry['s9y_comments'];
             $entryprops = $entry['props'];
             unset($entry['props']);
             unset($entry['s9y_comments']);
             if (!is_int($r = serendipity_updertEntry($entry))) {
                 echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . $r . '</div>';
             } else {
                 $this->debug('Saved entry ' . $r . ' (' . $entry['title'] . ')');
                 $entry['id'] = $r;
                 foreach ((array) $comments as $comment) {
                     $comment['entry_id'] = $r;
                     if ($rc = serendipity_db_insert('comments', $comment)) {
                         $cid = serendipity_db_insert_id('comments', 'id');
                         serendipity_approveComment($cid, $entry['id'], true);
                     } else {
                         echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . $rc . '</div>';
                     }
                 }
                 // Let the plugins do some additional stuff. Here it's used with
                 // event_entryproperties in mind to setup the nl2br-stuff
                 serendipity_plugin_api::hook_event('backend_import_entry', $entry, $entryprops);
             }
         }
         serendipity_db_end_transaction(true);
         return true;
     } else {
         return '<ul><li>' . implode('</li><li>', array_unique($tasks)) . '</li></ul>';
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:movabletype.inc.php

示例7: import


//.........这里部分代码省略.........
     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));
                 break;
             }
         }
         $topic_id = $entries[$x]['topic_id'];
         // Store original ID, we might need it at some point.
         serendipity_db_insert('entryproperties', array('entryid' => $entries[$x]['entryid'], 'property' => 'foreign_import_id', 'value' => $entries[$x]['topic_id']));
         // Convert SMF tags
         $t_res = @$this->nativeQuery("SELECT t.tag\r\n                                            FROM {$this->data['prefix']}tags_log AS tl\r\n                                            JOIN {$this->data['prefix']}tags AS t\r\n                                              ON tl.ID_TAG = t.ID_TAG\r\n                                           WHERE tl.ID_TOPIC = {$topic_id}\r\n                                             AND t.approved = 1");
         if (mysql_num_rows($t_res) > 0) {
             while ($a = mysql_fetch_assoc($t_res)) {
                 serendipity_db_insert('entrytags', array('entryid' => $entries[$x]['entryid'], 'tag' => $t_res['tag']));
             }
         }
         /* Comments */
         $c_res = @$this->nativeQuery("SELECT\r\n                tm.subject AS post_subject,\r\n                tm.body AS post_text,\r\n                tm.ID_MSG AS post_id,\r\n                tm.posterTime AS post_time,\r\n                tm.ID_BOARD AS forum_id,\r\n                tm.posterName AS poster_name,\r\n                tm.posterEmail AS poster_email\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_TOPIC = t.ID_TOPIC\r\n               WHERE t.ID_TOPIC = {$topic_id}\r\n            ", $gdb);
         if (!$c_res) {
             return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($gdb));
         }
         while ($a = mysql_fetch_assoc($c_res)) {
             if ($a['post_id'] == $entries[$x]['post_id']) {
                 continue;
             }
             $author = $a['poster_name'];
             $mail = $a['poster_email'];
             $url = '';
             foreach ($users as $user) {
                 if ($user['ID'] == $a['poster_id']) {
                     $author = $user['user_login'];
                     $mail = $user['user_email'];
                     $url = $user['user_url'];
                     break;
                 }
             }
             $a['post_text'] = html_entity_decode($a['post_text']);
             $comment = array('entry_id ' => $entries[$x]['entryid'], 'parent_id' => 0, 'timestamp' => $a['post_time'], 'author' => $author, 'email' => $mail, 'url' => $url, 'ip' => '', 'status' => 'approved', 'body' => $a['post_text'], 'subscribed' => 'false', 'type' => 'NORMAL');
             serendipity_db_insert('comments', $this->strtrRecursive($comment));
             $cid = serendipity_db_insert_id('comments', 'id');
             serendipity_approveComment($cid, $entries[$x]['entryid'], true);
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
     // That was fun.
     return true;
 }
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:smf.inc.php

示例8: import


//.........这里部分代码省略.........
     }
     /* 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'])) {
                     foreach ($users as $user) {
                         if ($user['ID'] == $a['member_id']) {
                             $author = $user['user_login'];
                             $mail = $user['user_email'];
                             $url = $user['url'];
                             break;
                         }
                     }
                 }
                 $comment = array('entry_id ' => $entry['entryid'], 'parent_id' => 0, 'timestamp' => $a['t_stamp'], 'author' => $author, 'email' => $mail, 'url' => $url, 'ip' => $a['comment_ip'], 'status' => $a['status'] == 'open' ? 'approved' : 'pending', 'body' => $a['body'], 'subscribed' => 'false', 'type' => 'NORMAL');
                 serendipity_db_insert('comments', $this->strtrRecursive($comment));
                 if ($a['status'] == 'open') {
                     $cid = serendipity_db_insert_id('comments', 'id');
                     serendipity_approveComment($cid, $entry['entryid'], true);
                 }
             }
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
     // That was fun.
     return true;
 }
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:101,代码来源:pmachine.inc.php

示例9: import


//.........这里部分代码省略.........
         $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'];
             }
         }
         if ($entryid > 0 && $categoryid > 0) {
             $data = array('entryid' => $entryid, 'categoryid' => $categoryid);
             serendipity_db_insert('entrycat', $this->strtrRecursive($data));
         }
     }
     /* Comments */
     $res = @$this->nativeQuery("SELECT sid AS comment_post_ID,\n                                           subject AS title,\n                                           comment AS comment_content,\n                                           email AS comment_author_email,\n                                           url AS comment_author_url,\n                                           name AS comment_author,\n                                           UNIX_TIMESTAMP(`date`) AS tstamp\n                                      FROM nuke_comments", $nukedb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($nukedb));
     }
     while ($a = mysql_fetch_assoc($res)) {
         foreach ($entries as $entry) {
             if ($entry['ID'] == $a['comment_post_ID']) {
                 $author = $a['comment_author'];
                 $mail = $a['comment_author_email'];
                 $url = $a['comment_author_url'];
                 $comment = array('entry_id ' => $entry['entryid'], 'parent_id' => 0, 'timestamp' => $a['tstamp'], 'author' => $author, 'email' => $mail, 'url' => $url, 'title' => $a['title'], 'ip' => '', 'status' => 'approved', 'body' => $a['comment_content'], 'subscribed' => 'false', 'type' => 'NORMAL');
                 serendipity_db_insert('comments', $this->strtrRecursive($comment));
                 $cid = serendipity_db_insert_id('comments', 'id');
                 serendipity_approveComment($cid, $entry['entryid'], true);
             }
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
     // That was fun.
     return true;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:nuke.inc.php

示例10: ON

    $sql = "SELECT c.*, e.title, a.email as authoremail, a.mail_comments\n            FROM {$serendipity['dbPrefix']}comments c\n            LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)\n            LEFT JOIN {$serendipity['dbPrefix']}authors a ON (e.authorid = a.authorid)\n            WHERE c.id = " . (int) $serendipity['GET']['id'] . " AND (status = 'pending' OR status LIKE 'confirm%')";
    $rs = serendipity_db_query($sql, true);
    if ($rs === false) {
        $errormsg .= ERROR . ': ' . sprintf(COMMENT_ALREADY_APPROVED, (int) $serendipity['GET']['id']);
    } else {
        serendipity_approveComment((int) $serendipity['GET']['id'], (int) $rs['entry_id']);
        $msg .= DONE . ': ' . sprintf(COMMENT_APPROVED, (int) $serendipity['GET']['id']);
    }
}
if (isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'pending' && serendipity_checkFormToken()) {
    $sql = "SELECT c.*, e.title, a.email as authoremail, a.mail_comments\n            FROM {$serendipity['dbPrefix']}comments c\n            LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)\n            LEFT JOIN {$serendipity['dbPrefix']}authors a ON (e.authorid = a.authorid)\n            WHERE c.id = " . (int) $serendipity['GET']['id'] . " AND status = 'approved'";
    $rs = serendipity_db_query($sql, true);
    if ($rs === false) {
        $errormsg .= ERROR . ': ' . sprintf(COMMENT_ALREADY_APPROVED, (int) $serendipity['GET']['id']);
    } else {
        serendipity_approveComment((int) $serendipity['GET']['id'], (int) $rs['entry_id'], true, true);
        $msg .= DONE . ': ' . sprintf(COMMENT_MODERATED, (int) $serendipity['GET']['id']);
    }
}
/* We are asked to delete a comment */
if (isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'delete' && serendipity_checkFormToken()) {
    serendipity_deleteComment($serendipity['GET']['id'], $serendipity['GET']['entry_id']);
    $msg .= DONE . ': ' . sprintf(COMMENT_DELETED, (int) $serendipity['GET']['id']);
}
/* We are either in edit mode, or preview mode */
if (isset($serendipity['GET']['adminAction']) && ($serendipity['GET']['adminAction'] == 'edit' || $serendipity['GET']['adminAction'] == 'reply') || isset($serendipity['POST']['preview'])) {
    $serendipity['smarty_raw_mode'] = true;
    // Force output of Smarty stuff in the backend
    serendipity_smarty_init();
    if ($serendipity['GET']['adminAction'] == 'reply' || $serendipity['GET']['adminAction'] == 'doReply') {
        $c = serendipity_fetchComments($serendipity['GET']['entry_id'], 1, 'co.id', false, 'NORMAL', ' AND co.id=' . (int) $serendipity['GET']['id']);
开发者ID:amirchrist,项目名称:Serendipity,代码行数:31,代码来源:comments.inc.php

示例11: import_wpxrss


//.........这里部分代码省略.........
     }
     $wp_ns = 'http://wordpress.org/export/1.0/';
     $dc_ns = 'http://purl.org/dc/elements/1.1/';
     $content_ns = 'http://purl.org/rss/1.0/modules/content/';
     $wp_core = $xml->channel->children($wp_ns);
     foreach ($wp_core->category as $idx => $cat) {
         //TODO: Parent generation unknown.
         $cat_name = (string) $cat->cat_name;
         if (!isset($s9y_cat[$cat_name])) {
             $cat = array('category_name' => $cat_name, 'category_description' => '', 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
             printf(CREATE_CATEGORY, htmlspecialchars($cat_name));
             echo "<br />\n";
             if ($dry_run) {
                 $s9y_cat[$cat_name] = time();
             } else {
                 serendipity_db_insert('category', $cat);
                 $s9y_cat[$cat_name] = serendipity_db_insert_id('category', 'categoryid');
             }
         }
     }
     /* ************* ITEMS **********************/
     foreach ($xml->channel->item as $idx => $item) {
         $wp_items = $item->children($wp_ns);
         $dc_items = $item->children($dc_ns);
         $content_items = $item->children($content_ns);
         // TODO: Attachments not handled
         if ((string) $wp_items->post_type == 'attachment' or (string) $wp_items->post_type == 'page') {
             continue;
         }
         $entry = array('title' => (string) $item->title, 'isdraft' => (string) $wp_items->status == 'publish' ? 'false' : 'true', 'allow_comments' => (string) $wp_items->comment_status == 'open' ? true : false, 'categories' => array(), 'body' => (string) $content_items->encoded);
         if (preg_match('@^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$@', (string) $wp_items->post_date, $timematch)) {
             $entry['timestamp'] = mktime($timematch[4], $timematch[5], $timematch[6], $timematch[2], $timematch[3], $timematch[1]);
         } else {
             $entry['timestamp'] = time();
         }
         if (isset($item->category[1])) {
             foreach ($item->category as $idx => $category) {
                 $cstring = (string) $category;
                 if (!isset($s9y_cat[$cstring])) {
                     echo "WARNING: {$category} unset!<br />\n";
                 } else {
                     $entry['categories'][] = $s9y_cat[$cstring];
                 }
             }
         } else {
             $cstring = (string) $item->category;
             $entry['categories'][] = $s9y_cat[$cstring];
         }
         $wp_user = (string) $dc_items->creator;
         if (!isset($s9y_users[$wp_user])) {
             if ($dry_run) {
                 $s9y_users[$wp_user]['authorid'] = time();
             } else {
                 $s9y_users[$wp_user]['authorid'] = serendipity_addAuthor($wp_user, md5(time()), $wp_user, '', USERLEVEL_EDITOR);
             }
             printf(CREATE_AUTHOR, htmlspecialchars($wp_user));
             echo "<br />\n";
         }
         $entry['authorid'] = $s9y_users[$wp_user]['authorid'];
         if ($dry_run) {
             $id = time();
         } else {
             $id = serendipity_updertEntry($entry);
         }
         $s9y_cid = array();
         // Holds comment ids to s9y ids association.
         $c_i = 0;
         foreach ($wp_items->comment as $comment) {
             $c_i++;
             $c_id = (string) $comment->comment_id;
             $c_pid = (string) $comment->comment_parent;
             $c_type = (string) $comment->comment_type;
             if ($c_type == 'pingback') {
                 $c_type2 = 'PINGBACK';
             } elseif ($c_type == 'trackback') {
                 $c_type2 = 'TRACKBACK';
             } else {
                 $c_type2 = 'NORMAL';
             }
             $s9y_comment = array('entry_id ' => $id, 'parent_id' => $s9y_cid[$c_pd], 'author' => (string) $comment->comment_author, 'email' => (string) $comment->comment_author_email, 'url' => (string) $comment->comment_author_url, 'ip' => (string) $comment->comment_author_IP, 'status' => empty($comment->comment_approved) || $comment->comment_approved == '1' ? 'approved' : 'pending', 'subscribed' => 'false', 'body' => (string) $comment->comment_content, 'type' => $c_type2);
             if (preg_match('@^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$@', (string) $comment->comment_date, $timematch)) {
                 $s9y_comment['timestamp'] = mktime($timematch[4], $timematch[5], $timematch[6], $timematch[2], $timematch[3], $timematch[1]);
             } else {
                 $s9y_comment['timestamp'] = time();
             }
             if ($dry_run) {
                 $cid = time();
             } else {
                 serendipity_db_insert('comments', $s9y_comment);
                 $cid = serendipity_db_insert_id('comments', 'id');
                 if ($s9y_comment['status'] == 'approved') {
                     serendipity_approveComment($cid, $id, true);
                 }
             }
             $s9y_cid[$c_id] = $cid;
         }
         echo "Entry '" . htmlspecialchars($entry['title']) . "' ({$c_i} comments) imported.<br />\n";
     }
     return true;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:generic.inc.php

示例12: learnAction

 function learnAction($id, $category, $action, $entry_id)
 {
     $comment = $this->getComment($id);
     if (is_array($comment)) {
         $comment = $comment['0'];
     }
     $this->startLearn($comment, $category);
     if ($action == 'delete') {
         serendipity_deleteComment($id, $entry_id);
     } else {
         if ($action == 'approve') {
             serendipity_approveComment($id, $entry_id);
         }
     }
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:15,代码来源:serendipity_event_spamblock_bayes.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();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $entries = array();
     if (!extension_loaded('mysqli')) {
         return MYSQL_REQUIRED;
     }
     $bblogdb = @mysqli_connect($this->data['host'], $this->data['user'], $this->data['pass']);
     if (!$bblogdb || mysqli_connect_error()) {
         return sprintf(COULDNT_CONNECT, serendipity_specialchars($this->data['host']));
     }
     if (!@mysqli_select_db($bblogdb, $this->data['name'])) {
         return sprintf(COULDNT_SELECT_DB, mysqli_error($bblogdb));
     }
     /* Users */
     $res = @$this->nativeQuery("SELECT id         AS ID,\n                                    password   AS pw,\n                                    nickname   AS user_login,\n                                    email      AS user_email,\n                                    url        AS user_url\n                               FROM {$this->data['prefix']}authors", $bblogdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_USER_INFO, mysqli_error($bblogdb));
     }
     for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
         $users[$x] = mysqli_fetch_assoc($res);
         $data = array('right_publish' => 1, 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'userlevel' => USERLEVEL_ADMIN, 'password' => md5($users[$x]['pw']));
         // Wicked. This is the first blog I've seen storing cleartext passwords :-D
         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 * FROM {$this->data['prefix']}sections", $bblogdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysqli_error($bblogdb));
     }
     // Get all the info we need
     for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
         $row = mysqli_fetch_assoc($res);
         $cat = array('category_name' => $row['nicename'], 'category_description' => $row['nicename'], 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
         serendipity_db_insert('category', $this->strtrRecursive($cat));
         $row['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
         $this->categories[] = $row;
     }
     serendipity_rebuildCategoryTree();
     /* Entries */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}posts ORDER BY postid;", $bblogdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_ENTRY_INFO, mysqli_error($bblogdb));
     }
     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'] == 'live' ? 'false' : 'true', 'allow_comments' => $entries[$x]['allowcomments'] == 'allow' ? 'true' : 'false', 'timestamp' => $entries[$x]['posttime'], 'body' => $this->strtr($entries[$x]['body']), 'extended' => '');
         $entry['authorid'] = '';
         $entry['author'] = '';
         foreach ($users as $user) {
             if ($user['ID'] == $entries[$x]['author']) {
                 $entry['authorid'] = $user['authorid'];
                 $entry['author'] = $user['user_login'];
                 break;
             }
         }
         if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
             return $entries[$x]['entryid'];
         }
         $sections = explode(':', $entries[$x]['sections']);
         foreach ($sections as $section) {
             if (empty($section)) {
                 continue;
             }
             foreach ($this->categories as $category) {
                 if ($category['sectionid'] == $section) {
                     $categoryid = $category['categoryid'];
                 }
             }
             if ($categoryid > 0) {
                 $data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $categoryid);
                 serendipity_db_insert('entrycat', $this->strtrRecursive($data));
             }
         }
     }
     /* Comments */
     $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comments WHERE type = 'comment';", $bblogdb);
     if (!$res) {
         return sprintf(COULDNT_SELECT_COMMENT_INFO, mysqli_error($bblogdb));
     }
     while ($a = mysqli_fetch_assoc($res)) {
         foreach ($entries as $entry) {
             if ($entry['postid'] == $a['postid']) {
                 $comment = array('entry_id ' => $entry['entryid'], 'parent_id' => 0, 'timestamp' => $a['posttime'], 'author' => $a['postername'], 'email' => $a['posteremail'], 'url' => $a['posterwebsite'], 'ip' => $a['ip'], 'status' => 'approved', 'body' => $a['commenttext'], 'subscribed' => 'false', 'type' => 'NORMAL');
                 serendipity_db_insert('comments', $this->strtrRecursive($comment));
                 $cid = serendipity_db_insert_id('comments', 'id');
                 serendipity_approveComment($cid, $entry['entryid'], true);
//.........这里部分代码省略.........
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:101,代码来源:bblog.inc.php

示例14: import


//.........这里部分代码省略.........
     }
     /* 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) {
                         if ($user['ID'] == $a['cmember']) {
                             $author = $user['user_login'];
                             $mail = $user['user_email'];
                             break;
                         }
                     }
                 }
                 if (empty($author) && empty($mail)) {
                     $author = $a['cuser'];
                     $mail = $a['cmail'];
                 }
                 $comment = array('entry_id ' => $entry['entryid'], 'parent_id' => 0, 'timestamp' => strtotime($a['ctime']), 'author' => $author, 'email' => $mail, 'url' => $a['chost'], 'ip' => $a['cip'], 'status' => 'approved', 'body' => $a['cbody'], 'subscribed' => 'false', 'type' => 'NORMAL');
                 serendipity_db_insert('comments', $this->strtrRecursive($comment));
                 $cid = serendipity_db_insert_id('comments', 'id');
                 serendipity_approveComment($cid, $entry['entryid'], true);
             }
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
     // That was fun.
     return true;
 }
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:nucleus.inc.php

示例15: import


//.........这里部分代码省略.........
         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;
                     }
                 }
                 $comment = array('entry_id ' => $entry['entryid'], 'parent_id' => 0, 'timestamp' => strtotime($a['date']), 'author' => $author, 'email' => $mail, 'url' => $url, 'ip' => $a['ip'], 'status' => 'approved', 'body' => $a['comment'], 'subscribed' => 'false', 'type' => 'NORMAL');
                 serendipity_db_insert('comments', $this->strtrRecursive($comment));
                 $cid = serendipity_db_insert_id('comments', 'id');
                 serendipity_approveComment($cid, $entry['entryid'], true);
             }
         }
     }
     $serendipity['noautodiscovery'] = $noautodiscovery;
     // That was fun.
     return true;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:geeklog.inc.php


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