本文整理汇总了PHP中serendipity_updertEntry函数的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_updertEntry函数的具体用法?PHP serendipity_updertEntry怎么用?PHP serendipity_updertEntry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serendipity_updertEntry函数的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);
//.........这里部分代码省略.........
示例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'])) {
//.........这里部分代码省略.........
示例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) {
//.........这里部分代码省略.........
示例4: serendipity_iframe
/**
* Prints the content of the iframe.
*
* Called by serendipity_is_iframe, when preview is requested. Fetches data from session.
* An iframe is used so that a single s9y page must not timeout on intensive operations,
* and so that the frontend stylesheet can be embedded without screwing up the backend.
*
* @access private
* @see serendipity_is_iframe()
* @param mixed The entry array (comes from session variable)
* @param string Indicates whether an entry is previewed or saved. Save performs XML-RPC calls.
* @param boolean Use smarty templating?
* @return boolean Indicates whether iframe data was printed
*/
function serendipity_iframe(&$entry, $mode = null)
{
global $serendipity;
if (empty($mode) || !is_array($entry)) {
return false;
}
$data = array();
$data['is_preview'] = true;
$data['mode'] = $mode;
switch ($mode) {
case 'save':
ob_start();
$res = serendipity_updertEntry($entry);
$data['updertHooks'] = ob_get_contents();
ob_end_clean();
if (is_string($res)) {
$data['res'] = $res;
}
if (!empty($serendipity['lastSavedEntry'])) {
$data['lastSavedEntry'] = $serendipity['lastSavedEntry'];
}
$data['entrylink'] = serendipity_archiveURL($res, $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
break;
case 'preview':
$serendipity['smarty_preview'] = true;
$data['preview'] = serendipity_printEntries(array($entry), $entry['extended'] != '' ? 1 : 0, true);
break;
}
return serendipity_smarty_show('preview_iframe.tpl', $data);
}
示例5: phoneblogz_post
function phoneblogz_post($postid, $pbuserno)
{
// Firstly try and download the file
$url = "http://www.phoneblogz.com/listen.php?user=" . $this->get_config("phoneblogz_accesscode") . "&id={$postid}";
$upload = $this->phoneblogz_upload_fromurl("pbpost.mp3", "", $url);
if (!isset($upload["error"])) {
// Deal with the local username
$localuserid = $this->get_config("phoneblogz_usermap_{$pbuserno}");
if ($localuserid === FALSE || $localuserid < 1) {
$localuserid = 1;
}
// Default to the admin user
// Get the local username for this user
$localuser = serendipity_fetchUsers($localuserid);
$localusername = $localuser[0]["realname"];
// Attempt to create a new post
$post_content = $this->get_config("phoneblogz_text");
$post_content = str_replace("[FLASH]", $this->phoneblogz_flash($upload["url"]), $post_content);
$post_content = str_replace("[USER]", $localusername, $post_content);
$first = strpos($post_content, "[");
$second = strpos($post_content, "]");
if ($first !== FALSE && $second !== FALSE && $second > $first) {
$link = "<a href=\"" . $upload["url"] . "\">";
$link .= substr($post_content, $first + 1, $second - $first - 1);
$link .= "</a>";
$post_content = substr($post_content, 0, $first) . $link . substr($post_content, $second + 1);
}
$oldsess = $_SESSION['serendipityRightPublish'];
$_SESSION['serendipityRightPublish'] = true;
$entry = array('body' => $post_content, 'title' => str_replace("[USER]", $localusername, $this->get_config('phoneblogz_subject')), 'timestamp' => time(), 'isdraft' => 'false', 'allow_comments' => true, 'authorid' => $localuserid, 'categories' => array($this->get_config('categoryid')));
$GLOBALS['serendipity']['POST']['properties'] = array('fake' => 'fake');
$post_ID = serendipity_updertEntry($entry);
$_SESSION['serendipityRightPublish'] = $oldsess;
$this->set_config("phoneblogz_status_{$postid}", $post_ID);
return array("postid" => $post_ID);
} else {
return array("error" => "Failed to upload the file. Exact error: " . $upload["error"]);
}
}
示例6: import
function import()
{
global $serendipity;
// Save this so we can return it to its original value at the end of this method.
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
if ($this->data['autodiscovery'] == 'false') {
$serendipity['noautodiscovery'] = 1;
}
$this->getTransTable();
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
$users = array();
$entries = array();
if (!extension_loaded('mysqli')) {
return MYSQL_REQUIRED;
}
$gdb = @mysqli_connect($this->data['host'], $this->data['user'], $this->data['pass']);
if (!$gdb || mysqli_connect_error()) {
return sprintf(COULDNT_CONNECT, serendipity_specialchars($this->data['host']));
}
if (!@mysqli_select_db($gdb, $this->data['name'])) {
return sprintf(COULDNT_SELECT_DB, mysqli_error($gdb));
}
/* Users */
$res = @$this->nativeQuery("SELECT user_id AS ID,\n username AS user_login,\n user_password AS user_pass,\n user_email AS user_email,\n user_website AS user_url,\n user_level\n FROM {$this->data['prefix']}users\n WHERE user_active = 1", $gdb);
if (!$res) {
return sprintf(COULDNT_SELECT_USER_INFO, mysqli_error($gdb));
}
for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
$users[$x] = mysqli_fetch_assoc($res);
$data = array('right_publish' => 1, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'userlevel' => $users[$x]['user_level'] == 0 ? USERLEVEL_EDITOR : USERLEVEL_ADMIN, 'password' => $users[$x]['user_pass']);
// MD5 compatible
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
$data['userlevel'] = $serendipity['serendipityUserlevel'];
}
serendipity_db_insert('authors', $this->strtrRecursive($data));
echo mysqli_error();
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
}
/* Categories */
$res = @$this->nativeQuery("SELECT cat_id AS cat_ID, \n cat_title AS cat_name \n FROM {$this->data['prefix']}categories", $gdb);
if (!$res) {
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysqli_error($gdb));
}
// Get all the info we need
for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
$parent_categories[] = mysqli_fetch_assoc($res);
}
for ($x = 0, $max_x = sizeof($parent_categories); $x < $max_x; $x++) {
$cat = array('category_name' => $parent_categories[$x]['cat_name'], 'category_description' => '', 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
serendipity_db_insert('category', $this->strtrRecursive($cat));
$parent_categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
}
/* Categories */
$res = @$this->nativeQuery("SELECT forum_id AS cat_ID,\n cat_id AS parent_cat_id, \n forum_name AS cat_name, \n forum_desc AS category_description \n FROM {$this->data['prefix']}forums ORDER BY forum_order;", $gdb);
if (!$res) {
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysqli_error($gdb));
}
// Get all the info we need
for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
$categories[] = mysqli_fetch_assoc($res);
}
// Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
for ($x = 0, $max_x = sizeof($categories); $x < $max_x; $x++) {
$pcatid = 0;
foreach ($parent_categories as $pcat) {
if ($pcat['cat_ID'] == $categories[$x]['parent_cat_id']) {
$pcatid = $pcat['cat_ID'];
break;
}
}
$cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => $pcatid, 'category_left' => 0, 'category_right' => 0);
serendipity_db_insert('category', $this->strtrRecursive($cat));
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
}
serendipity_rebuildCategoryTree();
/* Entries */
$res = @$this->nativeQuery("SELECT t.topic_title, \n t.topic_poster,\n t.forum_id,\n p.post_time,\n pt.post_subject,\n pt.post_text,\n count(p.topic_id) AS ccount,\n p.topic_id,\n MIN(p.post_id) AS post_id\n FROM {$this->data['prefix']}topics AS t\n LEFT OUTER JOIN {$this->data['prefix']}posts AS p\n ON t.topic_id = p.topic_id\n LEFT OUTER JOIN {$this->data['prefix']}posts_text AS pt\n ON pt.post_id = p.post_id\n GROUP BY p.topic_id\n ", $gdb);
if (!$res) {
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysqli_error($gdb));
}
for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
$entries[$x] = mysqli_fetch_assoc($res);
$entry = array('title' => $this->decode($entries[$x]['post_subject']), 'isdraft' => 'false', 'allow_comments' => 'true', 'timestamp' => $entries[$x]['post_time'], 'body' => $this->strtr($entries[$x]['post_text']), 'extended' => '');
$entry['authorid'] = '';
$entry['author'] = '';
foreach ($users as $user) {
if ($user['ID'] == $entries[$x]['topic_poster']) {
$entry['authorid'] = $user['authorid'];
$entry['author'] = $user['user_login'];
break;
}
}
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
return $entries[$x]['entryid'];
}
/* Entry/category */
foreach ($categories as $category) {
if ($category['cat_ID'] == $entries[$x]['forum_id']) {
$data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
//.........这里部分代码省略.........
示例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) {
//.........这里部分代码省略.........
示例8: import
function import()
{
global $serendipity;
if (!file_exists($this->data['url'])) {
printf(FILE_NOT_FOUND, htmlspecialchars($this->data['url']));
return false;
}
$file = file_get_contents($this->data['url']);
$tree =& $this->parseXML($file);
$serendipity['noautodiscovery'] = 1;
foreach ($tree[0]['children'] as $idx => $entry) {
if (!is_array($entry)) {
continue;
}
if ($entry['tag'] != 'entry') {
continue;
}
$new_entry = array('allow_comments' => true, 'extended' => '', 'categories' => array(), 'isdraft' => $this->data['type'] == 'draft' ? 'true' : 'false', 'categories' => array($this->data['category'] => $this->data['category']));
if (!is_array($entry['children'])) {
continue;
}
foreach ($entry['children'] as $idx2 => $entrydata) {
if (!is_array($entrydata)) {
continue;
}
switch ($entrydata['tag']) {
case 'eventtime':
$new_entry['timestamp'] = $this->getTimestamp($entrydata['value']);
break;
case 'date':
$new_entry['timestamp'] = $this->getTimestamp($entrydata['value']);
break;
case 'subject':
$new_entry['title'] = $entrydata['value'];
break;
case 'event':
$new_entry['body'] = $entrydata['value'];
break;
case 'comments':
$new_entry['comments'] = $this->gatherComments($entrydata);
break;
}
}
$id = serendipity_updertEntry($new_entry);
echo 'Inserted entry #' . $id . ', "' . htmlspecialchars($new_entry['title']) . '"<br />' . "\n";
if (is_array($new_entry['comments'])) {
$cid_map = array();
$jids = array();
foreach ($new_entry['comments'] as $comment) {
array_push($jids, $comment['jtalkid']);
if (array_key_exists($comment['jparentid'], $cid_map)) {
$comment['parent_id'] = $cid_map[$comment['jparentid']];
}
$cid = serendipity_insertComment($id, $comment);
$cid_map[$comment['jtalkid']] = $cid;
}
echo 'Inserted comments for entry #' . $id . '<br />' . "\n";
}
if (function_exists('ob_flush')) {
@ob_flush();
}
if (function_exists('flush')) {
@flush();
}
}
return true;
}
示例9: 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");
}
}
示例10: serendipity_serverOffsetHour
}
}
// Save server timezone in database always, so substract the offset we added for display; otherwise it would be added time and again
if (!empty($entry['timestamp'])) {
$entry['timestamp'] = serendipity_serverOffsetHour($entry['timestamp'], true);
}
// Save the entry, or just display a preview
$data['use_legacy'] = $use_legacy = true;
serendipity_plugin_api::hook_event('backend_entry_iframe', $use_legacy);
if ($use_legacy) {
$data['switched_output'] = true;
if ($serendipity['POST']['preview'] != 'true') {
/* We don't need an iframe to save a draft */
if ($serendipity['POST']['isdraft'] == 'true') {
$data['is_draft'] = true;
$errors = serendipity_updertEntry($entry);
if (is_numeric($errors)) {
$errors = "";
}
} else {
if ($serendipity['use_iframe']) {
$data['is_iframe'] = true;
$data['iframe'] = serendipity_iframe_create('save', $entry);
} else {
$data['iframe'] = serendipity_iframe($entry, 'save');
}
}
} else {
// Only display the preview
$serendipity['hidefooter'] = true;
// Advanced templates use this to show update status and elapsed time
示例11: 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));
//.........这里部分代码省略.........
示例12: displayTagUpdate
/**
* Backend Administration Method (7): Rebuild entry auto-keyword tags
*
* @see displayManageTags() case 7
*/
function displayTagUpdate()
{
global $serendipity;
$limit = 25;
$page = isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1;
$from = ($page - 1) * $limit;
$to = $page * $limit;
if ($serendipity['version'][0] > 1) {
echo '<h3>';
}
printf(PLUGIN_EVENT_FREETAG_REBUILD_FETCHNO, $from, $to);
$entries = serendipity_fetchEntries(null, true, $limit, false, false, 'timestamp DESC', '', true);
$total = serendipity_getTotalEntries();
if ($serendipity['version'][0] < 2) {
printf(PLUGIN_EVENT_FREETAG_REBUILD_TOTAL . '<br />', $total);
} else {
printf(PLUGIN_EVENT_FREETAG_REBUILD_TOTAL, $total);
echo '</h3>';
}
if (is_array($entries)) {
if ($serendipity['version'][0] > 1) {
echo '<ul class="plainList">' . "\n";
}
foreach ($entries as $entry) {
unset($entry['orderkey']);
unset($entry['loginname']);
unset($entry['email']);
if ($serendipity['version'][0] < 2) {
printf('%d - "%s"<br />', $entry['id'], self::specialchars_mapper($entry['title']));
} else {
printf(' <li>%d - "%s"', $entry['id'], self::specialchars_mapper($entry['title']));
}
$serendipity['POST']['properties']['fake'] = 'fake';
$current_cat = $entry['categories'];
$entry['categories'] = array();
foreach ($current_cat as $categoryidx => $category_data) {
$entry['categories'][$category_data['categoryid']] = $category_data['categoryid'];
}
$up = serendipity_updertEntry($entry);
if (is_string($up)) {
echo "<div>{$up}</div>\n";
}
if ($serendipity['version'][0] < 2) {
echo DONE . "<br />\n";
} else {
echo ' ... ' . DONE . "</li>\n";
}
}
if ($serendipity['version'][0] > 1) {
echo "</ul>\n";
}
}
if ($serendipity['version'][0] < 2) {
echo '<br />';
}
if ($to < $total) {
?>
<script type="text/javascript">
if (confirm("<?php
echo htmlspecialchars(PLUGIN_EVENT_FREETAG_REBUILD_FETCHNEXT, ENT_COMPAT, LANG_CHARSET);
?>
")) {
location.href = "?serendipity[adminModule]=event_display&serendipity[adminAction]=managetags&serendipity[tagview]=tagupdate&serendipity[page]=<?php
echo (int) ($page + 1);
?>
";
} else {
alert("<?php
echo DONE;
?>
");
}
</script>
<?php
} else {
if ($serendipity['version'][0] < 2) {
echo '<div class="serendipity_msg_notice">' . DONE . '</div>';
} else {
echo '<span class="msg_notice"><span class="icon-info-circled"></span>' . DONE . "</span>\n";
}
}
}
示例13: import
function import()
{
global $serendipity;
// Save this so we can return it to its original value at the end of this method.
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
if ($this->data['autodiscovery'] == 'false') {
$serendipity['noautodiscovery'] = 1;
}
$this->getTransTable();
$users = array();
$entries = array();
if (!extension_loaded('mysql')) {
return MYSQL_REQUIRED;
}
$nukedb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
if (!$nukedb) {
return sprintf(COULDNT_CONNECT, $this->data['host']);
}
if (!@mysql_select_db($this->data['name'])) {
return sprintf(COULDNT_SELECT_DB, mysql_error($nukedb));
}
/* Users: Authors */
$res = @$this->nativeQuery("SELECT\n aid AS user_login,\n `pwd` AS user_pass,\n email AS user_email,\n name AS user_name,\n radminsuper AS user_level,\n aid AS ID\n FROM nuke_authors", $nukedb);
if (!$res) {
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($nukedb));
}
for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
$users[$x] = mysql_fetch_assoc($res);
$data = array('right_publish' => true, 'realname' => $users[$x]['user_name'], 'username' => $users[$x]['user_login'], 'userlevel' => $users[$x]['user_level'] > 0 ? USERLEVEL_ADMIN : USERLEVEL_EDITOR, 'email' => $users[$x]['user_email'], 'password' => md5($users[$x]['user_pass']));
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
$data['userlevel'] = $serendipity['serendipityUserlevel'];
}
serendipity_db_insert('authors', $this->strtrRecursive($data));
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
}
/* Users: Users */
$res = @$this->nativeQuery("SELECT\n u.uname AS user_login,\n u.pass AS user_pass,\n u.email AS user_email,\n u.name AS user_name,\n s.user_level AS user_level,\n uname AS ID\n FROM nuke_users AS u\n JOIN nuke_users_status AS s\n ON u.uid = s.user_id\n ", $nukedb);
if (!$res) {
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($nukedb));
}
for ($x = $x, $max_x = $x + mysql_num_rows($res); $x < $max_x; $x++) {
$users[$x] = mysql_fetch_assoc($res);
if (empty($users[$x]['user_name'])) {
$users[$x]['user_name'] = $users[$x]['user_login'];
}
$data = array('right_publish' => true, 'realname' => $users[$x]['user_name'], 'username' => $users[$x]['user_login'], 'userlevel' => $users[$x]['user_level'] > 1 ? USERLEVEL_ADMIN : USERLEVEL_EDITOR, 'email' => $users[$x]['user_email'], 'password' => md5($users[$x]['user_pass']));
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
$data['userlevel'] = $serendipity['serendipityUserlevel'];
}
serendipity_db_insert('authors', $this->strtrRecursive($data));
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
}
/* Categories */
if (!$this->importCategories($nukedb)) {
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($nukedb));
}
serendipity_rebuildCategoryTree();
/* Entries */
$res = @$this->nativeQuery("SELECT\n sid AS ID,\n UNIX_TIMESTAMP(`time`) AS tstamp,\n aid AS post_author,\n informant AS informant,\n \n title AS post_title,\n hometext AS post_content,\n bodytext AS extended\n FROM nuke_stories", $nukedb);
if (!$res) {
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($nukedb));
}
for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
$entries[$x] = mysql_fetch_assoc($res);
if (!empty($entries[$x]['informant'])) {
$entries[$x]['post_author'] = $entries[$x]['informant'];
}
$entry = array('title' => $this->decode($entries[$x]['post_title']), 'isdraft' => 'false', 'allow_comments' => 'true', 'timestamp' => $entries[$x]['tstamp'], 'body' => $this->strtr($entries[$x]['post_content']), 'extended' => $this->strtr($entries[$x]['extended']));
$entry['authorid'] = '';
$entry['author'] = '';
foreach ($users as $user) {
if ($user['ID'] == $entries[$x]['post_author']) {
$entry['authorid'] = $user['authorid'];
$entry['author'] = $user['user_login'];
break;
}
}
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
return $entries[$x]['entryid'];
}
}
/* Even more category stuff */
$res = @$this->nativeQuery("SELECT sid AS postcat_post_ID,\n topic AS postcat_cat_ID\n FROM nuke_stories", $nukedb);
if (!$res) {
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($nukedb));
}
for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
$entrycat = mysql_fetch_assoc($res);
$entryid = 0;
$categoryid = 0;
foreach ($entries as $entry) {
if ($entry['ID'] == $entrycat['postcat_post_ID']) {
$entryid = $entry['entryid'];
break;
}
}
foreach ($this->categories as $category) {
if ($category['cat_ID'] == $entrycat['postcat_cat_ID']) {
$categoryid = $category['categoryid'];
}
//.........这里部分代码省略.........
示例14: import
function import()
{
global $serendipity;
if (serendipity_db_bool($this->data['wpxrss'])) {
return $this->import_wpxrss();
}
$c = new Onyx_RSS($this->data['charset']);
$c->parse($this->data['url']);
$this->data['encoding'] = $c->rss['encoding'];
$serendipity['noautodiscovery'] = 1;
while ($item = $c->getNextItem()) {
$entry = array();
if ($this->buildEntry($item, $entry)) {
serendipity_updertEntry($entry);
}
}
return true;
}
示例15: import
function import()
{
global $serendipity;
// Save this so we can return it to its original value at the end of this method.
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
if ($this->data['autodiscovery'] == 'false') {
$serendipity['noautodiscovery'] = 1;
}
$this->getTransTable();
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
$users = array();
$entries = array();
if (!extension_loaded('mysql')) {
return MYSQL_REQUIRED;
}
$txpdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
if (!$txpdb) {
return sprintf(COULDNT_CONNECT, $this->data['host']);
}
if (!@mysql_select_db($this->data['name'])) {
return sprintf(COULDNT_SELECT_DB, mysql_error($txpdb));
}
/* Users */
$res = @$this->nativeQuery("SELECT user_id AS ID,\n name AS user_login,\n `pass` AS user_pass,\n email AS user_email,\n privs AS user_level\n FROM {$this->data['prefix']}txp_users", $txpdb);
if (!$res) {
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($txpdb));
}
for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
$users[$x] = mysql_fetch_assoc($res);
$data = array('right_publish' => $users[$x]['user_level'] <= 4 ? 1 : 0, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'password' => md5('txp'));
// blame TXP for using PASSWORD().
if ($users[$x]['user_level'] == 1) {
$data['userlevel'] = USERLEVEL_EDITOR;
} elseif ($users[$x]['user_level'] == 2) {
$data['userlevel'] = USERLEVEL_CHIEF;
} else {
$data['userlevel'] = USERLEVEL_ADMIN;
}
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
$data['userlevel'] = $serendipity['serendipityUserlevel'];
}
serendipity_db_insert('authors', $this->strtrRecursive($data));
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
}
/* Categories */
if (!$this->importCategories('root', 0, $txpdb)) {
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($txpdb));
}
serendipity_rebuildCategoryTree();
/* Entries */
// Notice: Textpattern doesn't honor the prefix for this table. Wicked system.
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}textpattern ORDER BY Posted;", $txpdb);
if (!$res) {
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($txpdb));
}
for ($x = 0, $max_x = mysql_num_rows($res); $x < $max_x; $x++) {
$entries[$x] = mysql_fetch_assoc($res);
$entry = array('title' => $this->decode($entries[$x]['Title']), 'isdraft' => $entries[$x]['Status'] == '4' ? 'false' : 'true', 'allow_comments' => $entries[$x]['Annotate'] == '1' ? 'true' : 'false', 'timestamp' => strtotime($entries[$x]['Posted']), 'extended' => $this->strtr($entries[$x]['Body_html']), 'body' => $this->strtr($entries[$x]['Excerpt']));
$entry['authorid'] = '';
$entry['author'] = '';
foreach ($users as $user) {
if ($user['user_login'] == $entries[$x]['AuthorID']) {
$entry['authorid'] = $user['authorid'];
$entry['author'] = $user['user_login'];
break;
}
}
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
return $entries[$x]['entryid'];
}
/* Entry/category */
foreach ($this->categories as $category) {
if ($category['name'] == $entries[$x]['Category1'] || $category['name'] == $entries[$x]['Category2']) {
$data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
break;
}
}
}
/* Comments */
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}txp_discuss;", $txpdb);
if (!$res) {
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($txpdb));
}
while ($a = mysql_fetch_assoc($res)) {
foreach ($entries as $entry) {
if ($entry['ID'] == $a['parentid']) {
$author = $a['name'];
$mail = $a['email'];
$url = $a['web'];
$comment = array('entry_id ' => $entry['entryid'], 'parent_id' => 0, 'timestamp' => strtotime($a['posted']), 'author' => $author, 'email' => $mail, 'url' => $url, 'ip' => $a['ip'], 'status' => $a['visible'] == '1' ? 'approved' : 'pending', 'body' => $a['message'], 'subscribed' => 'false', 'type' => 'NORMAL');
serendipity_db_insert('comments', $this->strtrRecursive($comment));
if ($a['visible'] == '1') {
$cid = serendipity_db_insert_id('comments', 'id');
serendipity_approveComment($cid, $entry['entryid'], true);
}
}
}
}
$serendipity['noautodiscovery'] = $noautodiscovery;
//.........这里部分代码省略.........