cleanup tabs and whites

This commit is contained in:
Ian 2014-11-24 14:17:38 +01:00
parent 6d7e2f44a3
commit 8da4c647a8
38 changed files with 665 additions and 658 deletions

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -59,7 +59,7 @@ if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
}
}
}
serendipity_rebuildCategoryTree();
$serendipity['GET']['adminAction'] = 'view';
@ -128,7 +128,6 @@ if ( $serendipity['GET']['adminAction'] == 'delete' ) {
foreach ($cats as $cat_data) {
if ($cat_data['categoryid'] != $serendipity['GET']['cid'] && (serendipity_checkPermission('adminCategoriesMaintainOthers') || $cat_data['authorid'] == '0' || $cat_data['authorid'] == $serendipity['authorid'])) {
$data['cats'][] = $cat_data;
}
}
}
@ -163,7 +162,7 @@ if ( $serendipity['GET']['adminAction'] == 'edit' || $serendipity['GET']['adminA
$data['cid'] = $cid;
$data['this_cat'] = $this_cat;
$data['save'] = $save;
$groups = serendipity_getAllGroups();
$data['groups'] = $groups;
$data['read_groups'] = $read_groups;
@ -188,7 +187,7 @@ if ( $serendipity['GET']['adminAction'] == 'edit' || $serendipity['GET']['adminA
ob_end_clean();
}
if ( $serendipity['GET']['adminAction'] == 'view' ) {
if (empty($admin_category)) {

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
@ -133,13 +133,13 @@ if (isset($serendipity['GET']['adminAction']) && ($serendipity['GET']['adminActi
'parent_id' => $serendipity['GET']['id']
);
}
$target_url = '?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=doReply&amp;serendipity[id]=' . (int)$serendipity['GET']['id'] . '&amp;serendipity[entry_id]=' . (int)$serendipity['GET']['entry_id'] . '&amp;serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;' . 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 = '';

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
@ -217,7 +217,7 @@ switch($serendipity['GET']['adminAction']) {
$data['switched_output'] = false;
$filter_import = array('author', 'category', 'isdraft');
$sort_import = array('perPage', 'ordermode', 'order');
foreach($filter_import AS $f_import) {
serendipity_restoreVar($serendipity['COOKIE']['entrylist_filter_' . $f_import], $serendipity['GET']['filter'][$f_import]);
$data["get_filter_$f_import"] = $serendipity['GET']['filter'][$f_import];
@ -341,7 +341,7 @@ switch($serendipity['GET']['adminAction']) {
);
}
$data['entries'] = $smartentries;
$data['urltoken'] = serendipity_setFormToken('url');
$data['formtoken'] = serendipity_setFormToken();

View File

@ -1,4 +1,4 @@
<?php #
<?php
if (IN_serendipity !== true) {
die ('Don\'t hack!');
@ -50,7 +50,7 @@ if ( $serendipity['GET']['adminAction'] != 'delete' ) {
if ( ! (isset($_POST['NEW']) || $serendipity['GET']['adminAction'] == 'new') ) {
$data['start'] = true;
}
$data['deleteFormToken'] = serendipity_setFormToken('url');
$data['deleteFormToken'] = serendipity_setFormToken('url');
}
if ($serendipity['GET']['adminAction'] == 'edit' || isset($_POST['NEW']) || $serendipity['GET']['adminAction'] == 'new') {
@ -60,7 +60,7 @@ if ($serendipity['GET']['adminAction'] == 'edit' || isset($_POST['NEW']) || $ser
$data['edit'] = true;
}
$data['formToken'] = serendipity_setFormToken();
if ($serendipity['GET']['adminAction'] == 'edit') {
$group = serendipity_fetchGroup($serendipity['GET']['group']);
$from = &$group;
@ -109,7 +109,7 @@ if ($serendipity['GET']['adminAction'] == 'edit' || isset($_POST['NEW']) || $ser
$data['allplugins'][$plugid]['has_permission'] = serendipity_hasPluginPermissions($plugid, $from['id']);
}
ksort($allhooks);
$data['allhooks'] = $allhooks;
foreach($allhooks AS $hook => $set) {
$data['allhooks'][$hook]['has_permission'] = serendipity_hasPluginPermissions($hook, $from['id']);

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
@ -15,7 +15,7 @@ if (!is_object($serendipity['smarty'])) {
}
switch ($serendipity['GET']['adminAction']) {
case 'doSync':
$data['case_doSync'] = true;
$data['perm_adminImagesSync'] = true;
@ -66,7 +66,7 @@ switch ($serendipity['GET']['adminAction']) {
$data['messages'] = $messages;
unset($messages);
break;
case 'doMultiDelete':
if (!serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDelete')) {
@ -171,7 +171,7 @@ switch ($serendipity['GET']['adminAction']) {
$authorid = (isset($serendipity['POST']['all_authors']) && $serendipity['POST']['all_authors'] == 'true') ? '0' : $serendipity['authorid'];
$new_media = array();
$serendipity['POST']['imageurl'] = serendipity_specialchars($serendipity['POST']['imageurl']);
// First find out whether to fetch a file or accept an upload
@ -381,7 +381,7 @@ switch ($serendipity['GET']['adminAction']) {
// Directory exists and is writable. Now dive within subdirectories and kill 'em all.
serendipity_killPath($serendipity['serendipityPath'] . $serendipity['uploadPath'], $new_dir, (isset($serendipity['POST']['nuke']) ? true : false));
$data['ob_serendipity_killPath'] = ob_get_contents();
ob_end_clean();
ob_end_clean();
}
} else {
$data['print_ERROR_NO_DIRECTORY'] = sprintf(ERROR_NO_DIRECTORY, $new_dir);
@ -416,7 +416,7 @@ switch ($serendipity['GET']['adminAction']) {
ob_start();
serendipity_moveMediaDirectory($oldDir, $newDir);
$data['ob_serendipity_moveMediaDirectory'] = ob_get_contents();
ob_end_clean();
ob_end_clean();
$use_dir = $newDir;
}
serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'], $use_dir);
@ -681,7 +681,7 @@ switch ($serendipity['GET']['adminAction']) {
function showMediaLibrary($messages=false, $addvar_check = false, $smarty_vars = array()) {
global $serendipity;
if (!serendipity_checkPermission('adminImagesView')) {
return;
}

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -29,8 +29,8 @@ class Serendipity_Import {
* @access public
* @return string HTML-code of a interface/user hint
*/
function getImportNotes() {
return "";
function getImportNotes() {
return "";
}
/**
@ -42,7 +42,7 @@ class Serendipity_Import {
*/
function getCharsets($utf8_default = true) {
$charsets = array();
if (!$utf8_default) {
$charsets['native'] = LANG_CHARSET;
}
@ -54,11 +54,11 @@ class Serendipity_Import {
if (LANG_CHARSET != 'ISO-8859-1') {
$charsets['ISO-8859-1'] = 'ISO-8859-1';
}
if ($utf8_default) {
$charsets['native'] = LANG_CHARSET;
}
return $charsets;
}
@ -92,7 +92,7 @@ class Serendipity_Import {
return $string;
}
return $out;
case 'UTF-8':
default:
$out = utf8_decode($string);
@ -132,7 +132,7 @@ class Serendipity_Import {
return $data;
}
/**
* Get the transcoding table, depending on whether it was enabled for the instance of the importer plugin
*
@ -181,16 +181,16 @@ class Serendipity_Import {
case 'ISO-8859-1':
$dbn = 'latin1';
break;
case 'UTF-8':
$dbn = 'utf8';
break;
}
if ($dbn && $serendipity['dbNames']) {
mysql_query("SET NAMES " . $dbn, $db);
}
$return = &mysql_query($query, $db);
mysql_select_db($serendipity['dbName'], $serendipity['dbConn']);
serendipity_db_reconnect();
@ -217,7 +217,7 @@ if (isset($serendipity['GET']['importFrom']) && serendipity_checkFormToken()) {
/* import() MUST return (bool)true, otherwise we assume it failed */
if ( ($result = $importer->import()) !== true ) {
$data['result'] = $result;
}
}
/* Apprently we do not have valid data, ask for some */
} else {
$data['formToken'] = serendipity_setFormToken();

View File

@ -1,9 +1,9 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
/****************************************************************
* Blogger Importer v0.2, by Jawish Hameed (jawish.org) *
* Blogger Importer v0.2, by Jawish Hameed (jawish.org) *
****************************************************************/
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
@ -34,103 +34,103 @@ class Serendipity_Import_Blogger extends Serendipity_Import {
'name' => '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 .= '<a class="block_level standalone" href="https://www.google.com/accounts/AuthSubRequest?scope=http%3A%2F%2Fwww.blogger.com%2Ffeeds%2F&session=1&secure=0&next='. urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']) .'">Go to Google to grant access</a>';
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 .= '<a class="block_level standalone" href="https://www.google.com/accounts/AuthSubRequest?scope=http%3A%2F%2Fwww.blogger.com%2Ffeeds%2F&session=1&secure=0&next='. urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']) .'">Go to Google to grant access</a>';
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 '<span class="block_level">Successfully exported entries from Blogger</span>';
// 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 '<span class="block_level">Current list of authors: </span>'. join(', ', array_values($authorList));
// Do cleanup and report on entries
echo '<span class="block_level">The following entries were successfully imported:</span>';
echo '<ul>';
foreach ($entryList as $eId => $eDetails) {
// Update comment count for entry in s9y
serendipity_db_query("UPDATE ". $serendipity['dbPrefix'] ."entries SET comments = ". $eDetails[2] ." WHERE id = ". $eDetails[0]);
echo '<li>'. $eDetails[1] .' comments('. $eDetails[2] .')</li>';
}
echo '</ul>';
// Report fails
echo '<span class="block_level">The following entries ran into trouble and was not imported:</span>';
echo '<ul>';
foreach ($entryFailList as $eId => $eDetails) {
echo '<li>'. $eDetails .'</li>';
}
echo '</ul>';
// Reset autodiscovery
$serendipity['noautodiscovery'] = $noautodiscovery;
// All done!
echo '<span class="msg_notice">Import finished.</span>';
return true;
}
// 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 '<span class="block_level">Successfully exported entries from Blogger</span>';
// 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 '<span class="block_level">Current list of authors: </span>'. join(', ', array_values($authorList));
// Do cleanup and report on entries
echo '<span class="block_level">The following entries were successfully imported:</span>';
echo '<ul>';
foreach ($entryList as $eId => $eDetails) {
// Update comment count for entry in s9y
serendipity_db_query("UPDATE ". $serendipity['dbPrefix'] ."entries SET comments = ". $eDetails[2] ." WHERE id = ". $eDetails[0]);
echo '<li>'. $eDetails[1] .' comments('. $eDetails[2] .')</li>';
}
echo '</ul>';
// Report fails
echo '<span class="block_level">The following entries ran into trouble and was not imported:</span>';
echo '<ul>';
foreach ($entryFailList as $eId => $eDetails) {
echo '<li>'. $eDetails .'</li>';
}
echo '</ul>';
// Reset autodiscovery
$serendipity['noautodiscovery'] = $noautodiscovery;
// All done!
echo '<span class="msg_notice">Import finished.</span>';
return true;
}
}

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -136,35 +136,35 @@ class Serendipity_Import_Generic extends Serendipity_Import {
function import_wpxrss() {
// TODO: Backtranscoding to NATIVE charset. Currently only works with UTF-8.
$dry_run = false;
$serendipity['noautodiscovery'] = 1;
$uri = $this->data['url'];
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
serendipity_request_start();
$req = new HTTP_Request($uri, array('allowRedirects' => true, 'maxRedirects' => 5));
$res = $req->sendRequest();
if (PEAR::isError($res) || $req->getResponseCode() != '200') {
serendipity_request_end();
echo '<span class="block_level">' . IMPORT_FAILED . ': ' . serendipity_specialchars($this->data['url']) . '</span>';
return false;
}
$fContent = $req->getResponseBody();
serendipity_request_end();
echo '<span class="block_level">' . strlen($fContent) . " Bytes</span>";
if (version_compare(PHP_VERSION, '5.0') === -1) {
echo '<span class="block_level">';
printf(UNMET_REQUIREMENTS, 'PHP >= 5.0');
echo "</span>";
return false;
}
$xml = simplexml_load_string($fContent);
unset($fContent);
/* ************* USERS **********************/
$_s9y_users = serendipity_fetchUsers();
$s9y_users = array();
@ -214,12 +214,12 @@ class Serendipity_Import_Generic extends Serendipity_Import {
$wp_items = $item->children($wp_ns);
$dc_items = $item->children($dc_ns);
$content_items = $item->children($content_ns);
// TODO: Attachments not handled
if ((string)$wp_items->post_type == 'attachment' OR (string)$wp_items->post_type == 'page') {
continue;
}
$entry = array(
'title' => (string)$item->title,
'isdraft' => ((string)$wp_items->status == 'publish' ? 'false' : 'true'),
@ -227,7 +227,7 @@ class Serendipity_Import_Generic extends Serendipity_Import {
'categories' => array(),
'body' => (string)$content_items->encoded
);
if (preg_match('@^([0-9]{4})\-([0-9]{2})\-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$@', (string)$wp_items->post_date, $timematch)) {
$entry['timestamp'] = mktime($timematch[4], $timematch[5], $timematch[6], $timematch[2], $timematch[3], $timematch[1]);
} else {
@ -247,7 +247,7 @@ class Serendipity_Import_Generic extends Serendipity_Import {
$cstring = (string)$item->category;
$entry['categories'][] = $s9y_cat[$cstring];
}
$wp_user = (string)$dc_items->creator;
if (!isset($s9y_users[$wp_user])) {
if ($dry_run) {
@ -261,13 +261,13 @@ class Serendipity_Import_Generic extends Serendipity_Import {
}
$entry['authorid'] = $s9y_users[$wp_user]['authorid'];
if ($dry_run) {
$id = time();
} else {
$id = serendipity_updertEntry($entry);
}
$s9y_cid = array(); // Holds comment ids to s9y ids association.
$c_i = 0;
foreach($wp_items->comment AS $comment) {
@ -299,7 +299,7 @@ class Serendipity_Import_Generic extends Serendipity_Import {
} else {
$s9y_comment['timestamp'] = time();
}
if ($dry_run) {
$cid = time();
} else {
@ -311,7 +311,7 @@ class Serendipity_Import_Generic extends Serendipity_Import {
}
$s9y_cid[$c_id] = $cid;
}
echo "<span class='msg_notice'>Entry '" . serendipity_specialchars($entry['title']) . "' ($c_i comments) imported.</span>";
}
return true;

View File

@ -1,4 +1,5 @@
<?php # $Id: generic.inc.php 717 2005-11-21 09:56:25Z garvinhicking $
<?php
# $Id: generic.inc.php 717 2005-11-21 09:56:25Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# Copyright (c) 2009, Matthew Weigel
# All rights reserved. See LICENSE file for licensing details
@ -135,7 +136,7 @@ class Serendipity_Import_LiveJournalXML extends Serendipity_Import {
);
unset($vals);
}
return $tree;
}
@ -204,17 +205,17 @@ class Serendipity_Import_LiveJournalXML extends Serendipity_Import {
printf(FILE_NOT_FOUND, serendipity_specialchars($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' => '',
@ -222,7 +223,7 @@ class Serendipity_Import_LiveJournalXML extends Serendipity_Import {
'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) {
@ -238,11 +239,11 @@ class Serendipity_Import_LiveJournalXML extends Serendipity_Import {
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;
@ -266,7 +267,7 @@ class Serendipity_Import_LiveJournalXML extends Serendipity_Import {
}
echo '<span class="msg_notice">Inserted comments for entry #' . $id . '</span>';
}
if (function_exists('ob_flush')) {
@ob_flush();
}

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -70,7 +70,7 @@ class Serendipity_Import_Nucleus extends Serendipity_Import {
if ($this->data['autodiscovery'] == 'false') {
$serendipity['noautodiscovery'] = 1;
}
$this->getTransTable();
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -238,7 +238,7 @@ class Serendipity_Import_phpbb extends Serendipity_Import {
break;
}
}
/* Comments */
$topic_id = $entries[$x]['topic_id'];
$c_res = @$this->nativeQuery("SELECT t.topic_title,
@ -259,7 +259,7 @@ class Serendipity_Import_phpbb extends Serendipity_Import {
if (!$c_res) {
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($gdb));
}
while ($a = mysql_fetch_assoc($c_res)) {
if ($a['post_id'] == $entries[$x]['post_id']) {
continue;

View File

@ -1,4 +1,5 @@
<?php # $Id: b2evolution.inc.php 1093 2006-04-13 10:49:52Z garvinhicking $
<?php
# $Id: b2evolution.inc.php 1093 2006-04-13 10:49:52Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -104,10 +105,10 @@ class Serendipity_Import_Serendipity extends Serendipity_Import {
echo 'Dupe-Check: <pre>' . print_r($dupes, true) . '</pre>';
}
}
$res = $this->nativeQuery("SELECT * FROM {$this->data['prefix']}" . $table . " " . $where, $s9ydb);
echo mysql_error($s9ydb);
if (!$res || mysql_num_rows($res) < 1) {
return false;
}
@ -119,7 +120,7 @@ class Serendipity_Import_Serendipity extends Serendipity_Import {
foreach($primary_keys AS $primary_key) {
$primary_vals[$primary_key] = $row[$primary_key];
if ($table == 'comments') {
$primary_vals['entry_id'] = $row['entry_id'];
$primary_vals['entry_id'] = $row['entry_id'];
}
unset($row[$primary_key]);
}
@ -131,15 +132,15 @@ class Serendipity_Import_Serendipity extends Serendipity_Import {
if (is_array($fix_relations)) {
foreach($fix_relations AS $primary_key => $fix_relation) {
foreach($fix_relation AS $fix_relation_table => $fix_relation_primary_key) {
if ($table == 'comments' && $fix_relation_table == 'entries') {
$assoc_val = $primary_vals['entry_id'];
} elseif (isset($primary_vals[$fix_relation_primary_key])) {
if ($table == 'comments' && $fix_relation_table == 'entries') {
$assoc_val = $primary_vals['entry_id'];
} elseif (isset($primary_vals[$fix_relation_primary_key])) {
$assoc_val = $primary_vals[$fix_relation_primary_key];
} else {
$assoc_val = $row[$primary_key];
$assoc_val = $row[$primary_key];
}
if (!$this->execute && empty($assoc_val)) {
if ($this->debug) {
echo '<pre>';
@ -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 "<span>Fix relation from $fix_relation_table.$fix_relation_primary_key={$primary_vals[$fix_relation_primary_key]} to {$row[$primary_key]} (assoc_val: $assoc_val)</span>";
}
@ -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 . ':<pre>' . print_r($this->storage[$table], true) . '</pre>';
} 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);

View File

@ -1,8 +1,9 @@
<?php # $Id: voodoopad.inc.php 1 2005-04-16 06:39:31Z timputnam $
<?php
# $Id: voodoopad.inc.php 1 2005-04-16 06:39:31Z timputnam $
# Copyright (c) 2003-2005, Tim Putnam
/*****************************************************************
* VoodooPad Importer, by Tim Putnam
* VoodooPad Importer, by Tim Putnam
* http://deepbluesea.fracsoft.com *
*****************************************************************/
@ -39,7 +40,7 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import {
var $data = array();
var $inputFields = array();
var $force_recode = false;
function Serendipity_Import_VoodooPad($data) {
$this->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': // <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 '<span class="block_level">'.IMPORTER_VOODOO_CREATINGPAGE.': '. $mykey.'</span>';
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 '<span class="block_level">'.IMPORTER_VOODOO_UPDATINGPAGE.': '. $mykey.'</span>';
serendipity_db_update("staticpages", array("id" => $thispage["id"]), $thispage);
@ -174,7 +175,7 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import {
echo '<span class="block_level">'.IMPORTER_VOODOO_RECORDURL.': '.$thispage['headline'].'</span>';
$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 '<p>'.IMPORTER_VOODOO_WRITEINTRALINKS.'</p>';
$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 '<span class="msg_success">' . DONE . '</span>';
}
}
// 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), '<a href="'.$link.'">'.$alias.'</a>', $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;
}

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -49,11 +49,11 @@ class Serendipity_Import_WordPress extends Serendipity_Import {
'type' => '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 "<span class='block_level'>Importing users...</span>";
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 "<span class='msg_success'>Imported users.</span>";
// Clean memory
unset($users);
}
@ -158,7 +158,7 @@ class Serendipity_Import_WordPress extends Serendipity_Import {
for ($x=0 ; $x<mysql_num_rows($res) ; $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, $c = sizeof($categories) ; $x < $c ; $x++) {
$cat = array('category_name' => $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<mysql_num_rows($res) ; $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, $c = sizeof($categories) ; $x < $c ; $x++) {
$cat = array('category_name' => $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 "<span class='block_level'>Importing entries...</span>";
for ($x=0, $c = mysql_num_rows($res) ; $x < $c ; $x++ ) {
$entries[$x] = mysql_fetch_assoc($res);
$content = explode('<!--more-->', $entries[$x]['post_content'], 2);
$body = $content[0];
$extended = $content[1];
$entry = array('title' => $this->decode($entries[$x]['post_title']), // 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 "<span class='block_level'>ID: {$entries[$x]['ID']} - {$entry['title']}</span>";
return $entries[$x]['entryid'];
}
$assoc['entries'][$entries[$x]['ID']] = $entries[$x]['entryid'];
}
if ($debug) echo "<span class='msg_success'>Imported entries...</span>";
@ -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);

View File

@ -1,4 +1,4 @@
<?php #
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
@ -101,15 +101,15 @@ if ( (int)$serendipity['GET']['step'] == 0 ) {
$data['s9yversion'] = $serendipity['version'];
$errorCount = 0;
if (is_readable(S9Y_INCLUDE_PATH . 'checksums.inc.php')) {
$badsums = serendipity_verifyFTPChecksums();
if (empty($badsums)) {
$data['installerResultDiagnose_CHECKSUMS'][] = serendipity_installerResultDiagnose(S9Y_I_SUCCESS, CHECKSUMS_PASS);
} else {
} else {
foreach ($badsums as $file => $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);

View File

@ -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;

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
@ -30,7 +30,7 @@ switch($serendipity['POST']['adminAction']) {
serendipity_set_config_var('updateCheck', false);
break;
}
$user = serendipity_fetchAuthor($serendipity['authorid']);
// chrome-compatible, from Oliver Gassner, adapted from TextPattern. Hi guys, keep it up. :-)
@ -57,10 +57,10 @@ $comments = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPref
if (count($comments) > 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);

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -25,9 +25,9 @@ if ($serendipity['GET']['adminAction'] == 'save' && serendipity_checkFormToken()
} elseif ( (!empty($_POST['password'])
&&
!empty($_POST['check_password'])
&&
&&
$_POST['check_password'] != $_SESSION['serendipityPassword']
&&
&&
serendipity_passwordhash($_POST['check_password']) != $_SESSION['serendipityPassword'])
||
(!empty($_POST['password'])
@ -52,7 +52,7 @@ if ($serendipity['GET']['adminAction'] == 'save' && serendipity_checkFormToken()
if (!is_array($_POST[$item['var']])) {
continue;
}
// Check that no user may assign groups he's not allowed to.
foreach($_POST[$item['var']] AS $groupkey => $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);

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
if (IN_serendipity !== true) {
die ('Don\'t hack!');
@ -69,7 +69,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
return;
}
$data['plugin_to_conf'] = true;
$bag = new serendipity_property_bag;
$plugin->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);

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -27,11 +27,11 @@ class template_option {
function set_config($item, $value) {
global $serendipity;
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}options
WHERE okey = 't_" . serendipity_db_escape_string($serendipity['template']) . "'
AND name = '" . serendipity_db_escape_string($item) . "'");
if ($this->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);

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
if (IN_serendipity !== true) {
die ('Don\'t hack!');
@ -220,7 +220,7 @@ $tasks = array(array('version' => '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".<br /><pre>' . implode(', ', $dead_htmlarea_dirs) . '</pre>'),
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;
}

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -190,7 +190,7 @@ if ($serendipity['GET']['adminAction'] != 'delete') {
$data['users'][$user]['userlevel_name'] = $serendipity['permissionLevels'][$userdata['userlevel']];
}
}
if ( ! (isset($_POST['NEW']) || $serendipity['GET']['adminAction'] == 'new') && serendipity_checkPermission('adminUsersCreateNew')) {
$data['new'] = true;
}
@ -201,7 +201,7 @@ if ( ($serendipity['GET']['adminAction'] == 'edit' && serendipity_checkPermissio
$data['adminAction'] = $serendipity['GET']['adminAction'];
$data['show_form'] = true;
$data['formToken'] = serendipity_setFormToken();
if ($serendipity['GET']['adminAction'] == 'edit') {
$user = serendipity_fetchUsers($serendipity['GET']['userid']);
$group_intersect = serendipity_intersectGroup($user[0]['authorid']);
@ -214,7 +214,7 @@ if ( ($serendipity['GET']['adminAction'] == 'edit' && serendipity_checkPermissio
$from = &$user[0];
unset($from['password']);
} else {
$from = array();
}
} else {

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -83,7 +83,7 @@ function serendipity_db_insert($table, $values, $action = 'execute')
}
$q = "INSERT INTO {$serendipity['dbPrefix']}$table ($names) values ($vals)";
if ($action == 'execute') {
return serendipity_db_query($q);
} else {
@ -146,11 +146,11 @@ function serendipity_db_get_interval($val, $ival = 900) {
$ts = 'NOW()';
break;
}
switch($val) {
case 'interval':
return $interval;
default:
case 'ts':
return $ts;
@ -171,7 +171,7 @@ function serendipity_db_implode($string, &$array, $type = 'int') {
if (!is_array($array)) {
return '';
}
foreach($array AS $idx => $key) {
if ($type == 'int') {
$new_array[$idx] = (int)$key;

View File

@ -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 : */

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -86,7 +86,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
if ($benchmark) {
$end = microtime_float();
mysql_query("INSERT INTO BLOGLOG (request, timestamp, sql, exec_time, ip) VALUES ('" . serendipity_db_escape_string($_SERVER['REQUEST_URI']) . "', NOW(), '" . serendipity_db_escape_string($sql) . "', '" . (number_format($end-$start, 10)) . "', '" . serendipity_db_escape_string($_SERVER['REMOTE_ADDR']) . "')");
$psql = $sql;
$psql = preg_replace('@[0-9]{10}@', 'TIMESTAMP', $psql);
mysql_query("UPDATE BLOGLOG_TOTAL SET counter = counter + 1 WHERE sql = '" . serendipity_db_escape_string($psql) . "'");

View File

@ -255,7 +255,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
$rows = array();
foreach($serendipity['dbSth']->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)) {

View File

@ -1,4 +1,5 @@
<?php # $Id: sqlite.inc.php 1670 2007-04-10 13:23:34Z garvinhicking $
<?php
# $Id: sqlite.inc.php 1670 2007-04-10 13:23:34Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -49,7 +50,7 @@ function serendipity_db_connect()
return $serendipity['dbConn'];
}
// SQLite3 doesn't support persistent connections
// SQLite3 doesn't support persistent connections
$serendipity['dbConn'] = sqlite3_open((defined('S9Y_DATA_PATH') ? S9Y_DATA_PATH : $serendipity['serendipityPath']) . $serendipity['dbName'] . '.db');
return $serendipity['dbConn'];

View File

@ -1,4 +1,5 @@
<?php # $Id: sqlite.inc.php 1670 2007-04-10 13:23:34Z garvinhicking $
<?php
# $Id: sqlite.inc.php 1670 2007-04-10 13:23:34Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -49,7 +50,7 @@ function serendipity_db_connect()
return $serendipity['dbConn'];
}
// SQLite3 doesn't support persistent connections
// SQLite3 doesn't support persistent connections
$serendipity['dbConn'] = new SQLite3((defined('S9Y_DATA_PATH') ? S9Y_DATA_PATH : $serendipity['serendipityPath']) . $serendipity['dbName'] . '.db');
return $serendipity['dbConn'];
@ -148,7 +149,7 @@ function serendipity_db_sqlite_fetch_array($res, $type = SQLITE3_BOTH)
$row = false;
echo "SQLITE-EXCEPTION: " . $e->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']) {

View File

@ -1,5 +1,5 @@
<?php
# mysql_sqlrelay.inc.php modified from mysql.inc.php 2007-10-06
# mysql_sqlrelay.inc.php modified from mysql.inc.php 2007-10-06
# dantemason@gmail.com
/**
@ -149,7 +149,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
$cur = sqlrcur_alloc($serendipity['dbConn']);
$sql_b="INSERT INTO BLOGLOG (request, timestamp, sql, exec_time, ip) VALUES ('" . serendipity_db_escape_string($_SERVER['REQUEST_URI']) . "', NOW(), '" . serendipity_db_escape_string($sql) . "', '" . (number_format($end-$start, 10)) . "', '" . serendipity_db_escape_string($_SERVER['REMOTE_ADDR']) . "')";
$c = sqlrcur_sendQuery($cur, $sql_b);
$psql = $sql;
$psql = preg_replace('@[0-9]{10}@', 'TIMESTAMP', $psql);
$sql_U="UPDATE BLOGLOG_TOTAL SET counter = counter + 1 WHERE sql = '" . serendipity_db_escape_string($psql) . "'";
@ -205,7 +205,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
$row=generate_resultset($cur);
$rows=array();
for($idx=0, $idxc = count($row); $idx < $idxc ; $idx++) {
if (!empty($assocKey)) {
// You can fetch a key-associated array via the two function parameters assocKey and assocVal
@ -218,7 +218,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
$rows = $row;
}
}
return $rows;
}
@ -230,7 +230,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
* @access public
* @return int Value of the auto-increment column
*
* If you insert multiple rows using a single INSERT statement,
* If you insert multiple rows using a single INSERT statement,
* LAST_INSERT_ID() returns the value generated for the first inserted row only.
*/
function serendipity_db_insert_id($table = '', $id = '') {
@ -267,11 +267,11 @@ function serendipity_db_insert_id($table = '', $id = '') {
*/
function serendipity_db_affected_rows() {
global $serendipity;
/* int sqlrcur_affectedRows(int sqlrcurref)
* Returns the number of rows that were updated, inserted or deleted by the query.
* Not all databases support this call.
* Don't use it for applications which are designed to be portable across databases.
* Returns the number of rows that were updated, inserted or deleted by the query.
* Not all databases support this call.
* Don't use it for applications which are designed to be portable across databases.
* -1 is returned by databases which don't support this option.
*/
@ -459,7 +459,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/') ||
@ -476,10 +476,10 @@ 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;
case "sqlite":
static $search = array('{AUTOINCREMENT}', '{PRIMARY}', '{UNSIGNED}', '{FULLTEXT}', '{FULLTEXT_MYSQL}', '{BOOLEAN}', '{UTF_8}', '{TEXT}');
static $replace = array('INTEGER', 'PRIMARY KEY', '', '', '', 'BOOLEAN NOT NULL', '', 'LONGTEXT');

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -139,14 +139,14 @@ function serendipity_strftime($format, $timestamp = null, $useOffset = true, $us
}
$out = strftime($format, $timestamp);
break;
case 'persian-utf8':
if ($timestamp == null) {
$timestamp = serendipity_serverOffsetHour();
} elseif ($useOffset) {
$timestamp = serendipity_serverOffsetHour($timestamp);
}
require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
$out = persian_strftime_utf($format, $timestamp);
break;
@ -184,7 +184,7 @@ function serendipity_formatTime($format, $time, $useOffset = true, $useDate = fa
$cache[$format] = str_replace('%e', '%d', $cache[$format]);
}
}
return serendipity_mb('ucfirst', serendipity_strftime($cache[$format], (int)$time, $useOffset, $useDate));
}
@ -741,7 +741,7 @@ function serendipity_track_referrer($entry = 0) {
$ts = serendipity_db_get_interval('ts');
$interval = serendipity_db_get_interval('interval', 900);
$url_parts['query'] = substr($url_parts['query'], 0, 255);
$suppressq = "SELECT count(1)

View File

@ -1,4 +1,5 @@
<?php # $Id: functions.inc.php 114 2005-05-22 15:37:11Z garvinhicking $
<?php
# $Id: functions.inc.php 114 2005-05-22 15:37:11Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -126,8 +127,8 @@ function p2g($j_y, $j_m, $j_d){
*/
function persian_strftime_utf($format, $timestamp='') {
if($timestamp==''){
$timestamp = mktime();
if($timestamp==''){
$timestamp = mktime();
}
$g_d=date('j', $timestamp);
@ -276,10 +277,10 @@ function persian_strftime_utf($format, $timestamp='') {
function persian_date_utf($format, $timestamp='') {
if($timestamp==''){
$timestamp = mktime();
$timestamp = mktime();
}
$g_d=date('j', $timestamp);
$g_d=date('j', $timestamp);
$g_m=date('n', $timestamp);
$g_y=date('Y', $timestamp);
@ -288,8 +289,8 @@ function persian_date_utf($format, $timestamp='') {
$j_days_in_month = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
$leap = 0;
if ($g_m>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);

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -36,7 +36,7 @@ function serendipity_checkCommentToken($token, $cid) {
}
}
}
return $goodtoken;
}
@ -401,7 +401,7 @@ function serendipity_printComments($comments, $parentid = 0, $depth = 0, $trace
if (isset($comment['title'])) {
$comment['title'] = serendipity_specialchars($comment['title']);
}
if (serendipity_userLoggedIn()) {
if ($comment['subscribed'] == 'true') {
if ($comment['status'] == 'approved') {
@ -534,7 +534,7 @@ function serendipity_deleteComment($id, $entry_id, $type='comments', $token=fals
$goodtoken = serendipity_checkCommentToken($token, $id);
if ($_SESSION['serendipityAuthedUser'] === true || $goodtoken) {
$admin = '';
if (!$goodtoken && !serendipity_checkPermission('adminEntriesMaintainOthers')) {
$admin = " AND authorid = " . (int)$_SESSION['serendipityAuthorid'];
@ -542,7 +542,7 @@ function serendipity_deleteComment($id, $entry_id, $type='comments', $token=fals
// Load articles author id and check it
$sql = serendipity_db_query("SELECT authorid FROM {$serendipity['dbPrefix']}entries
WHERE entry_id = ". $entry_id, true);
if ($sql['authorid'] != $serendipity['authorid']) {
if ($sql['authorid'] != $serendipity['authorid']) {
return false; // wrong user having no adminEntriesMaintainOthers right
}
@ -652,24 +652,24 @@ function serendipity_approveComment($cid, $entry_id, $force = false, $moderate =
". ((!serendipity_checkPermission('adminEntriesMaintainOthers') && $force !== true && !$goodtoken) ? "AND e.authorid = '". (int)$serendipity['authorid'] ."'" : '') ."
". (($force === true) ? "" : "AND status = 'pending'");
$rs = serendipity_db_query($sql, true);
// Check for adminEntriesMaintainOthers
if (!$force && !$goodtoken && $rs['entry_authorid'] != $serendipity['authorid'] && !serendipity_checkPermission('adminEntriesMaintainOthers')) {
return false; // wrong user having no adminEntriesMaintainOthers right
}
$flip = false;
if ($moderate === 'flip') {
$flip = true;
$flip = false;
if ($moderate === 'flip') {
$flip = true;
if ($rs['status'] == 'pending') {
$sql = "UPDATE {$serendipity['dbPrefix']}comments SET status = 'approved' WHERE id = ". (int)$cid;
$moderate = false;
} else {
$sql = "UPDATE {$serendipity['dbPrefix']}comments SET status = 'pending' WHERE id = ". (int)$cid;
$moderate = true;
}
} elseif ($moderate) {
if ($rs['status'] == 'pending') {
$sql = "UPDATE {$serendipity['dbPrefix']}comments SET status = 'approved' WHERE id = ". (int)$cid;
$moderate = false;
} else {
$sql = "UPDATE {$serendipity['dbPrefix']}comments SET status = 'pending' WHERE id = ". (int)$cid;
$moderate = true;
}
} elseif ($moderate) {
$sql = "UPDATE {$serendipity['dbPrefix']}comments SET status = 'pending' WHERE id = ". (int)$cid;
} else {
$sql = "UPDATE {$serendipity['dbPrefix']}comments SET status = 'approved' WHERE id = ". (int)$cid;
@ -692,7 +692,7 @@ function serendipity_approveComment($cid, $entry_id, $force = false, $moderate =
AND type = 'NORMAL'
AND entry_id = " . (int)$entry_id . "
GROUP BY entry_id", true);
$counter_tb = serendipity_db_query("SELECT count(id) AS counter
FROM {$serendipity['dbPrefix']}comments
WHERE status = 'approved'
@ -722,11 +722,11 @@ function serendipity_approveComment($cid, $entry_id, $force = false, $moderate =
serendipity_plugin_api::hook_event('backend_approvecomment', $rs);
}
if ($flip) {
if ($moderate) return -1; // comment set to pending
if (!$moderate) return 1; // comment set to approved
}
if ($flip) {
if ($moderate) return -1; // comment set to pending
if (!$moderate) return 1; // comment set to approved
}
return true;
}
@ -740,7 +740,7 @@ function serendipity_approveComment($cid, $entry_id, $force = false, $moderate =
*/
function serendipity_confirmMail($cid, $hash) {
global $serendipity;
$q = "SELECT c.entry_id, e.title, e.timestamp, e.id
FROM {$serendipity['dbPrefix']}comments AS c
JOIN {$serendipity['dbPrefix']}entries AS e
@ -764,7 +764,7 @@ function serendipity_confirmMail($cid, $hash) {
serendipity_sendComment($cid, $row['email'], $name, $email, $url, $id, $row['title'], $comments, $type, serendipity_db_bool($ca['moderate_comments']));
}
*/
serendipity_approveComment($cid, $confirm['entry_id'], true);
return $confirm;
} else {
@ -835,7 +835,7 @@ function serendipity_insertComment($id, $commentInfo, $type = 'NORMAL', $source
} else {
$subscribe = 'false';
}
$dbhash = md5(uniqid(rand(), true));
if ($status == 'confirm') {
@ -936,7 +936,7 @@ function serendipity_insertComment($id, $commentInfo, $type = 'NORMAL', $source
if ($GLOBALS['tb_logging']) {
fclose($fp);
}
return $cid;
}
@ -1002,7 +1002,7 @@ function serendipity_saveComment($id, $commentInfo, $type = 'NORMAL', $source =
fwrite($fp, '[' . date('d.m.Y H:i') . '] insert comment into DB' . "\n");
fclose($fp);
}
$commentInfo['comment_cid'] = serendipity_insertComment($id, $commentInfo, $type, $source, $ca);
$commentInfo['comment_id'] = $id;
serendipity_plugin_api::hook_event('frontend_saveComment_finish', $ca, $commentInfo);
@ -1161,7 +1161,7 @@ function serendipity_sendComment($comment_id, $to, $fromName, $fromEmail, $fromU
$action_more = '';
foreach($eventData['action_more'] as $action) {
$action_more .= "\n" . str_repeat(' ', 3) . $action;
}
}
if ($type == 'TRACKBACK' || $type == 'PINGBACK') {

View File

@ -196,7 +196,7 @@ function serendipity_query_default($optname, $default, $usertemplate = false, $t
$test_path1 = $_SERVER['DOCUMENT_ROOT'] . rtrim(dirname($_SERVER['PHP_SELF']), '/') . '/';
}
$test_path2 = serendipity_getRealDir(__FILE__);
if (!empty($_SERVER['ORIG_PATH_TRANSLATED']) && file_exists(dirname($_SERVER['ORIG_PATH_TRANSLATED']) . '/serendipity_admin.php')) {
return realpath(rtrim(dirname($_SERVER['ORIG_PATH_TRANSLATED']), '/')) . '/';
}
@ -394,7 +394,7 @@ function serendipity_replaceEmbeddedConfigVars ($s) {
function serendipity_guessInput($type, $name, $value='', $default='') {
$data = array();
$curOptions = array();
switch ($type) {
case 'bool':
$value = serendipity_get_bool($value);
@ -456,9 +456,9 @@ function serendipity_printConfigTemplate($config, $from = false, $noForm = false
$data = array();
$data['noForm'] = $noForm;
$data['formToken'] = serendipity_setFormToken();
$data['allowToggle'] = $allowToggle;
foreach ($config as &$category) {
foreach ($category['items'] as &$item) {
@ -477,7 +477,7 @@ function serendipity_printConfigTemplate($config, $from = false, $noForm = false
if (in_array('hideValue', $item['flags'])) {
$value = '';
}
if (!$showDangerous && $item['view'] == 'dangerous') {
continue;
}
@ -694,7 +694,7 @@ function serendipity_installFiles($serendipity_core = '') {
if ($fp) {
fwrite($fp, 'php_value register_globals off'. "\n" .'php_value session.use_trans_sid 0');
fclose($fp);
$safeFP = @fopen($serendipity_core . '.installer_detection_failsafe', 'w');
fclose($safeFP);
$sock = fsockopen($serendipity_host, $_SERVER['SERVER_PORT'], $errorno, $errorstring, 10);
@ -1088,16 +1088,16 @@ global $serendipity;
* @param string filename is the path to the file to checksum
* @param string type forces a particular interpretation of newlines. Mime
* types and strings starting with 'text' will cause newlines to be stripped
* before the checksum is calculated (default: null, determine from finfo
* before the checksum is calculated (default: null, determine from finfo
* and extension)
* @return string An MD5 checksum of the file, with newlines removed if it's
* @return string An MD5 checksum of the file, with newlines removed if it's
* an ASCII type; or false if the file cannot be read
*/
function serendipity_FTPChecksum($filename, $type = null) {
/** Only read the finfo database once */
static $debug_exts = array();
// Must be able to read the file
// Must be able to read the file
if (!is_readable($filename)) {
return false;
}
@ -1113,16 +1113,16 @@ function serendipity_FTPChecksum($filename, $type = null) {
// If they're case-insensitive equal, strcasecmp() returns 0, or
// 'false'. So I use && to find if any of them are 0, in the
// most likely fail-fast order.
if (strcasecmp($ext, 'php') &&
if (strcasecmp($ext, 'php') &&
strcasecmp($ext, 'tpl') &&
strcasecmp($ext, 'sql') &&
strcasecmp($ext, 'js') &&
strcasecmp($ext, 'txt') &&
strcasecmp($ext, 'htc') &&
strcasecmp($ext, 'css') &&
strcasecmp($ext, 'dist') &&
strcasecmp($ext, 'lib') &&
strcasecmp($ext, 'sh') &&
strcasecmp($ext, 'js') &&
strcasecmp($ext, 'txt') &&
strcasecmp($ext, 'htc') &&
strcasecmp($ext, 'css') &&
strcasecmp($ext, 'dist') &&
strcasecmp($ext, 'lib') &&
strcasecmp($ext, 'sh') &&
strcasecmp($ext, 'html') &&
strcasecmp($ext, 'htm') &&
!empty($ext)) {
@ -1138,7 +1138,7 @@ function serendipity_FTPChecksum($filename, $type = null) {
// Calculate the checksum
$md5 = false;
if (stristr($type, 'text')) {
// This is a text-type file. We need to remove linefeeds before
// This is a text-type file. We need to remove linefeeds before
// calculating a checksum, to account for possible FTP conversions
// that are inconvenient, but still valid. But we don't want to
// allow newlines anywhere; just different *kinds* of newlines.
@ -1156,8 +1156,8 @@ function serendipity_FTPChecksum($filename, $type = null) {
/**
* Validate checksums for all required files.
*
* @return A list of all files that failed checksum, where keys are the
*
* @return A list of all files that failed checksum, where keys are the
* relative path of the file, and values are the bad checksum
*/
function serendipity_verifyFTPChecksums() {
@ -1167,7 +1167,7 @@ function serendipity_verifyFTPChecksums() {
// Load the checksums
$f = S9Y_INCLUDE_PATH . 'checksums.inc.php';
if (!file_exists($f) || filesize($f) < 1) {
return $badsums;
}
@ -1184,7 +1184,7 @@ function serendipity_verifyFTPChecksums() {
$path = $basedir . '/' . $prel;
// Don't take checksums of directories
if (is_dir($path)) {
// Weird that it's even here.
// Weird that it's even here.
continue;
}

View File

@ -1,4 +1,5 @@
<?php # $Id: functions.inc.php 85 2005-05-10 10:11:05Z garvinhicking $
<?php
# $Id: functions.inc.php 85 2005-05-10 10:11:05Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -132,7 +133,7 @@ function serendipity_makeFilename($str, $stripDots = false) {
// Nuke chars not allowed in our URI
$str = preg_replace('#[^' . PAT_FILENAME . ']#i', '', $str);
}
}
// Check if dots are allowed
if ($stripDots) {
@ -560,7 +561,7 @@ function serendipity_makePermalink($format, $data, $type = 'entry') {
$parent_path[] = serendipity_makeFilename($parent['category_name'], true);
}
}
}
}
$replacements =
array(

View File

@ -1,4 +1,5 @@
<?php # $entry['feed_id']: functions_entries.inc.php 435 2005-08-25 12:36:39Z garvinhicking $
<?php
# $entry['feed_id']: functions_entries.inc.php 435 2005-08-25 12:36:39Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -40,7 +41,7 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f
if (is_array($entries)) {
foreach ($entries as $key => $_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'];
}
}
}

View File

@ -1,4 +1,4 @@
<?php # $Id$
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -323,7 +323,7 @@ function add_trackback ($id, $title, $url, $name, $excerpt) {
// Decode HTML Entities
$excerpt = trackback_body_strip($excerpt);
$comment = array(
'title' => $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('@<methodCall>\s*<methodName>\s*pingback.ping\s*</methodName>\s*<params>\s*<param>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</param>\s*<param>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</param>\s*</params>\s*</methodCall>@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('@<head[^>]*>.*?<title[^>]*>(.*?)</title>.*?</head>@is',$fContent,$matches)) {
$comment['title'] = serendipity_entity_decode(strip_tags($matches[1]), ENT_COMPAT, LANG_CHARSET);
}
// Try to get content from first <p> tag on:
if (preg_match('@<p[^>]*>(.*?)</body>@is',$fContent,$matches)) {
$body = $matches[1];
@ -554,24 +554,24 @@ function fetchPingbackData( &$comment) {
$comment['comment'] = $body . '[..]';
}
}
if (function_exists('serendipity_request_end')) serendipity_request_end();
}
/**
* Strips any unneeded code from trackback / pingback bodies returning pure (UTF8) text.
*/
function trackback_body_strip( $body ){
// replace non brakeable space with normal space:
// replace non brakeable space with normal space:
$body = str_replace('&nbsp;', ' ', $body);
// strip html entities and tags.
$body = serendipity_entity_decode(strip_tags($body), ENT_COMPAT, LANG_CHARSET);
// replace whitespace with single space
// replace whitespace with single space
$body = preg_replace('@\s+@s', ' ', $body);
return $body;
}
@ -759,7 +759,7 @@ function serendipity_handle_references($id, $author, $title, $text, $dry_run = f
if (is_string($row)) {
if (is_object($serendipity['logger'])) $serendipity['logger']->debug($row);
}
$names[$i] = strip_tags($names[$i]);
if (empty($names[$i])) {
if (is_object($serendipity['logger'])) $serendipity['logger']->debug("Found reference $locations[$i] w/o name. Adding location as name");

View File

@ -1,4 +1,4 @@
<?php #
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
@ -361,7 +361,7 @@
'description' => COMMENT_TOKENS_DESC,
'type' => 'bool',
'default' => false,
'permission' => 'blogConfiguration'),
'permission' => 'blogConfiguration'),
array('var' => 'lang',
'title' => INSTALL_LANG,
@ -400,14 +400,14 @@
'permission' => 'blogConfiguration'),
array('var' => 'updateCheck',
'title' => UPDATE_NOTIFICATION,
'title' => UPDATE_NOTIFICATION,
'description' => UPDATE_NOTIFICATION_DESC,
'type' => 'list',
'default' => array('stable' => UPDATE_STABLE, 'beta' => UPDATE_BETA, 'false' => NO),
'permission' => 'blogConfiguration'),
array('var' => 'logLevel',
'title' => LOG_LEVEL,
'title' => LOG_LEVEL,
'description' => LOG_LEVEL_DESC,
'type' => 'list',
'default' => array('Off' => NO, 'error' => ERROR, 'debug' => DEBUG),
@ -512,7 +512,7 @@
'permission' => 'blogConfiguration'
);
}
array_push( $res['display']['items'],
array('var' => 'serverOffsetHours',
'title' => INSTALL_OFFSET,
@ -547,7 +547,7 @@
'type' => 'list',
'default' => array(false => NO, true => YES, 'client' => 'Client'),
'permission' => 'siteConfiguration'),
array('var' => 'feedBannerURL',
'title' => SYNDICATION_PLUGIN_BANNERURL,
'description' => SYNDICATION_PLUGIN_BANNERURL_DESC,
@ -561,7 +561,7 @@
'type' => 'string',
'default' => '',
'permission' => 'blogConfiguration'),
array('var' => 'feedBannerHeight',
'title' => SYNDICATION_PLUGIN_BANNERHEIGHT,
'description' => SYNDICATION_PLUGIN_BANNERHEIGHT_DESC,
@ -575,7 +575,7 @@
'type' => 'bool',
'default' => false,
'permission' => 'blogConfiguration'),
array ('var' => 'feedManagingEditor',
'title' => SYNDICATION_PLUGIN_MANAGINGEDITOR,
'description' => SYNDICATION_PLUGIN_MANAGINGEDITOR_DESC,
@ -682,7 +682,7 @@
'default' => ''),
array('var' => 'uploadResize',
'title' => MEDIA_UPLOAD_RESIZE,
'title' => MEDIA_UPLOAD_RESIZE,
'description' => MEDIA_UPLOAD_RESIZE_DESC,
'type' => 'bool',
'permission' => 'siteConfiguration',

View File

@ -127,7 +127,7 @@
'default' => true,
'permission' => 'personalConfigurationRightPublish',
'view' => 'dangerous'),
array('var' => 'simpleFilters',
'title' => SIMPLE_FILTERS,
'description' => SIMPLE_FILTERS_DESC,