diff --git a/include/admin/category.inc.php b/include/admin/category.inc.php index 828d6a89..eb74e1fe 100644 --- a/include/admin/category.inc.php +++ b/include/admin/category.inc.php @@ -1,4 +1,4 @@ - $serendipity['GET']['id'] ); } - + $target_url = '?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=doReply&serendipity[id]=' . (int)$serendipity['GET']['id'] . '&serendipity[entry_id]=' . (int)$serendipity['GET']['entry_id'] . '&serendipity[noBanner]=true&serendipity[noSidebar]=true&' . serendipity_setFormToken('url'); $codata = $serendipity['POST']; $codata['replyTo'] = (int)$serendipity['GET']['id']; $out = serendipity_printComments($c); $serendipity['smarty']->display(serendipity_getTemplateFile('comments.tpl', 'serendipityPath')); - + if (!isset($codata['name'])) { $codata['name'] = $serendipity['serendipityRealname']; } @@ -158,7 +158,7 @@ if (isset($serendipity['GET']['adminAction']) && ($serendipity['GET']['adminActi $codata['url'] = $comment[0]['url']; $codata['replyTo'] = $comment[0]['parent_id']; $codata['comment'] = $comment[0]['body']; - + /* If we are in preview, we get comment data from our form */ } elseif (isset($serendipity['POST']['preview'])) { $codata['name'] = $serendipity['POST']['name']; @@ -175,7 +175,7 @@ if (isset($serendipity['GET']['adminAction']) && ($serendipity['GET']['adminActi 'timestamp' => time() ) ); - + serendipity_printComments($pc_data); $serendipity['smarty']->display(serendipity_getTemplateFile('comments.tpl', 'serendipityPath')); } @@ -185,7 +185,7 @@ if (isset($serendipity['GET']['adminAction']) && ($serendipity['GET']['adminActi substr($codata['url'], 0, 8) != 'https://') { $codata['url'] = 'http://' . $codata['url']; } - + serendipity_displayCommentForm( $serendipity['GET']['entry_id'], $target_url, @@ -279,10 +279,10 @@ $sql = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']} WHERE 1 = 1 " . ($c_type !== null ? " AND c.type = '$c_type' " : '') . $and . (!serendipity_checkPermission('adminEntriesMaintainOthers') ? 'AND e.authorid = ' . (int)$serendipity['authorid'] : '') . " ORDER BY c.id DESC $limit"); - + ob_start(); # This event has to get send here so the spamblock-plugin can block an author now and the comment_page show that on this pageload -serendipity_plugin_api::hook_event('backend_comments_top', $sql); +serendipity_plugin_api::hook_event('backend_comments_top', $sql); $data['backend_comments_top'] = ob_get_contents(); ob_end_clean(); @@ -300,7 +300,7 @@ $data['c_type'] = $c_type; $i = 0; $comments = array(); -if(is_array($sql)) { +if(is_array($sql)) { foreach ($sql as $rs) { $i++; $comment = array( @@ -342,10 +342,10 @@ if(is_array($sql)) { $class = 'serendipity_admin_list_item_' . (($i % 2 == 0 ) ? 'even' : 'uneven'); if ($comment['status'] == 'pending') { - $class .= ' serendipity_admin_comment_pending'; + $class .= ' serendipity_admin_comment_pending'; $header_class = 'serendipityAdminMsgNote serendipity_admin_comment_pending_header'; } elseif (strstr($comment['status'], 'confirm')) { - $class .= ' serendipity_admin_comment_pending serendipity_admin_comment_confirm'; + $class .= ' serendipity_admin_comment_pending serendipity_admin_comment_confirm'; $header_class = 'serendipityAdminMsgNote serendipity_admin_comment_pending_header serendipity_admin_comment_confirm_header'; } else { $header_class = ''; diff --git a/include/admin/entries.inc.php b/include/admin/entries.inc.php index 4ed849bc..2ae18caf 100644 --- a/include/admin/entries.inc.php +++ b/include/admin/entries.inc.php @@ -1,4 +1,4 @@ - $set) { $data['allhooks'][$hook]['has_permission'] = serendipity_hasPluginPermissions($hook, $from['id']); diff --git a/include/admin/images.inc.php b/include/admin/images.inc.php index 247f547a..73ebf749 100644 --- a/include/admin/images.inc.php +++ b/include/admin/images.inc.php @@ -1,4 +1,4 @@ -import()) !== true ) { $data['result'] = $result; - } + } /* Apprently we do not have valid data, ask for some */ } else { $data['formToken'] = serendipity_setFormToken(); diff --git a/include/admin/importers/blogger.inc.php b/include/admin/importers/blogger.inc.php index f0600076..2f008427 100644 --- a/include/admin/importers/blogger.inc.php +++ b/include/admin/importers/blogger.inc.php @@ -1,9 +1,9 @@ - 'bCharset', 'value' => 'UTF-8', 'default' => $this->getCharsets()) - ); + ); } - - function getImportNotes(){ - if (empty($_REQUEST['token'])) { - $msg = 'In order to import your blog on Blogger, Serendipity needs to be able to access it via Google\'s Blogger Data APIs.'; - $msg .= 'Login to your Google/Blogger account and then click the link below.'; - $msg .= 'Go to Google to grant access'; - return $msg; - } else { - return ''; - } - } - + + function getImportNotes(){ + if (empty($_REQUEST['token'])) { + $msg = 'In order to import your blog on Blogger, Serendipity needs to be able to access it via Google\'s Blogger Data APIs.'; + $msg .= 'Login to your Google/Blogger account and then click the link below.'; + $msg .= 'Go to Google to grant access'; + return $msg; + } else { + return ''; + } + } + function validateData() { return sizeof($this->data); } - - function getInputFields() { - // Make sure Google login has been completed - if (!empty($_REQUEST['token'])) { - - // Prepare session token request - $req = new HTTP_Request('https://www.google.com/accounts/AuthSubSessionToken'); - $req->addHeader('Authorization', 'AuthSub token="'. $_REQUEST['token'] .'"'); - - // Request token - $req->sendRequest(); - - // Handle token reponse - if ($req->getResponseCode() != '200') return; - - // Extract Auth token - preg_match_all('/^(.+)=(.+)$/m', $req->getResponseBody(), $matches); - $tokens = array_combine($matches[1], $matches[2]); - unset($matches); - - // Add hidden auth token field to input field list - array_unshift($this->inputFields, array( 'text' => 'Google Auth Token (leave alone)', - 'type' => 'input', - 'name' => 'bAuthToken', - 'default' => $tokens['Token'])); - // Prepare blog list request - $req = new HTTP_Request('http://www.blogger.com/feeds/default/blogs'); - $req->addHeader('GData-Version', 2); - $req->addHeader('Authorization', 'AuthSub token="'. $tokens['Token'] .'"'); - - // Fetch blog list - $req->sendRequest(); - - // Handle errors - if ($req->getResponseCode() != '200') return false; - - // Load list - $bXml = simplexml_load_string($req->getResponseBody()); - - // Generate list of the blogs under the authenticated account - $bList = array(); - foreach ($bXml->entry as $entry) { - $bList[substr($entry->id, strpos($entry->id, 'blog-') + 5)] = $entry->title; - } - - // Add blog list to input fields for selection - array_unshift($this->inputFields, array('text' => 'Blog to import', - 'type' => 'list', - 'name' => 'bId', - 'value' => 0, - 'default' => $bList)); - - return $this->inputFields; - } else { - return array(); - } + function getInputFields() { + // Make sure Google login has been completed + if (!empty($_REQUEST['token'])) { + + // Prepare session token request + $req = new HTTP_Request('https://www.google.com/accounts/AuthSubSessionToken'); + $req->addHeader('Authorization', 'AuthSub token="'. $_REQUEST['token'] .'"'); + + // Request token + $req->sendRequest(); + + // Handle token reponse + if ($req->getResponseCode() != '200') return; + + // Extract Auth token + preg_match_all('/^(.+)=(.+)$/m', $req->getResponseBody(), $matches); + $tokens = array_combine($matches[1], $matches[2]); + unset($matches); + + // Add hidden auth token field to input field list + array_unshift($this->inputFields, array( 'text' => 'Google Auth Token (leave alone)', + 'type' => 'input', + 'name' => 'bAuthToken', + 'default' => $tokens['Token'])); + + // Prepare blog list request + $req = new HTTP_Request('http://www.blogger.com/feeds/default/blogs'); + $req->addHeader('GData-Version', 2); + $req->addHeader('Authorization', 'AuthSub token="'. $tokens['Token'] .'"'); + + // Fetch blog list + $req->sendRequest(); + + // Handle errors + if ($req->getResponseCode() != '200') return false; + + // Load list + $bXml = simplexml_load_string($req->getResponseBody()); + + // Generate list of the blogs under the authenticated account + $bList = array(); + foreach ($bXml->entry as $entry) { + $bList[substr($entry->id, strpos($entry->id, 'blog-') + 5)] = $entry->title; + } + + // Add blog list to input fields for selection + array_unshift($this->inputFields, array('text' => 'Blog to import', + 'type' => 'list', + 'name' => 'bId', + 'value' => 0, + 'default' => $bList)); + + return $this->inputFields; + } else { + return array(); + } } - - function _getCategoryList() { - $res = serendipity_fetchCategories('all'); - $ret = array(0 => NO_CATEGORY); - if (is_array($res)) { - foreach ($res as $v) { - $ret[$v['categoryid']] = $v['category_name']; - } - } - return $ret; - } - function import() { - global $serendipity; - - // Force user to select a blog to act on - if (empty($this->data['bId']) || $this->data['bId'] == 0) { - echo 'Please select a blog to import!'; - return false; - } - - // Save this so we can return it to its original value at the end of this method. + function _getCategoryList() { + $res = serendipity_fetchCategories('all'); + $ret = array(0 => NO_CATEGORY); + if (is_array($res)) { + foreach ($res as $v) { + $ret[$v['categoryid']] = $v['category_name']; + } + } + return $ret; + } + + function import() { + global $serendipity; + + // Force user to select a blog to act on + if (empty($this->data['bId']) || $this->data['bId'] == 0) { + echo 'Please select a blog to import!'; + return false; + } + + // 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') { @@ -138,143 +138,143 @@ class Serendipity_Import_Blogger extends Serendipity_Import { } $this->getTransTable(); - - // Prepare export request - $req = new HTTP_Request('http://www.blogger.com/feeds/'. $this->data['bId'] .'/archive'); - $req->addHeader('GData-Version', 2); - $req->addHeader('Authorization', 'AuthSub token="'. $this->data['bAuthToken'] .'"'); - - // Attempt fetch blog export - $req->sendRequest(); - - // Handle errors - if ($req->getResponseCode() != '200') { - echo "Error occured while trying to export the blog."; - return false; - } - - // Export success - echo 'Successfully exported entries from Blogger'; - - // Get Serendipity authors list - $authorList = array(); - $s9y_users = serendipity_fetchUsers(); - foreach ($s9y_users as $user) { - $authorList[$user['authorid']] = $user['username']; - } - unset($s9y_users); - - // Load export - $bXml = simplexml_load_string($req->getResponseBody()); - - // Process entries - $entryList = $entryFailList = array(); - foreach ($bXml->entry as $bEntry) { - - // Check entry type - switch ($bEntry->category['term']) { - case 'http://schemas.google.com/blogger/2008/kind#post': - // Process posts: - - // Create author if not in serendipity - $author = (string) $bEntry->author->name; - if (!array_search($author, $authorList)) { - serendipity_db_insert( 'authors', - array( 'right_publish' => 1, - 'realname' => $author, - 'username' => $author, - 'userlevel' => 0, - 'password' => md5($this->data['defaultpass'])) - ); - $authorid = serendipity_db_insert_id('authors', 'authorid'); - $authorList[$authorid] = $author; - } - - $sEntry = array('title' => $this->decode((string) $bEntry->title), - 'isdraft' => ($bEntry->children('http://purl.org/atom/app#')->control->draft == 'yes') ? 'true' : 'false', - 'allow_comments' => (count($bEntry->xpath("*[@rel='replies']")) > 0) ? 'true' : 'false', - 'timestamp' => strtotime($bEntry->published), - 'body' => $this->strtr((string) $bEntry->content), - 'extended' => '', - 'categories' => $this->data['bCategory'], - 'author' => $author, - 'authorid' => $authorid - ); - - // Add entry to s9y - echo '..~.. '; - if (is_int($id = serendipity_updertEntry($sEntry))) { - // Add entry id to processed table for later lookups - $entryList[(string) $bEntry->id] = array($id, $sEntry['title'], 0); - } else { - // Add to fail list - $entryFailList[] = $sEntry['title']; - } - - break; - - case 'http://schemas.google.com/blogger/2008/kind#comment': - // Process comments: - - // Extract entry id for comment - $cEntryId = $bEntry->xpath("thr:in-reply-to[@ref]"); - $cEntryId = (string) $cEntryId[0]['ref']; - - // Check to make sure the related entry has been added to s9y - if (array_key_exists($cEntryId, $entryList)) { - // Add to s9y - $sComment = array( 'entry_id ' => $entryList[$cEntryId][0], - 'parent_id' => 0, - 'timestamp' => strtotime($bEntry->published), - 'author' => (string) $bEntry->author->name, - 'email' => (string) $bEntry->author->email, - 'url' => (string) (isset($bEntry->author->uri)) ? $bEntry->author->uri : '', - 'ip' => '', - 'status' => 'approved', - 'body' => $this->strtr((string) $bEntry->content), - 'subscribed'=> 'false', - 'type' => 'NORMAL' - ); - serendipity_db_insert('comments', $sComment); - - // Update entry list with comment count - $entryList[$cEntryId][2]++; - } - - break; - } - - } - - // Report on resultant authors - echo 'Current list of authors: '. join(', ', array_values($authorList)); - - // Do cleanup and report on entries - echo 'The following entries were successfully imported:'; - echo '
'; @@ -150,7 +151,7 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { } $new_val = $this->storage[$fix_relation_table][$fix_relation_primary_key][$assoc_val]; - + if ($skip_dupes && $assoc_val == $new_val) { $insert = false; } @@ -158,7 +159,7 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { 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)"; } @@ -190,11 +191,11 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { $this->storage[$table][$primary_key][$primary_val] = $this->counter; } } - + foreach($this->storage[$table] AS $primary_key => $primary_data) { - foreach($primary_data AS $primary_val => $replace_val) { - serendipity_set_config_var('import_s9y_' . $table . '_' . $primary_key . '_' . $primary_val, $replace_val, 99); - } + foreach($primary_data AS $primary_val => $replace_val) { + serendipity_set_config_var('import_s9y_' . $table . '_' . $primary_key . '_' . $primary_val, $replace_val, 99); + } } } else { if ($this->debug && !$this->execute) { @@ -202,7 +203,7 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { } } } - + if (!$this->execute) { echo 'Storage on '. $table . ':' . print_r($this->storage[$table], true) . ''; } else { @@ -219,18 +220,18 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { $this->import_table( $s9ydb, 'groups', - array('id'), + array('id'), null, 'name', false ); $this->import_table( - $s9ydb, - 'groupconfig', + $s9ydb, + 'groupconfig', array('id'), - null, - false, + null, + false, array('id' => array('groups' => 'id')), true ); @@ -240,17 +241,17 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { global $serendipity; $this->import_table( - $s9ydb, - 'authors', - array('authorid'), - null, + $s9ydb, + 'authors', + array('authorid'), + null, 'username', false ); $this->import_table( - $s9ydb, - 'authorgroups', + $s9ydb, + 'authorgroups', false, null, false, @@ -259,8 +260,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'config', + $s9ydb, + 'config', false, ' WHERE authorid > 0', false, @@ -268,8 +269,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'permalinks', + $s9ydb, + 'permalinks', false, ' WHERE type = "author" ', false, @@ -281,8 +282,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { global $serendipity; $this->import_table( - $s9ydb, - 'entries', + $s9ydb, + 'entries', array('id'), null, false, @@ -290,8 +291,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'comments', + $s9ydb, + 'comments', array('id'), 'ORDER BY parent_id ASC', false, @@ -300,8 +301,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'entryproperties', + $s9ydb, + 'entryproperties', false, null, false, @@ -309,8 +310,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'references', + $s9ydb, + 'references', array('id'), null, false, @@ -318,8 +319,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'exits', + $s9ydb, + 'exits', false, null, false, @@ -327,8 +328,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'referrers', + $s9ydb, + 'referrers', false, null, false, @@ -336,8 +337,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'permalinks', + $s9ydb, + 'permalinks', false, ' WHERE type = "entry" ', false, @@ -349,8 +350,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { global $serendipity; $this->import_table( - $s9ydb, - 'images', + $s9ydb, + 'images', array('id'), null, false, @@ -358,8 +359,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'mediaproperties', + $s9ydb, + 'mediaproperties', false, null, false, @@ -367,8 +368,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'access', + $s9ydb, + 'access', false, ' WHERE artifact_type = "directory" ', false, @@ -381,8 +382,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { global $serendipity; $this->import_table( - $s9ydb, - 'category', + $s9ydb, + 'category', array('categoryid'), ' ORDER BY parentid ASC', false, @@ -391,8 +392,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'entrycat', + $s9ydb, + 'entrycat', false, null, false, @@ -401,8 +402,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'permalinks', + $s9ydb, + 'permalinks', false, ' WHERE type = "category" ', false, @@ -410,8 +411,8 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { ); $this->import_table( - $s9ydb, - 'access', + $s9ydb, + 'access', false, ' WHERE artifact_type = "category" ', false, @@ -458,7 +459,7 @@ class Serendipity_Import_Serendipity extends Serendipity_Import { if (!is_array($this->data['targets'])) { return "No targets selected"; } - + $this->storage = array(); foreach($this->data['targets'] AS $target) { $this->{'import_' . $target}($s9ydb); diff --git a/include/admin/importers/voodoopad.inc.php b/include/admin/importers/voodoopad.inc.php index 9cf25d13..c5cf82d0 100755 --- a/include/admin/importers/voodoopad.inc.php +++ b/include/admin/importers/voodoopad.inc.php @@ -1,8 +1,9 @@ -data = $data; $this->inputFields = array( @@ -89,7 +90,7 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import { $file = $_FILES['serendipity']['tmp_name']['import']['voodooPadXML']; // Create a parser and set it up with the callbacks - $xml_parser = xml_parser_create(''); + $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"); @@ -98,7 +99,7 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import { if (!file_exists($file)) { die(sprintf(DOCUMENT_NOT_FOUND, serendipity_specialchars($file))); } - + if(!($handle = fopen($file, "r"))) { die(sprintf(SKIPPING_FILE_UNREADABLE, serendipity_specialchars($file))); } @@ -117,7 +118,7 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import { // so loop through building and/or updating page objects while(list($key_a) = each($elements)) { $name = $elements[$key_a]->name; - + switch ($name) { case 'data': // indicates the start of the VoodooPad entry, so create page object $thispage = array(); @@ -138,10 +139,10 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import { $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; + $thispage['permalink'] = $serendipity['serendipityHTTPPath'] . 'index.php?serendipity[subpage]=' . $mykey; break; case 'alias': // The title and the string used to match links @@ -162,7 +163,7 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import { if (!isset($thispage['id'])) { echo ''.IMPORTER_VOODOO_CREATINGPAGE.': '. $mykey.''; serendipity_db_insert('staticpages', $thispage); - $serendipity["POST"]["staticpage"] = serendipity_db_insert_id("staticpages", 'id'); + $serendipity["POST"]["staticpage"] = serendipity_db_insert_id("staticpages", 'id'); } elseif ($this->data['updateExisting'] == 'true') { echo ''.IMPORTER_VOODOO_UPDATINGPAGE.': '. $mykey.''; serendipity_db_update("staticpages", array("id" => $thispage["id"]), $thispage); @@ -174,7 +175,7 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import { echo ''.IMPORTER_VOODOO_RECORDURL.': '.$thispage['headline'].''; $aliases[$thispage['headline']] = $thispage['content']; } - break; + break; } } @@ -192,9 +193,9 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import { // **TODO** Change this to pull out only entries for the current wiki echo ''.IMPORTER_VOODOO_WRITEINTRALINKS.'
'; - - $pages= &serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}staticpages ORDER BY pagetitle DESC"); - + + $pages= &serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}staticpages ORDER BY pagetitle DESC"); + foreach ($pages as $thispage) { // Parse the content string foreach ($aliases as $alias => $permalink) { @@ -204,13 +205,13 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import { for ($counter = 0; $counter <= 12; $counter+=1) { unset ($thispage[$counter]); } - + // Write back to the database serendipity_db_update("staticpages", array("id" => $thispage["id"]), $thispage); } - + echo '' . DONE . ''; - } + } // Search and replace avoiding content of links // **TODO** Fix this to avoid short links screwing up longer links @@ -219,16 +220,16 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import { $ns = ''; for ($i = 0; $i < count($r); $i++) { if ($r[$i] == "<") { - $i+=2; + $i+=2; continue; } $r[$i] = eregi_replace(sql_regcase($alias), ''.$alias.'', $r[$i]); } return join("", $r); - } + } } - + // XML Parser callbacks function start_element_handler($parser, $name, $attribs){ global $elements, $stack, $count, $depth; @@ -237,29 +238,29 @@ function start_element_handler($parser, $name, $attribs){ $element = new element; $elements[$id] = $element; $elements[$id]->name = $name; - + while(list($key, $value) = each($attribs)) { $elements[$id]->attributes[$key] = $value; } - + $elements[$id]->depth = $depth; array_push($stack, $id); - + $count++; $depth++; } function end_element_handler($parser, $name){ global $stack, $depth; - + array_pop($stack); - + $depth--; } function character_data_handler($parser, $data){ global $elements, $stack; - + $elements[$stack[count($stack)-1]]->data .= $data; } diff --git a/include/admin/importers/wordpress.inc.php b/include/admin/importers/wordpress.inc.php index d35b424d..964b3cc5 100644 --- a/include/admin/importers/wordpress.inc.php +++ b/include/admin/importers/wordpress.inc.php @@ -1,4 +1,4 @@ - 'bool', 'name' => 'autodiscovery', 'default' => 'false'), - + array('text' => IMPORT_WP_PAGES, 'type' => 'bool', 'name' => 'import_all', - 'default' => 'false' + 'default' => 'false' ) ); } @@ -100,7 +100,7 @@ class Serendipity_Import_WordPress extends Serendipity_Import { if (!@mysql_select_db($this->data['name'], $wpdb)) { return sprintf(COULDNT_SELECT_DB, mysql_error($wpdb)); } - + // This will hold the s9y <-> WP ID associations. $assoc = array(); @@ -113,12 +113,12 @@ class Serendipity_Import_WordPress extends Serendipity_Import { if ($debug) echo "Importing users..."; for ($x=0, $c = mysql_num_rows($res) ; $x < $c ; $x++) { $users[$x] = mysql_fetch_assoc($res); - + $data = array('right_publish' => (!isset($users[$x]['user_level']) || $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 (isset($users[$x]['user_level']) && $users[$x]['user_level'] <= 1) { $data['userlevel'] = USERLEVEL_EDITOR; } elseif (isset($users[$x]['user_level']) && $users[$x]['user_level'] < 5) { @@ -126,19 +126,19 @@ class Serendipity_Import_WordPress extends Serendipity_Import { } else { $data['userlevel'] = USERLEVEL_ADMIN; } - + if ($serendipity['serendipityUserlevel'] < $data['userlevel']) { $data['userlevel'] = $serendipity['serendipityUserlevel']; } - + serendipity_db_insert('authors', $this->strtrRecursive($data)); $users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid'); - + // Set association. $assoc['users'][$users[$x]['ID']] = $users[$x]['authorid']; } if ($debug) echo "Imported users."; - + // Clean memory unset($users); } @@ -158,7 +158,7 @@ class Serendipity_Import_WordPress extends Serendipity_Import { for ($x=0 ; $x$categories[$x]['cat_name'], @@ -166,14 +166,14 @@ class Serendipity_Import_WordPress extends Serendipity_Import { 'parentid' => 0, 'category_left' => 0, 'category_right' => 0); - + serendipity_db_insert('category', $this->strtrRecursive($cat)); $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid'); - + // Set association. $assoc['categories'][$categories[$x]['cat_ID']] = $categories[$x]['categoryid']; } - + foreach ($categories as $cat) { if ($cat['category_parent'] != 0) { // Find the parent @@ -184,7 +184,7 @@ class Serendipity_Import_WordPress extends Serendipity_Import { break; } } - + if ($par_id != 0) { serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET parentid={$par_id} @@ -225,7 +225,7 @@ class Serendipity_Import_WordPress extends Serendipity_Import { for ($x=0 ; $x $categories[$x]['cat_name'], @@ -233,14 +233,14 @@ class Serendipity_Import_WordPress extends Serendipity_Import { 'parentid' => 0, 'category_left' => 0, 'category_right' => 0); - + serendipity_db_insert('category', $this->strtrRecursive($cat)); $categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid'); - + // Set association. $assoc['categories'][$categories[$x]['cat_ID']] = $categories[$x]['categoryid']; } - + foreach ($categories as $cat) { if ($cat['category_parent'] != 0) { // Find the parent @@ -251,7 +251,7 @@ class Serendipity_Import_WordPress extends Serendipity_Import { break; } } - + if ($par_id != 0) { serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET parentid={$par_id} @@ -285,11 +285,11 @@ class Serendipity_Import_WordPress extends Serendipity_Import { if ($debug) echo "Importing entries..."; for ($x=0, $c = mysql_num_rows($res) ; $x < $c ; $x++ ) { $entries[$x] = mysql_fetch_assoc($res); - + $content = explode('', $entries[$x]['post_content'], 2); $body = $content[0]; $extended = $content[1]; - + $entry = array('title' => $this->decode($entries[$x]['post_title']), // htmlentities() is called later, so we can leave this. 'isdraft' => ($entries[$x]['post_status'] == 'publish') ? 'false' : 'true', 'allow_comments' => ($entries[$x]['comment_status'] == 'open' ) ? 'true' : 'false', @@ -297,13 +297,13 @@ class Serendipity_Import_WordPress extends Serendipity_Import { 'body' => $this->strtr($body), 'extended' => $this->strtr($extended), 'authorid' => $assoc['users'][$entries[$x]['post_author']]); - + if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) { printf(COULDNT_SELECT_ENTRY_INFO, mysql_error($wpdb)); echo "ID: {$entries[$x]['ID']} - {$entry['title']}"; return $entries[$x]['entryid']; } - + $assoc['entries'][$entries[$x]['ID']] = $entries[$x]['entryid']; } if ($debug) echo "Imported entries..."; @@ -311,7 +311,7 @@ class Serendipity_Import_WordPress extends Serendipity_Import { // Clean memory unset($entries); } - + /* Entry/category (WP < 2.3 style)*/ $no_entrycat = false; $res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}post2cat;", $wpdb); diff --git a/include/admin/installer.inc.php b/include/admin/installer.inc.php index 71fcaca9..9011ca5c 100644 --- a/include/admin/installer.inc.php +++ b/include/admin/installer.inc.php @@ -1,4 +1,4 @@ - $sum) { $data['installerResultDiagnose_CHECKSUMS'][] = serendipity_installerResultDiagnose(S9Y_I_WARNING, sprintf(CHECKSUM_FAILED, $file)); - } + } } } else { $data['installerResultDiagnose_CHECKSUMS'][] = serendipity_installerResultDiagnose(S9Y_I_WARNING, CHECKSUMS_NOT_FOUND); @@ -274,7 +274,7 @@ if ( (int)$serendipity['GET']['step'] == 0 ) { $data['installerResultDiagnose_PLUGINS'] = serendipity_installerResultDiagnose(S9Y_I_WARNING, NOT_WRITABLE . NOT_WRITABLE_SPARTACUS); } - if ( is_dir($basedir .'uploads/') ) { + if ( is_dir($basedir .'uploads/') ) { $data['is_dir_uploads'] = true; if ( is_writable($basedir . 'uploads/') ) { $data['installerResultDiagnose_UPLOADS'] = serendipity_installerResultDiagnose(S9Y_I_SUCCESS, WRITABLE); @@ -289,7 +289,7 @@ if ( (int)$serendipity['GET']['step'] == 0 ) { } } - if (function_exists('is_executable')) { + if (function_exists('is_executable')) { $data['is_imb_executable'] = true; if ($binary = serendipity_query_default('convert', false)) { if (is_executable($binary)) { @@ -300,29 +300,29 @@ if ( (int)$serendipity['GET']['step'] == 0 ) { } else { $data['installerResultDiagnose_IMB'] = serendipity_installerResultDiagnose(S9Y_I_WARNING, NOT_FOUND); } - } + } $data['showWritableNote'] = $showWritableNote; $data['errorCount'] = $errorCount; -} elseif ( $serendipity['GET']['step'] == '2a' ) { +} elseif ( $serendipity['GET']['step'] == '2a' ) { $config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE, null, array('simpleInstall')); - $data['ob_serendipity_printConfigTemplate'] = serendipity_printConfigTemplate($config, $from, true, false, false); + $data['ob_serendipity_printConfigTemplate'] = serendipity_printConfigTemplate($config, $from, true, false, false); -} elseif ( $serendipity['GET']['step'] == '2b' ) { +} elseif ( $serendipity['GET']['step'] == '2b' ) { $config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE); - $data['ob_serendipity_printConfigTemplate'] = serendipity_printConfigTemplate($config, $from, true, false, false); + $data['ob_serendipity_printConfigTemplate'] = serendipity_printConfigTemplate($config, $from, true, false, false); } elseif ( $serendipity['GET']['step'] == '3' ) { $serendipity['dbPrefix'] = $_POST['dbPrefix']; $t = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}authors", false, 'both', false, false, false, true); $data['authors_query'] = $t; - + if ( is_array($t) ) { // void } else { - serendipity_installDatabase(); + serendipity_installDatabase(); $data['install_DB'] = true; $authorid = serendipity_addAuthor($_POST['user'], $_POST['pass'], $_POST['realname'], $_POST['email'], USERLEVEL_ADMIN, 1); diff --git a/include/admin/maintenance.inc.php b/include/admin/maintenance.inc.php index 873cce00..a05ea671 100644 --- a/include/admin/maintenance.inc.php +++ b/include/admin/maintenance.inc.php @@ -11,7 +11,7 @@ ob_end_clean(); switch($serendipity['GET']['adminAction']) { case 'integrity': $data['action'] = "integrity"; - + if (!is_readable(S9Y_INCLUDE_PATH . 'checksums.inc.php') || 0 == filesize(S9Y_INCLUDE_PATH . 'checksums.inc.php') ) { $data['noChecksum'] = true; break; diff --git a/include/admin/overview.inc.php b/include/admin/overview.inc.php index fab7d848..5112cd1a 100644 --- a/include/admin/overview.inc.php +++ b/include/admin/overview.inc.php @@ -1,4 +1,4 @@ - 1) { foreach ($comments as &$comment) { $comment['entrylink'] = serendipity_archiveURL($comment['entry_id'], 'comments', 'serendipityHTTPPath', true) . '#c' . $comment['id']; - + $comment['fullBody'] = $comment['body']; $comment['summary'] = serendipity_mb('substr', $comment['body'], 0, 100); - + if (strlen($comment['fullBody']) > strlen($comment['summary']) ) { $comment['excerpt'] = true; @@ -93,7 +93,7 @@ if ($entriesAmount < 5) { true, false, 'timestamp DESC', - "isdraft = 'true' AND e.timestamp <= " . serendipity_serverOffsetHour() + "isdraft = 'true' AND e.timestamp <= " . serendipity_serverOffsetHour() ); if (is_array($entries) && is_array($drafts)) { $entries = array_merge($entries, $drafts); diff --git a/include/admin/personal.inc.php b/include/admin/personal.inc.php index 7cba15dc..338a4592 100644 --- a/include/admin/personal.inc.php +++ b/include/admin/personal.inc.php @@ -1,4 +1,4 @@ - $groupval) { if (in_array($groupval, $valid_groups)) { @@ -111,7 +111,7 @@ if ($serendipity['GET']['adminAction'] == 'save' && serendipity_checkFormToken() } $from = $_POST; } -} +} $data['formToken'] = serendipity_setFormToken(); $template = serendipity_parseTemplate(S9Y_CONFIG_USERTEMPLATE); @@ -120,7 +120,7 @@ $from = $user[0]; $from['groups'] = serendipity_getGroups($serendipity['authorid']); unset($from['password']); $data['config'] = serendipity_printConfigTemplate($template, $from, true, false); - + $add = array('internal' => true); serendipity_plugin_api::hook_event('backend_sidebar_entries_event_display_profiles', $from, $add); diff --git a/include/admin/plugins.inc.php b/include/admin/plugins.inc.php index c7647133..6ae01597 100644 --- a/include/admin/plugins.inc.php +++ b/include/admin/plugins.inc.php @@ -1,4 +1,4 @@ -introspect($bag); @@ -132,7 +132,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { $data['desc'] = $desc; $data['documentation'] = $documentation; $data['plugin'] = $plugin; - + if (@file_exists(dirname($plugin->pluginFile) . '/ChangeLog')) { $data['changelog'] = true; } @@ -154,7 +154,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { $data['adminAction'] = 'addnew'; $data['type'] = $serendipity['GET']['type']; - + $foreignPlugins = $pluginstack = $errorstack = array(); serendipity_plugin_api::hook_event('backend_plugins_fetchlist', $foreignPlugins); $pluginstack = array_merge((array)$foreignPlugins['pluginstack'], $pluginstack); @@ -213,7 +213,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { $props['local_documentation'] = 'plugins/' . $props['pluginPath'] . '/README'; } } - + $pluginstack[$class_data['true_name']] = $props; } else { // False is returned if a plugin could not be instantiated @@ -237,7 +237,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { $pluggroups[''][] = $plugdata; } } - + ksort($pluggroups); $data['count_pluginstack'] = count($pluginstack); @@ -259,7 +259,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { $data['only_group'] = $serendipity['GET']['only_group']; $data['available_upgrades'] = isset($pluggroups['UPGRADE']); $requirement_failures = array(); - + foreach($pluggroups AS $pluggroup => $groupstack) { foreach ($groupstack as $plug) { if ( !empty($plug['requirements']['serendipity']) && version_compare($plug['requirements']['serendipity'], serendipity_getCoreVersion($serendipity['version']), '>') ) { @@ -281,7 +281,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { $requirement_failures[$plug['class_name']] = array("smarty" => true); } } - + } } @@ -320,7 +320,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { serendipity_db_query("UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = ". $pos . " WHERE name='" . serendipity_db_escape_string($plugin['id']) . "'"); - + serendipity_plugin_api::update_plugin_placement( addslashes($plugin['id']), addslashes($plugin['placement']) @@ -362,7 +362,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { } } } - + $data['new_plugin_failed'] = ! $new_plugin; if ($fetchplugin_data['install'] && $new_plugin) { @@ -411,8 +411,8 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { if (isset($_POST['SAVE'])) { $data['save'] = true; $data['timestamp'] = serendipity_strftime('%H:%M:%S'); - } - + } + serendipity_plugin_api::hook_event('backend_pluginlisting_header', $null); ob_start(); @@ -432,7 +432,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { if (count($serendipity['memSnaps']) > 0) { $data['$memsnaps'] = $serendipity['memSnaps']; } - + } echo serendipity_smarty_show('admin/plugins.inc.tpl', $data); diff --git a/include/admin/templates.inc.php b/include/admin/templates.inc.php index c595905b..4d76ea2f 100644 --- a/include/admin/templates.inc.php +++ b/include/admin/templates.inc.php @@ -1,4 +1,4 @@ -config[$item]['scope'] == 'global') { serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}options WHERE okey = 't_global' @@ -79,7 +79,7 @@ if ($serendipity['GET']['adminAction'] == 'install' || $serendipity['GET']['admi } else { // template_engine was set by default to default, which screws up the fallback chain (to the default-template first) // The "Engine" now only applies to FRONTEND themes. Backend themes will always fall back to our default backend theme only, to ensure proper backend operation. - serendipity_set_config_var('template_engine', null); + serendipity_set_config_var('template_engine', null); if ($themeInfo['engine']) { serendipity_set_config_var('template_engine', $themeInfo['engine']); } @@ -140,7 +140,7 @@ if (is_array($template_config)) { include_once S9Y_INCLUDE_PATH . 'include/functions_plugins_admin.inc.php'; $template_vars =& serendipity_loadThemeOptions($template_config); - + $template_options = new template_option(); $template_options->import($template_config); $template_options->values =& $template_vars; @@ -158,7 +158,7 @@ if (is_array($template_config)) { 'template', $template_config_groups ); - + serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config); } else { serendipity_plugin_api::hook_event('backend_templates_configuration_none', $template_config); diff --git a/include/admin/upgrader.inc.php b/include/admin/upgrader.inc.php index 2b45e302..28d78dee 100644 --- a/include/admin/upgrader.inc.php +++ b/include/admin/upgrader.inc.php @@ -1,4 +1,4 @@ - '0.5.1', 'title' => 'Removal of obsolete and dead htmlarea directories', 'arguments' => array($dead_htmlarea_dirs), 'desc' => 'Serendipity 2.0 replaces old WYSIWYG-Editors in htmlarea directory with CKEDITOR. The following dead directories will be completely removed from "/htmlarea". ' . implode(', ', $dead_htmlarea_dirs) . ''), - + array('version' => '2.0-beta3', 'function' => 'serendipity_upgrader_move_syndication_config', 'title' => 'Export syndication plugin options', @@ -352,7 +352,7 @@ if (($showAbort && $serendipity['GET']['action'] == 'ignore') || $serendipity['G $showWritableNote = false; $basedir = $serendipity['serendipityPath']; $data['basedir'] = $basedir; - + $data['upgraderResultDiagnose1'] = array(); if (is_readable($basedir . 'checksums.inc.php')) { $data['checksums'] = true; @@ -400,9 +400,9 @@ if (($showAbort && $serendipity['GET']['action'] == 'ignore') || $serendipity['G $data['upgraderResultDiagnose3'][] = serendipity_upgraderResultDiagnose(S9Y_U_ERROR, NOT_WRITABLE); $showWritableNote = true; } - + $data['upgraderResultDiagnose4'] = array(); - if (is_dir($basedir . $serendipity['uploadHTTPPath'])) { + if (is_dir($basedir . $serendipity['uploadHTTPPath'])) { $data['isdir_uploadpath'] = is_dir($basedir . $serendipity['uploadHTTPPath']); if (is_writable($basedir . $serendipity['uploadHTTPPath'])) { $data['upgraderResultDiagnose4'][] = serendipity_upgraderResultDiagnose(S9Y_U_SUCCESS, WRITABLE); @@ -416,7 +416,7 @@ if (($showAbort && $serendipity['GET']['action'] == 'ignore') || $serendipity['G $data['errorCount'] = $errorCount; if ($errorCount < 1) { - if (sizeof($sqlfiles) > 0) { + if (sizeof($sqlfiles) > 0) { $data['database_update_types'] = sprintf(SERENDIPITY_UPGRADER_DATABASE_UPDATES, $serendipity['dbType']); $data['sqlfiles'] = $sqlfiles; } diff --git a/include/admin/users.inc.php b/include/admin/users.inc.php index 477ffdc9..829bf457 100644 --- a/include/admin/users.inc.php +++ b/include/admin/users.inc.php @@ -1,4 +1,4 @@ - $key) { if ($type == 'int') { $new_array[$idx] = (int)$key; diff --git a/include/db/generic.inc.php b/include/db/generic.inc.php index fc9e52df..00af175a 100644 --- a/include/db/generic.inc.php +++ b/include/db/generic.inc.php @@ -76,7 +76,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re $resultArray = $result->toArray(); $resultArray = $resultArray[0]; if(is_array($resultArray) && $result_type != "assoc") { - $i=0; # the underlying code expects additional numerical indices + $i=0; # the underlying code expects additional numerical indices foreach ($resultArray as $key=>$value) { $resultArray[$i] = $value; $i+=1; @@ -89,7 +89,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re if (count($resultArray) == 0) { return 1; } - } + } } return $resultArray; } @@ -216,14 +216,14 @@ function serendipity_db_connect() { if ($serendipity['dbType'] == "pdo-sqlite" || $serendipity['dbType'] == "sqlite3" || $serendipity['dbType'] == 'sqlite3oo' || $serendipity['dbType'] == "sqlite") { $dbName .= ".db"; # the old sqlite-wrapper appended this .db to the dbName, keep this for bc } - + $serendipity['dbConn'] = new Adapter( array( 'driver' => $serendipity['dbType'], 'database' => $dbName, 'username' => $serendipity['dbUser'], 'password' => $serendipity['dbPass'], - 'hostname' => $hash['dbHost'] + 'hostname' => $hash['dbHost'] ) ); @@ -252,7 +252,7 @@ function serendipity_db_schema_import($query) { static $replace = array('int(11) not null auto_increment', 'primary key', 'unsigned' , 'FULLTEXT', 'FULLTEXT', 'enum (\'true\', \'false\') NOT NULL default \'true\'', 'LONGTEXT'); static $is_utf8 = null; - + if ($is_utf8 === null) { $search[] = '{UTF_8}'; if ((isset($_POST['charset']) && $_POST['charset'] == 'UTF-8/') || @@ -270,7 +270,7 @@ function serendipity_db_schema_import($query) { case "postgresql": static $search = array('{AUTOINCREMENT}', '{PRIMARY}', '{UNSIGNED}', '{FULLTEXT}', '{FULLTEXT_MYSQL}', '{BOOLEAN}', 'int(1)', 'int(10)', 'int(11)', 'int(4)', '{UTF_8}', '{TEXT}'); - static $replace = array('SERIAL', 'primary key', '', + static $replace = array('SERIAL', 'primary key', '', '', '', 'BOOLEAN NOT NULL', 'int2', 'int4', 'int4', 'int4', '', 'text'); break; @@ -300,7 +300,7 @@ function serendipity_db_probe($hash, &$errs) { if ($hash['dbType'] == "pdo-sqlite" || $hash['dbType'] == "sqlite3" || $hash['dbType'] == "sqlite" || $hash['dbType'] == 'sqlite3oo') { $dbName .= ".db"; # the old sqlite-wrapper appended this .db to the dbName, keep this for bc } - + $hash['dbConn'] = new Adapter( array( 'driver' => $hash['dbType'], @@ -313,7 +313,7 @@ function serendipity_db_probe($hash, &$errs) { try { $hash['dbConn']->getDriver()->getConnection(); - } catch( Exception $e ) { + } catch( Exception $e ) { $errs[] = ($e->getMessage()); } } @@ -336,7 +336,7 @@ function serendipity_db_concat($string) { return 'concat(' . $string . ')'; break; } - + } /* vim: set sts=4 ts=4 expandtab : */ diff --git a/include/db/mysql.inc.php b/include/db/mysql.inc.php index b3c1ed6c..270ed638 100644 --- a/include/db/mysql.inc.php +++ b/include/db/mysql.inc.php @@ -1,4 +1,4 @@ -fetchAll($result_type) AS $row) { - $row = serendipity_db_sqlite_fetch_array($row, $result_type); + $row = serendipity_db_sqlite_fetch_array($row, $result_type); if (!empty($assocKey)) { // You can fetch a key-associated array via the two function parameters assocKey and assocVal if (empty($assocVal)) { diff --git a/include/db/sqlite3.inc.php b/include/db/sqlite3.inc.php index 3c9c6d91..5bc47701 100644 --- a/include/db/sqlite3.inc.php +++ b/include/db/sqlite3.inc.php @@ -1,4 +1,5 @@ -getMessage() . "\n"; } - + if (!is_array($row)) { return $row; } @@ -307,7 +308,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re return $type_map['false']; return $type_map['true']; } - + return $rows; } @@ -337,7 +338,7 @@ function serendipity_db_probe($hash, &$errs) $dbfile = $serendipity['serendipityPath'] . $dbName . '.db'; } - + $serendipity['dbConn'] = new SQLite3($dbfile); if ($serendipity['dbConn']) { diff --git a/include/db/sqlrelay.inc.php b/include/db/sqlrelay.inc.php index 8e99319d..615ab3a4 100644 --- a/include/db/sqlrelay.inc.php +++ b/include/db/sqlrelay.inc.php @@ -1,5 +1,5 @@ 1 && (($g_y%4==0 && $g_y%100!=0) || ($g_y%400==0))){ - $j_days_in_month[12]++; - $leap = 1; + $j_days_in_month[12]++; + $leap = 1; } $j_month_name = array('', 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', @@ -360,7 +361,7 @@ function persian_date_utf($format, $timestamp='') { $output_str.=$j_days_in_month[$jm]; break; case 'L': - $output_str.=$leap; + $output_str.=$leap; break; case 'o': case 'Y': @@ -444,71 +445,71 @@ function persian_date_utf($format, $timestamp='') { * @return int returned timestamp */ function persian_mktime($hour='', $min='', $sec='', $mon='', $day='', $year='', $is_dst=-1){ - $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); + $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); - if ( (string) $hour == '') { $hour = persian_date_utf('H'); } - if ( (string) $min == '') { $min = persian_date_utf('i'); } - if ( (string) $sec == '') { $sec = persian_date_utf('s'); } - if ( (string) $day == '') { $day = persian_date_utf('j'); } - if ( (string) $mon == '') { $mon = persian_date_utf('n'); } - if ( (string) $year == '') { $year = persian_date_utf('Y'); } + if ( (string) $hour == '') { $hour = persian_date_utf('H'); } + if ( (string) $min == '') { $min = persian_date_utf('i'); } + if ( (string) $sec == '') { $sec = persian_date_utf('s'); } + if ( (string) $day == '') { $day = persian_date_utf('j'); } + if ( (string) $mon == '') { $mon = persian_date_utf('n'); } + if ( (string) $year == '') { $year = persian_date_utf('Y'); } - /* - an ugly, beta code snippet to support days <= zero! - it should work, but days in one or more months should calculate! - */ + /* + an ugly, beta code snippet to support days <= zero! + it should work, but days in one or more months should calculate! + */ - /* - if($day <= 0){ - // change sign - $day = abs($day); + /* + if($day <= 0){ + // change sign + $day = abs($day); - // calculate months and days that shall decrease - // this do-while has a lot of errors!!! - do{ - // $month_days = $j_days_in_month[$mon] - $months = floor($day/30); - $days = $day % 30; - }while(); + // calculate months and days that shall decrease + // this do-while has a lot of errors!!! + do{ + // $month_days = $j_days_in_month[$mon] + $months = floor($day/30); + $days = $day % 30; + }while(); - $mon -= $months; - $day -= $days; - if ($day < 1) { - $mon--; - } - } - */ + $mon -= $months; + $day -= $days; + if ($day < 1) { + $mon--; + } + } + */ - if($mon <= 0){ - // change sign - $mon = abs($mon); + if($mon <= 0){ + // change sign + $mon = abs($mon); - // calculate years and months that shall decrease - $years = floor($mon/12); - $months = $mon % 12; + // calculate years and months that shall decrease + $years = floor($mon/12); + $months = $mon % 12; - $year -= $years; - $mon -= $months; - if ($mon < 1) { - $year--; - $mon += 12; - } - } + $year -= $years; + $mon -= $months; + if ($mon < 1) { + $year--; + $mon += 12; + } + } - if ($day < 1) { - $temp_month = $mon-1; - $temp_year = $year; - if($temp_month <= 0){ - $temp_month = 12; - $temp_year--; - } - if ($temp_month>1 && (($temp_year%4==0 && $temp_year%100!=0) || ($temp_year%400==0))){ - $j_days_in_month[12] = 30; - }else{ - $j_days_in_month[12] = 29; - } - $day += $j_days_in_month[$temp_month]; - } + if ($day < 1) { + $temp_month = $mon-1; + $temp_year = $year; + if($temp_month <= 0){ + $temp_month = 12; + $temp_year--; + } + if ($temp_month>1 && (($temp_year%4==0 && $temp_year%100!=0) || ($temp_year%400==0))){ + $j_days_in_month[12] = 30; + }else{ + $j_days_in_month[12] = 29; + } + $day += $j_days_in_month[$temp_month]; + } list($year, $mon, $day)=p2g($year, $mon, $day); return mktime($hour, $min, $sec, $mon, $day, $year, $is_dst); diff --git a/include/functions_comments.inc.php b/include/functions_comments.inc.php index 0987d55a..a23e7445 100644 --- a/include/functions_comments.inc.php +++ b/include/functions_comments.inc.php @@ -1,4 +1,4 @@ - $_entry) { $entry = &$entries[$key]; - + if (isset($entry['entrytimestamp'])) { $e_ts = $entry['entrytimestamp']; } else { @@ -60,7 +61,7 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f $entry['author'] .= ' - ' . $entry['ctitle']; } $entry['title'] = (!empty($entry['author']) ? $entry['author'] : ANONYMOUS) . ': ' . $entry['title']; - + // No HTML allowed here: $entry['body'] = strip_tags($entry['body']); } @@ -162,5 +163,5 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f $entry['per_entry_display_dat'] = $entry['display_dat']; } } - + } diff --git a/include/functions_trackbacks.inc.php b/include/functions_trackbacks.inc.php index 80e469f1..c35fcb6a 100644 --- a/include/functions_trackbacks.inc.php +++ b/include/functions_trackbacks.inc.php @@ -1,4 +1,4 @@ - $title, 'url' => $url, @@ -390,7 +390,7 @@ function add_trackback ($id, $title, $url, $name, $excerpt) { function add_pingback ($id, $postdata) { global $serendipity; log_pingback("Reached add_pingback. ID:[$id]"); - + // XML-RPC Method call without named parameter. This seems to be the default way using XML-RPC if(preg_match('@\s* @is', $postdata, $matches)) { log_pingback("Pingback wp structure."); @@ -410,7 +410,7 @@ function add_pingback ($id, $postdata) { $id = evaluateIdByLocalUrl($local); log_pingback("ID set to $id"); } - + if ($id>0) { // first check, if we already have this pingback $comments = serendipity_fetchComments($id,1,'co.id',true,'PINGBACK'," AND co.url='" . serendipity_db_escape_string($remote) . "'"); @@ -458,7 +458,7 @@ function add_pingback ($id, $postdata) { function evaluateIdByLocalUrl($localUrl) { global $serendipity; - + // Build an ID searchpattern in configured permaling structure: $permalink_article = $serendipity['permalinkStructure']; log_pingback("perma: $permalink_article"); @@ -467,7 +467,7 @@ function evaluateIdByLocalUrl($localUrl) { $permalink_article = str_replace('?','\?',$permalink_article); $permalink_article = str_replace('%id%','(\d+)',$permalink_article); $permalink_article = str_replace('%title%','[^/]*',$permalink_article); - $permalink_article_regex = '@' . $permalink_article . '$@'; + $permalink_article_regex = '@' . $permalink_article . '$@'; log_pingback("regex: $permalink_article_regex"); if (preg_match($permalink_article_regex, $localUrl, $matches)) { @@ -499,17 +499,17 @@ function getPingbackParam($paramName, $data) { */ function fetchPingbackData( &$comment) { global $serendipity; - + // Don't fetch remote page, if not explicitly allowed in serendipity_config_local.php: if (empty($serendipity['pingbackFetchPage'])) { return; } - + // If we don't have a comment or a commentors url, stop it. if (!isset($comment) || !is_array($comment) || !isset($comment['url'])) { return; } - + // Max amount of characters fetched from the page doing a pingback: $fetchPageMaxLength = 200; if (isset($serendipity['pingbackFetchPageMaxLength'])){ @@ -517,9 +517,9 @@ function fetchPingbackData( &$comment) { } require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; $url = $comment['url']; - + if (function_exists('serendipity_request_start')) serendipity_request_start(); - + // Request the page $req = new HTTP_Request($url, array('allowRedirects' => true, 'maxRedirects' => 5, 'timeout' => 20, 'readTimeout' => array(5,0))); @@ -527,7 +527,7 @@ function fetchPingbackData( &$comment) { $responses = "/(200 OK)|(30[0-9] Found)/"; // |(30[0-9] Moved) if ((PEAR::isError($req->sendRequest()) || preg_match($responses, $req->getResponseCode()))) { // nothing to do, - } + } else { $fContent = $req->getResponseBody(); @@ -535,7 +535,7 @@ function fetchPingbackData( &$comment) { if (preg_match('@]*>.*?\s*pingback.ping\s* \s*\s*\s* \s*\s* \s*\s*\s*([^<]*) \s*\s* \s*\s*([^<]*) \s*]*>(.*?) .*?@is',$fContent,$matches)) { $comment['title'] = serendipity_entity_decode(strip_tags($matches[1]), ENT_COMPAT, LANG_CHARSET); } - + // Try to get content from firsttag on: if (preg_match('@
]*>(.*?)