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


PHP serendipity_db_insert_id函数代码示例

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


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

示例1: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $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

示例2: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $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

示例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();
     $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

示例4: import

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

示例5: serendipity_insertImageInDatabase

/**
 * Insert a media item in the database
 *
 * @access public
 * @param   string      The filename of the media item
 * @param   string      The path to the media item
 * @param   int         The owner author of the item
 * @param   int         The timestamp of when the media item was inserted
 * @return  int         The new media ID
 */
function serendipity_insertImageInDatabase($filename, $directory, $authorid = 0, $time = NULL, $realname = NULL)
{
    global $serendipity;
    if (is_null($time)) {
        $time = time();
    }
    if (is_null($realname)) {
        $realname = $filename;
    }
    $filepath = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $filename;
    $filesize = @filesize($filepath);
    list($filebase, $extension) = serendipity_parseFileName($filename);
    $thumbpath = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $filebase . '.' . $serendipity['thumbSuffix'] . '.' . $extension;
    $thumbnail = file_exists($thumbpath) ? $serendipity['thumbSuffix'] : '';
    $fdim = @serendipity_getimagesize($filepath, '', $extension);
    $width = $fdim[0];
    $height = $fdim[1];
    $mime = $fdim['mime'];
    $query = sprintf("INSERT INTO {$serendipity['dbPrefix']}images (\n                    name,\n                    extension,\n                    mime,\n                    size,\n                    dimensions_width,\n                    dimensions_height,\n                    thumbnail_name,\n                    date,\n                    authorid,\n                    path,\n                    realname\n                   ) VALUES (\n                    '%s',\n                    '%s',\n                    '%s',\n                    %s,\n                    %s,\n                    %s,\n                    '%s',\n                    %s,\n                    %s,\n                    '%s',\n                    '%s'\n                   )", serendipity_db_escape_string($filebase), serendipity_db_escape_string($extension), serendipity_db_escape_string($mime), (int) $filesize, (int) $width, (int) $height, serendipity_db_escape_string($thumbnail), (int) $time, (int) $authorid, serendipity_db_escape_string($directory), serendipity_db_escape_string($realname));
    $sql = serendipity_db_query($query);
    if (is_string($sql)) {
        echo $query . '<br />';
        echo $sql . '<br />';
    }
    $image_id = serendipity_db_insert_id('images', 'id');
    if ($image_id > 0) {
        return $image_id;
    }
    return 0;
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:40,代码来源:functions_images.inc.php

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

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

示例8: fetchFeeds


//.........这里部分代码省略.........
             if (!empty($ep_id) and serendipity_db_bool($this->get_config('ignore_updates'))) {
                 if ($this->debug) {
                     printf("DEBUG: entry %s is known and ignore_updates is set.\n", $ep_id);
                 }
                 continue;
             }
             # NOTE: If $ep_id is NULL or EMPTY, it means that an entry with this title does not
             #       yet exist. Later on we check if a similar entry with the body exists and skip
             #       updates in this case. Else it means that the new entry needs to be inserted
             #       as a new one.
             # The entry is probably new?
             $entry = array('id' => $ep_id, 'title' => $item['title'], 'timestamp' => $item['date'], 'extended' => '', 'isdraft' => serendipity_db_bool($this->get_config('publishflag')) ? 'false' : 'true', 'allow_comments' => serendipity_db_bool($this->get_config('allow_comments')) ? 'true' : 'false', 'categories' => $feed['categoryids'], 'author' => $feed['feedname'], 'authorid' => $feed_authorid);
             // ----------------------------------------------------------
             //    CLSC: Added a few flavours
             if ($item['content:encoded']) {
                 $entry['body'] = $item['content:encoded'];
             } elseif ($item['description']) {
                 $entry['body'] = $item['description'];
             } elseif ($item['content']['encoded']) {
                 $entry['body'] = $item['content']['encoded'];
             } elseif ($item['atom_content']) {
                 $entry['body'] = $item['atom_content'];
             } elseif ($item['content']) {
                 $entry['body'] = $item['content'];
             }
             $md5hash = md5($feed_authorid . $item['title'] . $entry['body']);
             # Check 1: Have we seen this MD5?
             if ($this->debug) {
                 printf("DEBUG: lookup cache_md5[%s] finds %s.\n", $md5hash, empty($cache_md5[$md5hash]) ? "nothing" : $cache_md5[$md5hash]['entryid']);
             }
             # If we have this md5, title and body for this article
             # are unchanged. We do not need to do anything.
             if (isset($cache_md5[$md5hash])) {
                 continue;
             }
             # Check 2 (conditional: expire enabled?):
             #         Is this article too old?
             if ($this->get_config('expire') > 0) {
                 $expire = time() - 86400 * $this->get_config('expire');
                 if ($item['date'] < $expire) {
                     if ($this->debug) {
                         printf("DEBUG: '%s' is too old (%s < %s).\n", $item['title'], $item['date'], $expire);
                     }
                     continue;
                 }
             }
             # Check 3: Does this article match our expressions?
             if (!empty($feed['match_expression'])) {
                 $expressions = explode("~", $feed['match_expression']);
                 $match = 0;
                 foreach ($expressions as $expression) {
                     $expression = ltrim(rtrim($expression));
                     if (preg_match("~{$expression}~imsU", $entry['title'] . $entry['body'])) {
                         $match = 1;
                     }
                 }
                 if ($match == 0) {
                     continue;
                 }
             }
             $feed['articleurl'] = $item['link'];
             if ($item['author']) {
                 $feed['author'] = $item['author'];
             } elseif ($item['dc:creator']) {
                 $feed['author'] = $item['dc:creator'];
             }
             // Store as property
             // Plugins might need this.
             $serendipity['POST']['properties'] = array('fake' => 'fake');
             $markups = explode('^', $this->get_config('markup'));
             if (is_array($markups)) {
                 foreach ($markups as $markup) {
                     $serendipity['POST']['properties']['disable_markups'][] = $markup;
                 }
             }
             if ($opt['store_seperate']) {
                 if ($entry['id'] > 0) {
                     serendipity_db_query("UPDATE {$serendipity['dbPrefix']}aggregator_feedlist \n                        SET feedid      = '" . $feed['feedid'] . "',\n                            categoryid  = '" . $feed['categoryids'][0] . "',\n                            entrydate   = '" . serendipity_db_escape_string($entry['timestamp']) . "',\n                            entrytitle  = '" . serendipity_db_escape_string($entry['title']) . "',\n                            entrybody   = '" . serendipity_db_escape_string($entry['body']) . "',\n                            entryurl    = '" . serendipity_db_escape_string($item['link']) . "'\n                        WHERE id = " . $entry['id']);
                     $entryid = $entry['id'];
                 } else {
                     serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}aggregator_feedlist (\n                            feedid,\n                            categoryid,\n                            entrydate,\n                            entrytitle,\n                            entrybody,\n                            entryurl\n                        ) VALUES (\n                            '" . $feed['feedid'] . "',\n                            '" . $feed['categoryids'][0] . "',\n                            '" . serendipity_db_escape_string($entry['timestamp']) . "',\n                            '" . serendipity_db_escape_string($entry['title']) . "',\n                            '" . serendipity_db_escape_string($entry['body']) . "',\n                            '" . serendipity_db_escape_string($item['link']) . "'\n                        )");
                     $entryid = serendipity_db_insert_id();
                 }
                 $this->feedupdate_finish($feed, $entryid);
             } else {
                 $entryid = serendipity_updertEntry($entry);
                 $this->insertProperties($entryid, $feed, $md5hash);
             }
             if (!$opt['store_seperate']) {
                 printf(" Save '%s' as %s.\n", $item['title'], $entryid);
             }
         }
         if (!$opt['store_seperate']) {
             printf("Finish feed.\n");
         }
     }
     if (!$opt['store_seperate']) {
         printf("Finish planetarium.\n");
     }
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:101,代码来源:serendipity_event_aggregator.php

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

示例10: import

 function import()
 {
     global $serendipity;
     // Save this so we can return it to its original value at the end of this method.
     $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
     if ($this->data['autodiscovery'] == 'false') {
         $serendipity['noautodiscovery'] = 1;
     }
     $this->getTransTable();
     $this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
     $users = array();
     $entries = array();
     if (!extension_loaded('mysql')) {
         return MYSQL_REQUIRED;
     }
     $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

示例11: shownotes

    function shownotes()
    {
        global $serendipity;
        if ($serendipity['version'][0] < 2) {
            echo '<h3>' . PLUGIN_ADMINNOTES_TITLE . '</h3>';
        } else {
            echo '<h2>' . PLUGIN_ADMINNOTES_TITLE . '</h2>';
        }
        if (!serendipity_db_bool($this->get_config('feedback')) && $serendipity['serendipityUserlevel'] < USERLEVEL_CHIEF) {
            return false;
        }
        switch ($_REQUEST['action']) {
            case 'edit':
                $entry = $this->getMyNotes((int) $_REQUEST['note']);
                $mode = 'update';
            case 'new':
                if (!isset($mode)) {
                    $mode = 'insert';
                }
                if (!is_array($entry)) {
                    $entry = array();
                }
                if ($_REQUEST['submit']) {
                    $valid_groups = serendipity_getAllGroups($serendipity['authorid']);
                    $targets = array();
                    if (is_array($_REQUEST['note_target'])) {
                        foreach ($_REQUEST['note_target'] as $groupid) {
                            $found = false;
                            foreach ($valid_groups as $group) {
                                if ($group['confkey'] == $groupid) {
                                    $found = true;
                                    break;
                                }
                            }
                            if ($found) {
                                $targets[] = (int) $groupid;
                            }
                        }
                    }
                    if ($mode == 'update') {
                        $noteid = (int) $_REQUEST['note'];
                        $q = serendipity_db_query("UPDATE {$serendipity['dbPrefix']}adminnotes\n                                                 SET authorid = {$serendipity['authorid']},\n                                                     subject = '" . serendipity_db_escape_string($_REQUEST['note_subject']) . "',\n                                                     body = '" . serendipity_db_escape_string($_REQUEST['note_body']) . "',\n                                                     notetype = '" . serendipity_db_escape_string($_REQUEST['note_notetype']) . "'\n                                               WHERE noteid = {$noteid}");
                        $q = serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}adminnotes_to_groups WHERE noteid = {$noteid}");
                        foreach ($targets as $target) {
                            $q = serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}adminnotes_to_groups (noteid, groupid) VALUES ({$noteid}, {$target})");
                        }
                        if (is_string($q)) {
                            echo $q . "<br />\n";
                        }
                    } else {
                        serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}adminnotes (authorid, notetime, subject, body, notetype) VALUES ('" . $serendipity['authorid'] . "', " . time() . ", '" . serendipity_db_escape_string($_REQUEST['note_subject']) . "', '" . serendipity_db_escape_string($_REQUEST['note_body']) . "', '" . serendipity_db_escape_string($_REQUEST['note_notetype']) . "')");
                        $noteid = serendipity_db_insert_id('adminnotes', 'noteid');
                        foreach ($targets as $target) {
                            serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}adminnotes_to_groups (noteid, groupid) VALUES ({$noteid}, {$target})");
                        }
                    }
                    if ($serendipity['version'][0] < 2) {
                        echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>';
                    } else {
                        echo '<span class="msg_success"><span class="icon-ok-circled"></span> ' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</span>';
                    }
                }
                echo '<p>' . PLUGIN_ADMINNOTES_FEEDBACK_INFO . '</p>';
                echo '<form action="?" method="post">';
                echo serendipity_setFormToken();
                echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />';
                echo '<input type="hidden" name="serendipity[adminAction]" value="adminnotes" />';
                echo '<input type="hidden" name="action" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($_REQUEST['action']) : htmlspecialchars($_REQUEST['action'], ENT_COMPAT, LANG_CHARSET)) . '" />';
                echo '<input type="hidden" name="note" value="' . $entry['noteid'] . '" />';
                echo '<input type="hidden" name="note_notetype" value="note" />';
                if ($serendipity['version'][0] < 2) {
                    echo TITLE . '<br />';
                    echo '<input class="input_textbox" type="text" name="note_subject" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['subject']) : htmlspecialchars($entry['subject'], ENT_COMPAT, LANG_CHARSET)) . '" /><br /><br />';
                } else {
                    echo '<div class="form_field">';
                    echo '<label for="note_subject" class="block_level">' . TITLE . '</label>';
                    echo '<input id="note_subject" type="text" name="note_subject" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['subject']) : htmlspecialchars($entry['subject'], ENT_COMPAT, LANG_CHARSET)) . '">';
                    echo '</div>';
                }
                if ($serendipity['version'][0] < 2) {
                    echo USERCONF_GROUPS . '<br />';
                } else {
                    echo '<div class="form_multiselect">';
                    echo '<label for="note_target" class="block_level">' . USERCONF_GROUPS . '</label>';
                }
                $valid_groups = serendipity_getAllGroups($serendipity['authorid']);
                if (isset($_REQUEST['note_target'])) {
                    $selected = $_REQUEST['note_target'];
                } elseif ($mode == 'update') {
                    $sql = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}adminnotes_to_groups");
                    $selected = array();
                    foreach ($sql as $row) {
                        $selected[] = $row['groupid'];
                    }
                }
                echo '<select id="note_target" name="note_target[]" multiple="multiple" size="5">';
                foreach ($valid_groups as $group) {
                    # PRESELECT!
                    if (in_array($group['confkey'], (array) $selected) || count($selected) == 0) {
                        $is_selected = 'selected="selected"';
//.........这里部分代码省略.........
开发者ID:sqall01,项目名称:additional_plugins,代码行数:101,代码来源:serendipity_event_adminnotes.php

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

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

示例14: COUNT

 function &updateCategory()
 {
     global $serendipity;
     if (!is_numeric($this->category['id'])) {
         $q = 'SELECT COUNT(id) AS counter
                 FROM ' . $serendipity['dbPrefix'] . 'faq_categorys
                WHERE parent_id = ' . $this->category['parent_id'];
         $res = serendipity_db_query($q, true, 'assoc');
         $this->category['catorder'] = $res['counter'] + 1;
         $this->postgreCategoryPrepare();
         $result = serendipity_db_insert('faq_categorys', $this->category);
         $serendipity['POST']['cid'] = serendipity_db_insert_id('faq_categorys', 'id');
     } else {
         $result = serendipity_db_update('faq_categorys', array('id' => $this->category['id']), $this->category);
     }
     return $result;
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:17,代码来源:serendipity_event_faq.php

示例15: serendipity_handle_references


//.........这里部分代码省略.........
                $serendipity['logger']->debug("Found reference {$locations[$i]} w/o name. Adding location as name");
            }
            $names[$i] = $locations[$i];
        }
        if ($row[0] > 0 && isset($saved_references[$locations[$i] . $names[$i]])) {
            if (is_object($serendipity['logger'])) {
                $serendipity['logger']->debug("Found references for {$id}, skipping rest");
            }
            continue;
        }
        if (!isset($serendipity['noautodiscovery']) || !$serendipity['noautodiscovery']) {
            if (!$dry_run) {
                if (!isset($saved_urls[$locations[$i]])) {
                    if (is_object($serendipity['logger'])) {
                        $serendipity['logger']->debug("Enabling autodiscovery");
                    }
                    serendipity_reference_autodiscover($locations[$i], $url, $author, $title, serendipity_trackback_excerpt($text));
                } else {
                    if (is_object($serendipity['logger'])) {
                        $serendipity['logger']->debug("This reference was already used before in {$id} and therefore will not be trackbacked again");
                    }
                }
            } else {
                if (is_object($serendipity['logger'])) {
                    $serendipity['logger']->debug("Dry run: Skipping autodiscovery");
                }
            }
            $checked_locations[$locations[$i]] = true;
            // Store trackbacked link so that no further trackbacks will be sent to the same link
        } else {
            if (is_object($serendipity['logger'])) {
                $serendipity['logger']->debug("Skipping full autodiscovery");
            }
        }
    }
    $del = serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}references WHERE entry_id=" . (int) $id . " AND (type = '' OR type IS NULL)");
    if (is_string($del)) {
        if (is_object($serendipity['logger'])) {
            $serendipity['logger']->debug($del);
        }
    }
    if (is_object($serendipity['logger'])) {
        $serendipity['logger']->debug("Deleted references again");
    }
    if (!is_array($old_references)) {
        $old_references = array();
    }
    $duplicate_check = array();
    for ($i = 0; $i < $j; ++$i) {
        $i_link = serendipity_db_escape_string(strip_tags($names[$i]));
        $i_location = serendipity_db_escape_string($locations[$i]);
        // No link with same description AND same text should be inserted.
        if (isset($duplicate_check[$i_location . $i_link])) {
            continue;
        }
        if (isset($current_references[$locations[$i] . $names[$i]])) {
            $query = "INSERT INTO {$serendipity['dbPrefix']}references (id, entry_id, name, link) VALUES(";
            $query .= (int) $current_references[$locations[$i] . $names[$i]]['id'] . ", " . (int) $id . ", '" . $i_link . "', '" . $i_location . "')";
            $ins = serendipity_db_query($query);
            if (is_string($ins)) {
                if (is_object($serendipity['logger'])) {
                    $serendipity['logger']->debug($ins);
                }
            }
            $duplicate_check[$locations[$i] . $names[$i]] = true;
        } else {
            $query = "INSERT INTO {$serendipity['dbPrefix']}references (entry_id, name, link) VALUES(";
            $query .= (int) $id . ", '" . $i_link . "', '" . $i_location . "')";
            $ins = serendipity_db_query($query);
            if (is_string($ins)) {
                if (is_object($serendipity['logger'])) {
                    $serendipity['logger']->debug($ins);
                }
            }
            $old_references[] = array('id' => serendipity_db_insert_id('references', 'id'), 'name' => $i_link, 'link' => $i_location, 'entry_id' => (int) $id);
            $duplicate_check[$i_location . $i_link] = true;
        }
        if (is_object($serendipity['logger'])) {
            $serendipity['logger']->debug("Current lookup for {$locations[$i]}{$names[$i]} is" . print_r($current_references[$locations[$i] . $names[$i]], true));
        }
        if (is_object($serendipity['logger'])) {
            $serendipity['logger']->debug($query);
        }
    }
    if (is_object($serendipity['logger'])) {
        $serendipity['logger']->debug(print_r($old_references, true));
    }
    // Add citations
    preg_match_all('@<cite[^>]*>([^<]+)</cite>@i', $text, $matches);
    foreach ($matches[1] as $citation) {
        $query = "INSERT INTO {$serendipity['dbPrefix']}references (entry_id, name) VALUES(";
        $query .= (int) $id . ", '" . serendipity_db_escape_string($citation) . "')";
        $cite = serendipity_db_query($query);
        if (is_string($cite)) {
            if (is_object($serendipity['logger'])) {
                $serendipity['logger']->debug($cite);
            }
        }
    }
}
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:101,代码来源:functions_trackbacks.inc.php


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