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


PHP serendipity_db_insert函数代码示例

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


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

示例1: sendComment

 function sendComment($to, $title, $fromName, $fromEmail, $fromUrl, $comment)
 {
     global $serendipity;
     if (empty($fromName)) {
         $fromName = ANONYMOUS;
     }
     $key = md5(uniqid(rand(), true));
     //  CUSTOMIZE
     $subject = PLUGIN_SUGGEST_TITLE;
     $text = sprintf(PLUGIN_SUGGEST_MAIL, $serendipity['baseURL'] . '?suggestkey=' . $key);
     $db = array('email' => $fromEmail, 'entry_id' => 0, 'copycop' => '', 'ip' => $_SERVER['REMOTE_ADDR'], 'submitted' => time(), 'name' => $fromName, 'article' => $comment, 'title' => $title, 'validation' => $key);
     serendipity_db_insert('suggestmails', $db);
     return serendipity_sendMail($to, $subject, $text, $serendipity['blogMail'], null, $serendipity['blogTitle']);
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:14,代码来源:serendipity_event_suggest.php

示例2: save_oembed

 static function save_oembed($url, $oembed)
 {
     if (empty($url) || !isset($oembed)) {
         return false;
     }
     if (isset($oembed->html)) {
         $oembed->html = OEmbedDatabase::cleanup_html($oembed->html);
     }
     $save = array();
     $save['urlmd5'] = md5($url);
     $save['url'] = $url;
     $save['oetype'] = $oembed->type;
     $save['oeobj'] = serialize($oembed);
     serendipity_db_insert(PLUGIN_OEMBED_DATABASEVNAME, $save);
     return $oembed;
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:16,代码来源:OEmbedDatabase.php

示例3: saveCommentSpice

 static function saveCommentSpice($commentid, $twittername, $promo_name, $promo_url, $boo_url)
 {
     global $serendipity;
     if (empty($commentid) || !is_numeric($commentid) || empty($twittername) && empty($promo_name) && empty($boo_url)) {
         return true;
     }
     $spice = array('commentid' => $commentid);
     if (!empty($twittername)) {
         $spice['twittername'] = $twittername;
     }
     if (!empty($promo_name)) {
         $spice['promo_name'] = $promo_name;
     }
     if (!empty($promo_url)) {
         $spice['promo_url'] = $promo_url;
     }
     if (!empty($boo_url)) {
         $spice['boo'] = $boo_url;
     }
     return serendipity_db_insert('commentspice', $spice);
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:21,代码来源:DbSpice.class.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('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

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

示例6: serendipity_ACLGrant

/**
 * Allow access to a specific item (category or entry) for a specific usergroup
 *
 * ACL are Access Control Lists. They indicate which read/write permissions a
 * specific item has for specific usergroups.
 * An artifact in terms of Serendipity can be either a category or an entry, or
 * anything beyond that for future compatibility.
 * This function sets up the ACLs.
 *
 * @access public
 * @param   int     The ID of the artifact to set the access
 * @param   string  The type of an artifact (category|entry)
 * @param   string  The type of access to grant (read|write)
 * @param   array   The ID of the group to grant access to
 * @param   string  A variable option for an artifact
 * @return  boolean True if ACL was applied, false if not.
 */
function serendipity_ACLGrant($artifact_id, $artifact_type, $artifact_mode, $groups, $artifact_index = '')
{
    global $serendipity;
    if (empty($groups) || !is_array($groups)) {
        return false;
    }
    // Delete all old existing relations.
    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}access\n                                WHERE artifact_id    = " . (int) $artifact_id . "\n                                  AND artifact_type  = '" . serendipity_db_escape_string($artifact_type) . "'\n                                  AND artifact_mode  = '" . serendipity_db_escape_string($artifact_mode) . "'\n                                  AND artifact_index = '" . serendipity_db_escape_string($artifact_index) . "'");
    $data = array('artifact_id' => (int) $artifact_id, 'artifact_type' => $artifact_type, 'artifact_mode' => $artifact_mode, 'artifact_index' => $artifact_index);
    if (count($data) < 1) {
        return true;
    }
    foreach ($groups as $group) {
        $data['groupid'] = $group;
        serendipity_db_insert('access', $data);
    }
    return true;
}
开发者ID:beealone,项目名称:Serendipity,代码行数:35,代码来源:functions_config.inc.php

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

示例8: import_table

 function import_table(&$s9ydb, $table, $primary_keys, $where = null, $dupe_check = false, $fix_relations = false, $skip_dupes = false)
 {
     global $serendipity;
     echo "<br /><br />Starting with table <strong>{$table}</strong>...<br />\n";
     if ($dupe_check) {
         $dupes = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}" . $table . " " . $where, false, 'both', false, $dupe_check);
         if (!$this->execute) {
             echo 'Dupe-Check: <pre>' . print_r($dupes, true) . '</pre>';
         }
     }
     $res = $this->nativeQuery("SELECT * FROM {$this->data['prefix']}" . $table . " " . $where, $s9ydb);
     echo mysql_error($s9ydb);
     if (!$res || mysql_num_rows($res) < 1) {
         return false;
     }
     $this->counter = 100;
     while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
         $this->counter++;
         if (is_array($primary_keys)) {
             foreach ($primary_keys as $primary_key) {
                 $primary_vals[$primary_key] = $row[$primary_key];
                 unset($row[$primary_key]);
             }
         } else {
             $primary_vals = array();
         }
         $insert = true;
         if (is_array($fix_relations)) {
             foreach ($fix_relations as $primary_key => $fix_relation) {
                 foreach ($fix_relation as $fix_relation_table => $fix_relation_primary_key) {
                     if (isset($primary_vals[$fix_relation_primary_key])) {
                         $assoc_val = $primary_vals[$fix_relation_primary_key];
                     } else {
                         $assoc_val = $row[$primary_key];
                     }
                     if (!$this->execute && empty($assoc_val)) {
                         if ($this->debug) {
                             echo '<pre>';
                             print_r($row);
                             print_r($fix_relation);
                             echo '</pre>';
                         }
                     }
                     $new_val = $this->storage[$fix_relation_table][$fix_relation_primary_key][$assoc_val];
                     if ($skip_dupes && $assoc_val == $new_val) {
                         $insert = false;
                     }
                     if (!empty($new_val)) {
                         $row[$primary_key] = $new_val;
                     }
                     if (!$this->execute && $this->debug) {
                         echo "Fix relation from {$fix_relation_table}.{$fix_relation_primary_key}={$primary_vals[$fix_relation_primary_key]} to {$row[$primary_key]} (assoc_val: {$assoc_val})<br />\n";
                     }
                 }
             }
         }
         if ($insert) {
             if ($dupe_check && isset($dupes[$row[$dupe_check]])) {
                 if ($this->debug) {
                     echo "Skipping duplicate: <pre>" . print_r($dupes[$row[$dupe_check]], true) . "</pre><br />\n";
                 }
                 foreach ($primary_vals as $primary_key => $primary_val) {
                     $this->storage[$table][$primary_key][$primary_val] = $dupes[$row[$dupe_check]][$primary_key];
                     $this->storage['dupes'][$table][$primary_key][$primary_val] = $dupes[$row[$dupe_check]][$primary_key];
                 }
             } elseif ($this->execute) {
                 serendipity_db_insert($table, $this->strtrRecursive($row));
                 foreach ($primary_vals as $primary_key => $primary_val) {
                     $dbid = serendipity_db_insert_id($table, $primary_key);
                     $this->storage[$table][$primary_key][$primary_val] = $dbid;
                 }
                 echo "Migrated entry #{$dbid} into {$table}.<br />\n";
             } else {
                 if ($this->debug) {
                     echo 'DB Insert: <pre>' . print_r($row, true) . '</pre>';
                 }
                 foreach ($primary_vals as $primary_key => $primary_val) {
                     $this->storage[$table][$primary_key][$primary_val] = $this->counter;
                 }
             }
         } else {
             if ($this->debug && !$this->execute) {
                 echo "Ignoring Duplicate.<br />\n";
             }
         }
     }
     if (!$this->execute) {
         echo 'Storage on ' . $table . ':<pre>' . print_r($this->storage[$table], true) . '</pre>';
     } else {
         echo "Finished table <strong>{$table}</strong><br />\n";
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:92,代码来源:serendipity.inc.php

示例9: import

 function import()
 {
     global $serendipity;
     global $elements;
     // Dependency on static pages
     if (!class_exists('serendipity_event_staticpage')) {
         die(IMPORTER_VOODOO_REQUIREMENTFAIL . '<br/>');
     }
     // The selected file
     $file = $_FILES['serendipity']['tmp_name']['import']['voodooPadXML'];
     // Create a parser and set it up with the callbacks
     $xml_parser = xml_parser_create('');
     xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
     xml_set_element_handler($xml_parser, "start_element_handler", "end_element_handler");
     xml_set_character_data_handler($xml_parser, "character_data_handler");
     // Feed the contents of the file into the parser
     if (!file_exists($file)) {
         die(sprintf(DOCUMENT_NOT_FOUND, htmlspecialchars($file)));
     }
     if (!($handle = fopen($file, "r"))) {
         die(sprintf(SKIPPING_FILE_UNREADABLE, htmlspecialchars($file)));
     }
     while ($contents = fread($handle, 4096)) {
         xml_parse($xml_parser, $contents, feof($handle));
     }
     fclose($handle);
     xml_parser_free($xml_parser);
     // Maintain a list of the aliases and their links
     $aliases = array();
     // Now have a list of elements referenceable by id
     // so loop through building and/or updating page objects
     while (list($key_a) = each($elements)) {
         $name = $elements[$key_a]->name;
         switch ($name) {
             case 'data':
                 // <data> indicates the start of the VoodooPad entry, so create page object
                 $thispage = array();
                 break;
             case 'key':
                 // This is the unique identifier of the page
                 $mykey = serendipity_makeFilename($elements[$key_a]->data);
                 $mykey = basename($this->data['keyPrefix']) . $mykey;
                 // Pluck out the existing one if its there
                 $page = serendipity_db_query("SELECT * \n                                                    FROM {$serendipity['dbPrefix']}staticpages \n                                                    WHERE filename = '" . serendipity_db_escape_string($mykey . '.htm') . "'\n                                                    LIMIT 1", true, 'assoc');
                 if (is_array($page)) {
                     $thispage =& $page;
                     if (empty($thispage['timestamp'])) {
                         $thispage['timestamp'] = time();
                     }
                 }
                 $thispage['filename'] = $mykey . '.htm';
                 // Thanks for pointing this out to me and not just fixing it, I'm learning.
                 $thispage['permalink'] = $serendipity['serendipityHTTPPath'] . 'index.php?serendipity[subpage]=' . $mykey;
                 break;
             case 'alias':
                 // The title and the string used to match links
                 $thispage['articleformattitle'] = $this->data['wikiName'];
                 $thispage['pagetitle'] = $mykey;
                 $thispage['headline'] = $elements[$key_a]->data;
                 break;
             case 'content':
                 // The content of a voodoopad entry
             // The content of a voodoopad entry
             case 'path':
                 // The path of a url string
                 $thispage['content'] = $elements[$key_a]->data;
                 // If its a content link list it for referencing with the page permalink
                 if ($name == 'content') {
                     $aliases[$thispage['headline']] = $thispage['permalink'];
                     // Either replace or insert depending on previous existence
                     if (!isset($thispage['id'])) {
                         echo '<br/>' . IMPORTER_VOODOO_CREATINGPAGE . ': ' . $mykey;
                         serendipity_db_insert('staticpages', $thispage);
                         $serendipity["POST"]["staticpage"] = serendipity_db_insert_id("staticpages", 'id');
                     } elseif ($this->data['updateExisting'] == 'true') {
                         echo '<br/>' . IMPORTER_VOODOO_UPDATINGPAGE . ': ' . $mykey;
                         serendipity_db_update("staticpages", array("id" => $thispage["id"]), $thispage);
                     } else {
                         echo '<br/>' . IMPORTER_VOODOO_NOTUPDATING . ': ' . $mykey;
                     }
                 } else {
                     // If its a url, the content is the link instead
                     echo '<br/>' . IMPORTER_VOODOO_RECORDURL . ': ' . $thispage['headline'];
                     $aliases[$thispage['headline']] = $thispage['content'];
                 }
                 break;
         }
     }
     // Now rewrite the permalinks
     echo '<br/>';
     if ($this->data['shouldWriteLinks'] == 'true') {
         Serendipity_Import_VoodooPad::write_links($aliases);
     }
     return true;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:95,代码来源:voodoopad.inc.php

示例10: import

 function import()
 {
     global $serendipity;
     if (empty($this->data['bloggerfile']) || !file_exists($this->data['bloggerfile'])) {
         echo "Path to blogger file empty or path to file wrong! Go back and correct.";
         return false;
     }
     # get default pass from request
     $defaultpass = $this->data['defaultpass'];
     # get blogger uploaded file path from request and load file
     $html = file_get_contents($this->data['bloggerfile']);
     # find posts using pattern matching
     preg_match_all("/STARTPOST(.*)ENDPOST/sU", $html, $posts);
     # iterate through all posts
     foreach ($posts[1] as $post) {
         # locate the post title
         if (preg_match("/TITLE:(.*)/", $post, $title)) {
             $title = trim($title[1]);
             echo "<b>" . htmlspecialchars($title) . "</b><br />";
         } else {
             $title = "";
             echo "<b>Empty title</b><br />";
         }
         # locate the post author
         if (preg_match("/AUTHOR:(.*)/", $post, $author)) {
             $author = trim($author[1]);
             echo "<em>" . htmlspecialchars($author[1]) . "</em><br />";
         } else {
             $author = "";
             echo "<em>Unknown author</em><br />";
         }
         # locate the post date
         if (preg_match("/DATE:(.*)/", $post, $date)) {
             $date = strtotime(trim($date[1]));
             echo "Posted on " . htmlspecialchars($date[1]) . ".<br />";
         } else {
             $date = time();
             echo "Unknown posting time.<br />";
         }
         # locate the post body
         if (preg_match("/BODY:(.*)-----/sU", $post, $body)) {
             $body = trim($body[1]);
             echo strlen($body) . " Bytes of text.<br />";
         } else {
             $body = "";
             echo "<strong>Empty Body!</strong><br />";
         }
         # find all comments for the post using pattern matching
         if (preg_match_all("/COMMENT:(.*)----/sU", $post, $commentlist)) {
             echo count($commentlist[1]) . " comments found.<br />";
         } else {
             $commentlist = array();
             echo "No comments found.<br />";
         }
         $result = serendipity_db_query("SELECT authorid FROM " . $serendipity['dbPrefix'] . "authors WHERE username = '" . serendipity_db_escape_string($author) . "' LIMIT 1", true, 'assoc');
         if (!is_array($result)) {
             $data = array('right_publish' => 1, 'realname' => $author, 'username' => $author, 'userlevel' => 0, 'password' => md5($defaultpass));
             // MD5 compatible
             serendipity_db_insert('authors', $data);
             $authorid = serendipity_db_insert_id('authors', 'authorid');
         } else {
             $authorid = $result['authorid'];
         }
         $entry = array('title' => $title, 'isdraft' => 'false', 'allow_comments' => 'true', 'timestamp' => $date, 'body' => $body, 'extended' => '', 'author' => $author, 'authorid' => $authorid);
         echo "Entry insert...<br />";
         if (!is_int($id = serendipity_updertEntry($entry))) {
             echo "Inserting entry failed.<br />";
             return $id;
         } else {
             echo "Entry {$id} inserted.<br />";
         }
         # iterate through all comments
         $c = 0;
         foreach ($commentlist[1] as $comment) {
             $c++;
             # locate the author and author url
             $curl = '';
             $cauthor = '';
             $cdate = time();
             $cbody = '';
             if (preg_match("/AUTHOR:(.*)/", $comment, $cauthor) && preg_match("/href=\"(.*)\"/", $cauthor[1], $curl)) {
                 $curl = isset($curl[1]) ? trim($curl[1]) : '';
                 $cauthor = trim(strip_tags($cauthor[1]));
             }
             # locate the date
             if (preg_match("/DATE:(.*)/", $comment, $cdate)) {
                 $cdate = strtotime($cdate[1]);
             }
             # locate the comment body
             if (preg_match("/BODY:(.*)/s", $comment, $cbody)) {
                 $cbody = trim($cbody[1]);
             }
             $icomment = array('entry_id ' => $id, 'parent_id' => 0, 'timestamp' => $cdate, 'author' => $cauthor, 'email' => '', 'url' => $curl, 'ip' => '', 'status' => 'approved', 'body' => $cbody, 'subscribed' => 'false', 'type' => 'NORMAL');
             serendipity_db_insert('comments', $icomment);
         }
         serendipity_db_query("UPDATE " . $serendipity['dbPrefix'] . "entries SET comments = " . $c . " WHERE id = " . $id);
         echo "Comment count set to: " . $c . "<br />";
     }
     echo "Import finished.<br />";
     return true;
//.........这里部分代码省略.........
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:old_blogger.inc.php

示例11: import

 function import()
 {
     global $serendipity;
     $max_import = 9999;
     $serendipity['noautodiscovery'] = true;
     if (!is_dir($this->data['pivot_path']) || !is_readable($this->data['pivot_path'])) {
         $check_dir = $serendipity['serendipityPath'] . $this->data['pivot_path'];
         if (!is_dir($check_dir) || !is_readable($check_dir)) {
             return sprintf(ERROR_NO_DIRECTORY, serendipity_specialchars($this->data['pivot_path']));
         }
         $this->data['pivot_path'] = $check_dir;
     }
     printf('<span class="block_level">' . CHECKING_DIRECTORY . ': ', $this->data['pivot_path']) . '</span>';
     if ($root = opendir($this->data['pivot_path'])) {
         // Fetch category data:
         $s9y_categories = serendipity_fetchCategories('all');
         $categories = $this->unserialize($this->data['pivot_path'] . '/ser-cats.php');
         $pivot_to_s9y = array('categories' => array());
         echo '<ul>';
         foreach ($categories as $pivot_category_id => $category) {
             $found = false;
             $pivot_category = trim(stripslashes($category[0]));
             foreach ($s9y_categories as $idx => $item) {
                 if ($pivot_category == $item['category_name']) {
                     $found = $item['categoryid'];
                     break;
                 }
             }
             if ($found) {
                 echo '<li>Pivot Category "' . serendipity_specialchars($pivot_category) . '" mapped to Serendipity ID ' . $found . '</li>';
                 $pivot_to_s9y['categories'][$pivot_category] = $found;
             } else {
                 echo '<li>Created Pivot Category "' . serendipity_specialchars($pivot_category) . '".</li>';
                 $cat = array('category_name' => $pivot_category, 'category_description' => '', 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
                 serendipity_db_insert('category', $cat);
                 $pivot_to_s9y['categories'][$pivot_category] = serendipity_db_insert_id('category', 'categoryid');
             }
         }
         $i = 0;
         while (false !== ($dir = readdir($root))) {
             if ($dir[0] == '.') {
                 continue;
             }
             if (substr($dir, 0, 8) == 'standard') {
                 printf('<li>' . CHECKING_DIRECTORY . '...</li>', $dir);
                 $data = $this->unserialize($this->data['pivot_path'] . '/' . $dir . '/index-' . $dir . '.php');
                 if (empty($data) || !is_array($data) || count($data) < 1) {
                     echo '<li><span class="msg_error">FATAL: File <em>' . $dir . '/index-' . $dir . '.php</em> has no data!</span></li>';
                     flush();
                     ob_flush();
                     continue;
                 }
                 foreach ($data as $entry) {
                     $entryid = str_pad($entry['code'], 5, '0', STR_PAD_LEFT);
                     if ($i >= $max_import) {
                         echo '<li>Skipping entry data for #' . $entryid . '</li>';
                         continue;
                     }
                     echo '<li>Fetching entry data for #' . $entryid . '</li>';
                     $entrydata = $this->unserialize($this->data['pivot_path'] . '/' . $dir . '/' . $entryid . '.php');
                     if (empty($entrydata) || !is_array($entrydata) || count($entrydata) < 1) {
                         echo '<li><span class="msg_error">FATAL: File <em>' . $dir . '/' . $entryid . '.php</em> has no data!</span></li>';
                         flush();
                         ob_flush();
                         continue;
                     }
                     $entry = array();
                     $entry['title'] = trim(stripslashes($entrydata['title']));
                     $entry['categories'] = array();
                     if (is_array($entrydata['category'])) {
                         foreach ($entrydata['category'] as $pivot_category) {
                             $entry['categories'][] = $pivot_to_s9y['categories'][$pivot_category];
                         }
                     }
                     $entry['timestamp'] = $this->toTimestamp($entrydata['date']);
                     $entry['last_modified'] = !empty($entrydata['edit_date']) ? $this->toTimestamp($entrydata['edit_date']) : $entry['timestamp'];
                     $entry['isdraft'] = $entrydata['status'] == 'publish' ? 'false' : 'true';
                     $entry['body'] = stripslashes($entrydata['introduction']);
                     $entry['extended'] = stripslashes($entrydata['body']);
                     $entry['title'] = stripslashes($entrydata['title']);
                     $entry['authorid'] = $serendipity['authorid'];
                     $entry['author'] = $serendipity['serendipityUser'];
                     $entry['allow_comments'] = $entrydata['allow_comments'] ? 'true' : 'false';
                     $entry['moderate_comments'] = 'false';
                     $entry['exflag'] = !empty($entry['extended']) ? 1 : 0;
                     $entry['trackbacks'] = 0;
                     $entry['comments'] = isset($entrydata['comments']) ? count($entrydata['comments']) : 0;
                     serendipity_updertEntry($entry);
                     $i++;
                     if (isset($entrydata['comments']) && count($entrydata['comments']) > 0) {
                         foreach ($entrydata['comments'] as $comment) {
                             $comment = array('entry_id ' => $entry['id'], 'parent_id' => 0, 'timestamp' => $this->toTimestamp($comment['date']), 'author' => stripslashes($comment['name']), 'email' => stripslashes($comment['email']), 'url' => stripslashes($comment['url']), 'ip' => stripslashes($comment['ip']), 'status' => 'approved', 'body' => stripslashes($comment['comment']), 'subscribed' => $comment['notify'] ? 'true' : 'false', 'type' => 'NORMAL');
                             serendipity_db_insert('comments', $comment);
                         }
                     }
                     echo '<li><span class="msg_success">Entry #' . $entryid . ' imported</span></li>';
                     flush();
                     ob_flush();
                 }
             }
//.........这里部分代码省略.........
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:101,代码来源:pivot.inc.php

示例12: insertFeed

 function insertFeed(&$array)
 {
     global $serendipity;
     $query = "SELECT authorid\n                    FROM {$serendipity['dbPrefix']}authors\n                   WHERE realname='" . serendipity_db_escape_string($array['feedname']) . "'";
     if (!is_array($res = serendipity_db_query($query))) {
         serendipity_db_insert('authors', array('username' => $array['feedname'], 'realname' => $array['feedname'], 'password' => md5(mt_rand()), 'email' => $array['htmlurl'], 'userlevel' => 0, 'right_publish' => 1));
         $res = serendipity_db_query($query);
     }
     $r = serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}aggregator_feeds\n                                                 (feedname, feedurl, htmlurl, charset, match_expression, feedicon, last_update)\n                                        VALUES ('" . serendipity_db_escape_string($array['feedname']) . "',\n                                                '" . serendipity_db_escape_string($array['feedurl']) . "',\n                                                '" . serendipity_db_escape_string($array['htmlurl']) . "',\n                                                '" . serendipity_db_escape_string($array['charset']) . "',\n                                                '" . serendipity_db_escape_string($array['match_expression']) . "',\n                                                '" . serendipity_db_escape_string($array['feedicon']) . "',\n                                                '" . time() . "')");
     if ($r == false) {
         return $r;
     }
     if (!is_array($array['categoryids'])) {
         $array['categoryids'] = array();
         $array['categoryids'][] = $array['categoryid'];
     }
     return $this->insertFeedCats(serendipity_db_insert_id(), $array['categoryids']);
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:18,代码来源:serendipity_event_aggregator.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('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

示例14: importCategories

 function importCategories($nukedb)
 {
     $res = $this->nativeQuery("SELECT topicname   AS cat_name,\n                                          topictext   AS cat_description,\n                                          topicid     AS cat_ID\n                                     FROM nuke_topics", $nukedb);
     if (!$res) {
         echo mysql_error();
         return false;
     }
     // Get all the info we need
     for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
         $row = mysql_fetch_assoc($res);
         $cat = array('category_name' => $row['cat_name'], 'category_description' => $row['cat_description'], '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;
     }
     return true;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:17,代码来源:nuke.inc.php

示例15: import_wpxrss

 function import_wpxrss()
 {
     // TODO: Backtranscoding to NATIVE charset. Currently only works with UTF-8.
     $dry_run = false;
     $serendipity['noautodiscovery'] = 1;
     $uri = $this->data['url'];
     require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
     serendipity_request_start();
     $req = new HTTP_Request($uri, array('allowRedirects' => true, 'maxRedirects' => 5));
     $res = $req->sendRequest();
     if (PEAR::isError($res) || $req->getResponseCode() != '200') {
         serendipity_request_end();
         echo IMPORT_FAILED . ': ' . htmlspecialchars($this->data['url']);
         echo "<br />\n";
         return false;
     }
     $fContent = $req->getResponseBody();
     serendipity_request_end();
     echo strlen($fContent) . " Bytes<br />\n";
     if (version_compare(PHP_VERSION, '5.0') === -1) {
         printf(UNMET_REQUIREMENTS, 'PHP >= 5.0');
         echo "<br />\n";
         return false;
     }
     $xml = simplexml_load_string($fContent);
     unset($fContent);
     /* ************* USERS **********************/
     $_s9y_users = serendipity_fetchUsers();
     $s9y_users = array();
     if (is_array($s9y_users)) {
         foreach ($_s9y_users as $v) {
             $s9y_users[$v['realname']] = $v;
         }
     }
     /* ************* CATEGORIES **********************/
     $_s9y_cat = serendipity_fetchCategories('all');
     $s9y_cat = array();
     if (is_array($s9y_cat)) {
         foreach ($_s9y_cat as $v) {
             $s9y_cat[$v['category_name']] = $v['categoryid'];
         }
     }
     $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'];
//.........这里部分代码省略.........
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:generic.inc.php


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