Also support "last X" REST interface
This commit is contained in:
285
include/admin/category.inc.php
Normal file
285
include/admin/category.inc.php
Normal file
@ -0,0 +1,285 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('adminCategories')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$admin_category = (!serendipity_checkPermission('adminCategoriesMaintainOthers') ? "AND (authorid = 0 OR authorid = " . (int)$serendipity['authorid'] . ")" : '');
|
||||
|
||||
/* Add a new category */
|
||||
if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
|
||||
$name = $serendipity['POST']['cat']['name'];
|
||||
$desc = $serendipity['POST']['cat']['description'];
|
||||
|
||||
if (is_array($serendipity['POST']['cat']['write_authors']) && in_array(0, $serendipity['POST']['cat']['write_authors'])) {
|
||||
$authorid = 0;
|
||||
} else {
|
||||
$authorid = $serendipity['authorid'];
|
||||
}
|
||||
|
||||
$icon = $serendipity['POST']['cat']['icon'];
|
||||
$parentid = (isset($serendipity['POST']['cat']['parent_cat']) && is_numeric($serendipity['POST']['cat']['parent_cat'])) ? $serendipity['POST']['cat']['parent_cat'] : 0;
|
||||
|
||||
if ($serendipity['GET']['adminAction'] == 'new') {
|
||||
if ($parentid != 0) {
|
||||
// TODO: This doesn't seem to work as expected, serendipity_rebuildCategoryTree(); is still needed! Only activate this optimization function when it's really working :)
|
||||
// TODO: This works if only one subcategory exists. Otherwise, the first query will return an array.
|
||||
/*
|
||||
$res = serendipity_db_query("SELECT category_right FROM {$serendipity['dbPrefix']}category WHERE parentid={$parentid}");
|
||||
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET category_left=category_left+2, category_right=category_right+2 WHERE category_right>{$res}");
|
||||
*/
|
||||
}
|
||||
|
||||
$catid = serendipity_addCategory($name, $desc, $authorid, $icon, $parentid);
|
||||
serendipity_ACLGrant($catid, 'category', 'read', $serendipity['POST']['cat']['read_authors']);
|
||||
serendipity_ACLGrant($catid, 'category', 'write', $serendipity['POST']['cat']['write_authors']);
|
||||
|
||||
echo '<div class="serendipityAdminMsgSuccess">'. CATEGORY_SAVED .'</div>';
|
||||
|
||||
} elseif ($serendipity['GET']['adminAction'] == 'edit') {
|
||||
if (!serendipity_checkPermission('adminCategoriesMaintainOthers') && !serendipity_ACLCheck($serendipity['authorid'], $serendipity['GET']['cid'], 'category', 'write')) {
|
||||
echo '<div class="serendipityAdminMsgError">'. PERM_DENIED .'</div>';
|
||||
} else {
|
||||
/* Check to make sure parent is not a child of self */
|
||||
$r = serendipity_db_query("SELECT categoryid FROM {$serendipity['dbPrefix']}category c
|
||||
WHERE c.categoryid = ". (int)$parentid ."
|
||||
AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange((int)$serendipity['GET']['cid'])));
|
||||
if ( is_array($r) ) {
|
||||
$r = serendipity_db_query("SELECT category_name FROM {$serendipity['dbPrefix']}category
|
||||
WHERE categoryid = ". (int)$parentid);
|
||||
echo sprintf(ALREADY_SUBCATEGORY, htmlspecialchars($r[0]['category_name']), htmlspecialchars($name));
|
||||
} else {
|
||||
serendipity_updateCategory($serendipity['GET']['cid'], $name, $desc, $authorid, $icon, $parentid);
|
||||
serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'read', $serendipity['POST']['cat']['read_authors']);
|
||||
serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'write', $serendipity['POST']['cat']['write_authors']);
|
||||
echo '<div class="serendipityAdminMsgSuccess">'. CATEGORY_SAVED .'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
$serendipity['GET']['adminAction'] = 'view';
|
||||
}
|
||||
|
||||
/* Delete a category */
|
||||
if ($serendipity['GET']['adminAction'] == 'doDelete' && serendipity_checkFormToken()) {
|
||||
if ($serendipity['GET']['cid'] != 0) {
|
||||
$remaining_cat = (int)$serendipity['POST']['cat']['remaining_catid'];
|
||||
$category_ranges = serendipity_fetchCategoryRange((int)$serendipity['GET']['cid']);
|
||||
$category_range = implode(' AND ', $category_ranges);
|
||||
if ($serendipity['dbType'] == 'postgres' || $serendipity['dbType'] == 'sqlite') {
|
||||
$query = "UPDATE {$serendipity['dbPrefix']}entrycat
|
||||
SET categoryid={$remaining_cat} WHERE entryid IN
|
||||
(
|
||||
SELECT DISTINCT(e.id) FROM {$serendipity['dbPrefix']}entries e,
|
||||
{$serendipity['dbPrefix']}category c,
|
||||
{$serendipity['dbPrefix']}entrycat ec
|
||||
WHERE e.id=ec.entryid AND c.categoryid=ec.categoryid
|
||||
AND c.category_left BETWEEN {$category_range} {$admin_category}
|
||||
)";
|
||||
} else {
|
||||
$query = "UPDATE {$serendipity['dbPrefix']}entries e,
|
||||
{$serendipity['dbPrefix']}entrycat ec,
|
||||
{$serendipity['dbPrefix']}category c
|
||||
SET ec.categoryid={$remaining_cat}
|
||||
WHERE e.id = ec.entryid
|
||||
AND c.categoryid = ec.categoryid
|
||||
AND c.category_left BETWEEN {$category_range}
|
||||
{$admin_category}";
|
||||
}
|
||||
if ( serendipity_db_query($query) ) {
|
||||
if (serendipity_deleteCategory($category_range, $admin_category) ) {
|
||||
|
||||
foreach($category_ranges AS $cid) {
|
||||
if (serendipity_ACLCheck($serendipity['authorid'], $cid, 'category', 'write')) {
|
||||
serendipity_ACLGrant($cid, 'category', 'read', array());
|
||||
serendipity_ACLGrant($cid, 'category', 'write', array());
|
||||
}
|
||||
}
|
||||
|
||||
echo '<div class="serendipityAdminMsgSuccess">'. ($remaining_cat ? sprintf(CATEGORY_DELETED_ARTICLES_MOVED, (int)$serendipity['GET']['cid'], $remaining_cat) : sprintf(CATEGORY_DELETED,(int)$serendipity['GET']['cid'])) .'</div>';
|
||||
$serendipity['GET']['adminAction'] = 'view';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo '<div class="serendipityAdminMsgError">'. INVALID_CATEGORY .'</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( $serendipity['GET']['adminAction'] == 'delete' ) {
|
||||
$this_cat = serendipity_fetchCategoryInfo($serendipity['GET']['cid']);
|
||||
if ( (serendipity_checkPermission('adminCategoriesDelete') && serendipity_checkPermission('adminCategoriesMaintainOthers'))
|
||||
|| (serendipity_checkPermission('adminCategoriesDelete') && ($serendipity['authorid'] == $this_cat['authorid'] || $this_cat['authorid'] == '0'))
|
||||
|| (serendipity_checkPermission('adminCategoriesDelete') && serendipity_ACLCheck($serendipity['authorid'], $serendipity['GET']['cid'], 'category', 'write'))) {
|
||||
?>
|
||||
<form method="POST" name="serendipityCategory" action="?serendipity[adminModule]=category&serendipity[adminAction]=doDelete&serendipity[cid]=<?php echo $serendipity['GET']['cid'] ?>">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<br />
|
||||
<?php echo CATEGORY_REMAINING ?>:
|
||||
<select name="serendipity[cat][remaining_catid]">
|
||||
<option value="0">- <?php echo NO_CATEGORY ?> -</option>
|
||||
<?php
|
||||
$cats = serendipity_fetchCategories('all');
|
||||
/* TODO, show dropdown as nested categories */
|
||||
foreach ($cats as $cat_data) {
|
||||
if ($cat_data['categoryid'] != $serendipity['GET']['cid'] && (serendipity_checkPermission('adminCategoriesMaintainOthers') || $cat_data['authorid'] == '0' || $cat_data['authorid'] == $serendipity['authorid'])) {
|
||||
echo '<option value="' . $cat_data['categoryid'] . '">' . htmlspecialchars($cat_data['category_name']) . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="submit" name="REMOVE" value="<?php echo GO ?>" class="serendipityPrettyButton">
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<?php if ( $serendipity['GET']['adminAction'] == 'edit' || $serendipity['GET']['adminAction'] == 'new' ) {
|
||||
if ( $serendipity['GET']['adminAction'] == 'edit' ) {
|
||||
$cid = (int)$serendipity['GET']['cid'];
|
||||
$this_cat = serendipity_fetchCategoryInfo($cid);
|
||||
echo '<strong>'. sprintf(EDIT_THIS_CAT, htmlspecialchars($this_cat['category_name'])) .'</strong>';
|
||||
$save = SAVE;
|
||||
$read_groups = serendipity_ACLGet($cid, 'category', 'read');
|
||||
$write_groups = serendipity_ACLGet($cid, 'category', 'write');
|
||||
} else {
|
||||
$cid = false;
|
||||
$this_cat = array();
|
||||
echo '<strong>'. CREATE_NEW_CAT .'</strong>';
|
||||
$save = CREATE;
|
||||
$read_groups = array(0 => 0);
|
||||
$write_groups = array(0 => 0);
|
||||
}
|
||||
|
||||
$groups = serendipity_getAllGroups();
|
||||
?>
|
||||
<form method="POST" name="serendipityCategory">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<table cellpadding="5" width="100%">
|
||||
<tr>
|
||||
<td><?php echo NAME; ?></td>
|
||||
<td><input type="text" name="serendipity[cat][name]" value="<?php echo isset($this_cat['category_name']) ? htmlspecialchars($this_cat['category_name']) : ''; ?>" /></td>
|
||||
<td rowspan="5" align="center" valign="middle" width="200" style="border: 1px solid #ccc"><img src="<?php echo isset($this_cat['category_icon']) ? $this_cat['category_icon'] : '' ?>" id="imagepreview" <?php echo empty($this_cat['category_icon']) ? 'style="display: none"' : '' ?> /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo DESCRIPTION; ?></td>
|
||||
<td><input type="text" name="serendipity[cat][description]" value="<?php echo isset($this_cat['category_description']) ? htmlspecialchars($this_cat['category_description']) : ''; ?>" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo IMAGE; ?></td>
|
||||
<td>
|
||||
<script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>
|
||||
<input type="text" id="img_icon" name="serendipity[cat][icon]" value="<?php echo isset($this_cat['category_icon']) ? htmlspecialchars($this_cat['category_icon']) : ''; ?>" onchange="document.getElementById('imagepreview').src = this.value; document.getElementById('imagepreview').style.display = '';" />
|
||||
<script type="text/javascript" language="JavaScript">document.write('<input type="button" name="insImage" value="<?php echo IMAGE ; ?>" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[htmltarget]=img_icon&serendipity[filename_only]=true\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" class="serendipityPrettyButton" />');</script><!-- noscript>FIXXME: Emit a warning if JS is disabled</noscript -->
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><label for="read_authors"><?php echo PERM_READ; ?></label></td>
|
||||
<td>
|
||||
<select size="6" id="read_authors" multiple="multiple" name="serendipity[cat][read_authors][]">
|
||||
<option value="0" <?php echo (!is_array($this_cat) || (isset($this_cat['authorid']) && $this_cat['authorid'] == '0') || isset($read_groups[0])) ? 'selected="selected"' : ''; ?>><?php echo ALL_AUTHORS; ?></option>
|
||||
<?php
|
||||
foreach($groups AS $group) {
|
||||
echo '<option value="' . $group['confkey'] . '" ' . (isset($read_groups[$group['confkey']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($group['confvalue']) . '</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><label for="write_authors"><?php echo PERM_WRITE; ?></label></td>
|
||||
<td>
|
||||
<select size="6" id="write_authors" multiple="multiple" name="serendipity[cat][write_authors][]">
|
||||
<option value="0" <?php echo (!is_array($this_cat) || (isset($this_cat['authorid']) && $this_cat['authorid'] == '0') || isset($write_groups[0])) ? 'selected="selected"' : ''; ?>><?php echo ALL_AUTHORS; ?></option>
|
||||
<?php
|
||||
foreach($groups AS $group) {
|
||||
echo '<option value="' . $group['confkey'] . '" ' . (isset($write_groups[$group['confkey']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($group['confvalue']) . '</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><label for="parent_cat"><?php echo PARENT_CATEGORY; ?></label></td>
|
||||
<td>
|
||||
<select id="parent_cat" name="serendipity[cat][parent_cat]">
|
||||
<option value="0"<?php if ( (int)$serendipity['GET']['cid'] == 0 ) echo ' selected="selected"'; ?>>[ <?php echo NO_CATEGORY; ?> ]</option>
|
||||
<?php
|
||||
$categories = serendipity_fetchCategories('all');
|
||||
$categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
|
||||
foreach ( $categories as $cat ) {
|
||||
/* We can't be our own parent, the universe will collapse */
|
||||
if ( $cat['categoryid'] == $serendipity['GET']['cid'] ) {
|
||||
continue;
|
||||
}
|
||||
echo '<option value="'. $cat['categoryid'] .'"'. ($this_cat['parentid'] == $cat['categoryid'] ? ' selected="selected"' : '') .'>'. str_repeat(' ', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php serendipity_plugin_api::hook_event('backend_category_showForm', $cid, $this_cat); ?>
|
||||
</table>
|
||||
<div><input type="submit" name="SAVE" value="<?php echo $save; ?>" class="serendipityPrettyButton" /></div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
if ( $serendipity['GET']['adminAction'] == 'view' ) {
|
||||
if (empty($admin_category)) {
|
||||
$cats = serendipity_fetchCategories('all');
|
||||
} else {
|
||||
$cats = serendipity_fetchCategories(null, null, null, 'write');
|
||||
}
|
||||
|
||||
if ( is_array($cats) && sizeof($cats) > 0 ) {
|
||||
echo CATEGORY_INDEX .':';
|
||||
} else {
|
||||
echo '<div align="center">- '. NO_CATEGORIES .' -</div>';
|
||||
}
|
||||
?>
|
||||
<br /><br />
|
||||
<table cellspacing="0" cellpadding="4" width="100%" border=0>
|
||||
<?php
|
||||
if ( is_array($cats) ) {
|
||||
$categories = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
|
||||
foreach ( $categories as $category ) {
|
||||
?>
|
||||
<tr>
|
||||
<td width="16"><a href="?serendipity[adminModule]=category&serendipity[adminAction]=edit&serendipity[cid]=<?php echo $category['categoryid'] ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png') ?>" border="0" alt="<?php echo EDIT ?>" /></a></td>
|
||||
<td width="16"><a href="?serendipity[adminModule]=category&serendipity[adminAction]=delete&serendipity[cid]=<?php echo $category['categoryid'] ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png') ?>" border="0" alt="<?php echo DELETE ?>" /></a></td>
|
||||
<td width="16"><?php if ( !empty($category['category_icon']) ) {?><img src="<?php echo serendipity_getTemplateFile('admin/img/thumbnail.png') ?>" alt="" /><?php } else echo ' ' ?></td>
|
||||
<td width="300" style="padding-left: <?php echo ($category['depth']*15)+20 ?>px"><img src="<?php echo serendipity_getTemplateFile('admin/img/folder.png') ?>" style="vertical-align: bottom;"> <?php echo htmlspecialchars($category['category_name']) ?></td>
|
||||
<td><?php echo htmlspecialchars($category['category_description']) ?></td>
|
||||
<td align="right"><?php echo ($category['authorid'] == '0' ? ALL_AUTHORS : $category['realname']); ?></td>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
<tr>
|
||||
<td colspan="6" align="right">
|
||||
<a href="?serendipity[adminModule]=category&serendipity[adminAction]=new" class="serendipityPrettyButton"><?php echo CREATE_NEW_CAT ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php }
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
421
include/admin/comments.inc.php
Normal file
421
include/admin/comments.inc.php
Normal file
@ -0,0 +1,421 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('adminComments')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$commentsPerPage = (int)(!empty($serendipity['GET']['filter']['perpage']) ? $serendipity['GET']['filter']['perpage'] : 10);
|
||||
$summaryLength = 200;
|
||||
|
||||
if ( $serendipity['POST']['formAction'] == 'multiDelete' && sizeof($serendipity['POST']['delete']) != 0 && serendipity_checkFormToken()) {
|
||||
foreach ( $serendipity['POST']['delete'] as $k => $v ) {
|
||||
serendipity_deleteComment($k, $v);
|
||||
echo DONE . ': '. sprintf(COMMENT_DELETED, $k) . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* We are asked to save the edited comment, and we are not in preview mode */
|
||||
if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'doEdit' && !isset($serendipity['POST']['preview']) && serendipity_checkFormToken()) {
|
||||
$sql = "UPDATE {$serendipity['dbPrefix']}comments
|
||||
SET
|
||||
author = '" . serendipity_db_escape_string($serendipity['POST']['name']) . "',
|
||||
email = '" . serendipity_db_escape_string($serendipity['POST']['email']) . "',
|
||||
url = '" . serendipity_db_escape_string($serendipity['POST']['url']) . "',
|
||||
parent_id = '" . serendipity_db_escape_string($serendipity['POST']['replyTo']) . "',
|
||||
body = '" . serendipity_db_escape_string($serendipity['POST']['comment']) . "'
|
||||
WHERE id = " . (int)$serendipity['GET']['id'] . " AND
|
||||
entry_id = " . (int)$serendipity['POST']['entry_id'];
|
||||
serendipity_db_query($sql);
|
||||
echo COMMENT_EDITED;
|
||||
}
|
||||
|
||||
|
||||
/* We approve a comment */
|
||||
if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'approve' && serendipity_checkFormToken()) {
|
||||
$sql = "SELECT c.*, e.title, a.email as authoremail, a.mail_comments
|
||||
FROM {$serendipity['dbPrefix']}comments c
|
||||
LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)
|
||||
LEFT JOIN {$serendipity['dbPrefix']}authors a ON (e.authorid = a.authorid)
|
||||
WHERE c.id = " . (int)$serendipity['GET']['id'] ." AND status = 'pending'";
|
||||
$rs = serendipity_db_query($sql, true);
|
||||
|
||||
if ($rs === false) {
|
||||
echo ERROR .': '. sprintf(COMMENT_ALREADY_APPROVED, $serendipity['GET']['id']);
|
||||
} else {
|
||||
serendipity_approveComment($serendipity['GET']['id'], $rs['entry_id']);
|
||||
echo DONE . ': '. sprintf(COMMENT_APPROVED, $serendipity['GET']['id']);
|
||||
}
|
||||
}
|
||||
|
||||
/* We are asked to delete a comment */
|
||||
if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'delete' && serendipity_checkFormToken()) {
|
||||
serendipity_deleteComment($serendipity['GET']['id'], $serendipity['GET']['entry_id']);
|
||||
echo DONE . ': '. sprintf(COMMENT_DELETED, $serendipity['GET']['id']);
|
||||
}
|
||||
|
||||
/* We are either in edit mode, or preview mode */
|
||||
if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'edit' || isset($serendipity['POST']['preview'])) {
|
||||
|
||||
$serendipity['smarty_raw_mode'] = true; // Force output of Smarty stuff in the backend
|
||||
serendipity_smarty_init();
|
||||
|
||||
/* If we are not in preview, we need data from our database */
|
||||
if (!isset($serendipity['POST']['preview']) ) {
|
||||
$comment = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}comments WHERE id = ". (int)$serendipity['GET']['id']);
|
||||
$data['name'] = $comment[0]['author'];
|
||||
$data['email'] = $comment[0]['email'];
|
||||
$data['url'] = $comment[0]['url'];
|
||||
$data['replyTo'] = $comment[0]['parent_id'];
|
||||
$data['comment'] = $comment[0]['body'];
|
||||
|
||||
/* If we are in preview, we get data from our form */
|
||||
} elseif ( isset($serendipity['POST']['preview']) ) {
|
||||
$data['name'] = $serendipity['POST']['name'];
|
||||
$data['email'] = $serendipity['POST']['email'];
|
||||
$data['url'] = $serendipity['POST']['url'];
|
||||
$data['replyTo'] = $serendipity['POST']['replyTo'];
|
||||
$data['comment'] = $serendipity['POST']['comment'];
|
||||
$pc_data = array(
|
||||
array(
|
||||
'email' => $serendipity['POST']['email'],
|
||||
'author' => $serendipity['POST']['name'],
|
||||
'body' => $serendipity['POST']['comment'],
|
||||
'url' => $serendipity['POST']['url'],
|
||||
'timestamp' => time()
|
||||
)
|
||||
);
|
||||
|
||||
serendipity_printComments($pc_data);
|
||||
$serendipity['smarty']->display(serendipity_getTemplateFile('comments.tpl', 'serendipityPath'));
|
||||
}
|
||||
|
||||
serendipity_displayCommentForm(
|
||||
$serendipity['GET']['entry_id'],
|
||||
'?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=doEdit&serendipity[id]=' . $serendipity['GET']['id'] . '&serendipity[entry_id]=' . $serendipity['GET']['entry_id'] . '&' . serendipity_setFormToken('url'),
|
||||
NULL,
|
||||
$data,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
$serendipity['smarty']->display(serendipity_getTemplateFile('commentform.tpl', 'serendipityPath'));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Searchable fields */
|
||||
$filters = array('author', 'email', 'ip', 'url', 'body', 'referer');
|
||||
|
||||
/* Compress the filters into an "AND" SQL query, and a querystring */
|
||||
foreach ($filters as $filter) {
|
||||
$and .= (!empty($serendipity['GET']['filter'][$filter]) ? "AND c.". $filter ." LIKE '%". serendipity_db_escape_string($serendipity['GET']['filter'][$filter]) ."%'" : "");
|
||||
$searchString .= (!empty($serendipity['GET']['filter'][$filter]) ? "&serendipity[filter][". $filter ."]=". $serendipity['GET']['filter'][$filter] : "");
|
||||
}
|
||||
|
||||
if ($serendipity['GET']['filter']['show'] == 'approved') {
|
||||
$and .= "AND status = 'approved'";
|
||||
$searchString .= "&serendipity[filter][show]=approved";
|
||||
} elseif ($serendipity['GET']['filter']['show'] == 'pending') {
|
||||
$and .= "AND status = 'pending'";
|
||||
$searchString .= "&serendipity[filter][show]=pending";
|
||||
} else {
|
||||
$serendipity['GET']['filter']['show'] = 'all';
|
||||
}
|
||||
|
||||
if ($serendipity['GET']['filter']['type'] == 'TRACKBACK') {
|
||||
$c_type = 'TRACKBACK';
|
||||
$searchString .= "&serendipity[filter][type]=TRACKBACK";
|
||||
} elseif ($serendipity['GET']['filter']['type'] == 'NORMAL') {
|
||||
$c_type = 'NORMAL';
|
||||
$searchString .= "&serendipity[filter][type]=NORMAL";
|
||||
} else {
|
||||
$c_type = null;
|
||||
}
|
||||
|
||||
if ($serendipity['GET']['filter']['type'] == 'TRACKBACK') {
|
||||
$c_type = 'TRACKBACK';
|
||||
$searchString .= "&serendipity[filter][type]=TRACKBACK";
|
||||
} elseif ($serendipity['GET']['filter']['type'] == 'NORMAL') {
|
||||
$c_type = 'NORMAL';
|
||||
$searchString .= "&serendipity[filter][type]=NORMAL";
|
||||
} else {
|
||||
$c_type = null;
|
||||
}
|
||||
|
||||
if ($commentsPerPage != 10) {
|
||||
$searchString .= '&serendipity[filter][perpage]=' . $commentsPerPage;
|
||||
}
|
||||
|
||||
$searchString .= '&' . serendipity_setFormToken('url');
|
||||
|
||||
/* Paging */
|
||||
$sql = serendipity_db_query("SELECT COUNT(*) AS total FROM {$serendipity['dbPrefix']}comments c WHERE 1 = 1 " . ($c_type !== null ? " AND c.type = '$c_type' " : '') . $and, true);
|
||||
|
||||
$totalComments = $sql['total'];
|
||||
$pages = ($commentsPerPage == COMMENTS_FILTER_ALL ? 1 : ceil($totalComments/(int)$commentsPerPage));
|
||||
$page = (int)$serendipity['GET']['page'];
|
||||
if ( $page == 0 || $page > $pages ) {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$linkPrevious = 'serendipity_admin.php?serendipity[adminModule]=comments&serendipity[page]='. ($page-1) . $searchString;
|
||||
$linkNext = 'serendipity_admin.php?serendipity[adminModule]=comments&serendipity[page]='. ($page+1) . $searchString;
|
||||
|
||||
if ($commentsPerPage == COMMENTS_FILTER_ALL) {
|
||||
$limit = '';
|
||||
}else {
|
||||
$limit = serendipity_db_limit_sql(serendipity_db_limit(($page-1)*(int)$commentsPerPage, (int)$commentsPerPage));
|
||||
}
|
||||
|
||||
$sql = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']}comments c
|
||||
LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)
|
||||
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");
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function FT_toggle(id) {
|
||||
if ( document.getElementById(id + '_full').style.display == '' ) {
|
||||
document.getElementById(id + '_full').style.display='none';
|
||||
document.getElementById(id + '_summary').style.display='';
|
||||
document.getElementById(id + '_text').innerHTML = '<?php echo TOGGLE_ALL ?>';
|
||||
} else {
|
||||
document.getElementById(id + '_full').style.display='';
|
||||
document.getElementById(id + '_summary').style.display='none';
|
||||
document.getElementById(id + '_text').innerHTML = '<?php echo HIDE ?>';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function invertSelection() {
|
||||
var f = document.formMultiDelete;
|
||||
for (var i = 0; i < f.elements.length; i++) {
|
||||
if( f.elements[i].type == 'checkbox' ) {
|
||||
f.elements[i].checked = !(f.elements[i].checked);
|
||||
f.elements[i].onclick();
|
||||
}
|
||||
}
|
||||
}
|
||||
function highlightComment(id, checkvalue) {
|
||||
var comment = document.getElementById(id);
|
||||
if (checkvalue) {
|
||||
comment.style.borderColor = '#FF0000';
|
||||
comment.style.borderWidth = 2;
|
||||
} else {
|
||||
comment.style.borderColor = '';
|
||||
comment.style.borderWidth = '';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<form action="" method="GET" style="margin: 0">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<input type="hidden" name="serendipity[adminModule]" value="comments" />
|
||||
<input type="hidden" name="serendipity[page]" value="<?php echo $page ?>" />
|
||||
<table class="serendipity_admin_filters" width="100%">
|
||||
<tr>
|
||||
<td colspan="6" class="serendipity_admin_filters_headline"><strong><?php echo FILTERS ?></strong> - <?php echo FIND_COMMENTS ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo AUTHOR ?>:</td>
|
||||
<td><input type="text" name="serendipity[filter][author]" size="15" value="<?php echo $serendipity['GET']['filter']['author'] ?>" /></td>
|
||||
<td><?php echo EMAIL ?>:</td>
|
||||
<td><input type="text" name="serendipity[filter][email]" size="15" value="<?php echo $serendipity['GET']['filter']['email'] ?>" /></td>
|
||||
<td><?php echo URL ?>:</td>
|
||||
<td><input type="text" name="serendipity[filter][url]" size="15" value="<?php echo $serendipity['GET']['filter']['url'] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IP:</td>
|
||||
<td><input type="text" name="serendipity[filter][ip]" size="15" value="<?php echo $serendipity['GET']['filter']['ip'] ?>" /></td>
|
||||
<td><?php echo CONTENT ?>:</td>
|
||||
<td><input type="text" name="serendipity[filter][body]" size="15" value="<?php echo $serendipity['GET']['filter']['body'] ?>" /></td>
|
||||
<td><?php echo REFERER ?>:</td>
|
||||
<td><input type="text" name="serendipity[filter][referer]" size="15" value="<?php echo $serendipity['GET']['filter']['referer'] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo COMMENTS; ?>:</td>
|
||||
<td><select name="serendipity[filter][perpage]">
|
||||
<?php
|
||||
$filter_vals = array(10, 20, 50, COMMENTS_FILTER_ALL);
|
||||
foreach($filter_vals AS $filter_val) { ?>
|
||||
<option value="<?php echo $filter_val; ?>" <?php echo ($commentsPerPage == $filter_val ? ' selected="selected"' : ''); ?>><?php echo $filter_val; ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select></td>
|
||||
<td><?php echo COMMENTS_FILTER_SHOW ?>:</td>
|
||||
<td><select name="serendipity[filter][show]">
|
||||
<option value="all"<?php if ( $serendipity['GET']['filter']['show'] == 'all' ) echo ' selected="selected"' ?>><?php echo COMMENTS_FILTER_ALL ?></option>
|
||||
<option value="approved"<?php if ( $serendipity['GET']['filter']['show'] == 'approved' ) echo ' selected="selected"' ?>><?php echo COMMENTS_FILTER_APPROVED_ONLY ?></option>
|
||||
<option value="pending"<?php if ( $serendipity['GET']['filter']['show'] == 'pending' ) echo ' selected="selected"' ?>><?php echo COMMENTS_FILTER_NEED_APPROVAL ?></option>
|
||||
</select></td>
|
||||
<td><?php echo TYPE; ?></td>
|
||||
<td><select name="serendipity[filter][type]">
|
||||
<option value=""><?php echo COMMENTS_FILTER_ALL ?></option>
|
||||
<option value="NORMAL"<?php if ($c_type == 'NORMAL') echo ' selected="selected"' ?>><?php echo COMMENTS; ?></option>
|
||||
<option value="TRACKBACK"<?php if ($c_type == 'TRACKBACK') echo ' selected="selected"' ?>><?php echo TRACKBACKS; ?></option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" align="right"><input type="submit" name="submit" value=" - <?php echo GO ?> - " class="serendipityPrettyButton" /> <?php serendipity_plugin_api::hook_event('backend_comments_top', $sql); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<hr noshade="noshade" /><br />
|
||||
<?php
|
||||
if (!is_array($sql)) {
|
||||
echo '<div align="center">- '. NO_COMMENTS .' -</div>';
|
||||
} else {
|
||||
?>
|
||||
<form action="" method="POST" name="formMultiDelete" id="formMultiDelete">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<input type="hidden" name="serendipity[formAction]" value="multiDelete" />
|
||||
<table width="100%" cellpadding="3" border="0" cellspacing="0">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table width="100%" cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
<?php if ( $page != 1 && $page <= $pages ) { ?>
|
||||
<a href="<?php echo $linkPrevious; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/previous.png') ?>" /><?php echo PREVIOUS ?></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td align="center"><?php printf(PAGE_BROWSE_COMMENTS, $page, $pages, $totalComments); ?></td>
|
||||
<td align="right">
|
||||
<?php if ( $page != $pages ) { ?>
|
||||
<a href="<?php echo $linkNext; ?>" class="serendipityIconLinkRight"><?php echo NEXT ?><img src="<?php echo serendipity_getTemplateFile('admin/img/next.png') ?>" /></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
$i = 0;
|
||||
foreach ($sql as $rs) {
|
||||
$i++;
|
||||
$comment = array(
|
||||
'fullBody' => $rs['body'],
|
||||
'summary' => serendipity_mb('substr', $rs['body'], 0, $summaryLength),
|
||||
'status' => $rs['status'],
|
||||
'type' => $rs['type'],
|
||||
'id' => $rs['id'],
|
||||
'title' => $rs['title'],
|
||||
'timestamp' => $rs['timestamp'],
|
||||
'referer' => $rs['referer'],
|
||||
'url' => $rs['url'],
|
||||
'ip' => $rs['ip'],
|
||||
'email' => $rs['email'],
|
||||
'author' => (empty($rs['author']) ? ANONYMOUS : $rs['author']),
|
||||
'entry_id' => $rs['entry_id']
|
||||
);
|
||||
|
||||
$entrylink = serendipity_archiveURL($comment['entry_id'], 'comments', 'serendipityHTTPPath', true) . '#c' . $comment['id'];
|
||||
if (strlen($comment['fullBody']) > strlen($comment['summary']) ) {
|
||||
$comment['summary'] .= ' ...';
|
||||
$comment['excerpt'] = true;
|
||||
|
||||
// When summary is not the full body, strip HTML tags from summary, as it might break and leave unclosed HTML.
|
||||
$comment['fullBody'] = nl2br(htmlspecialchars($comment['fullBody']));
|
||||
$comment['summary'] = nl2br(strip_tags($comment['summary']));
|
||||
} else {
|
||||
$comment['excerpt'] = false;
|
||||
|
||||
$comment['fullBody'] = $comment['summary'] = nl2br(htmlspecialchars($comment['fullBody']));
|
||||
}
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_view_comment', $comment, '&serendipity[page]='. $page . $searchString);
|
||||
$class = 'serendipity_admin_list_item_' . (($i % 2 == 0 ) ? 'even' : 'uneven');
|
||||
$header_class = ($comment['status'] == 'pending' ? 'serendipityAdminMsgNote' : '');
|
||||
?>
|
||||
<tr>
|
||||
<td class="<?php echo $header_class; ?>"><a name="c<?php echo $comment['id'] ?>"></a>
|
||||
<?php echo ($comment['type'] == 'NORMAL' ? COMMENT : TRACKBACK) . ' #'. $comment['id'] .', '. IN_REPLY_TO .' <strong>'. $comment['title'] .'</strong>, '. ON . ' ' . serendipity_mb('ucfirst', serendipity_strftime('%b %e %Y, %H:%M', $comment['timestamp']))?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="serendipity_admin_list_item <?php echo $class ?>" id="comment_<?php echo $comment['id'] ?>">
|
||||
<table width="100%" cellspacing="0" cellpadding="3" border="0">
|
||||
<tr>
|
||||
<td rowspan="3" width="20" align="center"><input type="checkbox" name="serendipity[delete][<?php echo $comment['id'] ?>]" value="<?php echo $comment['entry_id'] ?>" onclick="highlightComment('comment_<?php echo $comment['id'] ?>', this.checked)" tabindex="<?php echo $i ?>" /></td>
|
||||
<td width="40%"><strong><?php echo AUTHOR ?></strong>: <?php echo htmlspecialchars($comment['author']) . $comment['action_author']; ?></td>
|
||||
<td><strong><?php echo EMAIL ?></strong>:
|
||||
<?php
|
||||
if ( empty($comment['email']) ) {
|
||||
echo 'N/A';
|
||||
} else {
|
||||
?>
|
||||
<a href="mailto:<?php echo htmlspecialchars($comment['email']) ?>"><?php echo htmlspecialchars($comment['email']) ?></a>
|
||||
<?php } ?>
|
||||
<?php echo $comment['action_email']; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="40%"><strong>IP</strong>:
|
||||
<?php
|
||||
if ( empty($comment['ip']) ) {
|
||||
echo '0.0.0.0';
|
||||
} else {
|
||||
echo htmlspecialchars($comment['ip']);
|
||||
}
|
||||
?>
|
||||
<?php echo $comment['action_ip']; ?>
|
||||
</td>
|
||||
<td><strong><?php echo URL; ?></strong>:
|
||||
<?php
|
||||
if ( empty($comment['url']) ) {
|
||||
echo 'N/A';
|
||||
} else {
|
||||
?>
|
||||
<a href="<?php echo htmlspecialchars($comment['url']) ?>" target="_blank"><?php echo htmlspecialchars($comment['url']) ?></a>
|
||||
<?php } ?>
|
||||
<?php echo $comment['action_url']; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="40%"> </td>
|
||||
<td><strong><?php echo REFERER; ?></strong>:
|
||||
<?php
|
||||
if ( empty($comment['referer']) ) {
|
||||
echo 'N/A';
|
||||
} else {
|
||||
?>
|
||||
<a href="<?php echo htmlspecialchars($comment['referer']) ?>" title="<?php echo htmlspecialchars($comment['referer']) ?>"><?php echo htmlspecialchars(serendipity_truncateString($comment['referer'],30)) ?></a>
|
||||
<?php } ?>
|
||||
<?php echo $comment['action_referer']; ?>
|
||||
</td>
|
||||
<tr>
|
||||
<td style="border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC" colspan="3">
|
||||
<div id="<?php echo $comment['id'] ?>_summary"><?php echo $comment['summary'] ?></div>
|
||||
<div id="<?php echo $comment['id'] ?>_full" style="display: none"><?php echo $comment['fullBody'] ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php if ($comment['status'] == 'pending') { ?>
|
||||
<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=approve&serendipity[id]=<?php echo $comment['id'] ?>&<?php echo serendipity_setFormToken('url'); ?>" class="serendipityIconLink" title="<?php echo APPROVE; ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/accept.png'); ?>" alt="<?php echo APPROVE ?>" /><?php echo APPROVE ?></a>
|
||||
<?php } ?>
|
||||
<?php if ($comment['excerpt']) { ?>
|
||||
<a href="#c<?php echo $comment['id'] ?>" onclick="FT_toggle(<?php echo $comment['id'] ?>); return false;" title="<?php echo VIEW; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?>" alt="<?php echo TOGGLE_ALL; ?>" /><span id="<?php echo $comment['id'] ?>_text"><?php echo TOGGLE_ALL ?></span></a>
|
||||
<?php } ?>
|
||||
<a target="_blank" href="<?php echo $entrylink; ?>" title="<?php echo VIEW; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?>" alt="<?php echo VIEW; ?>" /><?php echo VIEW ?></a>
|
||||
<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=edit&serendipity[id]=<?php echo $comment['id'] ?>&serendipity[entry_id]=<?php echo $comment['entry_id'] ?>&<?php echo serendipity_setFormToken('url'); ?>" title="<?php echo EDIT; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png'); ?>" alt="<?php echo EDIT; ?>" /><?php echo EDIT ?></a>
|
||||
<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=delete&serendipity[id]=<?php echo $comment['id'] ?>&serendipity[entry_id]=<?php echo $comment['entry_id'] ?>&<?php echo serendipity_setFormToken('url'); ?>" onclick='return confirm("<?php echo sprintf(COMMENT_DELETE_CONFIRM, $comment['id'], htmlspecialchars($comment['author'])) ?>")' title="<?php echo DELETE ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png'); ?>" alt="<?php echo DELETE; ?>" /><?php echo DELETE ?></a>
|
||||
<?php echo $comment['action_more']; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><hr noshade="noshade" /></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td><input type="button" name="toggle" value="<?php echo INVERT_SELECTIONS ?>" onclick="invertSelection()" class="serendipityPrettyButton" /> <input type="submit" name="toggle" value="<?php echo DELETE_SELECTED_COMMENTS ?>" onclick="return confirm('<?php echo COMMENTS_DELETE_CONFIRM ?>')" tabindex="<?php echo ($i+1) ?>" class="serendipityPrettyButton" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
77
include/admin/configuration.inc.php
Normal file
77
include/admin/configuration.inc.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
umask(0000);
|
||||
$umask = 0775;
|
||||
@define('IN_installer', true);
|
||||
|
||||
if (!isset($_POST['installAction'])) {
|
||||
$_POST['installAction'] = '';
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('siteConfiguration') && !serendipity_checkPermission('blogConfiguration')) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($_POST['installAction'] && serendipity_checkFormToken()) {
|
||||
case 'check':
|
||||
$oldConfig = $serendipity;
|
||||
$res = serendipity_updateConfiguration();
|
||||
if (is_array($res)) {
|
||||
echo DIAGNOSTIC_ERROR;
|
||||
echo '<span class="serendipityAdminMsgError">- ' . implode('<br />', $res) . '</span><br /><br />';
|
||||
} else {
|
||||
/* If we have new rewrite rules, then install them */
|
||||
$permalinkOld = array(
|
||||
$oldConfig['serendipityHTTPPath'],
|
||||
$oldConfig['serendipityPath'],
|
||||
$oldConfig['baseURL'],
|
||||
$oldConfig['indexFile'],
|
||||
$oldConfig['rewrite']);
|
||||
|
||||
$permalinkNew = array(
|
||||
$serendipity['serendipityHTTPPath'],
|
||||
$serendipity['serendipityPath'],
|
||||
$serendipity['baseURL'],
|
||||
$serendipity['indexFile'],
|
||||
$serendipity['rewrite']);
|
||||
|
||||
// Compare all old permalink section values against new one. A change in any of those
|
||||
// will force to update the .htaccess for rewrite rules.
|
||||
if ($serendipity['rewrite'] != 'none') {
|
||||
$permconf = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE);
|
||||
if (is_array($permconf) && is_array($permconf['permalinks']['items'])) {
|
||||
foreach($permconf['permalinks']['items'] AS $permitem) {
|
||||
$permalinkOld[] = $oldConfig[$permitem['var']];
|
||||
$permalinkNew[] = $serendipity[$permitem['var']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (serendipity_checkPermission('siteConfiguration') && serialize($permalinkOld) != serialize($permalinkNew)) {
|
||||
printf(ATTEMPT_WRITE_FILE, $serendipity['serendipityPath'] . '.htaccess');
|
||||
$res = serendipity_installFiles($serendipity['serendipityPath']);
|
||||
if (is_array($res)) {
|
||||
echo implode('<br />', $res);
|
||||
} else {
|
||||
echo DONE . '<br />';
|
||||
}
|
||||
|
||||
serendipity_buildPermalinks();
|
||||
}
|
||||
|
||||
echo '<br /><div class="serendipityAdminMsgSuccess">'. WRITTEN_N_SAVED .'</div>';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$from = &$serendipity;
|
||||
$t = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE);
|
||||
serendipity_printConfigTemplate($t, $from, false, true);
|
||||
break;
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
487
include/admin/entries.inc.php
Normal file
487
include/admin/entries.inc.php
Normal file
@ -0,0 +1,487 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('adminEntries')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sort_order = array('timestamp' => DATE,
|
||||
'isdraft' => PUBLISH . '/' . DRAFT,
|
||||
'a.realname' => AUTHOR,
|
||||
'category_name' => CATEGORY,
|
||||
'last_modified' => LAST_UPDATED,
|
||||
'title' => TITLE,
|
||||
'id' => 'ID');
|
||||
$per_page = array('12', '16', '50', '100');
|
||||
|
||||
|
||||
/**
|
||||
* Shows the entry panel overview
|
||||
*
|
||||
* Shows a list of existing entries, with pagination and cookie-remember settings.
|
||||
*
|
||||
* @access public
|
||||
* @return null
|
||||
*/
|
||||
function serendipity_drawList() {
|
||||
global $serendipity, $sort_order, $per_page;
|
||||
|
||||
$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]);
|
||||
serendipity_JSsetCookie('entrylist_filter_' . $f_import, $serendipity['GET']['filter'][$f_import]);
|
||||
}
|
||||
|
||||
foreach($sort_import AS $s_import) {
|
||||
serendipity_restoreVar($serendipity['COOKIE']['entrylist_sort_' . $s_import], $serendipity['GET']['sort'][$s_import]);
|
||||
serendipity_JSsetCookie('entrylist_sort_' . $s_import, $serendipity['GET']['sort'][$s_import]);
|
||||
}
|
||||
|
||||
$perPage = (!empty($serendipity['GET']['sort']['perPage']) ? $serendipity['GET']['sort']['perPage'] : $per_page[0]);
|
||||
$page = (int)$serendipity['GET']['page'];
|
||||
$offSet = $perPage*$page;
|
||||
|
||||
if (empty($serendipity['GET']['sort']['ordermode']) || $serendipity['GET']['sort']['ordermode'] != 'ASC') {
|
||||
$serendipity['GET']['sort']['ordermode'] = 'DESC';
|
||||
}
|
||||
|
||||
if (!empty($serendipity['GET']['sort']['order']) && !empty($sort_order[$serendipity['GET']['sort']['order']])) {
|
||||
$orderby = serendipity_db_escape_string($serendipity['GET']['sort']['order'] . ' ' . $serendipity['GET']['sort']['ordermode']);
|
||||
} else {
|
||||
$orderby = 'timestamp ' . serendipity_db_escape_string($serendipity['GET']['sort']['ordermode']);
|
||||
}
|
||||
|
||||
$filter = array();
|
||||
|
||||
if (!empty($serendipity['GET']['filter']['author'])) {
|
||||
$filter[] = "e.authorid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['author']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($serendipity['GET']['filter']['category'])) {
|
||||
$filter[] = "ec.categoryid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['category']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($serendipity['GET']['filter']['isdraft'])) {
|
||||
if ($serendipity['GET']['filter']['isdraft'] == 'draft') {
|
||||
$filter[] = "e.isdraft = 'true'";
|
||||
} elseif ($serendipity['GET']['filter']['isdraft'] == 'publish') {
|
||||
$filter[] = "e.isdraft = 'false'";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($serendipity['GET']['filter']['body'])) {
|
||||
if ($serendipity['dbType'] == 'mysql') {
|
||||
$filter[] = "MATCH (title,body,extended) AGAINST ('" . serendipity_db_escape_string($serendipity['GET']['filter']['body']) . "')";
|
||||
$full = true;
|
||||
}
|
||||
}
|
||||
|
||||
$filter_sql = implode(' AND ', $filter);
|
||||
|
||||
// Fetch the entries
|
||||
$entries = serendipity_fetchEntries(
|
||||
false,
|
||||
false,
|
||||
serendipity_db_limit(
|
||||
$offSet,
|
||||
$perPage
|
||||
),
|
||||
true,
|
||||
false,
|
||||
$orderby,
|
||||
$filter_sql
|
||||
);
|
||||
?>
|
||||
<form action="?" method="get">
|
||||
<div class="serendipity_admin_list">
|
||||
<input type="hidden" name="serendipity[action]" value="admin" />
|
||||
<input type="hidden" name="serendipity[adminModule]" value="entries" />
|
||||
<input type="hidden" name="serendipity[adminAction]" value="editSelect" />
|
||||
<table width="100%" class="serendipity_admin_filters">
|
||||
<tr>
|
||||
<td class="serendipity_admin_filters_headline" colspan="6"><strong><?php echo FILTERS ?></strong> - <?php echo FIND_ENTRIES ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" width="80"><?php echo AUTHOR ?></td>
|
||||
<td valign="top">
|
||||
<select name="serendipity[filter][author]">
|
||||
<option value="">--</option>
|
||||
<?php
|
||||
$users = serendipity_fetchUsers();
|
||||
if (is_array($users)) {
|
||||
foreach ($users AS $user) {
|
||||
echo '<option value="' . $user['authorid'] . '" ' . (isset($serendipity['GET']['filter']['author']) && $serendipity['GET']['filter']['author'] == $user['authorid'] ? 'selected="selected"' : '') . '>' . $user['realname'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
?> </select> <select name="serendipity[filter][isdraft]">
|
||||
<option value="all"><?php echo COMMENTS_FILTER_ALL; ?></option>
|
||||
<option value="draft" <?php echo (isset($serendipity['GET']['filter']['isdraft']) && $serendipity['GET']['filter']['isdraft'] == 'draft' ? 'selected="selected"' : ''); ?>><?php echo DRAFT; ?></option>
|
||||
<option value="publish" <?php echo (isset($serendipity['GET']['filter']['isdraft']) && $serendipity['GET']['filter']['isdraft'] == 'publish' ? 'selected="selected"' : ''); ?>><?php echo PUBLISH; ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td valign="top" width="80"><?php echo CATEGORY ?></td>
|
||||
<td valign="top">
|
||||
<select name="serendipity[filter][category]">
|
||||
<option value="">--</option>
|
||||
<?php
|
||||
$categories = serendipity_fetchCategories();
|
||||
$categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
|
||||
foreach ( $categories as $cat ) {
|
||||
echo '<option value="'. $cat['categoryid'] .'"'. ($serendipity['GET']['filter']['category'] == $cat['categoryid'] ? ' selected="selected"' : '') .'>'. str_repeat(' ', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
|
||||
}
|
||||
?> </select>
|
||||
</td>
|
||||
<td valign="top" width="80"><?php echo CONTENT ?></td>
|
||||
<td valign="top"><input size="10" type="text" name="serendipity[filter][body]" value="<?php echo (isset($serendipity['GET']['filter']['body']) ? htmlspecialchars($serendipity['GET']['filter']['body']) : '') ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="serendipity_admin_filters_headline" colspan="6"><strong><?php echo SORT_ORDER ?></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<?php echo SORT_BY ?>
|
||||
</td>
|
||||
<td>
|
||||
<select name="serendipity[sort][order]">
|
||||
<?php
|
||||
foreach($sort_order as $so_key => $so_val) {
|
||||
echo '<option value="' . $so_key . '" ' . (isset($serendipity['GET']['sort']['order']) && $serendipity['GET']['sort']['order'] == $so_key ? 'selected="selected"': '') . '>' . $so_val . '</option>' . "\n";
|
||||
}
|
||||
?> </select>
|
||||
</td>
|
||||
<td><?php echo SORT_ORDER ?></td>
|
||||
<td>
|
||||
<select name="serendipity[sort][ordermode]">
|
||||
<option value="DESC" <?php echo (isset($serendipity['GET']['sort']['ordermode']) && $serendipity['GET']['sort']['ordermode'] == 'DESC' ? 'selected="selected"' : '') ?>><?php echo SORT_ORDER_DESC ?></option>
|
||||
<option value="ASC" <?php echo (isset($serendipity['GET']['sort']['ordermode']) && $serendipity['GET']['sort']['ordermode'] == 'ASC' ? 'selected="selected"' : '') ?>><?php echo SORT_ORDER_ASC ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php echo ENTRIES_PER_PAGE ?></td>
|
||||
<td>
|
||||
<select name="serendipity[sort][perPage]">
|
||||
<?php
|
||||
foreach($per_page AS $per_page_nr) {
|
||||
echo '<option value="' . $per_page_nr . '" ' . (isset($serendipity['GET']['sort']['perPage']) && $serendipity['GET']['sort']['perPage'] == $per_page_nr ? 'selected="selected"' : '') . '>' . $per_page_nr . '</option>' . "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" colspan="6"><input type="submit" name="go" value="<?php echo GO ?>" class="serendipityPrettyButton" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="serendipity_admin_list" cellpadding="5" width="100%">
|
||||
<?php
|
||||
if (is_array($entries)) {
|
||||
$count = count($entries);
|
||||
$qString = '?serendipity[adminModule]=entries&serendipity[adminAction]=editSelect';
|
||||
foreach ((array)$serendipity['GET']['sort'] as $k => $v) {
|
||||
$qString .= '&serendipity[sort]['. $k .']='. $v;
|
||||
}
|
||||
foreach ((array)$serendipity['GET']['filter'] as $k => $v) {
|
||||
$qString .= '&serendipity[filter]['. $k .']='. $v;
|
||||
}
|
||||
$linkPrevious = $qString . '&serendipity[page]=' . ($page-1);
|
||||
$linkNext = $qString . '&serendipity[page]=' . ($page+1);
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php if ($offSet > 0) { ?>
|
||||
<a href="<?php echo $linkPrevious ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/previous.png') ?>" /><?php echo PREVIOUS ?></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td align="right">
|
||||
<?php if ($count == $perPage) { ?>
|
||||
<a href="<?php echo $linkNext ?>" class="serendipityIconLinkRight"><?php echo NEXT ?><img src="<?php echo serendipity_getTemplateFile('admin/img/next.png') ?>" /></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
// Print the entries
|
||||
$rows = 0;
|
||||
foreach ($entries as $entry) {
|
||||
$rows++;
|
||||
// Find out if the entry has been modified later than 30 minutes after creation
|
||||
if ($entry['timestamp'] <= ($entry['last_modified'] - 60*30)) {
|
||||
$lm = '<a href="#" title="' . LAST_UPDATED . ': ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entry['last_modified']) . '" onclick="alert(this.title)"><img src="'. serendipity_getTemplateFile('admin/img/clock.png') .'" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a>';
|
||||
} else {
|
||||
$lm = '';
|
||||
}
|
||||
|
||||
if (!$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
|
||||
$entry_pre = '<a href="#" title="' . ENTRY_PUBLISHED_FUTURE . '" onclick="alert(this.title)"><img src="'. serendipity_getTemplateFile('admin/img/clock_future.png') .'" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a> ';
|
||||
} else {
|
||||
$entry_pre = '';
|
||||
}
|
||||
|
||||
if (serendipity_db_bool($entry['isdraft'])) {
|
||||
$entry_pre .= ' ' . DRAFT . ': ';
|
||||
}
|
||||
?>
|
||||
<div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo ($rows % 2 ? 'even' : 'uneven'); ?>">
|
||||
<table width="100%" cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td>
|
||||
<strong><?php echo $entry_pre; ?><a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=<?php echo $entry['id']; ?>" title="#<?php echo $entry['id']; ?>"><?php echo serendipity_truncateString(htmlspecialchars($entry['title']),50) ?></a></strong>
|
||||
</td>
|
||||
<td align="right">
|
||||
<?php echo serendipity_formatTime(DATE_FORMAT_SHORT, $entry['timestamp']) . ' ' .$lm; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
echo POSTED_BY . ' ' . $entry['author'];
|
||||
if (count($entry['categories'])) {
|
||||
echo ' ' . IN . ' ';
|
||||
$cats = array();
|
||||
foreach ($entry['categories'] as $cat) {
|
||||
$caturl = serendipity_categoryURL($cat);
|
||||
$cats[] = '<a href="' . $caturl . '">' . $cat['category_name'] . '</a>';
|
||||
}
|
||||
echo implode(', ', $cats);
|
||||
}
|
||||
$entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
|
||||
?>
|
||||
|
||||
</td>
|
||||
<td align="right">
|
||||
<a target="_blank" href="<?php echo $entry['link']; ?>" title="<?php echo VIEW . ' #' . $entry['id']; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?>" alt="<?php echo VIEW; ?>" /><?php echo VIEW ?></a>
|
||||
<a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=<?php echo $entry['id']; ?>" title="<?php echo EDIT . ' #' . $entry['id']; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png'); ?>" alt="<?php echo EDIT; ?>" /><?php echo EDIT ?></a>
|
||||
<a href="?<?php echo serendipity_setFormToken('url'); ?>&serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=delete&serendipity[id]=<?php echo $entry['id']; ?>" title="<?php echo DELETE . ' #' . $entry['id']; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png'); ?>" alt="<?php echo DELETE; ?>" /><?php echo DELETE ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
} // end entries output
|
||||
?>
|
||||
|
||||
<table class="serendipity_admin_list" cellpadding="5" width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<?php if ($offSet > 0) { ?>
|
||||
<a href="<?php echo $linkPrevious ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/previous.png') ?>" /><?php echo PREVIOUS ?></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td align="right">
|
||||
<?php if ($count == $perPage) { ?>
|
||||
<a href="<?php echo $linkNext ?>" class="serendipityIconLinkRight"><?php echo NEXT ?><img src="<?php echo serendipity_getTemplateFile('admin/img/next.png') ?>" /></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo (($rows+1) % 2 ? 'even' : 'uneven'); ?>">
|
||||
<table width="100%" cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td>
|
||||
<?php echo EDIT_ENTRY ?>: #<input type="text" size="3" name="serendipity[id]" /> <input type="submit" name="serendipity[editSubmit]" value="<?php echo GO ?>" class="serendipityPrettyButton" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
// We've got nothing
|
||||
?>
|
||||
<div align="center">- <?php echo NO_ENTRIES_TO_PRINT ?> -</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
} // End function serendipity_drawList()
|
||||
|
||||
if (!empty($serendipity['GET']['editSubmit'])) {
|
||||
$serendipity['GET']['adminAction'] = 'edit';
|
||||
}
|
||||
|
||||
switch($serendipity['GET']['adminAction']) {
|
||||
case 'save':
|
||||
$entry = array(
|
||||
'id' => $serendipity['POST']['id'],
|
||||
'title' => $serendipity['POST']['title'],
|
||||
'timestamp' => $serendipity['POST']['timestamp'],
|
||||
'body' => $serendipity['POST']['body'],
|
||||
'extended' => $serendipity['POST']['extended'],
|
||||
'categories' => $serendipity['POST']['categories'],
|
||||
'isdraft' => $serendipity['POST']['isdraft'],
|
||||
'allow_comments' => $serendipity['POST']['allow_comments'],
|
||||
'moderate_comments' => $serendipity['POST']['moderate_comments'],
|
||||
'exflag' => (!empty($serendipity['POST']['extended']) ? true : false)
|
||||
);
|
||||
|
||||
if ($entry['allow_comments'] != 'true' && $entry['allow_comments'] !== true) {
|
||||
$entry['allow_comments'] = 'false';
|
||||
}
|
||||
|
||||
if ($entry['moderate_comments'] != 'true' && $entry['moderate_comments'] !== true) {
|
||||
$entry['moderate_comments'] = 'false';
|
||||
}
|
||||
|
||||
// Check if the user changed the timestamp.
|
||||
if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation'] && isset($serendipity['POST']['new_timestamp']) && $serendipity['POST']['new_timestamp'] != date(DATE_FORMAT_2, $serendipity['POST']['chk_timestamp'])) {
|
||||
// The user changed the timestamp, now set the DB-timestamp to the user's date
|
||||
$entry['timestamp'] = strtotime($serendipity['POST']['new_timestamp']);
|
||||
|
||||
if ($entry['timestamp'] == -1) {
|
||||
echo DATE_INVALID . '<br />';
|
||||
// The date given by the user is not convertable. Reset the timestamp.
|
||||
$entry['timestamp'] = $serendipity['POST']['timestamp'];
|
||||
}
|
||||
}
|
||||
|
||||
// Save server timezone in database always, so substract the offset we added for display; otherwise it would be added time and again
|
||||
if (!empty($entry['timestamp'])) {
|
||||
$entry['timestamp'] = serendipity_serverOffsetHour($entry['timestamp'], true);
|
||||
}
|
||||
|
||||
// Save the entry, or just display a preview
|
||||
$use_legacy = true;
|
||||
serendipity_plugin_api::hook_event('backend_entry_iframe', $use_legacy);
|
||||
|
||||
if ($use_legacy) {
|
||||
if ($serendipity['POST']['preview'] != 'true') {
|
||||
/* We don't need an iframe to save a draft */
|
||||
if ( $serendipity['POST']['isdraft'] == 'true' ) {
|
||||
echo '<div class="serendipityAdminMsgSuccess">' . IFRAME_SAVE_DRAFT . '</div><br />';
|
||||
serendipity_updertEntry($entry);
|
||||
} else {
|
||||
if ($serendipity['use_iframe']) {
|
||||
echo '<div class="serendipityAdminMsgSuccess">' . IFRAME_SAVE . '</div><br />';
|
||||
serendipity_iframe_create('save', $entry);
|
||||
} else {
|
||||
serendipity_iframe($entry, 'save');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Only display the preview
|
||||
$serendipity['hidefooter'] = true;
|
||||
if (!is_numeric($entry['timestamp'])) {
|
||||
$entry['timestamp'] = time();
|
||||
}
|
||||
|
||||
if (!isset($entry['trackbacks']) || !$entry['trackbacks']) {
|
||||
$entry['trackbacks'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($entry['comments']) || !$entry['comments']) {
|
||||
$entry['comments'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($entry['realname']) || !$entry['realname']) {
|
||||
if (!empty($serendipity['realname'])) {
|
||||
$entry['realname'] = $serendipity['realname'];
|
||||
} else {
|
||||
$entry['realname'] = $serendipity['serendipityUser'];
|
||||
}
|
||||
}
|
||||
|
||||
$categories = (array)$entry['categories'];
|
||||
$entry['categories'] = array();
|
||||
foreach ($categories as $catid) {
|
||||
if ($catid == 0) {
|
||||
continue;
|
||||
}
|
||||
$entry['categories'][] = serendipity_fetchCategoryInfo($catid);
|
||||
}
|
||||
|
||||
if (count($entry['categories']) < 1) {
|
||||
unset($entry['categories']);
|
||||
}
|
||||
|
||||
if (isset($entry['id'])) {
|
||||
$serendipity['GET']['id'] = $entry['id'];
|
||||
} else {
|
||||
$serendipity['GET']['id'] = 1;
|
||||
}
|
||||
|
||||
if ($serendipity['use_iframe']) {
|
||||
echo '<div class="serendipityAdminMsgSuccess">' . IFRAME_PREVIEW . '</div><br />';
|
||||
serendipity_iframe_create('preview', $entry);
|
||||
} else {
|
||||
serendipity_iframe($entry, 'preview');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// serendipity_updertEntry sets this global variable to store the entry id. Couldn't pass this
|
||||
// by reference or as return value because it affects too many places inside our API and dependant
|
||||
// function calls.
|
||||
if (!empty($serendipity['lastSavedEntry'])) {
|
||||
$entry['id'] = $serendipity['lastSavedEntry'];
|
||||
}
|
||||
|
||||
include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php';
|
||||
serendipity_printEntryForm(
|
||||
'?',
|
||||
array(
|
||||
'serendipity[action]' => 'admin',
|
||||
'serendipity[adminModule]' => 'entries',
|
||||
'serendipity[adminAction]' => 'save',
|
||||
'serendipity[timestamp]' => $entry['timestamp']
|
||||
),
|
||||
|
||||
$entry
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case 'doDelete':
|
||||
if (!serendipity_checkFormToken()) {
|
||||
break;
|
||||
}
|
||||
serendipity_deleteEntry((int)$serendipity['GET']['id']);
|
||||
printf(RIP_ENTRY, (int)$serendipity['GET']['id']);
|
||||
echo '<br />';
|
||||
|
||||
case 'editSelect':
|
||||
serendipity_drawList();
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if (!serendipity_checkFormToken()) {
|
||||
break;
|
||||
}
|
||||
$newLoc = '?' . serendipity_setFormToken('url') . '&serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=doDelete&serendipity[id]=' . (int)$serendipity['GET']['id'];
|
||||
printf(DELETE_SURE, (int)$serendipity['GET']['id']);
|
||||
?>
|
||||
<br />
|
||||
<br />
|
||||
<div>
|
||||
<a href="<?php echo htmlspecialchars($_SERVER["HTTP_REFERER"]); ?>" class="serendipityPrettyButton"><?php echo NOT_REALLY; ?></a>
|
||||
<?php echo str_repeat(' ', 10); ?>
|
||||
<a href="<?php echo $newLoc; ?>" class="serendipityPrettyButton"><?php echo DUMP_IT; ?></a>
|
||||
</div>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'edit':
|
||||
$entry = serendipity_fetchEntry('id', $serendipity['GET']['id'], 1, 1);
|
||||
|
||||
default:
|
||||
include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php';
|
||||
|
||||
serendipity_printEntryForm(
|
||||
'?',
|
||||
array(
|
||||
'serendipity[action]' => 'admin',
|
||||
'serendipity[adminModule]' => 'entries',
|
||||
'serendipity[adminAction]' => 'save'
|
||||
),
|
||||
(isset($entry) ? $entry : array())
|
||||
);
|
||||
}
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
12
include/admin/entries_overview.inc.php
Normal file
12
include/admin/entries_overview.inc.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ('Don\'t hack!');
|
||||
}
|
||||
|
||||
echo WELCOME_BACK . ' ' . $_SESSION['serendipityUser'];
|
||||
|
||||
?>
|
15
include/admin/export.inc.php
Normal file
15
include/admin/export.inc.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
?>
|
||||
<div>
|
||||
<a href="<?php echo $serendipity['baseURL'] ?>rss.php?version=2.0&all=1" class="serendipityPrettyButton"><?php echo EXPORT_FEED; ?></a>
|
||||
</div>
|
||||
<?php
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
207
include/admin/groups.inc.php
Normal file
207
include/admin/groups.inc.php
Normal file
@ -0,0 +1,207 @@
|
||||
<?php # $Id: users.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
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ('Don\'t hack!');
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('adminUsersGroups')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Delete a group */
|
||||
if (isset($_POST['DELETE_YES']) && serendipity_checkFormToken()) {
|
||||
$group = serendipity_fetchGroup($serendipity['POST']['group']);
|
||||
serendipity_deleteGroup($serendipity['POST']['group']);
|
||||
printf('<div class="serendipityAdminMsgSuccess">' . DELETED_GROUP . '</div>', $serendipity['POST']['group'], $group['name']);
|
||||
}
|
||||
|
||||
/* Save new group */
|
||||
if (isset($_POST['SAVE_NEW']) && serendipity_checkFormToken()) {
|
||||
$serendipity['POST']['group'] = serendipity_addGroup($serendipity['POST']['name']);
|
||||
$perms = serendipity_getAllPermissionNames();
|
||||
serendipity_updateGroupConfig($serendipity['POST']['group'], $perms, $serendipity['POST']);
|
||||
printf('<div class="serendipityAdminMsgSuccess">' . CREATED_GROUP . '</div>', '#' . $serendipity['POST']['group'] . ', ' . $serendipity['POST']['name']);
|
||||
}
|
||||
|
||||
|
||||
/* Edit a group */
|
||||
if (isset($_POST['SAVE_EDIT']) && serendipity_checkFormToken()) {
|
||||
$perms = serendipity_getAllPermissionNames();
|
||||
serendipity_updateGroupConfig($serendipity['POST']['group'], $perms, $serendipity['POST']);
|
||||
printf('<div class="serendipityAdminMsgSuccess">' . MODIFIED_GROUP . '</div>', $serendipity['POST']['name']);
|
||||
}
|
||||
|
||||
if ( $serendipity['GET']['adminAction'] != 'delete' ) {
|
||||
?>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><strong><?php echo GROUP; ?></strong></td>
|
||||
<td width="200"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<?php
|
||||
if (serendipity_checkPermission('adminUsersMaintainOthers')) {
|
||||
$groups = serendipity_getAllGroups();
|
||||
} elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
|
||||
$groups = serendipity_getAllGroups($serendipity['authorid']);
|
||||
} else {
|
||||
$groups = array();
|
||||
}
|
||||
$i = 0;
|
||||
foreach($groups as $group) {
|
||||
?>
|
||||
<div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo ($i++ % 2) ? 'even' : 'uneven' ?>">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($group['name']); ?></td>
|
||||
<td width="200" align="right"> [<a href="?serendipity[adminModule]=groups&serendipity[adminAction]=edit&serendipity[group]=<?php echo $group['id'] ?>"><?php echo EDIT ?></a>]
|
||||
- [<a href="?serendipity[adminModule]=groups&serendipity[adminAction]=delete&serendipity[group]=<?php echo $group['id'] ?>"><?php echo DELETE ?></a>]</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</tr>
|
||||
<?php if ( !isset($_POST['NEW']) ) { ?>
|
||||
<tr>
|
||||
<td colspan="3" align="right">
|
||||
<form action="?serendipity[adminModule]=groups" method="post">
|
||||
<input type="submit" name="NEW" value="<?php echo CREATE_NEW_GROUP; ?>" class="serendipityPrettyButton" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
if ($serendipity['GET']['adminAction'] == 'edit' || isset($_POST['NEW'])) {
|
||||
?>
|
||||
<br />
|
||||
<br />
|
||||
<hr noshade="noshade">
|
||||
<form action="?serendipity[adminModule]=groups" method="post">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<div>
|
||||
<h3>
|
||||
<?php
|
||||
if ($serendipity['GET']['adminAction'] == 'edit') {
|
||||
$group = serendipity_fetchGroup($serendipity['GET']['group']);
|
||||
echo EDIT;
|
||||
$from = &$group;
|
||||
echo '<input type="hidden" name="serendipity[group]" value="' . $from['id'] . '" />';
|
||||
} else {
|
||||
echo CREATE;
|
||||
$from = array();
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><?php echo NAME; ?></td>
|
||||
<td><input type="text" name="serendipity[name]" value="<?php echo htmlspecialchars($from['name']); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><?php echo USERCONF_GROUPS; ?></td>
|
||||
<td><select name="serendipity[members][]" multiple="multiple" size="5">
|
||||
<?php
|
||||
$allusers = serendipity_fetchUsers();
|
||||
$users = serendipity_getGroupUsers($from['id']);
|
||||
|
||||
$selected = array();
|
||||
foreach((array)$users AS $user) {
|
||||
$selected[$user['id']] = true;
|
||||
}
|
||||
|
||||
foreach($allusers AS $user) {
|
||||
echo '<option value="' . (int)$user['authorid'] . '" ' . (isset($selected[$user['authorid']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
<?php
|
||||
$perms = serendipity_getAllPermissionNames();
|
||||
ksort($perms);
|
||||
foreach($perms AS $perm => $userlevels) {
|
||||
if (isset($from[$perm]) && $from[$perm] === 'true') {
|
||||
$selected = 'checked="checked"';
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
if (!isset($section)) {
|
||||
$section = $perm;
|
||||
}
|
||||
|
||||
if ($section != $perm && substr($perm, 0, strlen($section)) == $section) {
|
||||
$indent = ' ';
|
||||
$indentB = '';
|
||||
} elseif ($section != $perm) {
|
||||
$indent = '<br />';
|
||||
$indentB = '<br />';
|
||||
$section = $perm;
|
||||
}
|
||||
|
||||
if (defined('PERMISSION_' . strtoupper($perm))) {
|
||||
$permname = constant('PERMISSION_' . strtoupper($perm));
|
||||
} else {
|
||||
$permname = $perm;
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission($perm)) {
|
||||
echo "<tr>\n";
|
||||
echo "<td>$indent" . htmlspecialchars($permname) . "</td>\n";
|
||||
echo '<td>' . $indentB . ' ' . (!empty($selected) ? YES : NO) . '</td>' . "\n";
|
||||
echo "</tr>\n";
|
||||
} else {
|
||||
echo "<tr>\n";
|
||||
echo "<td>$indent<label for=\"" . htmlspecialchars($perm) . "\">" . htmlspecialchars($permname) . "</label></td>\n";
|
||||
echo '<td>' . $indentB . '<input id="' . htmlspecialchars($perm) . '" type="checkbox" name="serendipity[' . htmlspecialchars($perm) . ']" value="true" ' . $selected . ' /></td>' . "\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
if ($serendipity['GET']['adminAction'] == 'edit') { ?>
|
||||
<input type="submit" name="SAVE_EDIT" value="<?php echo SAVE; ?>" class="serendipityPrettyButton" />
|
||||
<?php echo ' - ' . WORD_OR . ' - ' ?>
|
||||
<input type="submit" name="SAVE_NEW" value="<?php echo CREATE_NEW_GROUP; ?>" class="serendipityPrettyButton" />
|
||||
<?php } else { ?>
|
||||
<input type="submit" name="SAVE_NEW" value="<?php echo CREATE_NEW_GROUP; ?>" class="serendipityPrettyButton" />
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
} elseif ($serendipity['GET']['adminAction'] == 'delete') {
|
||||
$group = serendipity_fetchGroup($serendipity['GET']['group']);
|
||||
?>
|
||||
<form action="?serendipity[adminModule]=groups" method="post">
|
||||
<div>
|
||||
<?php printf(DELETE_GROUP, $serendipity['GET']['group'], $group['name']); ?>
|
||||
<br /><br />
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<input type="hidden" name="serendipity[group]" value="<?php echo $serendipity['GET']['group']; ?>" />
|
||||
<input type="submit" name="DELETE_YES" value="<?php echo DUMP_IT; ?>" class="serendipityPrettyButton" />
|
||||
<input type="submit" name="NO" value="<?php echo NOT_REALLY; ?>" class="serendipityPrettyButton" />
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
775
include/admin/images.inc.php
Normal file
775
include/admin/images.inc.php
Normal file
@ -0,0 +1,775 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('adminImages')) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($serendipity['GET']['adminAction']) {
|
||||
case 'imgedit':
|
||||
echo '<div class="warning js_warning"><em>' . PREFERENCE_USE_JS_WARNING . '</em></div>';
|
||||
|
||||
if (!isset($serendipity['eyecandy']) || serendipity_db_bool($serendipity['eyecandy'])) {
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
include(S9Y_INCLUDE_PATH . "include/functions_images_crop.inc.php");
|
||||
$media['is_imgedit'] = true;
|
||||
$media['css_imgedit'] = serendipity_getTemplateFile('admin/imgedit.css');
|
||||
|
||||
if (isset($serendipity['GET']['fid'])) {
|
||||
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
|
||||
if (!is_array($file) || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fullfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . '.' . $file['extension'];
|
||||
$httpfile = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['extension'];
|
||||
|
||||
$img = new imgedit($fullfile, $httpfile);
|
||||
|
||||
// Set the filenames used for the cropping areas. Width/Height are automagically detected. Orientation is either horizontal or vertical.
|
||||
$img->setArea('imgedit_area.gif', 'h');
|
||||
$img->setArea('imgedit_varea.gif', 'v');
|
||||
|
||||
// Let the IMGEditor do its magic. It will parse its results straightly into a template variable array.
|
||||
$img->main();
|
||||
$serendipity['smarty']->assign('imgedit', $img->imgedit_smarty);
|
||||
serendipity_smarty_fetch('IMGEDIT', $img->output_template);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sync':
|
||||
if (!serendipity_checkPermission('adminImagesSync')) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (function_exists('set_time_limit')) {
|
||||
@set_time_limit(0);
|
||||
}
|
||||
@ignore_user_abort();
|
||||
|
||||
echo '<p class="image_synch"><b>' . SYNCING . '</b></p><br />';
|
||||
flush();
|
||||
|
||||
$i = serendipity_syncThumbs();
|
||||
printf(SYNC_DONE, $i);
|
||||
|
||||
echo '<p class="image_resize"><b>' . RESIZING . '</b></p><br />';
|
||||
flush();
|
||||
|
||||
$i = serendipity_generateThumbs();
|
||||
printf(RESIZE_DONE, $i);
|
||||
|
||||
break;
|
||||
|
||||
case 'DoDelete':
|
||||
if (!serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDelete')) {
|
||||
break;
|
||||
}
|
||||
|
||||
$file = $serendipity['GET']['fname'];
|
||||
serendipity_deleteImage($serendipity['GET']['fid']);
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
|
||||
|
||||
if (!is_array($file) || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($serendipity['adminFile'])) {
|
||||
$serendipity['adminFile'] = 'serendipity_admin.php';
|
||||
}
|
||||
$abortLoc = $serendipity['serendipityHTTPPath'] . $serendipity['adminFile'] . '?serendipity[adminModule]=images';
|
||||
$newLoc = $abortLoc . '&serendipity[adminAction]=DoDelete&serendipity[fid]=' . (int)$serendipity['GET']['fid'] . '&' . serendipity_setFormToken('url');
|
||||
|
||||
printf('<div class="image_notify_delete">' . ABOUT_TO_DELETE_FILE . '</div>', $file['name'] .'.'. $file['extension']);
|
||||
?>
|
||||
<form method="get" id="delete_image">
|
||||
<div>
|
||||
<a href="<?php echo $newLoc; ?>" class="serendipityPrettyButton"><?php echo DUMP_IT ?></a>
|
||||
|
||||
<a href="<?php echo $abortLoc; ?>" class="serendipityPrettyButton"><?php echo ABORT_NOW ?></a>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'rename':
|
||||
$serendipity['GET']['fid'] = (int)$serendipity['GET']['fid'];
|
||||
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
|
||||
$serendipity['GET']['newname'] = serendipity_uploadSecure($serendipity['GET']['newname'], true);
|
||||
|
||||
if (!is_array($file) || !serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!serendipity_moveMediaDirectory(null, $serendipity['GET']['newname'], 'file', $serendipity['GET']['fid'], $file)) {
|
||||
?>
|
||||
<br />
|
||||
<input type="button" onclick="history.go(-1);" value="<?php echo BACK; ?>" class="serendipityPrettyButton" />
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
||||
// if we successfully rename
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
location.href="?serendipity[adminModule]=images&serendipity[adminAction]=default";
|
||||
</script>
|
||||
<noscript>
|
||||
<a href="?serendipity[adminModule]=images&serendipity[adminAction]=default"><?php echo DONE ?></a>
|
||||
</noscript>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'properties':
|
||||
$new_media = array(array('image_id' => $serendipity['GET']['fid']));
|
||||
serendipity_showPropertyForm($new_media);
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
if (!serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesAdd')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($serendipity['POST']['adminSubAction'] == 'properties') {
|
||||
$properties = serendipity_parsePropertyForm();
|
||||
$image_id = $properties['image_id'];
|
||||
$created_thumbnail = true;
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
location.href="?serendipity[adminModule]=images&serendipity[adminAction]=default";
|
||||
</script>
|
||||
<noscript>
|
||||
<a href="?serendipity[adminModule]=images&serendipity[adminAction]=default"><?php echo DONE ?></a>
|
||||
</noscript>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="image_add"><b><?php echo ADDING_IMAGE; ?></b></div>
|
||||
<br /><br />
|
||||
<?php
|
||||
|
||||
$authorid = (isset($serendipity['POST']['all_authors']) && $serendipity['POST']['all_authors'] == 'true') ? '0' : $serendipity['authorid'];
|
||||
|
||||
$new_media = array();
|
||||
// First find out whether to fetch a file or accept an upload
|
||||
if ($serendipity['POST']['imageurl'] != '' && $serendipity['POST']['imageurl'] != 'http://') {
|
||||
if (!empty($serendipity['POST']['target_filename'][2])) {
|
||||
// Faked hidden form 2 when submitting with JavaScript
|
||||
$tfile = $serendipity['POST']['target_filename'][2];
|
||||
$tindex = 2;
|
||||
} elseif (!empty($serendipity['POST']['target_filename'][1])) {
|
||||
// Fallback key when not using JavaScript
|
||||
$tfile = $serendipity['POST']['target_filename'][1];
|
||||
$tindex = 1;
|
||||
} else {
|
||||
$tfile = $serendipity['POST']['imageurl'];
|
||||
$tindex = 1;
|
||||
}
|
||||
|
||||
$tfile = serendipity_uploadSecure(basename($tfile));
|
||||
|
||||
if (serendipity_isActiveFile($tfile)) {
|
||||
printf(ERROR_FILE_FORBIDDEN, $tfile);
|
||||
break;
|
||||
}
|
||||
|
||||
$serendipity['POST']['target_directory'][$tindex] = serendipity_uploadSecure($serendipity['POST']['target_directory'][$tindex], true, true);
|
||||
$target = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'][$tindex] . $tfile;
|
||||
|
||||
$realname = $tfile;
|
||||
if (file_exists($target)) {
|
||||
echo '(' . $target . ') ' . ERROR_FILE_EXISTS_ALREADY . '<br />';
|
||||
$realname = serendipity_imageAppend($tfile, $target, $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'][$tindex]);
|
||||
}
|
||||
|
||||
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
|
||||
$options = array();
|
||||
serendipity_plugin_api::hook_event('backend_http_request', $options, 'image');
|
||||
serendipity_request_start();
|
||||
$req = &new HTTP_Request($serendipity['POST']['imageurl'], $options);
|
||||
// Try to get the URL
|
||||
|
||||
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
|
||||
printf(REMOTE_FILE_NOT_FOUND, $serendipity['POST']['imageurl']);
|
||||
} else {
|
||||
// Fetch file
|
||||
$fContent = $req->getResponseBody();
|
||||
|
||||
if ($serendipity['POST']['imageimporttype'] == 'hotlink') {
|
||||
$tempfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . '/hotlink_' . time();
|
||||
$fp = fopen($tempfile, 'w');
|
||||
fwrite($fp, $fContent);
|
||||
fclose($fp);
|
||||
|
||||
$image_id = @serendipity_insertHotlinkedImageInDatabase($tfile, $serendipity['POST']['imageurl'], $authorid, null, $tempfile);
|
||||
printf(HOTLINK_DONE. '<br />', $serendipity['POST']['imageurl'], $tfile);
|
||||
serendipity_plugin_api::hook_event('backend_image_addHotlink', $tempfile);
|
||||
} else {
|
||||
$fp = fopen($target, 'w');
|
||||
fwrite($fp, $fContent);
|
||||
fclose($fp);
|
||||
|
||||
printf(FILE_FETCHED . '<br />', $serendipity['POST']['imageurl'], $tfile);
|
||||
|
||||
if (serendipity_checkMediaSize($target)) {
|
||||
$thumbs = array(array(
|
||||
'thumbSize' => $serendipity['thumbSize'],
|
||||
'thumb' => $serendipity['thumbSuffix']
|
||||
));
|
||||
serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
|
||||
|
||||
foreach($thumbs as $thumb) {
|
||||
// Create thumbnail
|
||||
if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$tindex], $thumb['thumbSize'], $thumb['thumb']) ) {
|
||||
echo THUMB_CREATED_DONE . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
// Insert into database
|
||||
$image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$tindex], $authorid, null, $realname);
|
||||
serendipity_plugin_api::hook_event('backend_image_add', $target);
|
||||
$new_media[] = array(
|
||||
'image_id' => $image_id,
|
||||
'target' => $target,
|
||||
'created_thumbnail' => $created_thumbnail
|
||||
);
|
||||
}
|
||||
}
|
||||
serendipity_request_end();
|
||||
}
|
||||
} else {
|
||||
if (!is_array($serendipity['POST']['target_filename'])) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach($serendipity['POST']['target_filename'] AS $idx => $target_filename) {
|
||||
$uploadfile = &$_FILES['serendipity']['name']['userfile'][$idx];
|
||||
$uploadtmp = &$_FILES['serendipity']['tmp_name']['userfile'][$idx];
|
||||
if (!empty($target_filename)) {
|
||||
$tfile = $target_filename;
|
||||
} elseif (!empty($uploadfile)) {
|
||||
$tfile = $uploadfile;
|
||||
} else {
|
||||
// skip empty array
|
||||
continue;
|
||||
}
|
||||
|
||||
$tfile = serendipity_uploadSecure(basename($tfile));
|
||||
|
||||
if (serendipity_isActiveFile($tfile)) {
|
||||
printf(ERROR_FILE_FORBIDDEN, $tfile);
|
||||
echo '<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
$serendipity['POST']['target_directory'][$idx] = serendipity_uploadSecure($serendipity['POST']['target_directory'][$idx], true, true);
|
||||
$target = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'][$idx] . $tfile;
|
||||
|
||||
$realname = $tfile;
|
||||
if (file_exists($target)) {
|
||||
echo '(' . $target . ') ' . ERROR_FILE_EXISTS_ALREADY . '<br />';
|
||||
$realname = serendipity_imageAppend($tfile, $target, $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'][$idx]);
|
||||
}
|
||||
|
||||
// Accept file
|
||||
if (is_uploaded_file($uploadtmp) && serendipity_checkMediaSize($uploadtmp) && move_uploaded_file($uploadtmp, $target)) {
|
||||
printf(FILE_UPLOADED . '<br />', $uploadfile, $target);
|
||||
@umask(0000);
|
||||
@chmod($target, 0664);
|
||||
|
||||
$thumbs = array(array(
|
||||
'thumbSize' => $serendipity['thumbSize'],
|
||||
'thumb' => $serendipity['thumbSuffix']
|
||||
));
|
||||
serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
|
||||
|
||||
foreach($thumbs as $thumb) {
|
||||
// Create thumbnail
|
||||
if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$idx], $thumb['thumbSize'], $thumb['thumb']) ) {
|
||||
echo THUMB_CREATED_DONE . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
// Insert into database
|
||||
$image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$idx], $authorid, null, $realname);
|
||||
serendipity_plugin_api::hook_event('backend_image_add', $target);
|
||||
$new_media[] = array(
|
||||
'image_id' => $image_id,
|
||||
'target' => $target,
|
||||
'created_thumbnail' => $created_thumbnail
|
||||
);
|
||||
} else {
|
||||
echo ERROR_UNKNOWN_NOUPLOAD . '<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['go_properties'])) {
|
||||
serendipity_showPropertyForm($new_media);
|
||||
} else {
|
||||
$hidden = array(
|
||||
'author' => $serendipity['serendipityUser'],
|
||||
'authorid' => $serendipity['authorid']
|
||||
);
|
||||
|
||||
foreach($new_media AS $nm) {
|
||||
serendipity_insertMediaProperty('base_hidden', '', $nm['image_id'], $hidden);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'directoryDoDelete':
|
||||
if (!serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDirectories')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$new_dir = serendipity_uploadSecure($serendipity['GET']['dir'], true);
|
||||
if (is_dir($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir)) {
|
||||
if (!is_writable($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir)) {
|
||||
printf(DIRECTORY_WRITE_ERROR, $new_dir);
|
||||
} else {
|
||||
// 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));
|
||||
}
|
||||
} else {
|
||||
printf(ERROR_NO_DIRECTORY, $new_dir);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'directoryEdit':
|
||||
if (!serendipity_checkPermission('adminImagesDirectories')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$use_dir = serendipity_uploadSecure($serendipity['GET']['dir']);
|
||||
$checkpath = array(
|
||||
array(
|
||||
'relpath' => $use_dir
|
||||
)
|
||||
);
|
||||
|
||||
if (!serendipity_directoryACL($checkpath, 'write')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($serendipity['POST']['save'])) {
|
||||
$newDir = serendipity_uploadSecure($serendipity['POST']['newDir']);
|
||||
$oldDir = serendipity_uploadSecure($serendipity['POST']['oldDir']);
|
||||
|
||||
if ($oldDir != $newDir) {
|
||||
serendipity_moveMediaDirectory($oldDir, $newDir);
|
||||
$use_dir = $newDir;
|
||||
}
|
||||
serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'], $use_dir);
|
||||
serendipity_ACLGrant(0, 'directory', 'write', $serendipity['POST']['write_authors'], $use_dir);
|
||||
echo '<div>' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>';
|
||||
}
|
||||
|
||||
$groups = serendipity_getAllGroups();
|
||||
$read_groups = serendipity_ACLGet(0, 'directory', 'read', $use_dir);
|
||||
$write_groups = serendipity_ACLGet(0, 'directory', 'write', $use_dir);
|
||||
?>
|
||||
|
||||
<div class="image_directory_edit"><strong><?php echo MANAGE_DIRECTORIES ?></strong></div>
|
||||
<br />
|
||||
<form id="image_directory_edit_form" method="POST" action="?serendipity[adminModule]=images&serendipity[adminAction]=directoryEdit&serendipity[dir]=<?php echo htmlspecialchars($serendipity['GET']['dir']) ?>">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<input type="hidden" name="serendipity[oldDir]" value="<?php echo $use_dir; ?>" />
|
||||
<table cellpadding="5">
|
||||
<tr>
|
||||
<td width="100"><strong><?php echo NAME ?></strong></td>
|
||||
<td><input type="text" name="serendipity[newDir]" value="<?php echo $use_dir; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="read_authors"><?php echo PERM_READ; ?></label></td>
|
||||
<td>
|
||||
<select size="6" id="read_authors" multiple="multiple" name="serendipity[read_authors][]">
|
||||
<option value="0" <?php echo (isset($read_groups[0])) ? 'selected="selected"' : ''; ?>><?php echo ALL_AUTHORS; ?></option>
|
||||
<?php
|
||||
foreach($groups AS $group) {
|
||||
echo '<option value="' . $group['confkey'] . '" ' . (isset($read_groups[$group['confkey']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($group['confvalue']) . '</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><label for="write_authors"><?php echo PERM_WRITE; ?></label></td>
|
||||
<td>
|
||||
<select size="6" id="write_authors" multiple="multiple" name="serendipity[write_authors][]">
|
||||
<option value="0" <?php echo (isset($write_groups[0])) ? 'selected="selected"' : ''; ?>><?php echo ALL_AUTHORS; ?></option>
|
||||
<?php
|
||||
foreach($groups AS $group) {
|
||||
echo '<option value="' . $group['confkey'] . '" ' . (isset($write_groups[$group['confkey']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($group['confvalue']) . '</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<br />
|
||||
<div align="center">
|
||||
<input name="serendipity[save]" value="<?php echo SAVE ?>" class="serendipityPrettyButton" type="submit" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'directoryDelete':
|
||||
if (!serendipity_checkPermission('adminImagesDirectories')) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="image_directory_delete"><strong><?php echo DELETE_DIRECTORY ?></strong></div>
|
||||
<div class="image_directory_delete_desc"><?php echo DELETE_DIRECTORY_DESC ?></div>
|
||||
<br />
|
||||
<br />
|
||||
<form id="image_directory_delete_form" method="POST" action="?serendipity[adminModule]=images&serendipity[adminAction]=directoryDoDelete&serendipity[dir]=<?php echo htmlspecialchars($serendipity['GET']['dir']) ?>">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<table cellpadding="5">
|
||||
<tr>
|
||||
<td width="100"><strong><?php echo NAME ?></strong></td>
|
||||
<td><?php echo basename(htmlspecialchars($serendipity['GET']['dir'])) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="checkbox" name="serendipity[nuke]" value="true" style="margin: 0"> <?php echo FORCE_DELETE ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<br />
|
||||
<div align="center">
|
||||
<?php echo sprintf(CONFIRM_DELETE_DIRECTORY, htmlspecialchars($serendipity['GET']['dir'])) ?><br />
|
||||
<input name="SAVE" value="<?php echo DELETE_DIRECTORY ?>" class="serendipityPrettyButton" type="submit" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'directoryDoCreate':
|
||||
if (!serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDirectories')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$new_dir = serendipity_uploadSecure($serendipity['POST']['parent'] . '/' . $serendipity['POST']['name'], true);
|
||||
$new_dir = str_replace(array('..', '//'), array('', '/'), $new_dir);
|
||||
|
||||
/* TODO: check if directory already exist */
|
||||
if (@mkdir($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir)) {
|
||||
printf(DIRECTORY_CREATED, $serendipity['POST']['name']);
|
||||
@umask(0000);
|
||||
@chmod($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir, 0777);
|
||||
|
||||
// Apply parent ACL to new child.
|
||||
$array_parent_read = serendipity_ACLGet(0, 'directory', 'read', $serendipity['POST']['parent']);
|
||||
$array_parent_write = serendipity_ACLGet(0, 'directory', 'write', $serendipity['POST']['parent']);
|
||||
if (!is_array($array_parent_read) || count($array_parent_read) < 1) {
|
||||
$parent_read = array(0);
|
||||
} else {
|
||||
$parent_read = array_keys($array_parent_read);
|
||||
}
|
||||
if (!is_array($array_parent_write) || count($array_parent_write) < 1) {
|
||||
$parent_write = array(0);
|
||||
} else {
|
||||
$parent_write = array_keys($array_parent_write);
|
||||
}
|
||||
|
||||
serendipity_ACLGrant(0, 'directory', 'read', $parent_read, $new_dir . '/');
|
||||
serendipity_ACLGrant(0, 'directory', 'write', $parent_write, $new_dir . '/');
|
||||
} else {
|
||||
printf(DIRECTORY_WRITE_ERROR, $new_dir);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'directoryCreate':
|
||||
if (!serendipity_checkPermission('adminImagesDirectories')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$folders = serendipity_traversePath(
|
||||
$serendipity['serendipityPath'] . $serendipity['uploadPath'],
|
||||
'',
|
||||
true,
|
||||
NULL,
|
||||
1,
|
||||
NULL,
|
||||
'write'
|
||||
);
|
||||
?>
|
||||
<div class="image_directory_create"><strong><?php echo CREATE_DIRECTORY ?></strong></div>
|
||||
<div class="image_directory_create_desc"><?php echo CREATE_DIRECTORY_DESC ?></div>
|
||||
<br />
|
||||
<br />
|
||||
<form id="image_directory_create_form" method="POST" action="?serendipity[step]=directoryDoCreate&serendipity[adminModule]=images&serendipity[adminAction]=directoryDoCreate">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<table cellpadding="5">
|
||||
<tr>
|
||||
<td><?php echo NAME ?></td>
|
||||
<td><input type="text" name="serendipity[name]" value="" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo PARENT_DIRECTORY ?></td>
|
||||
<td><select name="serendipity[parent]">
|
||||
<option value=""><?php echo BASE_DIRECTORY ?></option>
|
||||
<?php foreach ( $folders as $folder ) { ?>
|
||||
<option <?php echo ($folder['relpath'] == $serendipity['GET']['only_path'] ? 'selected="selected"' : ''); ?> value="<?php echo $folder['relpath'] ?>"><?php echo str_repeat(' ', $folder['depth']*2) . ' '. $folder['name'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div><input name="SAVE" value="<?php echo CREATE_DIRECTORY ?>" class="serendipityPrettyButton" type="submit"></div>
|
||||
</form>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'directorySelect':
|
||||
if (!serendipity_checkPermission('adminImagesDirectories')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$folders = serendipity_traversePath(
|
||||
$serendipity['serendipityPath'] . $serendipity['uploadPath'],
|
||||
'',
|
||||
true,
|
||||
NULL,
|
||||
1,
|
||||
NULL,
|
||||
'write'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="image_directory_list"><?php echo DIRECTORIES_AVAILABLE; ?></div>
|
||||
<br />
|
||||
<table id="image_directory_listing" border="0" cellspacing="0" cellpadding="4" width="100%">
|
||||
<tr>
|
||||
<td colspan="4"><strong><?php echo BASE_DIRECTORY ?></strong></td>
|
||||
</tr>
|
||||
<?php foreach ($folders as $folder) { ?>
|
||||
<tr>
|
||||
<td width="16"><a href="?serendipity[adminModule]=images&serendipity[adminAction]=directoryEdit&serendipity[dir]=<?php echo htmlspecialchars($folder['relpath']) ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png') ?>" border="0" alt="<?php echo EDIT ?>" /></a></td>
|
||||
<td width="16"><a href="?serendipity[adminModule]=images&serendipity[adminAction]=directoryDelete&serendipity[dir]=<?php echo htmlspecialchars($folder['relpath']) ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png') ?>" alt="<?php echo DELETE ?>" border="0"></a></td>
|
||||
<td style="padding-left: <?php echo $folder['depth']*10 ?>"><?php echo $folder['name'] ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<br />
|
||||
<div><a href="?serendipity[adminModule]=images&serendipity[adminAction]=directoryCreate" class="serendipityPrettyButton"><?php echo CREATE_NEW_DIRECTORY ?></a></div>
|
||||
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'addSelect':
|
||||
if (!serendipity_checkPermission('adminImagesAdd')) {
|
||||
return;
|
||||
}
|
||||
|
||||
serendipity_restoreVar($serendipity['COOKIE']['addmedia_directory'], $serendipity['GET']['only_path']);
|
||||
$folders = serendipity_traversePath(
|
||||
$serendipity['serendipityPath'] . $serendipity['uploadPath'],
|
||||
'',
|
||||
true,
|
||||
NULL,
|
||||
1,
|
||||
NULL,
|
||||
'write'
|
||||
);
|
||||
|
||||
$form_hidden = '';
|
||||
if (isset($image_selector_addvars) && is_array($image_selector_addvars)) {
|
||||
// These variables may come from serendipity_admin_image_selector.php to show embedded upload form
|
||||
foreach($image_selector_addvars AS $imgsel_key => $imgsel_val) {
|
||||
$form_hidden .= ' <input type="hidden" name="serendipity[' . htmlspecialchars($imgsel_key) . ']" value="' . htmlspecialchars($imgsel_val) . '" />' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
serendipity_smarty_init();
|
||||
$mediaFiles = array(
|
||||
'token' => serendipity_setFormToken(),
|
||||
'form_hidden' => $form_hidden,
|
||||
'folders' => $folders,
|
||||
'only_path' => $serendipity['GET']['only_path'],
|
||||
'max_file_size' => $serendipity['maxFileSize'],
|
||||
'maxImgHeight' => $serendipity['maxImgHeight'],
|
||||
'maxImgWidth' => $serendipity['maxImgWidth'],
|
||||
);
|
||||
$serendipity['smarty']->assign('media', $mediaFiles);
|
||||
$serendipity['smarty']->display(serendipity_getTemplateFile('admin/media_upload.tpl', 'serendipityPath'));
|
||||
break;
|
||||
|
||||
case 'rotateCW':
|
||||
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
|
||||
if (!is_array($file) || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($serendipity['adminFile_redirect'])) {
|
||||
$serendipity['adminFile_redirect'] = htmlspecialchars($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
if (serendipity_rotateImg($serendipity['GET']['fid'], -90)) {
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
location.href="<?php echo $serendipity['adminFile_redirect'] ?>";
|
||||
</script>
|
||||
<noscript><a href="<?php echo $serendipity['adminFile_redirect'] ?>"><?php echo DONE ?></a></noscript>
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
|
||||
case 'rotateCCW':
|
||||
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
|
||||
if (!is_array($file) || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($serendipity['adminFile_redirect'])) {
|
||||
$serendipity['adminFile_redirect'] = htmlspecialchars($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
if (serendipity_rotateImg($serendipity['GET']['fid'], 90)) {
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
location.href="<?php echo $serendipity['adminFile_redirect'] ?>";
|
||||
</script>
|
||||
<noscript><a href="<?php echo $serendipity['adminFile_redirect'] ?>"><?php echo DONE ?></a></noscript>
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
|
||||
case 'scale':
|
||||
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
|
||||
|
||||
if (!is_array($file) || !serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
SCALING_IMAGE . '<br />',
|
||||
|
||||
$file['path'] . $file['name'] .'.'. $file['extension'],
|
||||
(int)$serendipity['GET']['width'],
|
||||
(int)$serendipity['GET']['height']
|
||||
);
|
||||
|
||||
echo serendipity_scaleImg($serendipity['GET']['fid'], $serendipity['GET']['width'], $serendipity['GET']['height']) . '<br />';
|
||||
echo DONE . '<br />';
|
||||
// Forward user to overview (we don't want the user's back button to rename things again)
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
location.href="?serendipity[adminModule]=images&serendipity[adminAction]=default";
|
||||
</script>
|
||||
<noscript><a href="?serendipity[adminModule]=images&serendipity[adminAction]=default"><?php echo DONE ?></a></noscript>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'scaleSelect':
|
||||
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
|
||||
|
||||
if (!is_array($file) || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$s = getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] .'.'. $file['extension']);
|
||||
?>
|
||||
<script type="text/javascript" language="javascript">
|
||||
<!--
|
||||
function rescale(dim, newval) {
|
||||
var originalWidth = <?php echo $s[0]; ?>;
|
||||
var originalHeight = <?php echo $s[1]; ?>;
|
||||
var ratio = originalHeight/originalWidth;
|
||||
var trans = new Array();
|
||||
trans['width'] = new Array('serendipity[height]', ratio);
|
||||
trans['height'] = new Array('serendipity[width]', 1/ratio);
|
||||
|
||||
if (document.serendipityScaleForm.elements['auto'].checked == true) {
|
||||
document.serendipityScaleForm.elements[trans[dim][0]].value=Math.round(trans[dim][1]*newval);
|
||||
}
|
||||
|
||||
document.getElementsByName('serendipityScaleImg')[0].style.width =
|
||||
document.serendipityScaleForm.elements['serendipity[width]'].value+'px';
|
||||
|
||||
document.getElementsByName('serendipityScaleImg')[0].style.height =
|
||||
document.serendipityScaleForm.elements['serendipity[height]'].value+'px';
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
<?php
|
||||
|
||||
printf(RESIZE_BLAHBLAH, htmlspecialchars($serendipity['GET']['fname']));
|
||||
printf(ORIGINAL_SIZE, $s[0],$s[1]);
|
||||
echo HERE_YOU_CAN_ENTER_BLAHBLAH;
|
||||
?>
|
||||
<form name="serendipityScaleForm" action="?" method="GET">
|
||||
<div>
|
||||
<?php echo NEWSIZE; ?>
|
||||
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<input type="hidden" name="serendipity[adminModule]" value="images" />
|
||||
<input type="hidden" name="serendipity[adminAction]" value="scale" />
|
||||
<input type="hidden" name="serendipity[fid]" value="<?php echo $serendipity["GET"]["fid"]; ?>" />
|
||||
|
||||
<input type="text" size="4" name="serendipity[width]" onchange="rescale('width' , value);" value="<?php echo $s[0]; ?>" />x
|
||||
<input type="text" size="4" name="serendipity[height]" onchange="rescale('height', value);" value="<?php echo $s[1]; ?>" />
|
||||
<br />
|
||||
|
||||
<?php echo KEEP_PROPORTIONS; ?>:
|
||||
<!-- <input type='button' value='preview'>-->
|
||||
<input type="checkbox" name="auto" checked="checked" /><br />
|
||||
<input type="button" name="scale" value="<?php echo IMAGE_RESIZE; ?>" onclick="if (confirm('<?php echo REALLY_SCALE_IMAGE; ?>')) document.serendipityScaleForm.submit();" class="serendipityPrettyButton" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<img src="<?php echo $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] .'.'. $file['extension'] ; ?>" name="serendipityScaleImg" style="width: <?php echo $s[0]; ?>px; height: <?php echo $s[1]; ?>px;" alt="" />
|
||||
<?php
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!serendipity_checkPermission('adminImagesView')) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript" language="javascript">
|
||||
<!--
|
||||
function rename(id, fname) {
|
||||
if(newname = prompt('<?php echo ENTER_NEW_NAME; ?>' + fname, fname)) {
|
||||
location.href='?<?php echo serendipity_setFormToken('url'); ?>&serendipity[adminModule]=images&serendipity[adminAction]=rename&serendipity[fid]='+ escape(id) + '&serendipity[newname]='+ escape(newname);
|
||||
}
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
<?php
|
||||
if (!isset($serendipity['thumbPerPage'])) {
|
||||
$serendipity['thumbPerPage'] = 2;
|
||||
}
|
||||
serendipity_displayImageList(
|
||||
isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1,
|
||||
$serendipity['thumbPerPage'],
|
||||
true
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
268
include/admin/import.inc.php
Normal file
268
include/admin/import.inc.php
Normal file
@ -0,0 +1,268 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('adminImport')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This won't do anything if safe-mode is ON, but let's try anyway since importing could take a while */
|
||||
if (function_exists('set_time_limit')) {
|
||||
@set_time_limit(0);
|
||||
}
|
||||
|
||||
/* Class construct. Each importer plugin must extend this class. */
|
||||
class Serendipity_Import {
|
||||
var $trans_table = '';
|
||||
|
||||
/**
|
||||
* Return textual notes of an importer plugin
|
||||
*
|
||||
* If an importer plugin needs to show any notes on the userinterface, those can be returned in this method.
|
||||
*
|
||||
* @access public
|
||||
* @return string HTML-code of a interface/user hint
|
||||
*/
|
||||
function getImportNotes() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of available charsets the user can choose from. Depends on current language of the blog.
|
||||
*
|
||||
* @access public
|
||||
* @param boolean If set to true, returns the option "UTF-8" as first select choice, which is then preselected. If false, the current language of the blog will be the default.
|
||||
* @return array Array of available charsets to choose from
|
||||
*/
|
||||
function getCharsets($utf8_default = true) {
|
||||
$charsets = array();
|
||||
|
||||
if (!$utf8_default) {
|
||||
$charsets['native'] = LANG_CHARSET;
|
||||
}
|
||||
|
||||
if (LANG_CHARSET != 'UTF-8') {
|
||||
$charsets['UTF-8'] = 'UTF-8';
|
||||
}
|
||||
|
||||
if (LANG_CHARSET != 'ISO-8859-1') {
|
||||
$charsets['ISO-8859-1'] = 'ISO-8859-1';
|
||||
}
|
||||
|
||||
if ($utf8_default) {
|
||||
$charsets['native'] = LANG_CHARSET;
|
||||
}
|
||||
|
||||
return $charsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes/Transcodes a string according to the selected charset, and the charset of the blog
|
||||
*
|
||||
* @access public
|
||||
* @param string input string to convert
|
||||
* @return string converted string
|
||||
*/
|
||||
function &decode($string) {
|
||||
// xml_parser_* functions to recoding from ISO-8859-1/UTF-8
|
||||
if (LANG_CHARSET == 'ISO-8859-1' || LANG_CHARSET == 'UTF-8') {
|
||||
return $string;
|
||||
}
|
||||
|
||||
$target = $this->data['charset'];
|
||||
|
||||
switch($target) {
|
||||
case 'native':
|
||||
return $string;
|
||||
|
||||
case 'ISO-8859-1':
|
||||
if (function_exists('iconv')) {
|
||||
$out = iconv('ISO-8859-1', LANG_CHARSET, $string);
|
||||
} elseif (function_exists('recode')) {
|
||||
$out = recode('iso-8859-1..' . LANG_CHARSET, $string);
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
return $out;
|
||||
|
||||
case 'UTF-8':
|
||||
default:
|
||||
$out = utf8_decode($string);
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode/Transcode a string with the indicated translation table (member property). Useful for transcoding HTML entities to native characters.
|
||||
*
|
||||
* @access public
|
||||
* @param string input string
|
||||
* @return string output string
|
||||
*/
|
||||
function strtr($data) {
|
||||
return strtr($this->decode($data), $this->trans_table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode/Transcode an array of strings.
|
||||
*
|
||||
* LONG
|
||||
*
|
||||
* @access public
|
||||
* @see $this->strtr()
|
||||
* @param array input array
|
||||
* @return array output array
|
||||
*/
|
||||
function strtrRecursive($data) {
|
||||
foreach ($data as $key => $val) {
|
||||
if (is_array($val)) {
|
||||
$data[$key] = $this->strtrRecursive($val);
|
||||
} else {
|
||||
$data[$key] = $this->strtr($val);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transcoding table, depending on whether it was enabled for the instance of the importer plugin
|
||||
*
|
||||
* The member property $this->trans_table will be filled with the output of this function
|
||||
*
|
||||
* @access public
|
||||
* @see $this->strtr()
|
||||
* @return null
|
||||
*/
|
||||
function getTransTable() {
|
||||
if (!serendipity_db_bool($this->data['use_strtr'])) {
|
||||
$this->trans_table = array();
|
||||
return true;
|
||||
}
|
||||
|
||||
// We need to convert interesting characters to HTML entities, except for those with special relevance to HTML.
|
||||
$this->trans_table = get_html_translation_table(HTML_ENTITIES);
|
||||
foreach (get_html_translation_table(HTML_SPECIALCHARS) as $char => $encoded) {
|
||||
if (isset($this->trans_table[$char])) {
|
||||
unset($this->trans_table[$char]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a DB query on the source database of the import, instead of a DB query on the target database
|
||||
*
|
||||
* @access public
|
||||
* @param string SQL Query
|
||||
* @param ressource DB connection resource
|
||||
* @return ressource SQL response
|
||||
*/
|
||||
function &nativeQuery($query, $db = false) {
|
||||
global $serendipity;
|
||||
|
||||
mysql_select_db($this->data['name']);
|
||||
$return = &mysql_query($query, $db);
|
||||
// print_r($return);
|
||||
mysql_select_db($serendipity['dbName']);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($serendipity['GET']['importFrom']) && serendipity_checkFormToken()) {
|
||||
|
||||
/* Include the importer */
|
||||
$class = @require_once(S9Y_INCLUDE_PATH . 'include/admin/importers/'. basename($serendipity['GET']['importFrom']) .'.inc.php');
|
||||
if ( !class_exists($class) ) {
|
||||
die('FAILURE: Unable to require import module, possible syntax error?');
|
||||
}
|
||||
|
||||
/* Init the importer with form data */
|
||||
$importer = new $class($serendipity['POST']['import']);
|
||||
|
||||
/* Yes sir, we are importing if we have valid data */
|
||||
if ( $importer->validateData() ) {
|
||||
echo IMPORT_STARTING . '<br />';
|
||||
|
||||
/* import() MUST return (bool)true, otherwise we assume it failed */
|
||||
if ( ($result = $importer->import()) !== true ) {
|
||||
echo IMPORT_FAILED .': '. $result . '<br />';
|
||||
} else {
|
||||
echo IMPORT_DONE . '<br />';
|
||||
}
|
||||
|
||||
|
||||
/* Apprently we do not have valid data, ask for some */
|
||||
} else {
|
||||
?>
|
||||
|
||||
<?php echo IMPORT_PLEASE_ENTER ?>:<br />
|
||||
<br />
|
||||
<form action="" method="POST" enctype="multipart/form-data">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<table cellpadding="3" cellspacing="2">
|
||||
<?php foreach ( $importer->getInputFields() as $field ) { ?>
|
||||
<tr>
|
||||
<td><?php echo $field['text'] ?></td>
|
||||
<td><?php serendipity_guessInput($field['type'], 'serendipity[import]['. $field['name'] .']', (isset($serendipity['POST']['import'][$field['name']]) ? $serendipity['POST']['import'][$field['name']] : $field['default']), $field['default']) ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php if ($notes = $importer->getImportNotes()){ ?>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<b><?php echo IMPORT_NOTES; ?></b><br />
|
||||
<?php echo $notes ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td colspan="2" align="right"><input type="submit" value="<?php echo IMPORT_NOW ?>" class="serendipityPrettyButton"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$importpath = S9Y_INCLUDE_PATH . 'include/admin/importers/';
|
||||
$dir = opendir($importpath);
|
||||
$list = array();
|
||||
while (($file = readdir($dir)) !== false ) {
|
||||
if (!is_file($importpath . $file) || !preg_match('@.php$@', $file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = include_once($importpath . $file);
|
||||
if ( class_exists($class) ) {
|
||||
$tmpClass = new $class(array());
|
||||
$list[substr($file, 0, strpos($file, '.'))] = $tmpClass->info['software'];
|
||||
unset($tmpClass);
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
ksort($list);
|
||||
?>
|
||||
<?php echo IMPORT_WELCOME ?>.<br />
|
||||
<?php echo IMPORT_WHAT_CAN ?>. <br />
|
||||
<br />
|
||||
<?php echo IMPORT_SELECT ?>:<br />
|
||||
<br />
|
||||
<form action="" method="GET">
|
||||
<input type="hidden" name="serendipity[adminModule]" value="import">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<strong><?php echo IMPORT_WEBLOG_APP ?>: </strong>
|
||||
<select name="serendipity[importFrom]">
|
||||
<?php foreach ($list as $v=>$k) { ?>
|
||||
<option value="<?php echo $v ?>"><?php echo $k ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input type="submit" value="<?php echo GO ?>" class="serendipityPrettyButton">
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
296
include/admin/importers/b2evolution.inc.php
Normal file
296
include/admin/importers/b2evolution.inc.php
Normal file
@ -0,0 +1,296 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* b2evolution Importer, by Garvin Hicking *
|
||||
* ****************************************************************/
|
||||
|
||||
class Serendipity_Import_b2evolution extends Serendipity_Import {
|
||||
var $info = array('software' => 'b2Evolution 0.9.0.11 Paris');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
var $categories = array();
|
||||
|
||||
function getImportNotes() {
|
||||
return '';
|
||||
}
|
||||
|
||||
function Serendipity_Import_b2evolution($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'UTF-8',
|
||||
'default' => $this->getCharsets(true)),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$users = array();
|
||||
$entries = array();
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
return MYSQL_REQUIRED;
|
||||
}
|
||||
|
||||
$b2db = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if (!$b2db) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($this->data['name'])) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($b2db));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = @$this->nativeQuery("SELECT ID AS ID,
|
||||
user_login AS user_login,
|
||||
user_pass AS user_pass,
|
||||
user_email AS user_email,
|
||||
user_level AS user_level,
|
||||
user_url AS user_url
|
||||
FROM evo_users", $b2db);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($b2db));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res); $x < $max_x ; $x++ ) {
|
||||
$users[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => ($users[$x]['user_level'] >= 2) ? 1 : 0,
|
||||
'realname' => $users[$x]['user_login'],
|
||||
'username' => $users[$x]['user_login'],
|
||||
'email' => $users[$x]['user_email'],
|
||||
'password' => $users[$x]['user_pass']); // MD5 compatible
|
||||
|
||||
if ( $users[$x]['user_level'] <= 2 ) {
|
||||
$data['userlevel'] = USERLEVEL_EDITOR;
|
||||
} elseif ($users[$x]['user_level'] <= 9) {
|
||||
$data['userlevel'] = USERLEVEL_CHIEF;
|
||||
} else {
|
||||
$data['userlevel'] = USERLEVEL_ADMIN;
|
||||
}
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
if (!$this->importCategories(null, 0, $b2db)) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($b2db));
|
||||
}
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @$this->nativeQuery("SELECT * FROM evo_posts ORDER BY ID;", $b2db);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($b2db));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['post_title']),
|
||||
'isdraft' => ($entries[$x]['post_status'] == 'published') ? 'false' : 'true',
|
||||
'allow_comments' => ($entries[$x]['post_comments'] == 'open' ) ? 'true' : 'false',
|
||||
'timestamp' => strtotime((isset($entries[$x]['post_issue_date']) ? $entries[$x]['post_issue_date'] : $entries[$x]['post_date'])),
|
||||
'body' => $this->strtr($entries[$x]['post_content']));
|
||||
|
||||
$entry['authorid'] = '';
|
||||
$entry['author'] = '';
|
||||
foreach ($users as $user) {
|
||||
if ($user['ID'] == $entries[$x]['post_author']) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
$entry['author'] = $user['user_login'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
|
||||
/* Entry/category */
|
||||
foreach ($this->categories as $category) {
|
||||
if ($category['cat_ID'] == $entries[$x]['post_category'] ) {
|
||||
$data = array('entryid' => $entries[$x]['entryid'],
|
||||
'categoryid' => $category['categoryid']);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Even more category stuff */
|
||||
$res = @$this->nativeQuery("SELECT * FROM evo_postcats;", $b2db);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($b2db));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entrycat = mysql_fetch_assoc($res);
|
||||
|
||||
$entryid = 0;
|
||||
$categoryid = 0;
|
||||
foreach($entries AS $entry) {
|
||||
if ($entry['ID'] == $entrycat['postcat_post_ID']) {
|
||||
$entryid = $entry['entryid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->categories AS $category) {
|
||||
if ($category['cat_ID'] == $entrycat['postcat_cat_ID']) {
|
||||
$categoryid = $category['categoryid'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($entryid > 0 && $categoryid > 0) {
|
||||
$data = array('entryid' => $entryid,
|
||||
'categoryid' => $categoryid);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @$this->nativeQuery("SELECT * FROM evo_comments;", $b2db);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($b2db));
|
||||
}
|
||||
|
||||
while ($a = mysql_fetch_assoc($res)) {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['ID'] == $a['comment_post_ID'] ) {
|
||||
$author = '';
|
||||
$mail = '';
|
||||
$url = '';
|
||||
if (!empty($a['comment_author_ID'])) {
|
||||
foreach($users AS $user) {
|
||||
if ($user['ID'] == $a['comment_author_ID']) {
|
||||
$author = $user['user_login'];
|
||||
$mail = $user['user_email'];
|
||||
$url = $user['user_url'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($author) && empty($mail)) {
|
||||
$author = $a['comment_author'];
|
||||
$mail = $a['comment_author_email'];
|
||||
$url = $a['comment_author_url'];
|
||||
}
|
||||
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => strtotime($a['comment_date']),
|
||||
'author' => $author,
|
||||
'email' => $mail,
|
||||
'url' => $url,
|
||||
'ip' => $a['comment_author_IP'],
|
||||
'status' => ($a['comment_status'] == 'published' ? 'approved' : 'pending'),
|
||||
'body' => $a['comment_content'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
if ($a['comment_status'] == 'published') {
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
|
||||
function importCategories($parentid = 0, $new_parentid = 0, $b2db) {
|
||||
if (is_null($parentid)) {
|
||||
$where = 'WHERE ISNULL(cat_parent_ID)';
|
||||
} else {
|
||||
$where = "WHERE cat_parent_ID = '" . mysql_escape_string($parentid) . "'";
|
||||
}
|
||||
|
||||
$res = $this->nativeQuery("SELECT * FROM evo_categories
|
||||
" . $where, $b2db);
|
||||
if (!$res) {
|
||||
echo mysql_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$row = mysql_fetch_assoc($res);
|
||||
$cat = array('category_name' => $row['cat_name'],
|
||||
'category_description' => $row['cat_description'],
|
||||
'parentid' => (int)$new_parentid,
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$row['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
$this->categories[] = $row;
|
||||
$this->importCategories($row['cat_ID'], $row['categoryid'], $b2db);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_b2evolution';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
263
include/admin/importers/bblog.inc.php
Normal file
263
include/admin/importers/bblog.inc.php
Normal file
@ -0,0 +1,263 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* bblog Importer, by Garvin Hicking *
|
||||
* ****************************************************************/
|
||||
|
||||
class Serendipity_Import_bblog extends Serendipity_Import {
|
||||
var $info = array('software' => 'bBlog 0.7.4');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
var $categories = array();
|
||||
|
||||
function Serendipity_Import_bblog($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => INSTALL_DBPREFIX,
|
||||
'type' => 'input',
|
||||
'name' => 'prefix',
|
||||
'default' => 'bB_'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'native',
|
||||
'default' => $this->getCharsets()),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
|
||||
$users = array();
|
||||
$entries = array();
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
return MYSQL_REQUIRED;
|
||||
}
|
||||
|
||||
$bblogdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if (!$bblogdb) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($this->data['name'])) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($bblogdb));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = @$this->nativeQuery("SELECT id AS ID,
|
||||
password AS pw,
|
||||
nickname AS user_login,
|
||||
email AS user_email,
|
||||
url AS user_url
|
||||
FROM {$this->data['prefix']}authors", $bblogdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($bblogdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res); $x < $max_x ; $x++ ) {
|
||||
$users[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => 1,
|
||||
'username' => $users[$x]['user_login'],
|
||||
'email' => $users[$x]['user_email'],
|
||||
'userlevel' => USERLEVEL_ADMIN,
|
||||
'password' => md5($users[$x]['pw'])); // Wicked. This is the first blog I've seen storing cleartext passwords :-D
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
echo mysql_error();
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}sections", $bblogdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($bblogdb));
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$row = mysql_fetch_assoc($res);
|
||||
$cat = array('category_name' => $row['nicename'],
|
||||
'category_description' => $row['nicename'],
|
||||
'parentid' => 0,
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$row['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
$this->categories[] = $row;
|
||||
}
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}posts ORDER BY postid;", $bblogdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($bblogdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['title']),
|
||||
'isdraft' => ($entries[$x]['status'] == 'live') ? 'false' : 'true',
|
||||
'allow_comments' => ($entries[$x]['allowcomments'] == 'allow' ) ? 'true' : 'false',
|
||||
'timestamp' => $entries[$x]['posttime'],
|
||||
'body' => $this->strtr($entries[$x]['body']),
|
||||
'extended' => '',
|
||||
);
|
||||
|
||||
$entry['authorid'] = '';
|
||||
$entry['author'] = '';
|
||||
foreach ($users as $user) {
|
||||
if ($user['ID'] == $entries[$x]['author']) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
$entry['author'] = $user['user_login'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
|
||||
$sections = explode(':', $entries[$x]['sections']);
|
||||
foreach($sections AS $section) {
|
||||
if (empty($section)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($this->categories AS $category) {
|
||||
if ($category['sectionid'] == $section) {
|
||||
$categoryid = $category['categoryid'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($categoryid > 0) {
|
||||
$data = array('entryid' => $entries[$x]['entryid'],
|
||||
'categoryid' => $categoryid);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comments WHERE type = 'comment';", $bblogdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($bblogdb));
|
||||
}
|
||||
|
||||
while ($a = mysql_fetch_assoc($res)) {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['postid'] == $a['postid'] ) {
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => $a['posttime'],
|
||||
'author' => $a['postername'],
|
||||
'email' => $a['posteremail'],
|
||||
'url' => $a['posterwebsite'],
|
||||
'ip' => $a['ip'],
|
||||
'status' => 'approved',
|
||||
'body' => $a['commenttext'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Trackbacks */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comments WHERE type = 'trackback';", $bblogdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($bblogdb));
|
||||
}
|
||||
|
||||
while ($a = mysql_fetch_assoc($res)) {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['postid'] == $a['postid'] ) {
|
||||
$trackback = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => $a['posttime'],
|
||||
'title' => $a['title'],
|
||||
'author' => $a['postername'],
|
||||
'email' => $a['posteremail'],
|
||||
'url' => $a['posterwebsite'],
|
||||
'ip' => $a['ip'],
|
||||
'status' => 'approved',
|
||||
'body' => $a['commenttext'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'TRACKBACK');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($trackback));
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_bblog';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
257
include/admin/importers/blogger.inc.php
Normal file
257
include/admin/importers/blogger.inc.php
Normal file
@ -0,0 +1,257 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
class Serendipity_Import_Blogger extends Serendipity_Import {
|
||||
var $info = array('software' => 'Blogger.com');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
function Serendipity_Import_Blogger($data) {
|
||||
global $serendipity;
|
||||
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => 'Path to your Blogger export file',
|
||||
'type' => 'input',
|
||||
'name' => 'bloggerfile',
|
||||
'value' => $serendipity['serendipityPath']),
|
||||
|
||||
array('text' => 'New author default password (used for non-existing authors on the serendipity backend, as author passwords from Blogger are not migrated)',
|
||||
'type' => 'input',
|
||||
'name' => 'defaultpass',
|
||||
'value' => ''),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'UTF-8',
|
||||
'default' => $this->getCharsets()),
|
||||
|
||||
array('text' => RSS_IMPORT_BODYONLY,
|
||||
'type' => 'bool',
|
||||
'name' => 'bodyonly',
|
||||
'value' => 'false'));
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function getImportNotes() {
|
||||
$out = '
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.style1 {
|
||||
font-size: large;
|
||||
font-weight: bold;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
.style2 {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: x-small;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
|
||||
<p class="style1">BLOGGER.COM to SERENDIPITY IMPORT</p>
|
||||
<p class="style2">Version 0.1,( 29/10/2005 )</p>
|
||||
<p class="style2"> <br />
|
||||
1. First go to Blogger.com, login.</p>
|
||||
<p class="style2">2. Go to the templates section. Set the following as your template. You should backup the current template if you want to reset it back after this operation. Click "Save template changes" button to save this new template.</p>
|
||||
<p class="style2">
|
||||
<label>
|
||||
<textarea name="textarea" cols="60" rows="20"><Blogger>
|
||||
STARTPOST
|
||||
|
||||
TITLE: <PostSubject><$BlogItemSubject$></PostSubject>
|
||||
AUTHOR: <$BlogItemAuthor$>
|
||||
DATE: <$BlogItemDateTime$>
|
||||
-----
|
||||
BODY:
|
||||
<$BlogItemBody$>
|
||||
-----
|
||||
<BlogItemCommentsEnabled>
|
||||
<BlogItemComments>
|
||||
COMMENT:
|
||||
AUTHOR: <$BlogCommentAuthor$>
|
||||
DATE: <$BlogCommentDateTime$>
|
||||
BODY: <$BlogCommentBody$>
|
||||
-----
|
||||
</BlogItemComments>
|
||||
</BlogItemCommentsEnabled>
|
||||
ENDPOST
|
||||
</Blogger>
|
||||
</textarea>
|
||||
</label>
|
||||
</p>
|
||||
<p class="style2">3. Go to the "Settings" section of blogger. </p>
|
||||
<p class="style2">4. Click the "Formatting" link. From the formatting options, find the "Timestamp Format" option and set it to the top most option. i.e the one with the date and time showing. Find the "Show" option, and set it to 999. Save changes</p>
|
||||
<p class="style2">5. Now click the "Comments" link. Find the "Comments Timestamp Format" option and set it to the 2nd option from the list. i.e the one with the date and time showing. Save changes. </p>
|
||||
<p class="style2">6. On the server with your Serendipity installation, create a directory called "blogger". </p>
|
||||
<p class="style2">7. Next, back on Blogger.com, go to the "Publishing" section. Set it to publish to an FTP server. Enter the details of the server with your Serendipity installation. Set the FTP path as the path to the "blogger" directory you created in the previous step. </p>
|
||||
<p class="style2">8. Go back to Blogger.com and find "Publish Entire Blog" under "Posting" -> "Status". Click the Publish entire blog button to let blogger publish the blog to your ftp server.</p>
|
||||
<p class="style2">9. Now in the box below type in the path to the "index.html" file blogger created under your "blogger" directory. File path should then look something like "/httpdocs/blogger/index.html".</p>
|
||||
<p class="style2">10. This script will create the users as from the blogger blog being imported. However if a user already exists, then that user will be used instead of creating a new user with similar name. For the new users that this script will create, you need to provide a default password. Type it in the box below.</p>
|
||||
<p class="style2">11. Click "Submit". Your posts and comments should be imported to serendipity!</p>
|
||||
<p class="style2"> If you have questions or problems, feel free to drop me a mail at jaa at technova dot com dot mv.<br />
|
||||
<br />
|
||||
Jaa<br />
|
||||
http://jaa.technova.com.mv</p>';
|
||||
return $out;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
if (empty($this->data['bloggerfile']) || !file_exists($this->data['bloggerfile'])) {
|
||||
echo "Path to blogger file empty or path to file wrong! Go back and correct.";
|
||||
return false;
|
||||
}
|
||||
|
||||
# get default pass from request
|
||||
$defaultpass = $this->data['defaultpass'];
|
||||
|
||||
# get blogger uploaded file path from request and load file
|
||||
$html = file_get_contents($this->data['bloggerfile']);
|
||||
|
||||
# find posts using pattern matching
|
||||
preg_match_all("/STARTPOST(.*)ENDPOST/sU", $html, $posts);
|
||||
|
||||
# iterate through all posts
|
||||
foreach($posts[1] as $post) {
|
||||
|
||||
# locate the post title
|
||||
if (preg_match("/TITLE:(.*)/", $post, $title)) {
|
||||
$title = trim($title[1]);
|
||||
echo "<b>" . htmlspecialchars($title) . "</b><br />";
|
||||
} else {
|
||||
$title = "";
|
||||
echo "<b>Empty title</b><br />";
|
||||
}
|
||||
|
||||
# locate the post author
|
||||
if (preg_match("/AUTHOR:(.*)/", $post, $author)) {
|
||||
$author = trim($author[1]);
|
||||
echo "<em>" . htmlspecialchars($author[1]) . "</em><br />";
|
||||
} else {
|
||||
$author = "";
|
||||
echo "<em>Unknown author</em><br />";
|
||||
}
|
||||
|
||||
# locate the post date
|
||||
if (preg_match("/DATE:(.*)/", $post, $date)) {
|
||||
$date = strtotime(trim($date[1]));
|
||||
echo "Posted on " . htmlspecialchars($date[1]) . ".<br />";
|
||||
} else {
|
||||
$date = time();
|
||||
echo "Unknown posting time.<br />";
|
||||
}
|
||||
|
||||
# locate the post body
|
||||
if (preg_match("/BODY:(.*)-----/sU", $post, $body)) {
|
||||
$body = trim($body[1]);
|
||||
echo strlen($body) . " Bytes of text.<br />";
|
||||
} else {
|
||||
$body = "";
|
||||
echo "<strong>Empty Body!</strong><br />";
|
||||
}
|
||||
|
||||
# find all comments for the post using pattern matching
|
||||
if (preg_match_all( "/COMMENT:(.*)----/sU", $post, $commentlist)) {
|
||||
echo count($commentlist[1]) . " comments found.<br />";
|
||||
} else {
|
||||
$commentlist = array();
|
||||
echo "No comments found.<br />";
|
||||
}
|
||||
|
||||
$result = serendipity_db_query("SELECT authorid FROM ". $serendipity['dbPrefix'] ."authors WHERE username = '". serendipity_db_escape_string($author) ."' LIMIT 1", true, 'assoc');
|
||||
if (!is_array($result)) {
|
||||
$data = array('right_publish' => 1,
|
||||
'realname' => $author,
|
||||
'username' => $author,
|
||||
'userlevel' => 0,
|
||||
'password' => md5($defaultpass)); // MD5 compatible
|
||||
serendipity_db_insert('authors', $data);
|
||||
$authorid = serendipity_db_insert_id('authors', 'authorid');
|
||||
} else {
|
||||
$authorid = $result['authorid'];
|
||||
}
|
||||
|
||||
|
||||
$entry = array('title' => $title,
|
||||
'isdraft' => 'false',
|
||||
'allow_comments' => 'true',
|
||||
'timestamp' => $date,
|
||||
'body' => $body,
|
||||
'extended' => '',
|
||||
'author' => $author,
|
||||
'authorid' => $authorid
|
||||
);
|
||||
|
||||
echo "Entry insert...<br />";
|
||||
if (!is_int($id = serendipity_updertEntry($entry))) {
|
||||
echo "Inserting entry failed.<br />";
|
||||
return $id;
|
||||
} else {
|
||||
echo "Entry $id inserted.<br />";
|
||||
}
|
||||
|
||||
# iterate through all comments
|
||||
$c = 0;
|
||||
foreach($commentlist[1] as $comment) {
|
||||
$c++;
|
||||
|
||||
# locate the author and author url
|
||||
$curl = '';
|
||||
$cauthor = '';
|
||||
$cdate = time();
|
||||
$cbody = '';
|
||||
|
||||
if (preg_match("/AUTHOR:(.*)/", $comment, $cauthor) && preg_match("/href=\"(.*)\"/", $cauthor[1], $curl)) {
|
||||
$curl = (isset($curl[1]) ? trim($curl[1]) : '');
|
||||
$cauthor = trim(strip_tags($cauthor[1]));
|
||||
}
|
||||
|
||||
# locate the date
|
||||
if (preg_match("/DATE:(.*)/", $comment, $cdate)) {
|
||||
$cdate = strtotime($cdate[1]);
|
||||
}
|
||||
|
||||
# locate the comment body
|
||||
if (preg_match("/BODY:(.*)/s", $comment, $cbody)) {
|
||||
$cbody = trim($cbody[1]);
|
||||
}
|
||||
|
||||
$icomment = array('entry_id ' => $id,
|
||||
'parent_id' => 0,
|
||||
'timestamp' => $cdate,
|
||||
'author' => $cauthor,
|
||||
'email' => '',
|
||||
'url' => $curl,
|
||||
'ip' => '',
|
||||
'status' => 'approved',
|
||||
'body' => $cbody,
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $icomment);
|
||||
}
|
||||
|
||||
serendipity_db_query("UPDATE ". $serendipity['dbPrefix'] ."entries SET comments = ". $c ." WHERE id = ". $id);
|
||||
echo "Comment count set to: ". $c ."<br />";
|
||||
}
|
||||
|
||||
echo "Import finished.<br />";
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_Blogger';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
255
include/admin/importers/bmachine.inc.php
Normal file
255
include/admin/importers/bmachine.inc.php
Normal file
@ -0,0 +1,255 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* bmachine Importer, by Garvin Hicking *
|
||||
* ****************************************************************/
|
||||
|
||||
class Serendipity_Import_bmachine extends Serendipity_Import {
|
||||
var $info = array('software' => 'boastMachine 3.0');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
var $categories = array();
|
||||
|
||||
function getImportNotes() {
|
||||
return '';
|
||||
}
|
||||
|
||||
function Serendipity_Import_bmachine($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'native',
|
||||
'default' => $this->getCharsets()),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$users = array();
|
||||
$entries = array();
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
return MYSQL_REQUIRED;
|
||||
}
|
||||
|
||||
$txpdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if (!$txpdb) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($this->data['name'])) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($txpdb));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = @$this->nativeQuery("SELECT id AS ID,
|
||||
user_login AS user_login,
|
||||
user_pass AS user_pass,
|
||||
user_email AS user_email,
|
||||
level AS user_level,
|
||||
user_url AS user_url
|
||||
FROM bmc_users", $txpdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($txpdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res); $x < $max_x ; $x++ ) {
|
||||
$users[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => ($users[$x]['user_level'] >= 2) ? 1 : 0,
|
||||
'realname' => $users[$x]['user_login'],
|
||||
'username' => $users[$x]['user_login'],
|
||||
'email' => $users[$x]['user_email'],
|
||||
'password' => $users[$x]['user_pass']); // MD5 compatible
|
||||
|
||||
if ( $users[$x]['user_level'] <= 2 ) {
|
||||
$data['userlevel'] = USERLEVEL_EDITOR;
|
||||
} elseif ($users[$x]['user_level'] == 3) {
|
||||
$data['userlevel'] = USERLEVEL_CHIEF;
|
||||
} else {
|
||||
$data['userlevel'] = USERLEVEL_ADMIN;
|
||||
}
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
$res = @$this->nativeQuery("SELECT id AS cat_ID,
|
||||
cat_name AS cat_name,
|
||||
cat_info AS category_description
|
||||
FROM bmc_cats ORDER BY id;", $txpdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($txpdb));
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$categories[] = mysql_fetch_assoc($res);
|
||||
}
|
||||
|
||||
// Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
|
||||
for ($x=0, $max_x = sizeof($categories) ; $x < $max_x ; $x++ ) {
|
||||
$cat = array('category_name' => $categories[$x]['cat_name'],
|
||||
'category_description' => $categories[$x]['category_description'],
|
||||
'parentid' => 0, // <---
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
}
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @$this->nativeQuery("SELECT * FROM bmc_posts ORDER BY id;", $txpdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($txpdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['title']),
|
||||
'isdraft' => ($entries[$x]['status'] == '1') ? 'false' : 'true',
|
||||
'allow_comments' => ($entries[$x]['m_cmt'] == '1' ) ? 'true' : 'false',
|
||||
'timestamp' => $entries[$x]['date'],
|
||||
'extended' => $this->strtr($entries[$x]['data']),
|
||||
'body' => $this->strtr($entries[$x]['summary']));
|
||||
|
||||
$entry['authorid'] = '';
|
||||
$entry['author'] = '';
|
||||
foreach ($users as $user) {
|
||||
if ($user['ID'] == $entries[$x]['author']) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
$entry['author'] = $user['user_login'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
|
||||
/* Entry/category */
|
||||
foreach ($this->categories as $category) {
|
||||
if ($category['cat_ID'] == $entries[$x]['cat'] ) {
|
||||
$data = array('entryid' => $entries[$x]['entryid'],
|
||||
'categoryid' => $category['categoryid']);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @$this->nativeQuery("SELECT * FROM bmc_comments;", $txpdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($txpdb));
|
||||
}
|
||||
|
||||
while ($a = mysql_fetch_assoc($res)) {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['id'] == $a['post'] ) {
|
||||
$author = '';
|
||||
$mail = '';
|
||||
$url = '';
|
||||
if (!empty($a['author'])) {
|
||||
foreach($users AS $user) {
|
||||
if ($user['ID'] == $a['author']) {
|
||||
$author = $user['user_login'];
|
||||
$mail = $user['user_email'];
|
||||
$url = $user['user_url'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($author) && empty($mail)) {
|
||||
$author = $a['auth_name'];
|
||||
$mail = $a['auth_email'];
|
||||
$url = $a['auth_url'];
|
||||
}
|
||||
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => $a['date'],
|
||||
'author' => $author,
|
||||
'email' => $mail,
|
||||
'url' => $url,
|
||||
'ip' => $a['auth_ip'],
|
||||
'status' => 'approved',
|
||||
'body' => $a['data'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_bmachine';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
245
include/admin/importers/geeklog.inc.php
Normal file
245
include/admin/importers/geeklog.inc.php
Normal file
@ -0,0 +1,245 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* geeklog Importer, by Garvin Hicking *
|
||||
* ****************************************************************/
|
||||
|
||||
class Serendipity_Import_geeklog extends Serendipity_Import {
|
||||
var $info = array('software' => 'Geeklog 1.3.11');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
var $categories = array();
|
||||
|
||||
function getImportNotes() {
|
||||
return 'GeekLog has a granular control over access privileges which cannot be migrated to Serendipity. All Users will be migrated as Superusers, you may need to set them to editor or chief users manually after import.';
|
||||
}
|
||||
|
||||
function Serendipity_Import_geeklog($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => INSTALL_DBPREFIX,
|
||||
'type' => 'input',
|
||||
'name' => 'prefix',
|
||||
'default' => 'gl_'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'native',
|
||||
'default' => $this->getCharsets()),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
|
||||
$users = array();
|
||||
$entries = array();
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
return MYSQL_REQUIRED;
|
||||
}
|
||||
|
||||
$gdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if (!$gdb) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($this->data['name'])) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($gdb));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = @$this->nativeQuery("SELECT uid AS ID,
|
||||
username AS user_login,
|
||||
passwd AS user_pass,
|
||||
email AS user_email,
|
||||
homepage AS user_url
|
||||
FROM {$this->data['prefix']}users", $gdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($gdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res); $x < $max_x ; $x++ ) {
|
||||
$users[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => 1,
|
||||
'realname' => $users[$x]['user_login'],
|
||||
'username' => $users[$x]['user_login'],
|
||||
'email' => $users[$x]['user_email'],
|
||||
'userlevel' => USERLEVEL_ADMIN,
|
||||
'password' => $users[$x]['user_pass']); // MD5 compatible
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
echo mysql_error();
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
$res = @$this->nativeQuery("SELECT tid AS cat_ID, topic AS cat_name, topic AS category_description FROM {$this->data['prefix']}topics ORDER BY tid;", $gdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($gdb));
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$categories[] = mysql_fetch_assoc($res);
|
||||
}
|
||||
|
||||
// Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
|
||||
for ($x=0, $max_x = sizeof($categories) ; $x < $max_x ; $x++ ) {
|
||||
$cat = array('category_name' => $categories[$x]['cat_name'],
|
||||
'category_description' => $categories[$x]['category_description'],
|
||||
'parentid' => 0, // <---
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
}
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}stories ORDER BY sid;", $gdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($gdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['title']),
|
||||
'isdraft' => ($entries[$x]['draft_flag'] == '0') ? 'false' : 'true',
|
||||
'allow_comments' => ($entries[$x]['comments'] == '1' ) ? 'true' : 'false',
|
||||
'timestamp' => strtotime($entries[$x]['date']),
|
||||
'body' => $this->strtr($entries[$x]['introtext']),
|
||||
'extended' => $this->strtr($entries[$x]['bodytext']),
|
||||
);
|
||||
|
||||
$entry['authorid'] = '';
|
||||
$entry['author'] = '';
|
||||
foreach ($users as $user) {
|
||||
if ($user['ID'] == $entries[$x]['uid']) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
$entry['author'] = $user['user_login'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
|
||||
/* Entry/category */
|
||||
foreach ($categories as $category) {
|
||||
if ($category['cat_ID'] == $entries[$x]['tid'] ) {
|
||||
$data = array('entryid' => $entries[$x]['entryid'],
|
||||
'categoryid' => $category['categoryid']);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comments;", $gdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($gdb));
|
||||
}
|
||||
|
||||
while ($a = mysql_fetch_assoc($res)) {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['sid'] == $a['sid'] ) {
|
||||
$author = '';
|
||||
$mail = '';
|
||||
$url = '';
|
||||
|
||||
foreach($users AS $user) {
|
||||
if ($user['ID'] == $a['uid']) {
|
||||
$author = $user['user_login'];
|
||||
$mail = $user['user_email'];
|
||||
$url = $user['user_url'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => strtotime($a['date']),
|
||||
'author' => $author,
|
||||
'email' => $mail,
|
||||
'url' => $url,
|
||||
'ip' => $a['ip'],
|
||||
'status' => 'approved',
|
||||
'body' => $a['comment'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_geeklog';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
148
include/admin/importers/generic.inc.php
Normal file
148
include/admin/importers/generic.inc.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
require_once S9Y_PEAR_PATH . 'Onyx/RSS.php';
|
||||
|
||||
class Serendipity_Import_Generic extends Serendipity_Import {
|
||||
var $info = array('software' => IMPORT_GENERIC_RSS);
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
function Serendipity_Import_Generic($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => RSS . ' ' . URL,
|
||||
'type' => 'input',
|
||||
'name' => 'url'),
|
||||
|
||||
array('text' => STATUS,
|
||||
'type' => 'list',
|
||||
'name' => 'type',
|
||||
'value' => 'publish',
|
||||
'default' => array('draft' => DRAFT, 'publish' => PUBLISH)),
|
||||
|
||||
array('text' => RSS_IMPORT_CATEGORY,
|
||||
'type' => 'list',
|
||||
'name' => 'category',
|
||||
'value' => 0,
|
||||
'default' => $this->_getCategoryList()),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'UTF-8',
|
||||
'default' => $this->getCharsets()),
|
||||
|
||||
array('text' => RSS_IMPORT_BODYONLY,
|
||||
'type' => 'bool',
|
||||
'name' => 'bodyonly',
|
||||
'value' => 'false'));
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
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 buildEntry($item, &$entry) {
|
||||
global $serendipity;
|
||||
|
||||
$bodyonly = serendipity_get_bool($this->data['bodyonly']);
|
||||
|
||||
if ($item['description']) {
|
||||
$entry['body'] = $this->decode($item['description']);
|
||||
}
|
||||
|
||||
if ($item['content:encoded']) {
|
||||
if (!isset($entry['body']) || $bodyonly) {
|
||||
$data = &$entry['body'];
|
||||
} else {
|
||||
$data = &$entry['extended'];
|
||||
}
|
||||
|
||||
// See if the 'description' element is a substring of the 'content:encoded' part. If it is,
|
||||
// we will only fetch the full 'content:encoded' part. If it's not a substring, we append
|
||||
// the 'content:encoded' part to either body or extended entry (respecting the 'bodyonly'
|
||||
// switch). We substract 4 letters because of possible '...' additions to an entry.
|
||||
$testbody = substr(trim(strip_tags($entry['body'])), 0, -4);
|
||||
if ($testbody != substr(trim(strip_tags($item['content:encoded'])), 0, strlen($testbody))) {
|
||||
$data .= $this->decode($item['content:encoded']);
|
||||
} else {
|
||||
$data = $this->decode($item['content:encoded']);
|
||||
}
|
||||
}
|
||||
|
||||
$entry['title'] = $this->decode($item['title']);
|
||||
$entry['timestamp'] = $this->decode(strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date']));
|
||||
if ($entry['timestamp'] == -1) {
|
||||
// strtotime does not seem to parse ISO 8601 dates
|
||||
if (preg_match('@^([0-9]{4})\-([0-9]{2})\-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})[\-\+]([0-9]{2}):([0-9]{2})$@', isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date'], $timematch)) {
|
||||
$entry['timestamp'] = mktime($timematch[4] - $timematch[7], $timematch[5] - $timematch[8], $timematch[6], $timematch[2], $timematch[3], $timematch[1]);
|
||||
} else {
|
||||
$entry['timestamp'] = time();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->data['type'] == 'draft') {
|
||||
$entry['isdraft'] = 'true';
|
||||
} else {
|
||||
$entry['isdraft'] = 'false';
|
||||
}
|
||||
|
||||
if (!empty($item['category'])) {
|
||||
$cat = serendipity_fetchCategoryInfo(0, trim($this->decode($item['category'])));
|
||||
if (is_array($cat) && isset($cat['categoryid'])) {
|
||||
$entry['categories'][] = $cat['categoryid'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($entry['categories'])) {
|
||||
$entry['categories'][] = $this->data['category'];
|
||||
}
|
||||
|
||||
if (!isset($entry['extended'])) {
|
||||
$entry['extended'] = '';
|
||||
}
|
||||
|
||||
$entry['allow_comments'] = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
$c = &new Onyx_RSS($this->data['charset']);
|
||||
$c->parse($this->data['url']);
|
||||
$this->data['encoding'] = $c->rss['encoding'];
|
||||
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
while ($item = $c->getNextItem()) {
|
||||
$entry = array();
|
||||
if ($this->buildEntry($item, $entry)) {
|
||||
serendipity_updertEntry($entry);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_Generic';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
215
include/admin/importers/livejournal.inc.php
Normal file
215
include/admin/importers/livejournal.inc.php
Normal file
@ -0,0 +1,215 @@
|
||||
<?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)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
require_once S9Y_PEAR_PATH . 'Onyx/RSS.php';
|
||||
|
||||
class Serendipity_Import_LiveJournalXML extends Serendipity_Import {
|
||||
var $info = array('software' => 'LiveJournal XML');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
function Serendipity_Import_LiveJournalXML($data) {
|
||||
global $serendipity;
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => 'LiveJournal XML',
|
||||
'type' => 'input',
|
||||
'name' => 'url',
|
||||
'default' => $serendipity['serendipityPath'] . $serendipity['uploadPath'] . 'EVbackup.xml'),
|
||||
|
||||
array('text' => RSS_IMPORT_CATEGORY,
|
||||
'type' => 'list',
|
||||
'name' => 'category',
|
||||
'value' => 0,
|
||||
'default' => $this->_getCategoryList()),
|
||||
|
||||
array('text' => STATUS,
|
||||
'type' => 'list',
|
||||
'name' => 'type',
|
||||
'value' => 'publish',
|
||||
'default' => array('publish' => PUBLISH, 'draft' => DRAFT)),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
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 GetChildren(&$vals, &$i) {
|
||||
$children = array();
|
||||
$cnt = sizeof($vals);
|
||||
while (++$i < $cnt) {
|
||||
// compare type
|
||||
switch ($vals[$i]['type']) {
|
||||
case 'cdata':
|
||||
$children[] = $vals[$i]['value'];
|
||||
break;
|
||||
|
||||
case 'complete':
|
||||
$children[] = array(
|
||||
'tag' => $vals[$i]['tag'],
|
||||
'attributes' => $vals[$i]['attributes'],
|
||||
'value' => $vals[$i]['value']
|
||||
);
|
||||
break;
|
||||
|
||||
case 'open':
|
||||
$children[] = array(
|
||||
'tag' => $vals[$i]['tag'],
|
||||
'attributes' => $vals[$i]['attributes'],
|
||||
'value' => $vals[$i]['value'],
|
||||
'children' => $this->GetChildren($vals, $i)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'close':
|
||||
return $children;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function &parseXML(&$xml) {
|
||||
// XML functions
|
||||
$xml_string = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||
if (preg_match('@(<\?xml.+\?>)@imsU', $xml, $xml_head)) {
|
||||
$xml_string = $xml_head[1];
|
||||
}
|
||||
|
||||
$encoding = 'UTF-8';
|
||||
if (preg_match('@encoding="([^"]+)"@', $xml_string, $xml_encoding)) {
|
||||
$encoding = $xml_encoding[1];
|
||||
}
|
||||
|
||||
preg_match_all('@(<entry>.*</entry>)@imsU', $xml, $xml_matches);
|
||||
if (!is_array($xml_matches)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$tree = array();
|
||||
$tree[$i] = array(
|
||||
'tag' => 'entries',
|
||||
'attributes' => '',
|
||||
'value' => '',
|
||||
'children' => array()
|
||||
);
|
||||
|
||||
foreach($xml_matches[0] as $xml_index => $xml_package) {
|
||||
$i = 0;
|
||||
|
||||
switch(strtolower($encoding)) {
|
||||
case 'iso-8859-1':
|
||||
case 'utf-8':
|
||||
$p = xml_parser_create($encoding);
|
||||
break;
|
||||
|
||||
default:
|
||||
$p = xml_parser_create('');
|
||||
}
|
||||
|
||||
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
|
||||
@xml_parser_set_option($p, XML_OPTION_TARGET_ENCODING, LANG_CHARSET);
|
||||
$xml_package = $xml_string . "\n" . $xml_package;
|
||||
xml_parse_into_struct($p, $xml_package, $vals);
|
||||
xml_parser_free($p);
|
||||
$tree[0]['children'][] = array(
|
||||
'tag' => $vals[$i]['tag'],
|
||||
'attributes' => $vals[$i]['attributes'],
|
||||
'value' => $vals[$i]['value'],
|
||||
'children' => $this->GetChildren($vals, $i)
|
||||
);
|
||||
unset($vals);
|
||||
}
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function getTimestamp($string) {
|
||||
if (preg_match('@(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})@', $string, $match)) {
|
||||
return mktime($match[4], $match[5], $match[6], $match[2], $match[3], $match[1]);
|
||||
} else {
|
||||
return time();
|
||||
}
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
if (!file_exists($this->data['url'])) {
|
||||
printf(FILE_NOT_FOUND, htmlspecialchars($this->data['url']));
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = file_get_contents($this->data['url']);
|
||||
$tree =& $this->parseXML($file);
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
|
||||
foreach($tree[0]['children'] AS $idx => $entry) {
|
||||
if (!is_array($entry)) continue;
|
||||
if ($entry['tag'] != 'entry') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$new_entry = array(
|
||||
'allow_comments' => true,
|
||||
'extended' => '',
|
||||
'categories' => array(),
|
||||
'isdraft' => ($this->data['type'] == 'draft' ? 'true' : 'false'),
|
||||
'categories' => array($this->data['category'] => $this->data['category'])
|
||||
);
|
||||
|
||||
if (!is_array($entry['children'])) continue;
|
||||
|
||||
foreach($entry['children'] AS $idx2 => $entrydata) {
|
||||
if (!is_array($entrydata)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch($entrydata['tag']) {
|
||||
case 'eventtime':
|
||||
$new_entry['timestamp'] = $this->getTimestamp($entrydata['value']);
|
||||
break;
|
||||
|
||||
case 'subject':
|
||||
$new_entry['title'] = $entrydata['value'];
|
||||
break;
|
||||
|
||||
case 'event':
|
||||
$new_entry['body'] = $entrydata['value'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$id = serendipity_updertEntry($new_entry);
|
||||
echo 'Inserted entry #' . $id . ', "' . htmlspecialchars($new_entry['title']) . '"<br />' . "\n";
|
||||
|
||||
if (function_exists('ob_flush')) {
|
||||
@ob_flush();
|
||||
}
|
||||
if (function_exists('flush')) {
|
||||
@flush();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_LiveJournalXML';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
475
include/admin/importers/movabletype.inc.php
Normal file
475
include/admin/importers/movabletype.inc.php
Normal file
@ -0,0 +1,475 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* MovableType Importer, by Evan Nemerson *
|
||||
*****************************************************************/
|
||||
|
||||
switch ($serendipity['lang']) {
|
||||
case 'de':
|
||||
@define('IMPORTER_MT_WARN_PLUGIN', 'Bitte installieren Sie das Plugin "%s"');
|
||||
@define('IMPORTER_MT_NOTE', 'Falls Sie weiter machen, ohne die Plugins zu installieren, werden m<>glicherweise Zeilenumbr<62>che falsch importiert (verdoppelt oder entfernt)');
|
||||
break;
|
||||
|
||||
case 'en':
|
||||
default:
|
||||
@define('IMPORTER_MT_WARN_PLUGIN', 'Please install the plugin "%s"');
|
||||
@define('IMPORTER_MT_NOTE', 'If you continue without installing those plugins, line breaks may be incorrectly imported (doubled or removed)');
|
||||
break;
|
||||
}
|
||||
|
||||
class Serendipity_Import_MovableType extends Serendipity_Import {
|
||||
var $info = array('software' => 'MovableType');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
function Serendipity_Import_MovableType($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => MT_DATA_FILE,
|
||||
'type' => 'file',
|
||||
'name' => 'mt_dat'),
|
||||
|
||||
array('text' => FORCE,
|
||||
'type' => 'bool',
|
||||
'name' => 'mt_force',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'UTF-8',
|
||||
'default' => $this->getCharsets(true)),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false'),
|
||||
|
||||
array('text' => 'Debugging',
|
||||
'type' => 'bool',
|
||||
'name' => 'debug',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function debug($string) {
|
||||
static $debug = null;
|
||||
static $c = 0;
|
||||
|
||||
if ($debug === null) {
|
||||
if ($this->data['debug'] == 'true') {
|
||||
$debug = true;
|
||||
} else {
|
||||
$debug = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
$c++;
|
||||
echo '#' . $c . ' [' . date('d.m.Y H:i.s') . '] ' . $string . "<br />\n";
|
||||
}
|
||||
}
|
||||
|
||||
function getImportNotes(){
|
||||
$notes = array();
|
||||
if (!class_exists('serendipity_event_nl2br')){
|
||||
$notes[] = sprintf(IMPORTER_MT_WARN_PLUGIN, 'serendipity_event_nl2br');
|
||||
}
|
||||
if (!class_exists('serendipity_event_entryproperties')){
|
||||
$notes[] = sprintf(IMPORTER_MT_WARN_PLUGIN, 'serendipity_event_entryproperties');
|
||||
}
|
||||
if (count($notes) > 0){
|
||||
return '<ul><li>'.implode('</li><li>', $notes).'</li></ul>'.IMPORTER_MT_NOTE;
|
||||
}
|
||||
}
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function toTime($string) {
|
||||
$ts = strtotime($string);
|
||||
$this->debug('Calling strtotime(' . $string . ') = ' . $ts);
|
||||
if ($ts <= 1) {
|
||||
// Match strings like: "11/16/2005 00:14:53 PM"
|
||||
if (preg_match('@([01][0-9])/([0-3][0-9])/([0-9]{4}) ([0-2][0-9]):([0-5][0-9]):([0-5][0-9]) (P|A|F|E)M@i', $string, $match)) {
|
||||
if ($match[7] == 'P' || $match[7] == 'E') {
|
||||
// Post mediam, add 12 hours.
|
||||
$match[4] = $match[4] + 12;
|
||||
}
|
||||
|
||||
$ts = mktime($match[4], $match[5], $match[6], $match[1], $match[2], $match[3]);
|
||||
$this->debug('Matched string date format: ' . $ts);
|
||||
}
|
||||
}
|
||||
|
||||
if ($ts <= 1) {
|
||||
$ts = time();
|
||||
}
|
||||
|
||||
return $ts;
|
||||
}
|
||||
|
||||
function doEntryWork(&$mt_entry, &$tasks){
|
||||
global $serendipity;
|
||||
|
||||
$authors = array();
|
||||
$entry = array();
|
||||
$entry['categories'] = array();
|
||||
$entryprops = array();
|
||||
|
||||
$this->debug("doEntryWork: " . print_r($mt_entry, true));
|
||||
|
||||
foreach($mt_entry as $name => $data) {
|
||||
$name = trim($name);
|
||||
if (is_string($data)) {
|
||||
$data = trim($data);
|
||||
}
|
||||
$this->debug($name . ': "' . print_r($data, true) . '"');
|
||||
switch($name) {
|
||||
case 's9y_comments':
|
||||
$entry['s9y_comments'] = $data;
|
||||
break;
|
||||
case 'AUTHOR':
|
||||
if ( !isset($authors[$data]) ) {
|
||||
$au_inf = serendipity_fetchAuthor($data);
|
||||
if ( !is_array($au_inf) ) {
|
||||
$tasks[] = sprintf(CREATE_AUTHOR, htmlspecialchars($data));
|
||||
$tasks[] = 'Input array is: ' . print_r($data, true) . '<br />Return is: ' . print_r($au_inf, true) . '<br />';
|
||||
$au_inf = serendipity_fetchAuthor($serendipity['authorid']);
|
||||
}
|
||||
$authors[$data] = $au_inf[0];
|
||||
}
|
||||
$entry['authorid'] = $authors[$data]['authorid'];
|
||||
$entry['author'] = $authors[$data]['username'];
|
||||
break;
|
||||
case 'TITLE':
|
||||
$entry['title'] = $data;
|
||||
break;
|
||||
case 'STATUS':
|
||||
$entry['isdraft'] = ($data == 'Publish') ? 'false' : 'true';
|
||||
break;
|
||||
case 'ALLOW COMMENTS':
|
||||
$entry['allow_comments'] = ($data == '1') ? 'true' : 'false';
|
||||
break;
|
||||
case 'DATE':
|
||||
$entry['timestamp'] = $this->totime($data);
|
||||
break;
|
||||
|
||||
case 's9y_body':
|
||||
case 'BODY':
|
||||
$entry['body'] = $data;
|
||||
break;
|
||||
|
||||
case 's9y_extended':
|
||||
case 'EXTENDED BODY':
|
||||
$entry['extended'] = $data;
|
||||
break;
|
||||
|
||||
case 'CONVERT BREAKS':
|
||||
$entryprops['nl2br'] = ($data == '1') ? true : false;
|
||||
break;
|
||||
|
||||
case 'PRIMARY CATEGORY':
|
||||
case 'CATEGORY':
|
||||
$categories = explode("\0", $data);
|
||||
#echo '<pre>' . print_r($this->categories, true) . '</pre>';
|
||||
foreach($categories AS $data) {
|
||||
$data = trim($data);
|
||||
$cat_found = false;
|
||||
if (is_array($this->categories)) {
|
||||
for ( $y=0 ; $y<sizeof($this->categories) ; $y++ ) {
|
||||
echo '"' . $this->categories[$y]['category_name'] . '" == "' . $data . '"<br />';
|
||||
if ( $this->categories[$y]['category_name'] == $data ) {
|
||||
$cat_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($cat_found) {
|
||||
if (!in_array($this->categories[$y]['categoryid'], $entry['categories']) ) {
|
||||
//$entries[$n]['categories'][] = $categories[$y]['categoryid'];
|
||||
$entry['categories'][] = $this->categories[$y]['categoryid'];
|
||||
}
|
||||
} else {
|
||||
$tasks[] = sprintf(CREATE_CATEGORY, htmlspecialchars($data));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$entry['props'] = $entryprops;
|
||||
return $entry;
|
||||
}
|
||||
|
||||
function doCommentWork(&$mt_entry, &$tasks, $type = 'NORMAL'){
|
||||
$comment = array(
|
||||
'parent_id' => 0,
|
||||
'status' => 'approved',
|
||||
'subscribed' => 'false',
|
||||
'type' => $type,
|
||||
'body' => ''
|
||||
);
|
||||
|
||||
$this->debug("MT_ENTRY: " . print_r($mt_entry, true));
|
||||
$parsed_entry = array();
|
||||
$unparsed_entry = explode("\n", $mt_entry[$type == 'NORMAL' ? 'COMMENT' : 'PING']);
|
||||
foreach($unparsed_entry AS $line) {
|
||||
if (preg_match('/^([A-Z\s]+):\s+(.*)$/', $line, $match)) {
|
||||
$parsed_entry[$match[1]] = $match[2];
|
||||
} else {
|
||||
$parsed_entry['s9y_body'] .= $line . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach($parsed_entry as $name => $data){
|
||||
$data = trim($data);
|
||||
$name = trim($name);
|
||||
|
||||
switch($name) {
|
||||
case 'EMAIL':
|
||||
$comment['email'] = $data;
|
||||
break;
|
||||
|
||||
case 'URL':
|
||||
$comment['url'] = $data;
|
||||
break;
|
||||
|
||||
case 'IP':
|
||||
$comment['ip'] = $data;
|
||||
break;
|
||||
|
||||
case 'AUTHOR':
|
||||
case 'BLOG NAME':
|
||||
$comment['author'] = $data;
|
||||
break;
|
||||
|
||||
case 'DATE':
|
||||
$comment['timestamp'] = $this->toTime($data);
|
||||
break;
|
||||
|
||||
case 'REPLY':
|
||||
case 'TITLE':
|
||||
break;
|
||||
|
||||
default:
|
||||
$comment['body'] .= $data;
|
||||
}
|
||||
}
|
||||
|
||||
$this->debug("S9Y_ENTRY: " . print_r($comment, true));
|
||||
return $comment;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
$force = ($this->data['mt_force'] == 'true');
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
// Rewritten to parse the file line by line. Can save quite some
|
||||
// memory on large blogs
|
||||
//$contents = file_get_contents($_FILES['serendipity']['tmp_name']['import']['mt_dat']);
|
||||
|
||||
$this->categories = serendipity_fetchCategories();
|
||||
$tasks = array();
|
||||
|
||||
$entries = array();
|
||||
|
||||
if (empty($_FILES['serendipity']['tmp_name']['import']['mt_dat'])) {
|
||||
$fh = fopen('/tmp/mt.dat', 'r');
|
||||
} else {
|
||||
$fh = fopen($_FILES['serendipity']['tmp_name']['import']['mt_dat'], 'r');
|
||||
}
|
||||
|
||||
$entry = array();
|
||||
$el = "";
|
||||
$c_el = "";
|
||||
$skip = false;
|
||||
$is_comment = false;
|
||||
$is_trackback = false;
|
||||
$nofetch = false;
|
||||
while (!feof($fh)) {
|
||||
if ($nofetch === false) {
|
||||
$this->debug('Next line');
|
||||
$line = $this->decode(fgets($fh, 8192));
|
||||
} else {
|
||||
$this->debug('NO Next line');
|
||||
// Keep line from previous run.
|
||||
$nofetch = false;
|
||||
}
|
||||
|
||||
if ($is_comment || $is_trackback) {
|
||||
$this->debug("COMMENT/TRACKBACK mode is active.");
|
||||
if (preg_match('/^--------/', $line)) {
|
||||
$this->debug("Next full section requested.");
|
||||
$is_comment = $is_trackback = false;
|
||||
} elseif (preg_match('/^-----/', $line)) {
|
||||
$this->debug("Next partial section requested.");
|
||||
if ($is_trackback) {
|
||||
$this->debug("Parsing trackback.");
|
||||
$entry['s9y_comments'][] = $this->doCommentWork($comment, $tasks, 'TRACKBACK');
|
||||
} elseif ($is_comment) {
|
||||
$this->debug("Parsing comment.");
|
||||
$entry['s9y_comments'][] = $this->doCommentWork($comment, $tasks, 'NORMAL');
|
||||
}
|
||||
$el = $c_el = "";
|
||||
}
|
||||
}
|
||||
|
||||
if ($skip && (!preg_match('/^--------/', $line))) {
|
||||
$this->debug("No next section match, and skip is activated. Skipping '$line'");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('/^--------/', $line)) {
|
||||
// We found the end marker of the current entry. Add to entries-Array
|
||||
$this->debug("End marker found. Parsing full entry.");
|
||||
$entries[] = $this->doEntryWork($entry, $tasks);
|
||||
$entry = array();
|
||||
$el = "";
|
||||
$c_el = "";
|
||||
$skip = false;
|
||||
$is_comment = false;
|
||||
$is_trackback = false;
|
||||
} elseif (preg_match('/^-----/', $line)) {
|
||||
$this->debug("New section match. Current EL: $el");
|
||||
unset($el); # DEBUG!
|
||||
if (empty($el)) {
|
||||
$line = $this->decode(fgets($fh, 8192));
|
||||
$this->debug("Inspecting next line: $line");
|
||||
$tline = trim($line);
|
||||
while (($is_comment || $is_trackback) && empty($tline)) {
|
||||
$line = $this->decode(fgets($fh, 8192));
|
||||
$tline = trim($line);
|
||||
$this->debug("Continuing inspecting next line: $line");
|
||||
}
|
||||
if (preg_match('/^--------/', $line)) {
|
||||
$this->debug('Next line is new element. End marker found. Parsing full entry.');
|
||||
$entries[] = $this->doEntryWork($entry, $tasks);
|
||||
$entry = array();
|
||||
$el = "";
|
||||
$c_el = "";
|
||||
$skip = false;
|
||||
$is_comment = false;
|
||||
$is_trackback = false;
|
||||
} elseif (preg_match('/^([A-Z\s]+):/', $line, $matches)) {
|
||||
$this->debug("Match result: $matches[1]");
|
||||
if ($matches[1] == 'COMMENT') {
|
||||
$this->debug("Marking COMMENT.");
|
||||
$is_comment = true;
|
||||
$is_trackback = false;
|
||||
$comment = array();
|
||||
$skip = false;
|
||||
} elseif ($matches[1] == 'PING') {
|
||||
$this->debug("Marking TRACKBACK");
|
||||
$is_comment = false;
|
||||
$is_trackback = true;
|
||||
$comment = array();
|
||||
$skip = false;
|
||||
}
|
||||
|
||||
$this->debug("Setting EL to {$matches[1]}");
|
||||
$el = $matches[1];
|
||||
$c_el = "";
|
||||
} else {
|
||||
$this->debug("Could not parse next line. Keeping it for next cycle.");
|
||||
$nofetch = true;
|
||||
}
|
||||
} else {
|
||||
$this->debug("Resetting EL to an empty string");
|
||||
$el = $c_el = "";
|
||||
}
|
||||
} elseif (empty($el)) {
|
||||
$this->debug("EL is empty. Line is '$line'");
|
||||
$content = "";
|
||||
if (preg_match('/^([A-Z\s]+):\s+(.*)$/s', $line, $matches)) {
|
||||
$this->debug("Section match {$matches[1]} found, input: {$matches[2]}");
|
||||
$c_el = $matches[1];
|
||||
$content = $matches[2];
|
||||
} elseif (!empty($c_el)) {
|
||||
$this->debug("Still in subsection of previous run: $c_el.");
|
||||
$content = trim($line);
|
||||
}
|
||||
|
||||
if (!empty($content)) {
|
||||
if ($is_comment || $is_trackback) {
|
||||
$this->debug("Appending to comments: $line");
|
||||
$comment[$c_el] = $content;
|
||||
} else {
|
||||
$this->debug("Appending to entry: $line");
|
||||
if (isset($entry[$c_el])) {
|
||||
$entry[$c_el] .= "\0" . $content;
|
||||
} else {
|
||||
$entry[$c_el] = $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($is_comment || $is_trackback) {
|
||||
$this->debug("Appending Line in current Element $el to comments: $line");
|
||||
$comment[$el] .= $line;
|
||||
} else {
|
||||
$this->debug("Appending Line in current Element $el to entries: $line");
|
||||
$entry[$el] .= $line;
|
||||
}
|
||||
}
|
||||
fclose($fh);
|
||||
|
||||
if ( !sizeof($tasks) || $force == true ) {
|
||||
serendipity_db_begin_transaction();
|
||||
foreach ($entries as $entry) {
|
||||
#echo '<pre>' . printR_($entry, true) . '</pre><br />';
|
||||
#continue;
|
||||
if (empty($entry['authorid'])) {
|
||||
$entry['authorid'] = $serendipity['authorid'];
|
||||
$entry['author'] = $serendipity['realname'];
|
||||
}
|
||||
|
||||
if (!isset($entry['isdraft'])) {
|
||||
$entry['isdraft'] = 'false';
|
||||
}
|
||||
|
||||
if (!isset($entry['allow_comments'])) {
|
||||
$entry['allow_comments'] = 'true';
|
||||
}
|
||||
|
||||
$comments = $entry['s9y_comments'];
|
||||
$entryprops = $entry['props'];
|
||||
unset($entry['props']);
|
||||
unset($entry['s9y_comments']);
|
||||
|
||||
if ( !is_int($r = serendipity_updertEntry($entry)) ) {
|
||||
echo '<div class="serendipityAdminMsgError">' . $r . '</div>';
|
||||
} else {
|
||||
$this->debug('Saved entry ' . $r . ' (' . $entry['title'] . ')');
|
||||
$entry['id'] = $r;
|
||||
foreach((array)$comments AS $comment) {
|
||||
$comment['entry_id'] = $r;
|
||||
if ($rc = serendipity_db_insert('comments', $comment)) {
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['id'], true);
|
||||
} else {
|
||||
echo '<div class="serendipityAdminMsgError">' . $rc . '</div>';
|
||||
}
|
||||
}
|
||||
// Let the plugins do some additional stuff. Here it's used with
|
||||
// event_entryproperties in mind to setup the nl2br-stuff
|
||||
serendipity_plugin_api::hook_event('backend_import_entry', $entry, $entryprops);
|
||||
}
|
||||
}
|
||||
serendipity_db_end_transaction(true);
|
||||
return true;
|
||||
} else {
|
||||
return '<ul><li>'.implode('</li><li>', array_unique($tasks)).'</li></ul>';
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'Serendipity_Import_MovableType';
|
||||
?>
|
244
include/admin/importers/nucleus.inc.php
Normal file
244
include/admin/importers/nucleus.inc.php
Normal file
@ -0,0 +1,244 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* Nucleus Importer, by Garvin Hicking *
|
||||
* ****************************************************************/
|
||||
|
||||
class Serendipity_Import_Nucleus extends Serendipity_Import {
|
||||
var $info = array('software' => 'Nucleus');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
|
||||
function Serendipity_Import_Nucleus($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => INSTALL_DBPREFIX,
|
||||
'type' => 'input',
|
||||
'name' => 'prefix',
|
||||
'default' => 'nucleus_'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'native',
|
||||
'default' => $this->getCharsets()),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
|
||||
$users = array();
|
||||
$categories = array();
|
||||
$entries = array();
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
return MYSQL_REQUIRED;;
|
||||
}
|
||||
|
||||
$nucdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if (!$nucdb) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($this->data['name'])) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($nucdb));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = @$this->nativeQuery("SELECT mnumber AS ID, mname AS user_login, mpassword AS user_pass, memail AS user_email, madmin AS user_level FROM {$this->data['prefix']}member;", $nucdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($nucdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res); $x < $max_x ; $x++ ) {
|
||||
$users[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => ($users[$x]['user_level'] >= 1) ? 1 : 0,
|
||||
'realname' => $users[$x]['user_login'],
|
||||
'username' => $users[$x]['user_login'],
|
||||
'email' => $users[$x]['user_email'],
|
||||
'password' => $users[$x]['user_pass']); // Nucleus uses md5, too.
|
||||
|
||||
if ( $users[$x]['user_level'] < 1 ) {
|
||||
$data['userlevel'] = USERLEVEL_EDITOR;
|
||||
} else {
|
||||
$data['userlevel'] = USERLEVEL_ADMIN;
|
||||
}
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
$res = @$this->nativeQuery("SELECT catid AS cat_ID, cname AS cat_name, cdesc AS category_description FROM {$this->data['prefix']}category ORDER BY catid;", $nucdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($nucdb));
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$categories[] = mysql_fetch_assoc($res);
|
||||
}
|
||||
|
||||
// Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
|
||||
for ($x=0, $max_x = sizeof($categories) ; $x < $max_x ; $x++ ) {
|
||||
$cat = array('category_name' => $categories[$x]['cat_name'],
|
||||
'category_description' => $categories[$x]['category_description'],
|
||||
'parentid' => 0, // <---
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
}
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}item ORDER BY itime;", $nucdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($nucdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['ititle']),
|
||||
'isdraft' => ($entries[$x]['idraft'] != '1') ? 'false' : 'true',
|
||||
'allow_comments' => ($entries[$x]['iclosed'] == '1' ) ? 'false' : 'true',
|
||||
'timestamp' => strtotime($entries[$x]['itime']),
|
||||
'extended' => $this->strtr($entries[$x]['imore']),
|
||||
'body' => $this->strtr($entries[$x]['ibody']));
|
||||
|
||||
$entry['authorid'] = '';
|
||||
$entry['author'] = '';
|
||||
foreach ($users as $user) {
|
||||
if ($user['ID'] == $entries[$x]['iauthor']) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
$entry['author'] = $user['realname'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
|
||||
/* Entry/category */
|
||||
foreach ($categories as $category) {
|
||||
if ($category['cat_ID'] == $entries[$x]['icat'] ) {
|
||||
$data = array('entryid' => $entries[$x]['entryid'],
|
||||
'categoryid' => $category['categoryid']);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comment;", $nucdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($nucdb));
|
||||
}
|
||||
|
||||
while ($a = mysql_fetch_assoc($res)) {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['inumber'] == $a['citem'] ) {
|
||||
$author = '';
|
||||
$mail = '';
|
||||
if (!empty($a['cmember'])) {
|
||||
foreach($users AS $user) {
|
||||
if ($user['ID'] == $a['cmember']) {
|
||||
$author = $user['user_login'];
|
||||
$mail = $user['user_email'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($author) && empty($mail)) {
|
||||
$author = $a['cuser'];
|
||||
$mail = $a['cmail'];
|
||||
}
|
||||
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => strtotime($a['ctime']),
|
||||
'author' => $author,
|
||||
'email' => $mail,
|
||||
'url' => $a['chost'],
|
||||
'ip' => $a['cip'],
|
||||
'status' => 'approved',
|
||||
'body' => $a['cbody'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_Nucleus';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
308
include/admin/importers/phpbb.inc.php
Normal file
308
include/admin/importers/phpbb.inc.php
Normal file
@ -0,0 +1,308 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* phpbb Importer, by Garvin Hicking *
|
||||
* ****************************************************************/
|
||||
|
||||
class Serendipity_Import_phpbb extends Serendipity_Import {
|
||||
var $info = array('software' => 'phpBB');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
var $categories = array();
|
||||
|
||||
function Serendipity_Import_phpbb($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => INSTALL_DBPREFIX,
|
||||
'type' => 'input',
|
||||
'name' => 'prefix',
|
||||
'default' => 'phpbb_'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'native',
|
||||
'default' => $this->getCharsets(false)),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
|
||||
$users = array();
|
||||
$entries = array();
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
return MYSQL_REQUIRED;
|
||||
}
|
||||
|
||||
$gdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if (!$gdb) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($this->data['name'])) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($gdb));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = @$this->nativeQuery("SELECT user_id AS ID,
|
||||
username AS user_login,
|
||||
user_password AS user_pass,
|
||||
user_email AS user_email,
|
||||
user_website AS user_url,
|
||||
user_level
|
||||
FROM {$this->data['prefix']}users
|
||||
WHERE user_active = 1", $gdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($gdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res); $x < $max_x ; $x++ ) {
|
||||
$users[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => 1,
|
||||
'realname' => $users[$x]['user_login'],
|
||||
'username' => $users[$x]['user_login'],
|
||||
'email' => $users[$x]['user_email'],
|
||||
'userlevel' => ($users[$x]['user_level'] == 0 ? USERLEVEL_EDITOR : USERLEVEL_ADMIN),
|
||||
'password' => $users[$x]['user_pass']); // MD5 compatible
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
echo mysql_error();
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
$res = @$this->nativeQuery("SELECT cat_id AS cat_ID,
|
||||
cat_title AS cat_name
|
||||
FROM {$this->data['prefix']}categories", $gdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($gdb));
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$parent_categories[] = mysql_fetch_assoc($res);
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = sizeof($parent_categories) ; $x < $max_x ; $x++ ) {
|
||||
$cat = array('category_name' => $parent_categories[$x]['cat_name'],
|
||||
'category_description' => '',
|
||||
'parentid' => 0, // <---
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$parent_categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
$res = @$this->nativeQuery("SELECT forum_id AS cat_ID,
|
||||
cat_id AS parent_cat_id,
|
||||
forum_name AS cat_name,
|
||||
forum_desc AS category_description
|
||||
FROM {$this->data['prefix']}forums ORDER BY forum_order;", $gdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($gdb));
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$categories[] = mysql_fetch_assoc($res);
|
||||
}
|
||||
|
||||
// Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
|
||||
for ($x=0, $max_x = sizeof($categories) ; $x < $max_x ; $x++ ) {
|
||||
$pcatid = 0;
|
||||
foreach($parent_categories AS $pcat) {
|
||||
if ($pcat['cat_ID'] == $categories[$x]['parent_cat_id']) {
|
||||
$pcatid = $pcat['cat_ID'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$cat = array('category_name' => $categories[$x]['cat_name'],
|
||||
'category_description' => $categories[$x]['category_description'],
|
||||
'parentid' => $pcatid, // <---
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
}
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @$this->nativeQuery("SELECT t.topic_title,
|
||||
t.topic_poster,
|
||||
t.forum_id,
|
||||
p.post_time,
|
||||
pt.post_subject,
|
||||
pt.post_text,
|
||||
count(p.topic_id) AS ccount,
|
||||
p.topic_id,
|
||||
MIN(p.post_id) AS post_id
|
||||
FROM {$this->data['prefix']}topics AS t
|
||||
LEFT OUTER JOIN {$this->data['prefix']}posts AS p
|
||||
ON t.topic_id = p.topic_id
|
||||
LEFT OUTER JOIN {$this->data['prefix']}posts_text AS pt
|
||||
ON pt.post_id = p.post_id
|
||||
GROUP BY p.topic_id
|
||||
", $gdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($gdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['post_subject']),
|
||||
'isdraft' => 'false',
|
||||
'allow_comments' => 'true',
|
||||
'timestamp' => $entries[$x]['post_time'],
|
||||
'body' => $this->strtr($entries[$x]['post_text']),
|
||||
'extended' => ''
|
||||
);
|
||||
|
||||
$entry['authorid'] = '';
|
||||
$entry['author'] = '';
|
||||
foreach ($users as $user) {
|
||||
if ($user['ID'] == $entries[$x]['topic_poster']) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
$entry['author'] = $user['user_login'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
|
||||
/* Entry/category */
|
||||
foreach ($categories as $category) {
|
||||
if ($category['cat_ID'] == $entries[$x]['forum_id'] ) {
|
||||
$data = array('entryid' => $entries[$x]['entryid'],
|
||||
'categoryid' => $category['categoryid']);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$topic_id = $entries[$x]['topic_id'];
|
||||
$c_res = @$this->nativeQuery("SELECT t.topic_title,
|
||||
t.topic_poster,
|
||||
p.poster_id,
|
||||
t.forum_id,
|
||||
p.post_time,
|
||||
pt.post_subject,
|
||||
pt.post_text,
|
||||
pt.post_id
|
||||
FROM {$this->data['prefix']}topics AS t
|
||||
LEFT OUTER JOIN {$this->data['prefix']}posts AS p
|
||||
ON t.topic_id = p.topic_id
|
||||
LEFT OUTER JOIN {$this->data['prefix']}posts_text AS pt
|
||||
ON pt.post_id = p.post_id
|
||||
WHERE p.topic_id = {$topic_id}
|
||||
", $gdb);
|
||||
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;
|
||||
}
|
||||
$author = '';
|
||||
$mail = '';
|
||||
$url = '';
|
||||
|
||||
foreach($users AS $user) {
|
||||
if ($user['ID'] == $a['poster_id']) {
|
||||
$author = $user['user_login'];
|
||||
$mail = $user['user_email'];
|
||||
$url = $user['user_url'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$comment = array('entry_id ' => $entries[$x]['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => $a['post_time'],
|
||||
'author' => $author,
|
||||
'email' => $mail,
|
||||
'url' => $url,
|
||||
'ip' => '',
|
||||
'status' => 'approved',
|
||||
'body' => $a['post_text'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entries[$x]['entryid'], true);
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_phpbb';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
202
include/admin/importers/pivot.inc.php
Normal file
202
include/admin/importers/pivot.inc.php
Normal file
@ -0,0 +1,202 @@
|
||||
<?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)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
# Loosely based on the Importer by Stefan Koopmanschap for TXP:
|
||||
# http://www.leftontheweb.com/pivot_to_textpattern.phps
|
||||
|
||||
class Serendipity_Import_Pivot extends Serendipity_Import {
|
||||
var $info = array('software' => 'Pivot');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
function Serendipity_Import_Pivot($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => PARENT_DIRECTORY,
|
||||
'type' => 'input',
|
||||
'name' => 'pivot_path',
|
||||
'default' => '/path/to/pivot/db/'),
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
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 toTimestamp($string) {
|
||||
if (empty($string)) {
|
||||
return time();
|
||||
}
|
||||
|
||||
$parts = explode('-', $string);
|
||||
return mktime($parts[3], $parts[4], 0, $parts[1], $parts[2], $parts[0]);
|
||||
}
|
||||
|
||||
function &unserialize($file) {
|
||||
$c = file_get_contents($file);
|
||||
$entrydata = str_replace(array('<?php /* pivot */ die(); ?>', "\r"), array('', ''), $c);
|
||||
$entrydata = unserialize($entrydata);
|
||||
|
||||
if (empty($entrydata) || !is_array($entrydata)) {
|
||||
$entrydata = str_replace(array('<?php /* pivot */ die(); ?>'), array(''), $c);
|
||||
$entrydata = unserialize($entrydata);
|
||||
}
|
||||
|
||||
return $entrydata;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
$max_import = 9999;
|
||||
|
||||
$serendipity['noautodiscovery'] = true;
|
||||
if (!is_dir($this->data['pivot_path']) || !is_readable($this->data['pivot_path'])) {
|
||||
$check_dir = $serendipity['serendipityPath'] . $this->data['pivot_path'];
|
||||
if (!is_dir($check_dir) || !is_readable($check_dir)) {
|
||||
return sprintf(ERROR_NO_DIRECTORY, $this->data['pivot_path']);
|
||||
}
|
||||
$this->data['pivot_path'] = $check_dir;
|
||||
}
|
||||
|
||||
printf('<br />' . CHECKING_DIRECTORY . '<br /><br />', $this->data['pivot_path']);
|
||||
if ($root = opendir($this->data['pivot_path'])) {
|
||||
// Fetch category data:
|
||||
$s9y_categories = serendipity_fetchCategories('all');
|
||||
$categories = $this->unserialize($this->data['pivot_path'] . '/ser-cats.php');
|
||||
$pivot_to_s9y = array(
|
||||
'categories' => array()
|
||||
);
|
||||
|
||||
foreach($categories AS $pivot_category_id => $category) {
|
||||
$found = false;
|
||||
$pivot_category = trim(stripslashes($category[0]));
|
||||
foreach($s9y_categories AS $idx => $item) {
|
||||
if ($pivot_category == $item['category_name']) {
|
||||
$found = $item['categoryid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found) {
|
||||
echo '· Pivot Category "' . htmlspecialchars($pivot_category) . '" mapped to Serendipity ID ' . $found . '<br />';
|
||||
$pivot_to_s9y['categories'][$pivot_category] = $found;
|
||||
} else {
|
||||
echo '· Created Pivot Category "' . htmlspecialchars($pivot_category) . '".<br />';
|
||||
$cat = array('category_name' => $pivot_category,
|
||||
'category_description' => '',
|
||||
'parentid' => 0,
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
|
||||
serendipity_db_insert('category', $cat);
|
||||
$pivot_to_s9y['categories'][$pivot_category] = serendipity_db_insert_id('category', 'categoryid');
|
||||
}
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while (false !== ($dir = readdir($root))) {
|
||||
if ($dir{0} == '.') continue;
|
||||
if (substr($dir, 0, 8) == 'standard') {
|
||||
printf(' · ' . CHECKING_DIRECTORY . '...<br />', $dir);
|
||||
$data = $this->unserialize($this->data['pivot_path'] . '/' . $dir . '/index-' . $dir . '.php');
|
||||
|
||||
if (empty($data) || !is_array($data) || count($data) < 1) {
|
||||
echo ' · <strong style="color: red">FATAL: File <em>' . $dir . '/index-' . $dir . '.php</em> has no data!</strong><br />';
|
||||
flush();
|
||||
ob_flush();
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($data as $entry) {
|
||||
$entryid = str_pad($entry['code'], 5, '0', STR_PAD_LEFT);
|
||||
|
||||
if ($i >= $max_import) {
|
||||
echo ' · Skipping entry data for #' . $entryid . '<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
echo ' · Fetching entry data for #' . $entryid . '<br />';
|
||||
$entrydata = $this->unserialize($this->data['pivot_path'] . '/' . $dir . '/' . $entryid . '.php');
|
||||
if (empty($entrydata) || !is_array($entrydata) || count($entrydata) < 1) {
|
||||
echo ' · <strong style="color: red">FATAL: File <em>' . $dir . '/' . $entryid . '.php</em> has no data!</strong><br />';
|
||||
flush();
|
||||
ob_flush();
|
||||
continue;
|
||||
}
|
||||
|
||||
$entry = array();
|
||||
$entry['title'] = trim(stripslashes($entrydata['title']));
|
||||
$entry['categories'] = array();
|
||||
if (is_array($entrydata['category'])) {
|
||||
foreach($entrydata['category'] AS $pivot_category) {
|
||||
$entry['categories'][] = $pivot_to_s9y['categories'][$pivot_category];
|
||||
}
|
||||
}
|
||||
$entry['timestamp'] = $this->toTimestamp($entrydata['date']);
|
||||
$entry['last_modified'] = (!empty($entrydata['edit_date']) ? $this->toTimestamp($entrydata['edit_date']) : $entry['timestamp']);
|
||||
$entry['isdraft'] = ($entrydata['status'] == 'publish' ? 'false' : 'true');
|
||||
$entry['body'] = stripslashes($entrydata['introduction']);
|
||||
$entry['extended'] = stripslashes($entrydata['body']);
|
||||
$entry['title'] = stripslashes($entrydata['title']);
|
||||
$entry['authorid'] = $serendipity['authorid'];
|
||||
$entry['author'] = $serendipity['serendipityUser'];
|
||||
$entry['allow_comments'] = ($entrydata['allow_comments'] ? 'true' : 'false');
|
||||
$entry['moderate_comments'] = 'false';
|
||||
$entry['exflag'] = (!empty($entry['extended']) ? 1 : 0);
|
||||
$entry['trackbacks'] = 0;
|
||||
$entry['comments'] = (isset($entrydata['comments']) ? count($entrydata['comments']) : 0);
|
||||
serendipity_updertEntry($entry);
|
||||
$i++;
|
||||
|
||||
if (isset($entrydata['comments']) && count($entrydata['comments']) > 0) {
|
||||
foreach($entrydata['comments'] as $comment) {
|
||||
$comment = array('entry_id ' => $entry['id'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => $this->toTimestamp($comment['date']),
|
||||
'author' => stripslashes($comment['name']),
|
||||
'email' => stripslashes($comment['email']),
|
||||
'url' => stripslashes($comment['url']),
|
||||
'ip' => stripslashes($comment['ip']),
|
||||
'status' => 'approved',
|
||||
'body' => stripslashes($comment['comment']),
|
||||
'subscribed'=> ($comment['notify'] ? 'true' : 'false'),
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $comment);
|
||||
}
|
||||
}
|
||||
echo ' · <strong style="color: green">Entry #' . $entryid . ' imported</strong><br />';
|
||||
flush();
|
||||
ob_flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return sprintf(ERROR_NO_DIRECTORY, $this->data['pivot_path']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_Pivot';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
252
include/admin/importers/pmachine.inc.php
Normal file
252
include/admin/importers/pmachine.inc.php
Normal file
@ -0,0 +1,252 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* pMachine Importer, by Garvin Hicking *
|
||||
* ****************************************************************/
|
||||
|
||||
class Serendipity_Import_pMachine extends Serendipity_Import {
|
||||
var $info = array('software' => 'pMachine Pro 2.4');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
|
||||
function Serendipity_Import_pMachine($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => INSTALL_DBPREFIX,
|
||||
'type' => 'input',
|
||||
'name' => 'prefix',
|
||||
'default' => 'pm_'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'native',
|
||||
'default' => $this->getCharsets()),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
|
||||
$users = array();
|
||||
$categories = array();
|
||||
$entries = array();
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
return MYSQL_REQUIRED;
|
||||
}
|
||||
|
||||
$pmdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if (!$pmdb) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($this->data['name'])) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($pmdb));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = @$this->nativeQuery("SELECT id AS ID,
|
||||
username AS user_login,
|
||||
`password` AS user_pass,
|
||||
email AS user_email,
|
||||
status AS user_level,
|
||||
url AS url
|
||||
FROM {$this->data['prefix']}members", $pmdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($pmdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res); $x < $max_x ; $x++ ) {
|
||||
$users[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => ($users[$x]['user_level'] >= 3) ? 1 : 0,
|
||||
'realname' => $users[$x]['user_login'],
|
||||
'username' => $users[$x]['user_login'],
|
||||
'email' => $users[$x]['user_email'],
|
||||
'password' => $users[$x]['user_pass']); // pMachine uses md5, too.
|
||||
|
||||
if ( $users[$x]['user_level'] < 12 ) {
|
||||
$data['userlevel'] = USERLEVEL_EDITOR;
|
||||
} else {
|
||||
$data['userlevel'] = USERLEVEL_ADMIN;
|
||||
}
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
$res = @$this->nativeQuery("SELECT id AS cat_ID,
|
||||
category AS cat_name,
|
||||
category AS category_description
|
||||
FROM {$this->data['prefix']}categories ORDER BY id", $pmdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($pmdb));
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$categories[] = mysql_fetch_assoc($res);
|
||||
}
|
||||
|
||||
// Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
|
||||
for ($x=0, $max_x = sizeof($categories) ; $x < $max_x ; $x++ ) {
|
||||
$cat = array('category_name' => $categories[$x]['cat_name'],
|
||||
'category_description' => $categories[$x]['category_description'],
|
||||
'parentid' => 0, // <---
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
}
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}weblog ORDER BY t_stamp;", $pmdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($pmdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['title']),
|
||||
'isdraft' => ($entries[$x]['status'] == 'open') ? 'false' : 'true',
|
||||
'allow_comments' => ($entries[$x]['showcomments'] == '1' ) ? 'true' : 'false',
|
||||
'timestamp' => $entries[$x]['t_stamp'],
|
||||
'extended' => $this->strtr($entries[$x]['more']),
|
||||
'body' => $this->strtr($entries[$x]['body']));
|
||||
|
||||
$entry['authorid'] = '';
|
||||
$entry['author'] = '';
|
||||
foreach ($users as $user) {
|
||||
if ($user['ID'] == $entries[$x]['member_id']) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
$entry['author'] = $user['username'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
|
||||
/* Entry/category */
|
||||
foreach ($categories as $category) {
|
||||
if ($category['cat_ID'] == $entries[$x]['category'] ) {
|
||||
$data = array('entryid' => $entries[$x]['entryid'],
|
||||
'categoryid' => $category['categoryid']);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comments;", $pmdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($pmdb));
|
||||
}
|
||||
|
||||
while ($a = mysql_fetch_assoc($res)) {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['post_id'] == $a['post_id'] ) {
|
||||
$author = '';
|
||||
$mail = '';
|
||||
$url = '';
|
||||
if (!empty($a['member_id'])) {
|
||||
foreach($users AS $user) {
|
||||
if ($user['ID'] == $a['member_id']) {
|
||||
$author = $user['user_login'];
|
||||
$mail = $user['user_email'];
|
||||
$url = $user['url'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => $a['t_stamp'],
|
||||
'author' => $author,
|
||||
'email' => $mail,
|
||||
'url' => $url,
|
||||
'ip' => $a['comment_ip'],
|
||||
'status' => ($a['status'] == 'open' ? 'approved' : 'pending'),
|
||||
'body' => $a['body'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
if ($a['status'] == 'open') {
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_pMachine';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
276
include/admin/importers/sunlog.inc.php
Normal file
276
include/admin/importers/sunlog.inc.php
Normal file
@ -0,0 +1,276 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* sunlog Importer, by Garvin Hicking *
|
||||
* ****************************************************************/
|
||||
|
||||
class Serendipity_Import_sunlog extends Serendipity_Import {
|
||||
var $info = array('software' => 'Sunlog 0.4.4');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
var $categories = array();
|
||||
|
||||
function getImportNotes() {
|
||||
return 'Sunlog uses a crypted string to represent stored passwords. Thus, those passwords are incompatible with the MD5 hashing of Serendipity and can not be reconstructed. The passwords for all users have been set to "sunlog". <strong>You need to modify the passwords manually for each user</strong>, we are sorry for that inconvenience.<br />'
|
||||
. '<br />'
|
||||
. 'Sunlog has a granular control over access privileges which cannot be migrated to Serendipity. All Users will be migrated as Superusers, you may need to set them to editor or chief users manually after import.';
|
||||
}
|
||||
|
||||
function Serendipity_Import_sunlog($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => INSTALL_DBPREFIX,
|
||||
'type' => 'input',
|
||||
'name' => 'prefix',
|
||||
'default' => 'sunlog_'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'native',
|
||||
'default' => $this->getCharsets()),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
|
||||
$users = array();
|
||||
$entries = array();
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
return MYSQL_REQUIRED;
|
||||
}
|
||||
|
||||
$sunlogdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if (!$sunlogdb) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($this->data['name'])) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($sunlogdb));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = @$this->nativeQuery("SELECT id AS ID,
|
||||
name AS user_login,
|
||||
email AS user_email,
|
||||
homepage AS user_url
|
||||
FROM {$this->data['prefix']}users", $sunlogdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($sunlogdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res); $x < $max_x ; $x++ ) {
|
||||
$users[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => 1,
|
||||
'realname' => $users[$x]['user_login'],
|
||||
'username' => $users[$x]['user_login'],
|
||||
'email' => $users[$x]['user_email'],
|
||||
'userlevel' => USERLEVEL_ADMIN,
|
||||
'password' => md5('sunlog'));
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
echo mysql_error();
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
if (!$this->importCategories(null, 0, $sunlogdb)) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($sunlogdb));
|
||||
}
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}articles ORDER BY id;", $sunlogdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($sunlogdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['title']),
|
||||
'isdraft' => ($entries[$x]['draft'] == '0') ? 'false' : 'true',
|
||||
'allow_comments' => ($entries[$x]['c_comments'] == '1' ) ? 'true' : 'false',
|
||||
'timestamp' => strtotime($entries[$x]['timestamp']),
|
||||
'body' => $this->strtr($entries[$x]['lead_converted']),
|
||||
'extended' => $this->strtr($entries[$x]['article_converted']),
|
||||
);
|
||||
|
||||
$entry['authorid'] = '';
|
||||
$entry['author'] = '';
|
||||
foreach ($users as $user) {
|
||||
if ($user['ID'] == $entries[$x]['author']) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
$entry['author'] = $user['user_login'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Even more category stuff */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}transfer_c;", $sunlogdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($sunlogdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entrycat = mysql_fetch_assoc($res);
|
||||
|
||||
$entryid = 0;
|
||||
$categoryid = 0;
|
||||
foreach($entries AS $entry) {
|
||||
if ($entry['id'] == $entrycat['article']) {
|
||||
$entryid = $entry['entryid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->categories AS $category) {
|
||||
if ($category['id'] == $entrycat['category']) {
|
||||
$categoryid = $category['categoryid'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($entryid > 0 && $categoryid > 0) {
|
||||
$data = array('entryid' => $entryid,
|
||||
'categoryid' => $categoryid);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}c_comments;", $sunlogdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($sunlogdb));
|
||||
}
|
||||
|
||||
while ($a = mysql_fetch_assoc($res)) {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['id'] == $a['for_entry'] ) {
|
||||
$author = '';
|
||||
$mail = '';
|
||||
$url = '';
|
||||
|
||||
foreach($users AS $user) {
|
||||
if ($user['ID'] == $a['user']) {
|
||||
$author = $user['user_login'];
|
||||
$mail = $user['user_email'];
|
||||
$url = $user['user_url'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => strtotime($a['insertdate']),
|
||||
'author' => $author,
|
||||
'email' => $mail,
|
||||
'url' => $url,
|
||||
'ip' => '',
|
||||
'status' => 'approved',
|
||||
'body' => $a['comment'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
|
||||
function importCategories($parentid = 0, $new_parentid = 0, $sunlogdb) {
|
||||
$where = "WHERE parent = '" . mysql_escape_string($parentid) . "'";
|
||||
|
||||
$res = $this->nativeQuery("SELECT * FROM {$this->data['prefix']}categories
|
||||
" . $where, $sunlogdb);
|
||||
if (!$res) {
|
||||
echo mysql_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$row = mysql_fetch_assoc($res);
|
||||
$cat = array('category_name' => $row['title'],
|
||||
'category_description' => $row['optional_1'] . ' ' . $row['optional_2'] . ' ' . $row['optional_3'],
|
||||
'parentid' => (int)$new_parentid,
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$row['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
$this->categories[] = $row;
|
||||
$this->importCategories($row['id'], $row['categoryid'], $sunlogdb);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_sunlog';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
251
include/admin/importers/textpattern.inc.php
Normal file
251
include/admin/importers/textpattern.inc.php
Normal file
@ -0,0 +1,251 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* textpattern Importer, by Garvin Hicking *
|
||||
* ****************************************************************/
|
||||
|
||||
class Serendipity_Import_textpattern extends Serendipity_Import {
|
||||
var $info = array('software' => 'Textpattern 1.0rc1');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
var $categories = array();
|
||||
|
||||
function getImportNotes() {
|
||||
return 'Textpattern uses MySQLs native PASSWORD() function to save passwords. Thus, those passwords are incompatible with the MD5 hashing of Serendipity. The passwords for all users have been set to "txp". <strong>You need to modify the passwords manually for each user</strong>, we are sorry for that inconvenience.<br />';
|
||||
}
|
||||
|
||||
function Serendipity_Import_textpattern($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => INSTALL_DBPREFIX,
|
||||
'type' => 'input',
|
||||
'name' => 'prefix',
|
||||
'default' => ''),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'UTF-8',
|
||||
'default' => $this->getCharsets(true)),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
|
||||
$users = array();
|
||||
$entries = array();
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
return MYSQL_REQUIRED;
|
||||
}
|
||||
|
||||
$txpdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if (!$txpdb) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($this->data['name'])) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($txpdb));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = @$this->nativeQuery("SELECT user_id AS ID,
|
||||
name AS user_login,
|
||||
`pass` AS user_pass,
|
||||
email AS user_email,
|
||||
privs AS user_level
|
||||
FROM {$this->data['prefix']}txp_users", $txpdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($txpdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res); $x < $max_x ; $x++ ) {
|
||||
$users[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => ($users[$x]['user_level'] <= 4) ? 1 : 0,
|
||||
'realname' => $users[$x]['user_login'],
|
||||
'username' => $users[$x]['user_login'],
|
||||
'email' => $users[$x]['user_email'],
|
||||
'password' => md5('txp')); // blame TXP for using PASSWORD().
|
||||
|
||||
if ( $users[$x]['user_level'] == 1 ) {
|
||||
$data['userlevel'] = USERLEVEL_EDITOR;
|
||||
} elseif ($users[$x]['user_level'] == 2) {
|
||||
$data['userlevel'] = USERLEVEL_CHIEF;
|
||||
} else {
|
||||
$data['userlevel'] = USERLEVEL_ADMIN;
|
||||
}
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
if (!$this->importCategories('root', 0, $txpdb)) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($txpdb));
|
||||
}
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
// Notice: Textpattern doesn't honor the prefix for this table. Wicked system.
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}textpattern ORDER BY Posted;", $txpdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($txpdb));
|
||||
}
|
||||
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['Title']),
|
||||
'isdraft' => ($entries[$x]['Status'] == '4') ? 'false' : 'true',
|
||||
'allow_comments' => ($entries[$x]['Annotate'] == '1' ) ? 'true' : 'false',
|
||||
'timestamp' => strtotime($entries[$x]['Posted']),
|
||||
'extended' => $this->strtr($entries[$x]['Body_html']),
|
||||
'body' => $this->strtr($entries[$x]['Excerpt']));
|
||||
|
||||
$entry['authorid'] = '';
|
||||
$entry['author'] = '';
|
||||
foreach ($users as $user) {
|
||||
if ($user['user_login'] == $entries[$x]['AuthorID']) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
$entry['author'] = $user['user_login'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
|
||||
/* Entry/category */
|
||||
foreach ($this->categories as $category) {
|
||||
if ($category['name'] == $entries[$x]['Category1'] || $category['name'] == $entries[$x]['Category2']) {
|
||||
$data = array('entryid' => $entries[$x]['entryid'],
|
||||
'categoryid' => $category['categoryid']);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}txp_discuss;", $txpdb);
|
||||
if (!$res) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($txpdb));
|
||||
}
|
||||
|
||||
while ($a = mysql_fetch_assoc($res)) {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['ID'] == $a['parentid'] ) {
|
||||
$author = $a['name'];
|
||||
$mail = $a['email'];
|
||||
$url = $a['web'];
|
||||
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => strtotime($a['posted']),
|
||||
'author' => $author,
|
||||
'email' => $mail,
|
||||
'url' => $url,
|
||||
'ip' => $a['ip'],
|
||||
'status' => ($a['visible'] == '1' ? 'approved' : 'pending'),
|
||||
'body' => $a['message'],
|
||||
'subscribed'=> 'false',
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
if ($a['visible'] == '1') {
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
|
||||
function importCategories($parentname = 'root', $parentid = 0, $txpdb) {
|
||||
$res = $this->nativeQuery("SELECT * FROM {$this->data['prefix']}txp_category
|
||||
WHERE parent = '" . mysql_escape_string($parentname) . "' AND type = 'article'", $txpdb);
|
||||
if (!$res) {
|
||||
echo mysql_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++) {
|
||||
$row = mysql_fetch_assoc($res);
|
||||
$cat = array('category_name' => $row['name'],
|
||||
'category_description' => $row['name'],
|
||||
'parentid' => $parentid,
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$row['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
$this->categories[] = $row;
|
||||
$this->importCategories($row['name'], $row['categoryid'], $txpdb);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_textpattern';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
267
include/admin/importers/voodoopad.inc.php
Executable file
267
include/admin/importers/voodoopad.inc.php
Executable file
@ -0,0 +1,267 @@
|
||||
<?php # $Id: voodoopad.inc.php 1 2005-04-16 06:39:31Z timputnam $
|
||||
# Copyright (c) 2003-2005, Tim Putnam
|
||||
|
||||
/*****************************************************************
|
||||
* VoodooPad Importer, by Tim Putnam
|
||||
* http://deepbluesea.fracsoft.com *
|
||||
*****************************************************************/
|
||||
|
||||
// These are used by the XML parser
|
||||
class element{
|
||||
var $name = '';
|
||||
var $attributes = array();
|
||||
var $data = '';
|
||||
var $depth = 0;
|
||||
}
|
||||
$elements = $stack = array();
|
||||
$count = $depth = 0;
|
||||
|
||||
// Language, language...
|
||||
switch ($serendipity['lang']) {
|
||||
case 'en':
|
||||
default:
|
||||
@define('IMPORTER_VOODOO_FILEPROMPT', 'VoodooPad XML file');
|
||||
@define('IMPORTER_VOODOO_CREATEINTRALINKSPROMPT', 'Recreate intra-links?');
|
||||
@define('IMPORTER_VOODOO_WIKINAMEPROMPT','Wiki name');
|
||||
@define('IMPORTER_VOODOO_KEYPREFIXPROMPT','Prefix for static page DB key');
|
||||
@define('IMPORTER_VOODOO_UPDATEEXISTINGPROMPT','Update existing entries?');
|
||||
@define('IMPORTER_VOODOO_CREATINGPAGE','Creating page');
|
||||
@define('IMPORTER_VOODOO_UPDATINGPAGE','Updating page');
|
||||
@define('IMPORTER_VOODOO_NOTUPDATING','Not updating');
|
||||
@define('IMPORTER_VOODOO_RECORDURL','Recording link URL');
|
||||
@define('IMPORTER_VOODOO_WRITEINTRALINKS','Writing intra-links..');
|
||||
@define('IMPORTER_VOODOO_REQUIREMENTFAIL', 'This importer requires the Static Pages plugin to be installed. All static pages are currently scanned for a match.');
|
||||
break;
|
||||
}
|
||||
|
||||
class Serendipity_Import_VoodooPad extends Serendipity_Import {
|
||||
var $info = array('software' => 'VoodooPad');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
function Serendipity_Import_VoodooPad($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(
|
||||
array('text' => IMPORTER_VOODOO_FILEPROMPT,
|
||||
'type' => 'file',
|
||||
'name' => 'voodooPadXML'),
|
||||
array('text' => IMPORTER_VOODOO_CREATEINTRALINKSPROMPT,
|
||||
'type' => 'bool',
|
||||
'name' => 'shouldWriteLinks',
|
||||
'default' => 'true'),
|
||||
array('text' => IMPORTER_VOODOO_WIKINAMEPROMPT,
|
||||
'type' => 'input',
|
||||
'name' => 'wikiName',
|
||||
'default' => ''),
|
||||
array('text' => IMPORTER_VOODOO_KEYPREFIXPROMPT,
|
||||
'type' => 'input',
|
||||
'name' => 'keyPrefix',
|
||||
'default' => '' ),
|
||||
array('text' => IMPORTER_VOODOO_UPDATEEXISTINGPROMPT,
|
||||
'type' => 'bool',
|
||||
'name' => 'updateExisting',
|
||||
'default' => 'true' ) );
|
||||
}
|
||||
|
||||
function getImportNotes(){
|
||||
return IMPORTER_VOODOO_REQUIREMENTFAIL;
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($_FILES['serendipity']['tmp_name']['import']['voodooPadXML']);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
global $elements;
|
||||
|
||||
// Dependency on static pages
|
||||
if (!class_exists('serendipity_event_staticpage')) {
|
||||
die(IMPORTER_VOODOO_REQUIREMENTFAIL . '<br/>');
|
||||
}
|
||||
|
||||
// The selected file
|
||||
$file = $_FILES['serendipity']['tmp_name']['import']['voodooPadXML'];
|
||||
|
||||
// Create a parser and set it up with the callbacks
|
||||
$xml_parser = xml_parser_create('');
|
||||
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
|
||||
xml_set_element_handler($xml_parser, "start_element_handler", "end_element_handler");
|
||||
xml_set_character_data_handler($xml_parser, "character_data_handler");
|
||||
|
||||
// Feed the contents of the file into the parser
|
||||
if (!file_exists($file)) {
|
||||
die(sprintf(DOCUMENT_NOT_FOUND, htmlspecialchars($file)));
|
||||
}
|
||||
|
||||
if(!($handle = fopen($file, "r"))) {
|
||||
die(sprintf(SKIPPING_FILE_UNREADABLE, htmlspecialchars($file)));
|
||||
}
|
||||
|
||||
while($contents = fread($handle, 4096)) {
|
||||
xml_parse($xml_parser, $contents, feof($handle));
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
xml_parser_free($xml_parser);
|
||||
|
||||
// Maintain a list of the aliases and their links
|
||||
$aliases = array();
|
||||
|
||||
// Now have a list of elements referenceable by id
|
||||
// so loop through building and/or updating page objects
|
||||
while(list($key_a) = each($elements)) {
|
||||
$name = $elements[$key_a]->name;
|
||||
|
||||
switch ($name) {
|
||||
case 'data': // <data> indicates the start of the VoodooPad entry, so create page object
|
||||
$thispage = array();
|
||||
break;
|
||||
|
||||
case 'key': // This is the unique identifier of the page
|
||||
$mykey = serendipity_makeFilename($elements[$key_a]->data);
|
||||
$mykey = basename($this->data['keyPrefix']) . $mykey;
|
||||
|
||||
// Pluck out the existing one if its there
|
||||
$page = serendipity_db_query("SELECT *
|
||||
FROM {$serendipity['dbPrefix']}staticpages
|
||||
WHERE filename = '" . serendipity_db_escape_string($mykey.'.htm') . "'
|
||||
LIMIT 1", true, 'assoc');
|
||||
if (is_array($page)) {
|
||||
$thispage =& $page;
|
||||
if (empty($thispage['timestamp'])) {
|
||||
$thispage['timestamp'] = time();
|
||||
}
|
||||
}
|
||||
|
||||
$thispage['filename'] = $mykey.'.htm';
|
||||
// Thanks for pointing this out to me and not just fixing it, I'm learning.
|
||||
$thispage['permalink'] = $serendipity['serendipityHTTPPath'] . 'index.php?serendipity[subpage]=' . $mykey;
|
||||
break;
|
||||
|
||||
case 'alias': // The title and the string used to match links
|
||||
$thispage['articleformattitle'] = $this->data['wikiName'];
|
||||
$thispage['pagetitle'] = $mykey;
|
||||
$thispage['headline'] = $elements[$key_a]->data;
|
||||
break;
|
||||
|
||||
case 'content': // The content of a voodoopad entry
|
||||
case 'path': // The path of a url string
|
||||
$thispage['content'] = $elements[$key_a]->data;
|
||||
|
||||
// If its a content link list it for referencing with the page permalink
|
||||
if ( $name == 'content' ){
|
||||
$aliases[$thispage['headline']] = $thispage['permalink'];
|
||||
|
||||
// Either replace or insert depending on previous existence
|
||||
if (!isset($thispage['id'])) {
|
||||
echo '<br/>'.IMPORTER_VOODOO_CREATINGPAGE.': '. $mykey;
|
||||
serendipity_db_insert('staticpages', $thispage);
|
||||
$serendipity["POST"]["staticpage"] = serendipity_db_insert_id("staticpages", 'id');
|
||||
} elseif ($this->data['updateExisting'] == 'true') {
|
||||
echo '<br/>'.IMPORTER_VOODOO_UPDATINGPAGE.': '. $mykey;
|
||||
serendipity_db_update("staticpages", array("id" => $thispage["id"]), $thispage);
|
||||
} else {
|
||||
echo '<br/>'.IMPORTER_VOODOO_NOTUPDATING.': '. $mykey;
|
||||
}
|
||||
} else {
|
||||
// If its a url, the content is the link instead
|
||||
echo '<br/>'.IMPORTER_VOODOO_RECORDURL.': '.$thispage['headline'];
|
||||
$aliases[$thispage['headline']] = $thispage['content'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Now rewrite the permalinks
|
||||
echo '<br/>';
|
||||
if ($this->data['shouldWriteLinks'] == 'true') {
|
||||
Serendipity_Import_VoodooPad::write_links($aliases);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function write_links($aliases) {
|
||||
// Here we run through the static pages database and put in cross links
|
||||
// around the keywords in the text
|
||||
global $serendipity;
|
||||
|
||||
// **TODO** Change this to pull out only entries for the current wiki
|
||||
echo '<br/><p>'.IMPORTER_VOODOO_WRITEINTRALINKS.'</p>';
|
||||
|
||||
$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) {
|
||||
$thispage['content'] = Serendipity_Import_VoodooPad::wikify($alias, $permalink, $thispage['content']);
|
||||
}
|
||||
|
||||
for ($counter = 0; $counter <= 12; $counter+=1) {
|
||||
unset ($thispage[$counter]);
|
||||
}
|
||||
|
||||
// Write back to the database
|
||||
serendipity_db_update("staticpages", array("id" => $thispage["id"]), $thispage);
|
||||
}
|
||||
|
||||
echo DONE . '<br />';
|
||||
}
|
||||
|
||||
// Search and replace avoiding content of links
|
||||
// **TODO** Fix this to avoid short links screwing up longer links
|
||||
function wikify($alias, $link, $txt) {
|
||||
$r = preg_split('((>)|(<))', $txt, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$ns = '';
|
||||
for ($i = 0; $i < count($r); $i++) {
|
||||
if ($r[$i] == "<") {
|
||||
$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;
|
||||
|
||||
$id = $count;
|
||||
$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;
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_VoodooPad';
|
||||
?>
|
254
include/admin/importers/wordpress-pg.inc.php
Normal file
254
include/admin/importers/wordpress-pg.inc.php
Normal file
@ -0,0 +1,254 @@
|
||||
<?php # $Id: wordpress.inc.php,v 1.16 2005/05/17 11:34:48 garvinhicking Exp $
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* WordPress PostgreSQL Importer, by Devrim GUNDUZ *
|
||||
*****************************************************************/
|
||||
|
||||
class Serendipity_Import_WordPress_PG extends Serendipity_Import {
|
||||
var $info = array('software' => 'WordPress PostgreSQL');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
|
||||
function Serendipity_Import_WordPress_PG($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'password'),
|
||||
|
||||
array('text' => INSTALL_DBPORT,
|
||||
'type' => 'input',
|
||||
'name' => 'port'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => INSTALL_DBPREFIX,
|
||||
'type' => 'input',
|
||||
'name' => 'prefix'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'UTF-8',
|
||||
'default' => $this->getCharsets(true)),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
|
||||
$users = array();
|
||||
$categories = array();
|
||||
$entries = array();
|
||||
|
||||
if ( !extension_loaded('pgsql') ) {
|
||||
return PGSQL_REQUIRED;;
|
||||
}
|
||||
|
||||
$wpdb = pg_connect("$this->data['host'], $this->data['port'], $this->data['user'], $this->data['pass'], $this->data['name']");
|
||||
if ( !$wpdb ) {
|
||||
return sprintf(PGSQL_COULDNT_CONNECT, $this->data['pass']);
|
||||
}
|
||||
|
||||
/* Users */
|
||||
$res = pg_query($wpdb, "SELECT ID, user_login, user_pass, user_email, user_level FROM {$this->data['prefix']}users;");
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, pg_last_error($wpdb));
|
||||
}
|
||||
|
||||
for ( $x=0 ; $x<pg_num_rows($res) ; $x++ ) {
|
||||
$users[$x] = pg_fetch_assoc($res);
|
||||
|
||||
$data = array('right_publish' => ($users[$x]['user_level'] >= 1) ? 1 : 0,
|
||||
'realname' => $users[$x]['user_login'],
|
||||
'username' => $users[$x]['user_login'],
|
||||
'password' => $users[$x]['user_pass']); // WP uses md5, too.
|
||||
|
||||
if ( $users[$x]['user_level'] <= 1 ) {
|
||||
$data['userlevel'] = USERLEVEL_EDITOR;
|
||||
} elseif ( $users[$x]['user_level'] < 5 ) {
|
||||
$data['userlevel'] = USERLEVEL_CHIEF;
|
||||
} else {
|
||||
$data['userlevel'] = USERLEVEL_ADMIN;
|
||||
}
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
$res = @pg_query($wpdb, "SELECT cat_ID, cat_name, category_description, category_parent FROM {$this->data['prefix']}categories ORDER BY category_parent, cat_ID;");
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, pg_last_error($wpdb));
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
for ( $x=0 ; $x<pg_num_rows($res) ; $x++ )
|
||||
$categories[] = pg_fetch_assoc($res);
|
||||
|
||||
// Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
|
||||
for ( $x=0 ; $x<sizeof($categories) ; $x++ ) {
|
||||
$cat = array('category_name' => $categories[$x]['cat_name'],
|
||||
'category_description' => $categories[$x]['category_description'],
|
||||
'parentid' => 0, // <---
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
}
|
||||
|
||||
// There has to be a more efficient way of doing this...
|
||||
foreach ( $categories as $cat ) {
|
||||
if ( $cat['category_parent'] != 0 ) {
|
||||
// Find the parent
|
||||
$par_id = 0;
|
||||
foreach ( $categories as $possible_par ) {
|
||||
if ( $possible_par['cat_ID'] == $cat['category_parent'] ) {
|
||||
$par_id = $possible_par['categoryid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $par_id != 0 ) {
|
||||
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET parentid={$par_id} WHERE categoryid={$cat['categoryid']};");
|
||||
} // else { echo "D'oh! " . random_string_of_profanity(); }
|
||||
}
|
||||
}
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @pg_query($wpdb, "SELECT * FROM {$this->data['prefix']}posts ORDER BY post_date;");
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, pg_last_error($wpdb));
|
||||
}
|
||||
|
||||
for ( $x=0 ; $x<pg_num_rows($res) ; $x++ ) {
|
||||
$entries[$x] = pg_fetch_assoc($res);
|
||||
|
||||
$entry = array('title' => $this->decode($entries[$x]['post_title']), // 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',
|
||||
'timestamp' => strtotime($entries[$x]['post_date']),
|
||||
'body' => $this->strtr($entries[$x]['post_content']));
|
||||
|
||||
foreach ( $users as $user ) {
|
||||
if ( $user['ID'] == $entries[$x]['post_author'] ) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry)) ) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Entry/category */
|
||||
$res = @pg_query($wpdb, "SELECT * FROM {$this->data['prefix']}post2cat;");
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, pg_last_error($wpdb));
|
||||
}
|
||||
|
||||
while ( $a = pg_fetch_assoc($res) ) {
|
||||
foreach ( $categories as $category ) {
|
||||
if ( $category['cat_ID'] == $a['category_id'] ) {
|
||||
foreach ( $entries as $entry ) {
|
||||
if ( $a['post_id'] == $entry['ID'] ) {
|
||||
$data = array('entryid' => $entry['entryid'],
|
||||
'categoryid' => $category['categoryid']);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @pg_query($wpdb, "SELECT * FROM {$this->data['prefix']}comments;");
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, pg_last_error($wpdb));
|
||||
}
|
||||
|
||||
while ( $a = pg_fetch_assoc($res) ) {
|
||||
foreach ( $entries as $entry ) {
|
||||
if ( $entry['ID'] == $a['comment_post_ID'] ) {
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => strtotime($a['comment_date']),
|
||||
'author' => $a['comment_author'],
|
||||
'email' => $a['comment_author_email'],
|
||||
'url' => $a['comment_author_url'],
|
||||
'ip' => $a['comment_author_IP'],
|
||||
'status' => (empty($a['comment_approved']) || $a['comment_approved'] == '1') ? 'approved' : 'pending',
|
||||
'subscribed'=> 'false',
|
||||
'body' => $a['comment_content'],
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
if ($comment['status'] == 'approved') {
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_WordPress_PG';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
255
include/admin/importers/wordpress.inc.php
Normal file
255
include/admin/importers/wordpress.inc.php
Normal file
@ -0,0 +1,255 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
/*****************************************************************
|
||||
* WordPress Importer, by Evan Nemerson *
|
||||
*****************************************************************/
|
||||
|
||||
class Serendipity_Import_WordPress extends Serendipity_Import {
|
||||
var $info = array('software' => 'WordPress');
|
||||
var $data = array();
|
||||
var $inputFields = array();
|
||||
|
||||
|
||||
function Serendipity_Import_WordPress($data) {
|
||||
$this->data = $data;
|
||||
$this->inputFields = array(array('text' => INSTALL_DBHOST,
|
||||
'type' => 'input',
|
||||
'name' => 'host'),
|
||||
|
||||
array('text' => INSTALL_DBUSER,
|
||||
'type' => 'input',
|
||||
'name' => 'user'),
|
||||
|
||||
array('text' => INSTALL_DBPASS,
|
||||
'type' => 'protected',
|
||||
'name' => 'pass'),
|
||||
|
||||
array('text' => INSTALL_DBNAME,
|
||||
'type' => 'input',
|
||||
'name' => 'name'),
|
||||
|
||||
array('text' => INSTALL_DBPREFIX,
|
||||
'type' => 'input',
|
||||
'name' => 'prefix'),
|
||||
|
||||
array('text' => CHARSET,
|
||||
'type' => 'list',
|
||||
'name' => 'charset',
|
||||
'value' => 'UTF-8',
|
||||
'default' => $this->getCharsets(true)),
|
||||
|
||||
array('text' => CONVERT_HTMLENTITIES,
|
||||
'type' => 'bool',
|
||||
'name' => 'use_strtr',
|
||||
'default' => 'true'),
|
||||
|
||||
array('text' => ACTIVATE_AUTODISCOVERY,
|
||||
'type' => 'bool',
|
||||
'name' => 'autodiscovery',
|
||||
'default' => 'false')
|
||||
);
|
||||
}
|
||||
|
||||
function validateData() {
|
||||
return sizeof($this->data);
|
||||
}
|
||||
|
||||
function getInputFields() {
|
||||
return $this->inputFields;
|
||||
}
|
||||
|
||||
function import() {
|
||||
global $serendipity;
|
||||
|
||||
// Save this so we can return it to its original value at the end of this method.
|
||||
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
|
||||
|
||||
if ($this->data['autodiscovery'] == 'false') {
|
||||
$serendipity['noautodiscovery'] = 1;
|
||||
}
|
||||
|
||||
$this->getTransTable();
|
||||
|
||||
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
|
||||
$users = array();
|
||||
$categories = array();
|
||||
$entries = array();
|
||||
|
||||
if ( !extension_loaded('mysql') ) {
|
||||
return MYSQL_REQUIRED;;
|
||||
}
|
||||
|
||||
$wpdb = @mysql_connect($this->data['host'], $this->data['user'], $this->data['pass']);
|
||||
if ( !$wpdb ) {
|
||||
return sprintf(COULDNT_CONNECT, $this->data['host']);
|
||||
}
|
||||
|
||||
if ( !@mysql_select_db($this->data['name']) ) {
|
||||
return sprintf(COULDNT_SELECT_DB, mysql_error($wpdb));
|
||||
}
|
||||
|
||||
/* Users */
|
||||
// Fields: ID, user_login, user_pass, user_email, user_level
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}users;", $wpdb);
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_USER_INFO, mysql_error($wpdb));
|
||||
}
|
||||
|
||||
for ( $x=0 ; $x<mysql_num_rows($res) ; $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 ) {
|
||||
$data['userlevel'] = USERLEVEL_CHIEF;
|
||||
} else {
|
||||
$data['userlevel'] = USERLEVEL_ADMIN;
|
||||
}
|
||||
|
||||
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
|
||||
$data['userlevel'] = $serendipity['serendipityUserlevel'];
|
||||
}
|
||||
|
||||
serendipity_db_insert('authors', $this->strtrRecursive($data));
|
||||
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
$res = @$this->nativeQuery("SELECT cat_ID, cat_name, category_description, category_parent FROM {$this->data['prefix']}categories ORDER BY category_parent, cat_ID;", $wpdb);
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($wpdb));
|
||||
}
|
||||
|
||||
// Get all the info we need
|
||||
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 ; $x<sizeof($categories) ; $x++ ) {
|
||||
$cat = array('category_name' => $categories[$x]['cat_name'],
|
||||
'category_description' => $categories[$x]['category_description'],
|
||||
'parentid' => 0, // <---
|
||||
'category_left' => 0,
|
||||
'category_right' => 0);
|
||||
|
||||
serendipity_db_insert('category', $this->strtrRecursive($cat));
|
||||
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
|
||||
}
|
||||
|
||||
// There has to be a more efficient way of doing this...
|
||||
foreach ( $categories as $cat ) {
|
||||
if ( $cat['category_parent'] != 0 ) {
|
||||
// Find the parent
|
||||
$par_id = 0;
|
||||
foreach ( $categories as $possible_par ) {
|
||||
if ( $possible_par['cat_ID'] == $cat['category_parent'] ) {
|
||||
$par_id = $possible_par['categoryid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $par_id != 0 ) {
|
||||
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET parentid={$par_id} WHERE categoryid={$cat['categoryid']};");
|
||||
} // else { echo "D'oh! " . random_string_of_profanity(); }
|
||||
}
|
||||
}
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
|
||||
/* Entries */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}posts ORDER BY post_date;", $wpdb);
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($wpdb));
|
||||
}
|
||||
|
||||
for ( $x=0 ; $x<mysql_num_rows($res) ; $x++ ) {
|
||||
$entries[$x] = mysql_fetch_assoc($res);
|
||||
|
||||
$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',
|
||||
'timestamp' => strtotime($entries[$x]['post_date']),
|
||||
'body' => $this->strtr($entries[$x]['post_content']));
|
||||
|
||||
foreach ( $users as $user ) {
|
||||
if ( $user['ID'] == $entries[$x]['post_author'] ) {
|
||||
$entry['authorid'] = $user['authorid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry)) ) {
|
||||
return $entries[$x]['entryid'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Entry/category */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}post2cat;", $wpdb);
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysql_error($wpdb));
|
||||
}
|
||||
|
||||
while ( $a = mysql_fetch_assoc($res) ) {
|
||||
foreach ( $categories as $category ) {
|
||||
if ( $category['cat_ID'] == $a['category_id'] ) {
|
||||
foreach ( $entries as $entry ) {
|
||||
if ( $a['post_id'] == $entry['ID'] ) {
|
||||
$data = array('entryid' => $entry['entryid'],
|
||||
'categoryid' => $category['categoryid']);
|
||||
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
$res = @$this->nativeQuery("SELECT * FROM {$this->data['prefix']}comments;", $wpdb);
|
||||
if ( !$res ) {
|
||||
return sprintf(COULDNT_SELECT_COMMENT_INFO, mysql_error($wpdb));
|
||||
}
|
||||
|
||||
while ( $a = mysql_fetch_assoc($res) ) {
|
||||
foreach ( $entries as $entry ) {
|
||||
if ( $entry['ID'] == $a['comment_post_ID'] ) {
|
||||
$comment = array('entry_id ' => $entry['entryid'],
|
||||
'parent_id' => 0,
|
||||
'timestamp' => strtotime($a['comment_date']),
|
||||
'author' => $a['comment_author'],
|
||||
'email' => $a['comment_author_email'],
|
||||
'url' => $a['comment_author_url'],
|
||||
'ip' => $a['comment_author_IP'],
|
||||
'status' => (empty($a['comment_approved']) || $a['comment_approved'] == '1') ? 'approved' : 'pending',
|
||||
'subscribed'=> 'false',
|
||||
'body' => $a['comment_content'],
|
||||
'type' => 'NORMAL');
|
||||
|
||||
serendipity_db_insert('comments', $this->strtrRecursive($comment));
|
||||
if ($comment['status'] == 'approved') {
|
||||
$cid = serendipity_db_insert_id('comments', 'id');
|
||||
serendipity_approveComment($cid, $entry['entryid'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['noautodiscovery'] = $noautodiscovery;
|
||||
|
||||
// That was fun.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Serendipity_Import_WordPress';
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
520
include/admin/installer.inc.php
Normal file
520
include/admin/installer.inc.php
Normal file
@ -0,0 +1,520 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
umask(0000);
|
||||
$umask = 0775;
|
||||
@define('IN_installer', true);
|
||||
|
||||
define('S9Y_I_ERROR', -1);
|
||||
define('S9Y_I_WARNING', 0);
|
||||
define('S9Y_I_SUCCESS', 1);
|
||||
|
||||
if (defined('S9Y_DATA_PATH')) {
|
||||
// Shared installation. S9Y_INCLUDE_PATH points to repository,
|
||||
// S9Y_DATA_PATH points to the local directory.
|
||||
$basedir = S9Y_DATA_PATH;
|
||||
} else {
|
||||
// Usual installation within DOCUMENT_ROOT.
|
||||
$basedir = serendipity_query_default('serendipityPath', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a return code constant if it's successfull or an error and return HTML code
|
||||
*
|
||||
* The diagnosis checks return codes of several PHP checks. Depending
|
||||
* on the input, a specially formatted string is returned.
|
||||
*
|
||||
* @access public
|
||||
* @param int Return code
|
||||
* @param string String to return wrapped in special HTML markup
|
||||
* @return string returned String
|
||||
*/
|
||||
function serendipity_installerResultDiagnose($result, $s) {
|
||||
global $errorCount;
|
||||
if ( $result === S9Y_I_SUCCESS ) {
|
||||
return '<span style="color: green; font-weight: bold">'. $s .'</span>';
|
||||
}
|
||||
if ( $result === S9Y_I_WARNING ) {
|
||||
return '<span style="color: orange; font-weight: bold">'. $s .' [?]</span>';
|
||||
}
|
||||
if ( $result === S9Y_I_ERROR ) {
|
||||
$errorCount++;
|
||||
return '<span style="color: red; font-weight: bold">'. $s .' [!]</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/* If register_globals is enabled and we use the dual GET/POST submission method, we will
|
||||
receive the value of the POST-variable inside the GET-variable, which is of course unwanted.
|
||||
Thus we transfer a new variable GETSTEP via POST and set that to an internal GET value. */
|
||||
if (!empty($serendipity['POST']['getstep']) && is_numeric($serendipity['POST']['getstep'])) {
|
||||
$serendipity['GET']['step'] = $serendipity['POST']['getstep'];
|
||||
}
|
||||
|
||||
/* From configuration to install */
|
||||
if ( sizeof($_POST) > 1 && $serendipity['GET']['step'] == 3 ) {
|
||||
/* One problem, if the user chose to do an easy install, not all config vars has been transfered
|
||||
Therefore we fetch all config vars with their default values, and merge them with our POST data */
|
||||
|
||||
$config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE);
|
||||
foreach ( $config as $category ) {
|
||||
foreach ( $category['items'] as $item ) {
|
||||
if ( !isset($_POST[$item['var']]) ) {
|
||||
$_POST[$item['var']] = serendipity_query_default($item['var'], $item['default']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array($errors = serendipity_checkInstallation()) ) {
|
||||
foreach ( $errors as $error ) {
|
||||
echo '<div class="serendipityAdminMsgError">'. $error .'</div>';
|
||||
}
|
||||
|
||||
$from = $_POST;
|
||||
/* Back to configuration, user did something wrong */
|
||||
$serendipity['GET']['step'] = $serendipity['POST']['step'];
|
||||
} else {
|
||||
/* We're good, move to install process */
|
||||
$serendipity['GET']['step'] = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if ( (int)$serendipity['GET']['step'] == 0 ) {
|
||||
?>
|
||||
<?php echo WELCOME_TO_INSTALLATION ?>.
|
||||
<br /><?php echo FIRST_WE_TAKE_A_LOOK ?>.
|
||||
<br /><?php echo sprintf(ERRORS_ARE_DISPLAYED_IN, serendipity_installerResultDiagnose(S9Y_I_ERROR, RED), serendipity_installerResultDiagnose(S9Y_I_WARNING, YELLOW), serendipity_installerResultDiagnose(S9Y_I_SUCCESS, GREEN)); ?>.
|
||||
<br />
|
||||
<br>
|
||||
<div align="center">- <?php echo sprintf(PRE_INSTALLATION_REPORT, $serendipity['version']) ?> -</div><br />
|
||||
|
||||
|
||||
<?php $errorCount = 0 ?>
|
||||
<div align="center">
|
||||
<table class="serendipity_admin_list_item serendipity_admin_list_item_even" width="90%" align="center">
|
||||
<tr>
|
||||
<td colspan="2" style="font-weight: bold"><?php echo PHP_INSTALLATION ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo OPERATING_SYSTEM ?></td>
|
||||
<td><?php echo php_uname('s') .' '. php_uname('r') .', '. php_uname('m') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo WEBSERVER_SAPI ?></td>
|
||||
<td><?php echo php_sapi_name() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PHP version >= 4.1.2</td>
|
||||
<td width="200"><?php
|
||||
if ( version_compare(phpversion(), '4.1.2', '>=') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, YES .', '. phpversion());
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_ERROR, NO);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Database extensions</td>
|
||||
<td width="200"><?php
|
||||
|
||||
if ( sizeof(($_res = serendipity_probeInstallation('dbType'))) == 0 ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_ERROR, NONE);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, implode(', ', $_res));
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Session extension</td>
|
||||
<td width="200"><?php
|
||||
if ( extension_loaded('session') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, YES);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, NO);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PCRE extension</td>
|
||||
<td width="200"><?php
|
||||
if ( extension_loaded('pcre') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, YES);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, NO);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>GDlib extension</td>
|
||||
<td width="200"><?php
|
||||
if ( extension_loaded('gd') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, YES);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, NO);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>OpenSSL extension</td>
|
||||
<td><?php
|
||||
if ( extension_loaded('openssl') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, YES);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, NO);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>mbstring extension</td>
|
||||
<td width="200"><?php
|
||||
if ( extension_loaded('mbstring') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, YES);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, NO);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>iconv extension</td>
|
||||
<td width="200"><?php
|
||||
if ( extension_loaded('iconv') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, YES);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, NO);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>zlib extension</td>
|
||||
<td width="200"><?php
|
||||
if ( extension_loaded('zlib') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, YES);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, NO);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Imagemagick binary </td>
|
||||
<td><?php
|
||||
if ($binary = serendipity_query_default('convert', false)) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, $binary);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, NOT_FOUND);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<table class="serendipity_admin_list_item serendipity_admin_list_item_even" width="90%" align="center">
|
||||
<tr>
|
||||
<td colspan="3" style="font-weight: bold"><?PHP echo PHPINI_CONFIGURATION ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td width="150"><em><?php echo RECOMMENDED ?></em></td>
|
||||
<td width="150"><em><?php echo ACTUAL ?></em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>safe_mode</td>
|
||||
<td width="150"><strong><?php echo 'OFF' ?></strong></td>
|
||||
<td width="150"><?php
|
||||
if ( !serendipity_ini_bool(ini_get('safe_mode')) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, 'OFF');
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, 'ON');
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>register_globals</td>
|
||||
<td width="150"><strong><?php echo 'OFF' ?></strong></td>
|
||||
<td width="150"><?php
|
||||
if ( serendipity_ini_bool(ini_get('register_globals')) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, 'ON');
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, 'OFF');
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>magic_quotes_gpc</td>
|
||||
<td width="150"><strong><?php echo 'OFF' ?></strong></td>
|
||||
<td width="150"><?php
|
||||
if ( !serendipity_ini_bool(ini_get('magic_quotes_gpc')) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, 'OFF');
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, 'ON');
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>magic_quotes_runtime</td>
|
||||
<td width="150"><strong><?php echo 'OFF' ?></strong></td>
|
||||
<td width="150"><?php
|
||||
if ( !serendipity_ini_bool(ini_get('magic_quotes_runtime')) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, 'OFF');
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_ERROR, 'ON');
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>session.use_trans_sid</td>
|
||||
<td width="150"><strong><?php echo 'OFF' ?></strong></td>
|
||||
<td width="150"><?php
|
||||
if ( !serendipity_ini_bool(ini_get('session.use_trans_sid')) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, 'OFF');
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, 'ON');
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>allow_url_fopen</td>
|
||||
<td width="150"><strong><?php echo 'ON' ?></strong></td>
|
||||
<td width="150"><?php
|
||||
if ( serendipity_ini_bool(ini_get('allow_url_fopen')) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, 'ON');
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, 'OFF');
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>file_uploads</td>
|
||||
<td width="150"><strong><?php echo 'ON' ?></strong></td>
|
||||
<td width="150"><?php
|
||||
if ( serendipity_ini_bool(ini_get('file_uploads')) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, 'ON');
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_ERROR, 'OFF');
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>post_max_size</td>
|
||||
<td width="150"><strong>10M</strong></td>
|
||||
<td width="150"><?php
|
||||
if ( serendipity_ini_bytesize(ini_get('post_max_size')) >= (10*1024*1024) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, ini_get('post_max_size'));
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, ini_get('post_max_size'));
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>upload_max_filesize</td>
|
||||
<td width="150"><strong>10M</strong></td>
|
||||
<td width="150"><?php
|
||||
if ( serendipity_ini_bytesize(ini_get('upload_max_filesize')) >= (10*1024*1024) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, ini_get('upload_max_filesize'));
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, ini_get('upload_max_filesize'));
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
<table class="serendipity_admin_list_item serendipity_admin_list_item_even" width="90%" align="center">
|
||||
<tr>
|
||||
<td colspan="2" style="font-weight: bold"><?php echo PERMISSIONS ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $basedir ?></td>
|
||||
<td width="200"><?php
|
||||
$basewritable = False;
|
||||
if ( is_writable($basedir) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, WRITABLE);
|
||||
$basewritable = True;
|
||||
} else {
|
||||
#Figure out if we already have all we need
|
||||
#PATH_SMARTY_COMPILE/
|
||||
#uploads/
|
||||
#archives/
|
||||
#.htaccess
|
||||
#serendipity_config_local.inc.php
|
||||
# For completeness we could test to make sure the directories
|
||||
# really are directories, but that's probably overkill
|
||||
foreach (array('archives/', PATH_SMARTY_COMPILE . '/', 'uploads/', '.htaccess', 'serendipity_config_local.inc.php') as $path) {
|
||||
if (!is_writeable($basedir . $path)) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_ERROR, NOT_WRITABLE);
|
||||
$showWritableNote = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$showWritableNote) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, WRITABLE);
|
||||
}
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $basedir . PATH_SMARTY_COMPILE?></td>
|
||||
<td width="200"><?php
|
||||
if ( is_writable($basedir . PATH_SMARTY_COMPILE) ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, WRITABLE);
|
||||
} else {
|
||||
if ($basewritable) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, WRITABLE);
|
||||
#This directory will be created later in the process
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_ERROR, NOT_WRITABLE);
|
||||
$showWritableNote = true;
|
||||
}
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $basedir . 'archives/'?></td>
|
||||
<td width="200"><?php
|
||||
if ( is_writable($basedir . 'archives/') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, WRITABLE);
|
||||
} else {
|
||||
if ($basewritable) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, WRITABLE);
|
||||
#This directory will be created later in the process
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_ERROR, NOT_WRITABLE);
|
||||
$showWritableNote = true;
|
||||
}
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php if ( is_dir($basedir .'uploads/') ) { ?>
|
||||
<tr>
|
||||
<td><?php echo $basedir . 'uploads/'?></td>
|
||||
<td width="200"><?php
|
||||
if ( is_writable($basedir . 'uploads/') ) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, WRITABLE);
|
||||
} else {
|
||||
if ($basewritable) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, WRITABLE);
|
||||
#This directory will be created later in the process
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_ERROR, NOT_WRITABLE);
|
||||
$showWritableNote = true;
|
||||
}
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php if (function_exists('is_executable')) { ?>
|
||||
<tr>
|
||||
<td>Execute Imagemagick binary </td>
|
||||
<td><?php
|
||||
if ($binary = serendipity_query_default('convert', false)) {
|
||||
if (is_executable($binary)) {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, YES);
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, NO);
|
||||
}
|
||||
} else {
|
||||
echo serendipity_installerResultDiagnose(S9Y_I_WARNING, NOT_FOUND);
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php if ( $showWritableNote === true ) { ?>
|
||||
<div class="serendipityAdminMsgNote"><?php echo sprintf(PROBLEM_PERMISSIONS_HOWTO, 'chmod 1777') ?></div>
|
||||
<?php } ?>
|
||||
|
||||
<div align="center">
|
||||
<?php if ( $errorCount > 0 ) { ?>
|
||||
<div class="serendipityAdminMsgError"><?php echo PROBLEM_DIAGNOSTIC ?></div>
|
||||
<h2><a href="serendipity_admin.php"><?php echo RECHECK_INSTALLATION ?></a></h2>
|
||||
<?php } else { ?>
|
||||
<?php echo SELECT_INSTALLATION_TYPE ?>:
|
||||
<h2><a href="?serendipity[step]=2a"><?php echo SIMPLE_INSTALLATION ?></a> - <a href="?serendipity[step]=2b"><?php echo EXPERT_INSTALLATION ?></a></h2>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } elseif ( $serendipity['GET']['step'] == '2a' ) { ?>
|
||||
<form action="?" method="post">
|
||||
<input type="hidden" name="serendipity[step]" value="<?php echo $serendipity['GET']['step'] ?>">
|
||||
<input type="hidden" name="serendipity[getstep]" value="3">
|
||||
<?php
|
||||
$config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE, null, array('simpleInstall'));
|
||||
serendipity_printConfigTemplate($config, $from, true, false, false);
|
||||
?>
|
||||
<div align="center"><input name="submit" type="submit" value="<?php echo COMPLETE_INSTALLATION ?>" class="serendipityPrettyButton"></div>
|
||||
</form>
|
||||
|
||||
<?php } elseif ( $serendipity['GET']['step'] == '2b' ) { ?>
|
||||
<form action="?" method="post">
|
||||
<input type="hidden" name="serendipity[step]" value="<?php echo $serendipity['GET']['step'] ?>">
|
||||
<input type="hidden" name="serendipity[getstep]" value="3">
|
||||
<?php
|
||||
$config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE);
|
||||
serendipity_printConfigTemplate($config, $from, true, false, false);
|
||||
?>
|
||||
<div align="center"><input name="submit" type="submit" value="<?php echo COMPLETE_INSTALLATION ?>" class="serendipityPrettyButton"></div>
|
||||
</form>
|
||||
|
||||
<?php } elseif ( (int)$serendipity['GET']['step'] == 3 ) { ?>
|
||||
<?php
|
||||
|
||||
$serendipity['dbPrefix'] = $_POST['dbPrefix'];
|
||||
|
||||
echo CHECK_DATABASE_EXISTS .'...';
|
||||
$t = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}authors", false, 'both', false, false, false, true);
|
||||
if ( is_array($t) ) {
|
||||
echo ' <strong>'. THEY_DO .'</strong>, '. WONT_INSTALL_DB_AGAIN;
|
||||
echo '<br />';
|
||||
echo '<br />';
|
||||
} else {
|
||||
echo ' <strong>'. THEY_DONT .'</strong>';
|
||||
echo '<br />';
|
||||
|
||||
echo CREATE_DATABASE;
|
||||
serendipity_installDatabase();
|
||||
echo ' <strong>' . DONE . '</strong><br />';
|
||||
|
||||
echo sprintf(CREATING_PRIMARY_AUTHOR, $_POST['user']) .'...';
|
||||
$authorid = serendipity_addAuthor($_POST['user'], $_POST['pass'], $_POST['realname'], $_POST['email'], USERLEVEL_ADMIN);
|
||||
$mail_comments = (serendipity_db_bool($_POST['want_mail']) ? 1 : 0);
|
||||
serendipity_set_user_var('mail_comments', $mail_comments, $authorid);
|
||||
serendipity_set_user_var('mail_trackbacks', $mail_comments, $authorid);
|
||||
serendipity_set_user_var('right_publish', 1, $authorid);
|
||||
serendipity_addDefaultGroup('USERLEVEL_EDITOR_DESC', USERLEVEL_EDITOR);
|
||||
serendipity_addDefaultGroup('USERLEVEL_CHIEF_DESC', USERLEVEL_CHIEF);
|
||||
serendipity_addDefaultGroup('USERLEVEL_ADMIN_DESC', USERLEVEL_ADMIN);
|
||||
|
||||
echo ' <strong>' . DONE . '</strong><br />';
|
||||
|
||||
echo SETTING_DEFAULT_TEMPLATE .'... ';
|
||||
serendipity_set_config_var('template', $serendipity['defaultTemplate']);
|
||||
echo ' <strong>' . DONE . '</strong><br />';
|
||||
|
||||
echo INSTALLING_DEFAULT_PLUGINS .'... ';
|
||||
include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
|
||||
serendipity_plugin_api::register_default_plugins();
|
||||
echo ' <strong>' . DONE . '</strong><br />';
|
||||
|
||||
}
|
||||
|
||||
echo sprintf(ATTEMPT_WRITE_FILE, '.htaccess') . '... ';
|
||||
$errors = serendipity_installFiles($basedir);
|
||||
if ( $errors === true ) {
|
||||
echo ' <strong>' . DONE . '</strong><br />';
|
||||
} else {
|
||||
echo ' <strong>' . FAILED . '</strong><br />';
|
||||
foreach ( $errors as $error ) {
|
||||
echo '<div class="serendipityAdminMsgError">'. $error .'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( serendipity_updateConfiguration() ) {
|
||||
echo '<div class="serendipityAdminMsgSuccess">'. SERENDIPITY_INSTALLED .'</div>';
|
||||
echo '<div align="center" style="font-size: large"><a href="'. $_POST['serendipityHTTPPath'] .'">'. VISIT_BLOG_HERE .'</a></div>';
|
||||
echo '<div align="center">'. THANK_YOU_FOR_CHOOSING .'</div>';
|
||||
} else {
|
||||
echo '<div class="serendipityAdminMsgSuccess">'. ERROR_DETECTED_IN_INSTALL .'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
42
include/admin/overview.inc.php
Normal file
42
include/admin/overview.inc.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
$user = serendipity_fetchAuthor($serendipity['authorid']);
|
||||
|
||||
$output = array(
|
||||
'welcome' => WELCOME_BACK . ' ' . $user[0]['realname'],
|
||||
'show_links' => true,
|
||||
'links_title' => FURTHER_LINKS,
|
||||
'links' => array(
|
||||
'<a href="http://www.s9y.org/">' . FURTHER_LINKS_S9Y . '</a>',
|
||||
'<a href="http://www.s9y.org/33.html">' . FURTHER_LINKS_S9Y_DOCS . '</a>',
|
||||
'<a href="http://blog.s9y.org/">' . FURTHER_LINKS_S9Y_BLOG . '</a>',
|
||||
'<a href="http://www.s9y.org/forums/">' . FURTHER_LINKS_S9Y_FORUMS . '</a>',
|
||||
'<a href="http://php-blog.sf.net/">' . FURTHER_LINKS_S9Y_SPARTACUS . '</a>'
|
||||
),
|
||||
'links_css' => 'further_links',
|
||||
'more' => ''
|
||||
);
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_frontpage_display', $output);
|
||||
|
||||
echo $output['welcome'];
|
||||
|
||||
if ($output['show_links']) {
|
||||
echo '<div class="' . $output['links_css'] . '">' . "\n";
|
||||
echo '<p>' . $output['links_title'] . '</p>' . "\n";
|
||||
echo '<ul>' . "\n";
|
||||
foreach($output['links'] AS $link) {
|
||||
echo '<li>' . $link . '</li>' . "\n";
|
||||
}
|
||||
echo '</ul>' . "\n";
|
||||
echo '</div>' . "\n";
|
||||
}
|
||||
|
||||
echo $output['more'];
|
105
include/admin/personal.inc.php
Normal file
105
include/admin/personal.inc.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('personalConfiguration')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$from = array();
|
||||
|
||||
if ($serendipity['GET']['adminAction'] == 'save' && serendipity_checkFormToken()) {
|
||||
$config = serendipity_parseTemplate(S9Y_CONFIG_USERTEMPLATE);
|
||||
if ( (!serendipity_checkPermission('adminUsersEditUserlevel') || !serendipity_checkPermission('adminUsersMaintainOthers') )
|
||||
&& (int)$_POST['userlevel'] > $serendipity['serendipityUserlevel']) {
|
||||
echo '<div class="serendipityAdminMsgError">' . CREATE_NOT_AUTHORIZED_USERLEVEL . '</div>';
|
||||
} elseif (empty($_POST['username'])) {
|
||||
echo '<div class="serendipityAdminMsgError">' . USERCONF_CHECK_USERNAME_ERROR . '</div>';
|
||||
} elseif (!empty($_POST['password']) && $_POST['check_password'] != $_SESSION['serendipityPassword'] && md5($_POST['check_password']) != $_SESSION['serendipityPassword']) {
|
||||
echo '<div class="serendipityAdminMsgError">' . USERCONF_CHECK_PASSWORD_ERROR . '</div>';
|
||||
} else {
|
||||
$valid_groups = serendipity_getGroups($serendipity['authorid'], true);
|
||||
|
||||
foreach($config as $category) {
|
||||
foreach ($category['items'] as $item) {
|
||||
if (in_array('groups', $item['flags'])) {
|
||||
if (serendipity_checkPermission('adminUsersMaintainOthers')) {
|
||||
|
||||
// Void, no fixing neccessarry
|
||||
|
||||
} elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
|
||||
|
||||
// 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)) {
|
||||
continue;
|
||||
} elseif ($groupval == 2 && in_array(3, $valid_groups)) {
|
||||
// Admin is allowed to assign users to chief editors
|
||||
continue;
|
||||
} elseif ($groupval == 1 && in_array(2, $valid_groups)) {
|
||||
// Chief is allowed to assign users to editors
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($_POST[$item['var']][$groupkey]);
|
||||
}
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($_POST[$item['var']]) < 1) {
|
||||
echo '<div class="serendipityAdminMsgError">' . WARNING_NO_GROUPS_SELECTED . '</div>';
|
||||
} else {
|
||||
serendipity_updateGroups($_POST[$item['var']], $serendipity['authorid'], false);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (serendipity_checkConfigItemFlags($item, 'local')) {
|
||||
serendipity_set_user_var($item['var'], $_POST[$item['var']], $serendipity['authorid'], true);
|
||||
}
|
||||
|
||||
if (serendipity_checkConfigItemFlags($item, 'configuration')) {
|
||||
serendipity_set_config_var($item['var'], $_POST[$item['var']], $serendipity['authorid']);
|
||||
}
|
||||
}
|
||||
|
||||
$pl_data = array(
|
||||
'id' => $serendipity['POST']['authorid'],
|
||||
'authorid' => $serendipity['POST']['authorid'],
|
||||
'username' => $_POST['username'],
|
||||
'realname' => $_POST['realname'],
|
||||
'email' => $_POST['email']
|
||||
);
|
||||
serendipity_updatePermalink($pl_data, 'author');
|
||||
serendipity_plugin_api::hook_event('backend_users_edit', $pl_data);
|
||||
}
|
||||
$from = $_POST;
|
||||
?>
|
||||
<div class="serendipityAdminMsgSuccess"><?php echo sprintf(MODIFIED_USER, $_POST['realname']) ?></div>
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
<form action="?serendipity[adminModule]=personal&serendipity[adminAction]=save" method="post">
|
||||
<?php
|
||||
echo serendipity_setFormToken();
|
||||
$template = serendipity_parseTemplate(S9Y_CONFIG_USERTEMPLATE);
|
||||
$user = serendipity_fetchUsers($serendipity['authorid']);
|
||||
$from = $user[0];
|
||||
$from['groups'] = serendipity_getGroups($serendipity['authorid']);
|
||||
unset($from['password']);
|
||||
serendipity_printConfigTemplate($template, $from, true, false);
|
||||
?>
|
||||
<div align="right"><input type="submit" name="SAVE" value="<?php echo SAVE; ?>" /></div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
$add = array('internal' => true);
|
||||
serendipity_plugin_api::hook_event('backend_sidebar_entries_event_display_profiles', $from, $add);
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
481
include/admin/plugins.inc.php
Normal file
481
include/admin/plugins.inc.php
Normal file
@ -0,0 +1,481 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ('Don\'t hack!');
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('adminPlugins')) {
|
||||
return;
|
||||
}
|
||||
|
||||
include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
|
||||
include_once S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php';
|
||||
include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php';
|
||||
include_once S9Y_INCLUDE_PATH . 'include/functions_plugins_admin.inc.php';
|
||||
|
||||
if (isset($_GET['serendipity']['plugin_to_move']) && isset($_GET['submit']) && serendipity_checkFormToken()) {
|
||||
if (isset($_GET['serendipity']['event_plugin'])) {
|
||||
$plugins = serendipity_plugin_api::enum_plugins('event', false);
|
||||
} else {
|
||||
$plugins = serendipity_plugin_api::enum_plugins('event', true);
|
||||
}
|
||||
|
||||
/* Renumber the sort order to be certain that one actually exists
|
||||
Also look for the one we're going to move */
|
||||
$idx_to_move = -1;
|
||||
for($idx = 0; $idx < count($plugins); $idx++) {
|
||||
$plugins[$idx]['sort_order'] = $idx;
|
||||
|
||||
if ($plugins[$idx]['name'] == $_GET['serendipity']['plugin_to_move']) {
|
||||
$idx_to_move = $idx;
|
||||
}
|
||||
}
|
||||
|
||||
/* If idx_to_move is still -1 then we never found it (shouldn't happen under normal conditions)
|
||||
Also make sure the swaping idx is around */
|
||||
if ($idx_to_move >= 0 && (($_GET['submit'] == 'move down' && $idx_to_move < (count($plugins)-1)) || ($_GET['submit'] == 'move up' && $idx_to_move > 0))) {
|
||||
|
||||
/* Swap the one were moving with the one that's in the spot we're moving to */
|
||||
$tmp = $plugins[$idx_to_move]['sort_order'];
|
||||
|
||||
$plugins[$idx_to_move]['sort_order'] = (int)$plugins[$idx_to_move + ($_GET['submit'] == 'move down' ? 1 : -1)]['sort_order'];
|
||||
$plugins[$idx_to_move + ($_GET['submit'] == 'move down' ? 1 : -1)]['sort_order'] = (int)$tmp;
|
||||
|
||||
/* Update table */
|
||||
foreach($plugins as $plugin) {
|
||||
$key = serendipity_db_escape_string($plugin['name']);
|
||||
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = {$plugin['sort_order']} WHERE name='$key'");
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Moving The first Right oriented plugin up,
|
||||
or the last left oriented plugin down
|
||||
should not be displayed to the user as an option.
|
||||
It's a behavior which really has no meaning. */
|
||||
}
|
||||
|
||||
if (isset($_GET['serendipity']['plugin_to_conf'])) {
|
||||
/* configure a specific instance */
|
||||
$plugin =& serendipity_plugin_api::load_plugin($_GET['serendipity']['plugin_to_conf']);
|
||||
|
||||
if (!($plugin->protected === FALSE || $plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$bag = new serendipity_property_bag;
|
||||
$plugin->introspect($bag);
|
||||
|
||||
if (method_exists($plugin, 'performConfig')) {
|
||||
$plugin->performConfig($bag);
|
||||
}
|
||||
|
||||
$name = htmlspecialchars($bag->get('name'));
|
||||
$desc = htmlspecialchars($bag->get('description'));
|
||||
|
||||
$config_names = $bag->get('configuration');
|
||||
|
||||
if (isset($_POST['SAVECONF']) && serendipity_checkFormToken()) {
|
||||
/* enum properties and set their values */
|
||||
|
||||
$save_errors = array();
|
||||
foreach ($config_names as $config_item) {
|
||||
$cbag = new serendipity_property_bag;
|
||||
if ($plugin->introspect_config_item($config_item, $cbag)) {
|
||||
$value = $_POST['serendipity']['plugin'][$config_item];
|
||||
|
||||
$validate = $plugin->validate($config_item, $cbag, $value);
|
||||
|
||||
if ($validate === true) {
|
||||
// echo $config_item . " validated: $validate<br />\n";
|
||||
$plugin->set_config($config_item, $value);
|
||||
} else {
|
||||
$save_errors[] = $validate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$plugin->cleanup();
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ( isset($save_errors) && is_array($save_errors) && count($save_errors) > 0 ) { ?>
|
||||
<div class="serendipityAdminMsgError">
|
||||
<?php
|
||||
echo ERROR . ":<br />\n";
|
||||
echo "<ul>\n";
|
||||
foreach($save_errors AS $save_error) {
|
||||
echo '<li>' . $save_error . "</li>\n";
|
||||
}
|
||||
echo "</ul>\n";
|
||||
?>
|
||||
</div>
|
||||
<?php } elseif ( isset($_POST['SAVECONF'])) { ?>
|
||||
<div class="serendipityAdminMsgSuccess"><?php echo DONE .': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')); ?></div>
|
||||
<?php } ?>
|
||||
|
||||
<form method="post" name="serendipityPluginConfigure">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<table cellpadding="5" style="border: 1px dashed" width="90%" align="center">
|
||||
<tr>
|
||||
<th width="100"><?php echo NAME; ?></th>
|
||||
<td><?php echo $name; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><?php echo DESCRIPTION; ?></th>
|
||||
<td><?php echo $desc; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<?php serendipity_plugin_config($plugin, $bag, $name, $desc, $config_names); ?>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
} elseif ( $serendipity['GET']['adminAction'] == 'addnew' ) {
|
||||
?>
|
||||
<?php if ( $serendipity['GET']['type'] == 'event' ) { ?>
|
||||
<h2><?php echo EVENT_PLUGINS ?></h2>
|
||||
<?php } else { ?>
|
||||
<h2><?php echo SIDEBAR_PLUGINS ?></h2>
|
||||
<?php } ?>
|
||||
<br />
|
||||
<?php
|
||||
$foreignPlugins = $pluginstack = $errorstack = array();
|
||||
serendipity_plugin_api::hook_event('backend_plugins_fetchlist', $foreignPlugins);
|
||||
$pluginstack = array_merge((array)$foreignPlugins['pluginstack'], $pluginstack);
|
||||
$errorstack = array_merge((array)$foreignPlugins['errorstack'], $errorstack);
|
||||
|
||||
$plugins = serendipity_plugin_api::get_installed_plugins();
|
||||
$classes = serendipity_plugin_api::enum_plugin_classes(($serendipity['GET']['type'] == 'event'));
|
||||
usort($classes, 'serendipity_pluginListSort');
|
||||
|
||||
$counter = 0;
|
||||
foreach ($classes as $class_data) {
|
||||
$pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
|
||||
$plugin =& serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $serendipity['GET']['type']);
|
||||
|
||||
if (is_object($plugin)) {
|
||||
// Object is returned when a plugin could not be cached.
|
||||
$bag = new serendipity_property_bag;
|
||||
$plugin->introspect($bag);
|
||||
|
||||
// If a foreign plugin is upgradable, keep the new version number.
|
||||
if (isset($foreignPlugins['pluginstack'][$class_data['name']]) && $foreignPlugins['pluginstack'][$class_data['name']]['upgradable']) {
|
||||
$class_data['upgrade_version'] = $foreignPlugins['pluginstack'][$class_data['name']]['upgrade_version'];
|
||||
}
|
||||
|
||||
$props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $foreignPlugins);
|
||||
|
||||
$counter++;
|
||||
} elseif (is_array($plugin)) {
|
||||
// Array is returned if a plugin could be fetched from info cache
|
||||
$props = $plugin;
|
||||
} else {
|
||||
$props = false;
|
||||
}
|
||||
|
||||
if (is_array($props)) {
|
||||
if (version_compare($props['version'], $props['upgrade_version'], '<')) {
|
||||
$props['upgradable'] = true;
|
||||
$props['customURI'] .= $foreignPlugins['baseURI'] . $foreignPlugins['upgradeURI'];
|
||||
}
|
||||
|
||||
$props['installable'] = !($props['stackable'] === false && in_array($class_data['true_name'], $plugins));
|
||||
$props['requirements'] = unserialize($props['requirements']);
|
||||
|
||||
$pluginstack[$class_data['true_name']] = $props;
|
||||
} else {
|
||||
// False is returned if a plugin could not be instantiated
|
||||
$errorstack[] = $class_data['true_name'];
|
||||
}
|
||||
}
|
||||
|
||||
usort($pluginstack, 'serendipity_pluginListSort');
|
||||
$pluggroups = array();
|
||||
$pluggroups[''] = array();
|
||||
foreach($pluginstack AS $plugname => $plugdata) {
|
||||
if ($serendipity['GET']['only_group'] == 'ALL') {
|
||||
$pluggroups['ALL'][] = $plugdata;
|
||||
} elseif ($serendipity['GET']['only_group'] == 'UPGRADE' && $plugdata['upgradable']) {
|
||||
$pluggroups['UPGRADE'][] = $plugdata;
|
||||
} elseif (is_array($plugdata['groups'])) {
|
||||
foreach($plugdata['groups'] AS $group) {
|
||||
$pluggroups[$group][] = $plugdata;
|
||||
}
|
||||
} else {
|
||||
$pluggroups[''][] = $plugdata;
|
||||
}
|
||||
}
|
||||
ksort($pluggroups);
|
||||
|
||||
foreach($errorstack as $e_idx => $e_name) {
|
||||
echo ERROR . ': ' . $e_name . '<br />';
|
||||
}
|
||||
|
||||
if ($serendipity['GET']['only_group'] == 'UPGRADE') {
|
||||
serendipity_plugin_api::hook_event('backend_pluginlisting_header_upgrade', $pluggroups);
|
||||
}
|
||||
?>
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<?php
|
||||
$available_groups = array_keys($pluggroups);
|
||||
foreach($pluggroups AS $pluggroup => $groupstack) {
|
||||
if (empty($pluggroup)) {
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="2" class="serendipity_pluginlist_header">
|
||||
<form action="serendipity_admin.php" method="get">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<input type="hidden" name="serendipity[adminModule]" value="plugins" />
|
||||
<input type="hidden" name="serendipity[adminAction]" value="addnew" />
|
||||
<input type="hidden" name="serendipity[type]" value="<?php echo htmlspecialchars($serendipity['GET']['type']); ?>" />
|
||||
<?php echo FILTERS; ?>: <select name="serendipity[only_group]">
|
||||
<?php foreach((array)$available_groups AS $available_group) {
|
||||
?>
|
||||
<option value="<?php echo $available_group; ?>" <?php echo ($serendipity['GET']['only_group'] == $available_group ? 'selected="selected"' : ''); ?>><?php echo serendipity_groupname($available_group); ?>
|
||||
<?php } ?>
|
||||
<option value="ALL" <?php echo ($serendipity['GET']['only_group'] == 'ALL' ? 'selected="selected"' : ''); ?>><?php echo ALL_CATEGORIES; ?>
|
||||
<option value="UPGRADE" <?php echo ($serendipity['GET']['only_group'] == 'UPGRADE' ? 'selected="selected"' : ''); ?>><?php echo WORD_NEW; ?>
|
||||
</select>
|
||||
<input type="submit" value="<?php echo GO; ?>" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
if (!empty($serendipity['GET']['only_group'])) {
|
||||
continue;
|
||||
}
|
||||
} elseif (!empty($serendipity['GET']['only_group']) && $pluggroup != $serendipity['GET']['only_group']) {
|
||||
continue;
|
||||
} else {
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="2" class="serendipity_pluginlist_section"><strong><?php echo serendipity_groupname($pluggroup); ?></strong></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><strong>Plugin</strong></td>
|
||||
<td width="100" align="center"><strong>Action</strong></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($groupstack as $plug) {
|
||||
$jsLine = " onmouseout=\"document.getElementById('serendipity_plugin_". $plug['class_name'] ."').className='';\"";
|
||||
$jsLine .= " onmouseover=\"document.getElementById('serendipity_plugin_". $plug['class_name'] ."').className='serendipity_admin_list_item_uneven';\"";
|
||||
|
||||
$pluginInfo = $notice = array();
|
||||
if (!empty($plug['author'])) {
|
||||
$pluginInfo[] = AUTHOR . ': ' . $plug['author'];
|
||||
}
|
||||
|
||||
if (!empty($plug['version'])) {
|
||||
$pluginInfo[] = VERSION . ': ' . $plug['version'];
|
||||
}
|
||||
|
||||
if (!empty($plug['upgrade_version']) && $plug['upgrade_version'] != $plug['version']) {
|
||||
$pluginInfo[] = sprintf(UPGRADE_TO_VERSION, $plug['upgrade_version']);
|
||||
}
|
||||
|
||||
if (!empty($plug['pluginlocation']) && $plug['pluginlocation'] != 'local') {
|
||||
$pluginInfo[] = '(' . htmlspecialchars($plug['pluginlocation']) . ')';
|
||||
$installimage = serendipity_getTemplateFile('admin/img/install_now_' . strtolower($plug['pluginlocation']) . '.png');
|
||||
} else {
|
||||
$installimage = serendipity_getTemplateFile('admin/img/install_now.png');
|
||||
}
|
||||
|
||||
if (!isset($plug['customURI'])) {
|
||||
$plug['customURI'] = '';
|
||||
}
|
||||
|
||||
if ( !empty($plug['requirements']['serendipity']) && version_compare($plug['requirements']['serendipity'], serendipity_getCoreVersion($serendipity['version']), '>') ) {
|
||||
$notice['requirements_failures'][] = 's9y ' . $plug['requirements']['serendipity'];
|
||||
}
|
||||
|
||||
if ( !empty($plug['requirements']['php']) && version_compare($plug['requirements']['php'], phpversion(), '>') ) {
|
||||
$notice['requirements_failures'][] = 'PHP ' . $plug['requirements']['php'];
|
||||
}
|
||||
|
||||
/* Enable after Smarty 2.6.7 upgrade.
|
||||
* TODO: How can we get current Smarty version here? $smarty is not created!
|
||||
if ( !empty($plug['requirements']['smarty']) && version_compare($plug['requirements']['smarty'], '2.6.7', '>') ) {
|
||||
$notice['requirements_failures'][] = 'Smarty: ' . $plug['requirements']['smarty'];
|
||||
}
|
||||
*/
|
||||
|
||||
if (count($notice['requirements_failures']) > 0) {
|
||||
$plug['requirements_fail'] = true;
|
||||
}
|
||||
|
||||
?>
|
||||
<tr id="serendipity_plugin_<?php echo $plug['class_name']; ?>">
|
||||
<td colspan="2" <?php echo $jsLine ?>>
|
||||
<table width="100%" cellpadding="3" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td><strong><?php echo $plug['name'] ?></strong></td>
|
||||
<td width="100" align="center" valign="middle" rowspan="3">
|
||||
<?php if ( $plug['requirements_fail'] == true ) { ?>
|
||||
<span style="color: #cccccc"><?php printf(UNMET_REQUIREMENTS, implode(', ', $notice['requirements_failures'])); ?></span>
|
||||
<?php } elseif ( $plug['upgradable'] == true ) { ?>
|
||||
<a href="?serendipity[adminModule]=plugins&serendipity[pluginPath]=<?php echo $plug['pluginPath']; ?>&serendipity[install_plugin]=<?php echo $plug['plugin_class'] . $plug['customURI'] ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/upgrade_now.png') ?>" title="<?php echo UPGRADE ?>" alt="<?php echo UPGRADE ?>" border="0" /></a>
|
||||
<?php } elseif ($plug['installable'] == true) { ?>
|
||||
<a href="?serendipity[adminModule]=plugins&serendipity[pluginPath]=<?php echo $plug['pluginPath']; ?>&serendipity[install_plugin]=<?php echo $plug['plugin_class'] . $plug['customURI'] ?>"><img src="<?php echo $installimage ?>" title="<?php echo INSTALL ?>" alt="<?php echo INSTALL ?>" border="0" /></a>
|
||||
<?php } else { ?>
|
||||
<span style="color: #cccccc"><?php echo ALREADY_INSTALLED ?></span>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 10px"><?php echo $plug['description'] ?></td>
|
||||
</tr>
|
||||
<?php if (count($pluginInfo) > 0) { ?>
|
||||
<tr>
|
||||
<td style="padding-left: 10px; font-size: x-small"><?php echo implode('; ', $pluginInfo); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="2" align="right"><?php printf(PLUGIN_AVAILABLE_COUNT, count($pluginstack)); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
/* show general plugin list */
|
||||
|
||||
/* preparse Javascript-generated input */
|
||||
if (isset($_POST['SAVE']) && !empty($_POST['serendipity']['pluginorder'])) {
|
||||
$parts = explode(':', $_POST['serendipity']['pluginorder']);
|
||||
$col_assoc = array(
|
||||
'left_col' => 'left',
|
||||
'right_col' => 'right',
|
||||
'hide_col' => 'hide',
|
||||
'event_col' => 'event',
|
||||
'eventh_col' => 'eventh'
|
||||
);
|
||||
foreach($parts AS $sidepart) {
|
||||
preg_match('@^(.+)\((.*)\)$@imsU', $sidepart, $matches);
|
||||
if (!isset($col_assoc[$matches[1]])) {
|
||||
continue;
|
||||
}
|
||||
$pluginsidelist = explode(',', $matches[2]);
|
||||
foreach($pluginsidelist AS $pluginname) {
|
||||
$pluginname = trim(urldecode(str_replace(array('s9ycid', '-'), array('', '%'), $pluginname)));
|
||||
|
||||
if (empty($pluginname)) {
|
||||
continue;
|
||||
}
|
||||
$serendipity['POST']['placement'][$pluginname] = $col_assoc[$matches[1]];
|
||||
$new_order[] = $pluginname;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($new_order)) {
|
||||
foreach($new_order AS $new_order_pos => $order_plugin) {
|
||||
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = ". (int)$new_order_pos . " WHERE name='" . serendipity_db_escape_string($order_plugin) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['SAVE']) && isset($_POST['serendipity']['placement']) && serendipity_checkFormToken()) {
|
||||
foreach ($_POST['serendipity']['placement'] as $plugin_name => $placement) {
|
||||
serendipity_plugin_api::update_plugin_placement(
|
||||
addslashes($plugin_name),
|
||||
addslashes($placement)
|
||||
);
|
||||
|
||||
serendipity_plugin_api::update_plugin_owner(
|
||||
addslashes($plugin_name),
|
||||
addslashes($_POST['serendipity']['ownership'][$plugin_name])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($serendipity['GET']['install_plugin'])) {
|
||||
$authorid = $serendipity['authorid'];
|
||||
if (serendipity_checkPermission('adminPluginsMaintainOthers')) {
|
||||
$authorid = '0';
|
||||
}
|
||||
|
||||
$fetchplugin_data = array('GET' => &$serendipity['GET'],
|
||||
'install' => true);
|
||||
serendipity_plugin_api::hook_event('backend_plugins_fetchplugin', $fetchplugin_data);
|
||||
|
||||
if ($fetchplugin_data['install']) {
|
||||
$serendipity['debug']['pluginload'] = array();
|
||||
$inst = serendipity_plugin_api::create_plugin_instance($serendipity['GET']['install_plugin'], null, (serendipity_plugin_api::is_event_plugin($serendipity['GET']['install_plugin']) ? 'event': 'right'), $authorid, serendipity_db_escape_string($serendipity['GET']['pluginPath']));
|
||||
|
||||
/* Load the new plugin */
|
||||
$plugin = &serendipity_plugin_api::load_plugin($inst);
|
||||
if (!is_object($plugin)) {
|
||||
echo "DEBUG: Plugin $inst not an object: " . print_r($plugin, true) . ".<br />Input: " . print_r($serendipity['GET'], true) . ".<br /><br />\n\nPlease report this bug. This error can happen if a plugin was not properly downloaded (check your plugins directory if the requested plugin was downloaded) or the inclusion of a file failed (permissions?)<br />\n";
|
||||
echo "Backtrace:<br />\n" . implode("<br />\n", $serendipity['debug']['pluginload']) . "<br />";
|
||||
}
|
||||
$bag = new serendipity_property_bag;
|
||||
$plugin->introspect($bag);
|
||||
|
||||
if ($bag->is_set('configuration')) {
|
||||
/* Only play with the plugin if there is something to play with */
|
||||
echo '<script type="text/javascript">location.href = \'' . $serendipity['baseurl'] . '?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $inst . '\';</script>';
|
||||
die();
|
||||
} else {
|
||||
/* If no config is available, redirect to plugin overview, because we do not want that a user can install the plugin a second time via accidental browser refresh */
|
||||
echo '<script type="text/javascript">location.href = \'' . $serendipity['baseurl'] . '?serendipity[adminModule]=plugins\';</script>';
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['REMOVE']) && serendipity_checkFormToken()) {
|
||||
if (is_array($_POST['serendipity']['plugin_to_remove'])) {
|
||||
foreach ($_POST['serendipity']['plugin_to_remove'] as $key) {
|
||||
$plugin =& serendipity_plugin_api::load_plugin($key);
|
||||
|
||||
if ($plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers')) {
|
||||
serendipity_plugin_api::remove_plugin_instance($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if (isset($_POST['SAVE'])) { ?>
|
||||
<div class="serendipityAdminMsgSuccess"><?php echo DONE .': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')); ?></div>
|
||||
<?php } ?>
|
||||
|
||||
<div><?php echo BELOW_IS_A_LIST_OF_INSTALLED_PLUGINS ?></div>
|
||||
<?php
|
||||
if (!isset($serendipity['eyecandy']) || serendipity_db_bool($serendipity['eyecandy'])) {
|
||||
echo '<script src="bundled-libs/dragdrop.js" type="text/javascript"></script>';
|
||||
echo '<div class="warning js_warning"><em>' . PREFERENCE_USE_JS_WARNING . '</em></div>';
|
||||
}
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_pluginlisting_header', $serendipity['eyecandy']);
|
||||
?>
|
||||
<br />
|
||||
|
||||
<h3><?php echo SIDEBAR_PLUGINS ?></h3>
|
||||
<a href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/install.png') ?>" style="border: 0px none ; vertical-align: middle; display: inline;" alt="" /><?php echo sprintf(CLICK_HERE_TO_INSTALL_PLUGIN, SIDEBAR_PLUGIN) ?></a>
|
||||
<?php serendipity_plugin_api::hook_event('backend_plugins_sidebar_header', $serendipity); ?>
|
||||
<?php show_plugins(false); ?>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<h3><?php echo EVENT_PLUGINS ?></h3>
|
||||
<a href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[type]=event" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/install.png') ?>" style="border: 0px none ; vertical-align: middle; display: inline;" alt="" /><?php echo sprintf(CLICK_HERE_TO_INSTALL_PLUGIN, EVENT_PLUGIN) ?></a>
|
||||
<?php serendipity_plugin_api::hook_event('backend_plugins_event_header', $serendipity); ?>
|
||||
<?php show_plugins(true); ?>
|
||||
|
||||
<?php
|
||||
}
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
182
include/admin/templates.inc.php
Normal file
182
include/admin/templates.inc.php
Normal file
@ -0,0 +1,182 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('adminTemplates')) {
|
||||
return;
|
||||
}
|
||||
|
||||
class template_option {
|
||||
var $config = null;
|
||||
var $values = null;
|
||||
var $keys = null;
|
||||
|
||||
function introspect_config_item($item, &$bag) {
|
||||
foreach($this->config[$item] AS $key => $val) {
|
||||
$bag->add($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
function get_config($item) {
|
||||
return $this->values[$item];
|
||||
}
|
||||
|
||||
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) . "'");
|
||||
serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}options (okey, name, value)
|
||||
VALUES ('t_" . serendipity_db_escape_string($serendipity['template']) . "', '" . serendipity_db_escape_string($item) . "', '" . serendipity_db_escape_string($value) . "')");
|
||||
return true;
|
||||
}
|
||||
|
||||
function import(&$config) {
|
||||
foreach($config AS $key => $item) {
|
||||
$this->config[$item['var']] = $item;
|
||||
$this->keys[$item['var']] = $item['var'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($serendipity['GET']['adminAction'] == 'install' ) {
|
||||
serendipity_plugin_api::hook_event('backend_templates_fetchtemplate', $serendipity);
|
||||
|
||||
$themeInfo = serendipity_fetchTemplateInfo($serendipity['GET']['theme']);
|
||||
|
||||
serendipity_set_config_var('template', $serendipity['GET']['theme']);
|
||||
serendipity_set_config_var('template_engine', isset($themeInfo['engine']) ? $themeInfo['engine'] : 'default');
|
||||
|
||||
echo '<div class="serendipityAdminMsgSuccess">'. sprintf(TEMPLATE_SET, $serendipity['GET']['theme']) .'</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( @file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] .'/layout.php') ) {
|
||||
echo '<div class="serendipityAdminMsgNote">'. WARNING_TEMPLATE_DEPRECATED .'</div>';
|
||||
}
|
||||
|
||||
echo '<h3>' . STYLE_OPTIONS . '</h3>';
|
||||
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php')) {
|
||||
serendipity_smarty_init();
|
||||
include_once $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php';
|
||||
}
|
||||
|
||||
if (is_array($template_config)) {
|
||||
if ($serendipity['POST']['adminAction'] == 'configure') {
|
||||
foreach($serendipity['POST']['template'] AS $option => $value) {
|
||||
template_option::set_config($option, $value);
|
||||
}
|
||||
echo '<div class="serendipityAdminMsgSuccess">' . DONE .': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>';
|
||||
}
|
||||
|
||||
echo '<form method="post" action="serendipity_admin.php">';
|
||||
echo '<input type="hidden" name="serendipity[adminModule]" value="templates" />';
|
||||
echo '<input type="hidden" name="serendipity[adminAction]" value="configure" />';
|
||||
|
||||
include 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;
|
||||
|
||||
serendipity_plugin_config(
|
||||
$template_options,
|
||||
$template_vars,
|
||||
$serendipity['template'],
|
||||
$serendipity['template'],
|
||||
$template_options->keys,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'template'
|
||||
);
|
||||
echo '</form><br />';
|
||||
} else {
|
||||
echo '<p>' . STYLE_OPTIONS_NONE . '</p>';
|
||||
}
|
||||
|
||||
echo '<h3>' . SELECT_TEMPLATE . '</h3>';
|
||||
?>
|
||||
<br /><br />
|
||||
<?php
|
||||
$i = 0;
|
||||
$stack = array();
|
||||
serendipity_plugin_api::hook_event('backend_templates_fetchlist', $stack);
|
||||
$themes = serendipity_fetchTemplates();
|
||||
foreach($themes AS $theme) {
|
||||
$stack[$theme] = serendipity_fetchTemplateInfo($theme);
|
||||
}
|
||||
ksort($stack);
|
||||
|
||||
foreach ($stack as $theme => $info) {
|
||||
$i++;
|
||||
|
||||
/* Sorry, but we don't display engines */
|
||||
if ( strtolower($info['engine']) == 'yes' ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/preview.png')) {
|
||||
$preview = '<img src="' . $serendipity['templatePath'] . $theme . '/preview.png" width="100" style="border: 1px #000000 solid" />';
|
||||
} elseif (!empty($info['previewURL'])) {
|
||||
$preview = '<img src="' . $info['previewURL'] . '" width="100" style="border: 1px #000000 solid" />';
|
||||
} else {
|
||||
$preview = ' ';
|
||||
}
|
||||
|
||||
if (empty($info['customURI'])) {
|
||||
$info['customURI'] = '';
|
||||
}
|
||||
|
||||
$unmetRequirements = array();
|
||||
if ( isset($info['require serendipity']) && version_compare($info['require serendipity'], serendipity_getCoreVersion($serendipity['version']), '>') ) {
|
||||
$unmetRequirements[] = 'Serendipity '. $info['require serendipity'];
|
||||
}
|
||||
|
||||
/* TODO: Smarty versioncheck */
|
||||
|
||||
$class = (($i % 2) ? 'even' : 'uneven');
|
||||
|
||||
?>
|
||||
<div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo $class ?>">
|
||||
<table width="100%" id="serendipity_theme_<?php echo $theme; ?>">
|
||||
<tr>
|
||||
<td colspan="2"><strong><?php echo $info['name']; ?></strong></td>
|
||||
<td valign="middle" align="center" width="70" rowspan="2">
|
||||
<?php
|
||||
if ( $serendipity['template'] != $theme ) {
|
||||
if ( !sizeof($unmetRequirements) ) {
|
||||
?>
|
||||
<a href="?serendipity[adminModule]=templates&serendipity[adminAction]=install&serendipity[theme]=<?php echo $theme . $info['customURI']; ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/install_now' . $info['customIcon'] . '.png') ?>" alt="<?php echo SET_AS_TEMPLATE ?>" title="<?php echo SET_AS_TEMPLATE ?>" border="0" /></a>
|
||||
<?php } else { ?>
|
||||
<span style="color: #cccccc"><?php echo sprintf(UNMET_REQUIREMENTS, implode(', ', $unmetRequirements)); ?></span>
|
||||
<?php
|
||||
}
|
||||
} ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width="100" style="padding-left: 10px"><?php echo $preview; ?></td>
|
||||
<td valign="top">
|
||||
<?php echo AUTHOR; ?>: <?php echo $info['author'];?><br />
|
||||
<?php echo LAST_UPDATED; ?>: <?php echo $info['date']; ?><br />
|
||||
<?php echo CUSTOM_ADMIN_INTERFACE; ?>: <?php echo $info['custom_admin_interface']; ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
361
include/admin/upgrader.inc.php
Normal file
361
include/admin/upgrader.inc.php
Normal file
@ -0,0 +1,361 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ('Don\'t hack!');
|
||||
}
|
||||
|
||||
require_once(S9Y_INCLUDE_PATH . 'include/functions_installer.inc.php');
|
||||
require_once(S9Y_INCLUDE_PATH . 'include/functions_upgrader.inc.php');
|
||||
|
||||
define('S9Y_U_ERROR', -1);
|
||||
define('S9Y_U_WARNING', 0);
|
||||
define('S9Y_U_SUCCESS', 1);
|
||||
|
||||
/**
|
||||
* Checks a return code constant if it's successfull or an error and return HTML code
|
||||
*
|
||||
* The diagnosis checks return codes of several PHP checks. Depending
|
||||
* on the input, a specially formatted string is returned.
|
||||
*
|
||||
* @access public
|
||||
* @param int Return code
|
||||
* @param string String to return wrapped in special HTML markup
|
||||
* @return string returned String
|
||||
*/
|
||||
function serendipity_upgraderResultDiagnose($result, $s) {
|
||||
global $errorCount;
|
||||
|
||||
if ( $result === S9Y_U_SUCCESS ) {
|
||||
return '<span style="color: green; font-weight: bold">'. $s .'</span>';
|
||||
}
|
||||
|
||||
if ( $result === S9Y_U_WARNING ) {
|
||||
return '<span style="color: orange; font-weight: bold">'. $s .'</span>';
|
||||
}
|
||||
|
||||
if ( $result === S9Y_U_ERROR ) {
|
||||
$errorCount++;
|
||||
return '<span style="color: red; font-weight: bold">'. $s .'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
// Setting this value to 'FALSE' is recommended only for SHARED BLOG INSTALLATIONS. This enforces all shared blogs with a common
|
||||
// codebase to only allow upgrading, no bypassing and thus causing instabilities.
|
||||
// This variable can also be set as $serendipity['UpgraderShowAbort'] inside serendipity_config_local.inc.php to prevent
|
||||
// your setting being changed when updating serendipity in first place.
|
||||
$showAbort = (isset($serendipity['UpgraderShowAbort']) ? $serendipity['UpgraderShowAbort'] : true);
|
||||
|
||||
$abortLoc = $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[action]=ignore';
|
||||
$upgradeLoc = $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[action]=upgrade';
|
||||
|
||||
/* Functions which needs to be run if installed version is equal or lower */
|
||||
$tasks = array(array('version' => '0.5.1',
|
||||
'function' => 'serendipity_syncThumbs',
|
||||
'title' => 'Image Sync',
|
||||
'desc' => 'Version 0.5.1 introduces image sync with the database'. "\n" .
|
||||
'With your permission I would like to perform the image sync'),
|
||||
|
||||
array('version' => '0.6.5',
|
||||
'function' => 'serendipity_rebuildCategoryTree',
|
||||
'title' => 'Nested subcategories, post to multiple categories',
|
||||
'desc' => 'This update will update the categories table of your database and update the relations from entries to categories.'. "\n" .
|
||||
'This is a possibly dangerous task to perform, so <strong style="color: red">make sure you have a backup of your database!</strong>'),
|
||||
|
||||
array('version' => '0.6.8',
|
||||
'function' => 'serendipity_installFiles',
|
||||
'title' => 'Update of .htaccess file',
|
||||
'desc' => 'Changes were made to the .htaccess file, you need to regenerate it'),
|
||||
|
||||
array('version' => '0.6.10',
|
||||
'functon' => 'serendipity_installFiles',
|
||||
'title' => 'Update of .htaccess file',
|
||||
'desc' => 'Changes were made to the .htaccess file, you need to regenerate it'),
|
||||
|
||||
array('version' => '0.6.12',
|
||||
'function' => 'serendipity_installFiles',
|
||||
'title' => 'Update of .htaccess file',
|
||||
'desc' => 'Changes were made to the .htaccess file, you need to regenerate it'),
|
||||
|
||||
array('version' => '0.8-alpha3',
|
||||
'function' => 'serendipity_removeFiles',
|
||||
'title' => 'Removal of obsolete files',
|
||||
'arguments' => array($obsolete_files),
|
||||
'desc' => 'The directory structure has been reworked. The following files will be moved to a folder called "backup". If you made manual changes to those files, be sure to read the file docs/CHANGED_FILES to re-implement your changes.<br /><div style="font-size: x-small; margin: 15px">' . implode(', ', $obsolete_files) . '</div>'),
|
||||
|
||||
array('version' => '0.8-alpha4',
|
||||
'function' => 'serendipity_removeFiles',
|
||||
'title' => 'Removal of serendipity_entries.php',
|
||||
'arguments' => array(array('serendipity_entries.php')),
|
||||
'desc' => 'In order to implement the new administration, we have to remove the leftovers'),
|
||||
|
||||
array('version' => '0.8-alpha4',
|
||||
'function' => 'serendipity_installFiles',
|
||||
'title' => 'Update of .htaccess file',
|
||||
'desc' => 'In order to implement the new administration, changes were made to the .htaccess file, you need to regenerate it'),
|
||||
|
||||
array('version' => '0.8-alpha7',
|
||||
'function' => 'serendipity_removeObsoleteVars',
|
||||
'title' => 'Removal of obsolete configuration variables',
|
||||
'desc' => 'Because of the new configuration parsing methods, some database variables are now only stored in serendipity_config_local.inc.php. Those obsolete variables will be removed from the database'),
|
||||
|
||||
array('version' => '0.8-alpha8',
|
||||
'function' => array('serendipity_plugin_api', 'create_plugin_instance'),
|
||||
'arguments' => array('serendipity_event_browsercompatibility', null, 'event'),
|
||||
'title' => 'Plugin for Browser Compatibility',
|
||||
'desc' => 'Includes some CSS-behaviours and other functions to maximize browser compatibility'),
|
||||
|
||||
array('version' => '0.8-alpha9',
|
||||
'function' => 'serendipity_installFiles',
|
||||
'title' => 'Update of .htaccess file',
|
||||
'desc' => 'In order to implement author views, changes were made to the .htaccess file, you need to regenerate it'),
|
||||
|
||||
array('version' => '0.8-alpha11',
|
||||
'function' => 'serendipity_installFiles',
|
||||
'title' => 'Update of .htaccess file',
|
||||
'desc' => 'In order to implement URL rewrite improvement, changes were made to the .htaccess file, you need to regenerate it'),
|
||||
|
||||
array('version' => '0.8-alpha12',
|
||||
'type' => 'TEMPLATE_NOTICE',
|
||||
'function' => '',
|
||||
'title' => '<b>TEMPLATE_NOTICE:</b> The template file "entries.tpl" has changed.',
|
||||
'desc' => 'Authors can now have longer real names instead of only their loginnames. Those new fields need to be displayed in your Template, if you manually created one. Following variables were changes:
|
||||
<b>{$entry.username}</b> => <b>{$entry.author}</b>
|
||||
<b>{$entry.link_username}</b> => <b>{$entry.link_author}</b>
|
||||
Those variables have been replaced in all bundled templates and those in our additional_themes repository.
|
||||
' . serendipity_upgraderResultDiagnose(S9Y_U_WARNING, 'Manual user interaction is required! This can NOT be done automatically!')),
|
||||
|
||||
array('version' => '0.8-beta3',
|
||||
'function' => 'serendipity_fixPlugins',
|
||||
'arguments' => array('markup_column_names'),
|
||||
'title' => 'Configuration options of markup plugins',
|
||||
'desc' => 'Because of the latest multilingual improvements in Serendipity, the database key names for certain configuration directives only found in markup plugins need to be renamed.<br />'
|
||||
. 'This will be automatically handled by Serendipity for all internally bundled and external plugins. If you are using the external plugins "GeShi" and "Markdown", please make sure you will upgrade to their latest versions!<br />'
|
||||
. 'We also advise that you check the plugin configuration of all your markup plugins (like emoticate, nl2br, s9ymarkup, bbcode) and see if the settings you made are all properly migrated.'),
|
||||
|
||||
array('version' => '0.8-beta5',
|
||||
'function' => 'serendipity_smarty_purge',
|
||||
'title' => 'Clear Smarty compiled templates',
|
||||
'desc' => 'Smarty has been upgraded to its latest stable version, and we therefore need to purge all compiled templates and cache'),
|
||||
|
||||
array('version' => '0.9-alpha2',
|
||||
'function' => 'serendipity_buildPermalinks',
|
||||
'title' => 'Build permalink patterns',
|
||||
'desc' => 'This version introduces user-configurable Permalinks and needs to pre-cache the list of all permalinks to be later able to fetch the corresponding entries for a permalink.'),
|
||||
|
||||
array('version' => '0.9-alpha3',
|
||||
'function' => 'serendipity_addDefaultGroups',
|
||||
'title' => 'Introduce author groups',
|
||||
'desc' => 'This version introduces customizable user groups. Your existing users will be migrated into the new default groups.'),
|
||||
|
||||
);
|
||||
|
||||
/* Fetch SQL files which needs to be run */
|
||||
$dir = opendir(S9Y_INCLUDE_PATH . 'sql/');
|
||||
$tmpfiles = array();
|
||||
while (($file = readdir($dir)) !== false ) {
|
||||
if (preg_match('@db_update_(.*)_(.*)_(.*).sql@', $file, $res)) {
|
||||
list(, $verFrom, $verTo, $dbType) = $res;
|
||||
if (version_compare($verFrom, $serendipity['versionInstalled']) >= 0) {
|
||||
$tmpFiles[$verFrom][$dbType] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sqlfiles = array();
|
||||
if (is_array($tmpFiles)) {
|
||||
foreach ($tmpFiles as $version => $db) {
|
||||
if (array_key_exists($serendipity['dbType'], $db) === false ) {
|
||||
$sqlfiles[$version] = $db['mysql'];
|
||||
} else {
|
||||
$sqlfiles[$version] = $db[$serendipity['dbType']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@uksort($sqlfiles, "strnatcasecmp");
|
||||
|
||||
if ($serendipity['GET']['action'] == 'ignore') {
|
||||
/* Todo: Don't know what to put here? */
|
||||
|
||||
} elseif ($serendipity['GET']['action'] == 'upgrade') {
|
||||
|
||||
$errors = array();
|
||||
|
||||
/* Install SQL files */
|
||||
foreach ($sqlfiles as $sqlfile) {
|
||||
$sql = file_get_contents(S9Y_INCLUDE_PATH .'sql/'. $sqlfile);
|
||||
$sql = str_replace('{PREFIX}', $serendipity['dbPrefix'], $sql);
|
||||
preg_match_all("@(.*);@iUs", $sql, $res);
|
||||
foreach ($res[0] as $sql) {
|
||||
$r = serendipity_db_schema_import($sql);
|
||||
if (is_string($r)) {
|
||||
$errors[] = trim($r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Call functions */
|
||||
foreach ($tasks as $task) {
|
||||
if (!empty($task['function']) && version_compare($serendipity['versionInstalled'], $task['version'], '<') ) {
|
||||
if (is_callable($task['function'])) {
|
||||
echo sprintf('Calling %s ...<br />', (is_array($task['function']) ? $task['function'][0] . '::'. $task['function'][1] : $task['function']));;
|
||||
|
||||
if (empty($task['arguments'])) {
|
||||
call_user_func($task['function']);
|
||||
} else {
|
||||
call_user_func_array($task['function'], $task['arguments']);
|
||||
}
|
||||
} else {
|
||||
$errors[] = 'Unable to call '. $task['function'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($errors)) {
|
||||
echo DIAGNOSTIC_ERROR . '<br /><br />';
|
||||
echo '<span class="serendipityAdminMsgError">- ' . implode('<br />', $errors) . '</span><br /><br />';
|
||||
}
|
||||
|
||||
/* I don't care what you told me, I will always nuke Smarty cache */
|
||||
serendipity_smarty_purge();
|
||||
|
||||
}
|
||||
|
||||
if (($showAbort && $serendipity['GET']['action'] == 'ignore') || $serendipity['GET']['action'] == 'upgrade') {
|
||||
$privateVariables = array();
|
||||
if (isset($serendipity['UpgraderShowAbort'])) {
|
||||
$privateVariables['UpgraderShowAbort'] = $serendipity['UpgraderShowAbort'];
|
||||
}
|
||||
|
||||
$r = serendipity_updateLocalConfig(
|
||||
$serendipity['dbName'],
|
||||
$serendipity['dbPrefix'],
|
||||
$serendipity['dbHost'],
|
||||
$serendipity['dbUser'],
|
||||
$serendipity['dbPass'],
|
||||
$serendipity['dbType'],
|
||||
$serendipity['dbPersistent'],
|
||||
$privateVariables
|
||||
);
|
||||
|
||||
if ($serendipity['GET']['action'] == 'ignore') {
|
||||
echo SERENDIPITY_UPGRADER_YOU_HAVE_IGNORED;
|
||||
} elseif ($serendipity['GET']['action'] == 'upgrade') {
|
||||
printf('<div class="serendipityAdminMsgSuccess">'. SERENDIPITY_UPGRADER_NOW_UPGRADED .'</div>', $serendipity['version']);
|
||||
}
|
||||
echo '<br />';
|
||||
printf('<div align="center">'. SERENDIPITY_UPGRADER_RETURN_HERE .'</div>', '<a href="'. $serendipity['serendipityHTTPPath'] .'">', '</a>');
|
||||
$_SESSION['serendipityAuthedUser'] = false;
|
||||
@session_destroy();
|
||||
} else {
|
||||
echo '<h2>' . SERENDIPITY_UPGRADER_WELCOME . '</h2>';
|
||||
printf(SERENDIPITY_UPGRADER_PURPOSE . '<br />', $serendipity['versionInstalled']);
|
||||
printf(SERENDIPITY_UPGRADER_WHY . '.', $serendipity['version']);
|
||||
echo '<br />' . FIRST_WE_TAKE_A_LOOK . '.';
|
||||
?>
|
||||
<br /><br />
|
||||
<div align="center"><?php printf(ERRORS_ARE_DISPLAYED_IN, serendipity_upgraderResultDiagnose(S9Y_U_ERROR, RED), serendipity_upgraderResultDiagnose(S9Y_U_WARNING, YELLOW), serendipity_upgraderResultDiagnose(S9Y_U_SUCCESS, GREEN)); ?>.<br />
|
||||
<?php
|
||||
$errorCount = 0;
|
||||
$showWritableNote = false;
|
||||
$basedir = $serendipity['serendipityPath'];
|
||||
?>
|
||||
<div align="center">
|
||||
<table class="serendipity_admin_list_item serendipity_admin_list_item_even" width="90%" align="center">
|
||||
<tr>
|
||||
<td colspan="2" style="font-weight: bold"><?php echo PERMISSIONS ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $basedir ?></td>
|
||||
<td width="200"><?php
|
||||
if ( is_writable($basedir) ) {
|
||||
echo serendipity_upgraderResultDiagnose(S9Y_U_SUCCESS, WRITABLE);
|
||||
} else {
|
||||
echo serendipity_upgraderResultDiagnose(S9Y_U_ERROR, NOT_WRITABLE);
|
||||
$showWritableNote = true;
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $basedir . PATH_SMARTY_COMPILE?></td>
|
||||
<td width="200"><?php
|
||||
if ( is_writable($basedir . PATH_SMARTY_COMPILE) ) {
|
||||
echo serendipity_upgraderResultDiagnose(S9Y_U_SUCCESS, WRITABLE);
|
||||
} else {
|
||||
echo serendipity_upgraderResultDiagnose(S9Y_U_ERROR, NOT_WRITABLE);
|
||||
$showWritableNote = true;
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php if (is_dir($basedir . $serendipity['uploadHTTPPath'])) { ?>
|
||||
<tr>
|
||||
<td><?php echo $basedir . $serendipity['uploadHTTPPath']; ?></td>
|
||||
<td width="200"><?php
|
||||
if (is_writable($basedir . $serendipity['uploadHTTPPath'])) {
|
||||
echo serendipity_upgraderResultDiagnose(S9Y_U_SUCCESS, WRITABLE);
|
||||
} else {
|
||||
echo serendipity_upgraderResultDiagnose(S9Y_U_ERROR, NOT_WRITABLE);
|
||||
$showWritableNote = true;
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
<?php if ($showWritableNote === true) { ?>
|
||||
<div class="serendipityAdminMsgNote"><?php echo sprintf(PROBLEM_PERMISSIONS_HOWTO, 'chmod 1777') ?></div>
|
||||
<?php }
|
||||
|
||||
if ($errorCount > 0) { ?>
|
||||
<div align="center">
|
||||
<div class="serendipityAdminMsgError"><?php echo PROBLEM_DIAGNOSTIC ?></div>
|
||||
<h2><a href="serendipity_admin.php"><?php echo RECHECK_INSTALLATION ?></a></h2>
|
||||
</div>
|
||||
<?php }
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($errorCount < 1) {
|
||||
if (sizeof($sqlfiles) > 0) { ?>
|
||||
<br />
|
||||
<h3><?php printf(SERENDIPITY_UPGRADER_DATABASE_UPDATES, $serendipity['dbType']) ?>:</h3>
|
||||
<?php echo SERENDIPITY_UPGRADER_FOUND_SQL_FILES ?>:<br />
|
||||
<?php
|
||||
foreach ($sqlfiles as $sqlfile) {
|
||||
echo '<div style="padding-left: 5px"><strong>'. $sqlfile .'</strong></div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<br />
|
||||
|
||||
<h3><?php echo SERENDIPITY_UPGRADER_VERSION_SPECIFIC ?>:</h3>
|
||||
<?php
|
||||
$taskCount = 0;
|
||||
|
||||
foreach ( $tasks as $task ) {
|
||||
if (version_compare($serendipity['versionInstalled'], $task['version'], '<')) {
|
||||
echo '<div><strong>'. $task['version'] .' - '. $task['title'] .'</strong></div>';
|
||||
echo '<div style="padding-left: 5px">'. nl2br($task['desc']) .'</div><br />';
|
||||
$taskCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($taskCount == 0) {
|
||||
echo SERENDIPITY_UPGRADER_NO_VERSION_SPECIFIC;
|
||||
}
|
||||
?>
|
||||
|
||||
<br /><br />
|
||||
<hr noshade="noshade">
|
||||
<?php if ($taskCount > 0 || sizeof($sqlfiles) > 0) { ?>
|
||||
<strong><?php echo SERENDIPITY_UPGRADER_PROCEED_QUESTION ?></strong>
|
||||
<br /><br /><a href="<?php echo $upgradeLoc; ?>" class="serendipityPrettyButton"><?php echo SERENDIPITY_UPGRADER_PROCEED_DOIT ?></a> <?php if ($showAbort) { ?><a href="<?php echo $abortLoc; ?>" class="serendipityPrettyButton"><?php echo SERENDIPITY_UPGRADER_PROCEED_ABORT ?></a><?php } ?>
|
||||
<?php } else { ?>
|
||||
<strong><?php echo SERENDIPITY_UPGRADER_NO_UPGRADES ?></strong>
|
||||
<br /><br /><a href="<?php echo $upgradeLoc; ?>" class="serendipityPrettyButton"><?php echo SERENDIPITY_UPGRADER_CONSIDER_DONE ?></a>
|
||||
<?php }
|
||||
}
|
||||
}
|
307
include/admin/users.inc.php
Normal file
307
include/admin/users.inc.php
Normal file
@ -0,0 +1,307 @@
|
||||
<?php # $Id$
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ('Don\'t hack!');
|
||||
}
|
||||
|
||||
if (!serendipity_checkPermission('adminUsers')) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once(S9Y_INCLUDE_PATH . 'include/functions_installer.inc.php');
|
||||
|
||||
/* Delete a user */
|
||||
if (isset($_POST['DELETE_YES']) && serendipity_checkFormToken()) {
|
||||
$user = serendipity_fetchUsers($serendipity['POST']['user']);
|
||||
if (($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN && $user[0]['userlevel'] >= $serendipity['serendipityUserlevel']) || !serendipity_checkPermission('adminUsersDelete')) {
|
||||
echo '<div class="serendipityAdminMsgError">' . CREATE_NOT_AUTHORIZED . '</div>';
|
||||
} elseif ($_POST['userlevel'] > $serendipity['serendipityUserlevel']) {
|
||||
echo '<div class="serendipityAdminMsgError">' . CREATE_NOT_AUTHORIZED_USERLEVEL . '</div>';
|
||||
} else {
|
||||
$group_intersect = serendipity_intersectGroup($user[0]['authorid']);
|
||||
|
||||
if (serendipity_checkPermission('adminUsersMaintainOthers') ||
|
||||
(serendipity_checkPermission('adminUsersMaintainSame') && $group_intersect)) {
|
||||
serendipity_deleteAuthor($user[0]['authorid']);
|
||||
printf('<div class="serendipityAdminMsgSuccess">' . DELETED_USER . '</div>', $serendipity['POST']['user'], $user[0]['realname']);
|
||||
serendipity_plugin_api::hook_event('backend_users_delete', $user[0]);
|
||||
} else {
|
||||
echo '<div class="serendipityAdminMsgError">' . CREATE_NOT_AUTHORIZED_USERLEVEL . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Save new user */
|
||||
if (isset($_POST['SAVE_NEW']) && serendipity_checkFormToken()) {
|
||||
if (($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN && $_POST['userlevel'] >= $serendipity['serendipityUserlevel']) || !serendipity_checkPermission('adminUsersCreateNew')) {
|
||||
echo '<div class="serendipityAdminMsgError">' . CREATE_NOT_AUTHORIZED . '</div>';
|
||||
} else {
|
||||
$serendipity['POST']['user'] = serendipity_addAuthor($_POST['username'], $_POST['pass'], $_POST['realname'], $_POST['email'], $_POST['userlevel']);
|
||||
|
||||
$valid_groups = serendipity_getGroups($serendipity['authorid'], true);
|
||||
/* Save all the properties */
|
||||
$config = serendipity_parseTemplate(S9Y_CONFIG_USERTEMPLATE);
|
||||
foreach($config as $category) {
|
||||
foreach ($category['items'] as $item) {
|
||||
if (in_array('groups', $item['flags'])) {
|
||||
if (serendipity_checkPermission('adminUsersMaintainOthers')) {
|
||||
|
||||
// Void, no fixing neccessarry
|
||||
|
||||
} elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
|
||||
// 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)) {
|
||||
continue;
|
||||
} elseif ($groupval == 2 && in_array(3, $valid_groups)) {
|
||||
// Admin is allowed to assign users to chief editors
|
||||
continue;
|
||||
} elseif ($groupval == 1 && in_array(2, $valid_groups)) {
|
||||
// Chief is allowed to assign users to editors
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($_POST[$item['var']][$groupkey]);
|
||||
}
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($_POST[$item['var']]) < 1) {
|
||||
echo '<div class="serendipityAdminMsgError">' . WARNING_NO_GROUPS_SELECTED . '</div>';
|
||||
} else {
|
||||
serendipity_updateGroups($_POST[$item['var']], $serendipity['POST']['user'], false);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (serendipity_checkConfigItemFlags($item, 'local')) {
|
||||
serendipity_set_user_var($item['var'], $_POST[$item['var']], $serendipity['POST']['user'], ($serendipity['authorid'] == $serendipity['POST']['authorid'] ? true : false));
|
||||
}
|
||||
|
||||
if (serendipity_checkConfigItemFlags($item, 'configuration')) {
|
||||
serendipity_set_config_var($item['var'], $_POST[$item['var']], $serendipity['POST']['user']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_users_add', $serendipity['POST']['user']);
|
||||
printf('<div class="serendipityAdminMsgSuccess">' . CREATED_USER . '</div>', '#' . $serendipity['POST']['user'] . ', ' . $_POST['realname']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Edit a user */
|
||||
if (isset($_POST['SAVE_EDIT']) && serendipity_checkFormToken()) {
|
||||
$user = serendipity_fetchUsers($serendipity['POST']['user']);
|
||||
if (!serendipity_checkPermission('adminUsersMaintainOthers') && $user[0]['userlevel'] >= $serendipity['serendipityUserlevel']) {
|
||||
echo '<div class="serendipityAdminMsgError">' . CREATE_NOT_AUTHORIZED . '</div>';
|
||||
} elseif ($_POST['userlevel'] > $serendipity['serendipityUserlevel']) {
|
||||
echo '<div class="serendipityAdminMsgError">' . CREATE_NOT_AUTHORIZED_USERLEVEL . '</div>';
|
||||
} else {
|
||||
$valid_groups = serendipity_getGroups($serendipity['authorid'], true);
|
||||
$config = serendipity_parseTemplate(S9Y_CONFIG_USERTEMPLATE);
|
||||
foreach($config as $category) {
|
||||
foreach ($category['items'] as $item) {
|
||||
if (in_array('groups', $item['flags'])) {
|
||||
if (serendipity_checkPermission('adminUsersMaintainOthers')) {
|
||||
|
||||
// Void, no fixing neccessarry
|
||||
|
||||
} elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
|
||||
|
||||
// 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)) {
|
||||
continue;
|
||||
} elseif ($groupval == 2 && in_array(3, $valid_groups)) {
|
||||
// Admin is allowed to assign users to chief editors
|
||||
continue;
|
||||
} elseif ($groupval == 1 && in_array(2, $valid_groups)) {
|
||||
// Chief is allowed to assign users to editors
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($_POST[$item['var']][$groupkey]);
|
||||
}
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($_POST[$item['var']]) < 1) {
|
||||
echo '<div class="serendipityAdminMsgError">' . WARNING_NO_GROUPS_SELECTED . '</div>';
|
||||
} else {
|
||||
serendipity_updateGroups($_POST[$item['var']], $serendipity['POST']['user'], false);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (serendipity_checkConfigItemFlags($item, 'local')) {
|
||||
serendipity_set_user_var($item['var'], $_POST[$item['var']], $serendipity['POST']['user'], ($serendipity['authorid'] == $serendipity['POST']['user'] ? true : false));
|
||||
}
|
||||
|
||||
if (serendipity_checkConfigItemFlags($item, 'configuration')) {
|
||||
serendipity_set_config_var($item['var'], $_POST[$item['var']], $serendipity['POST']['user']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pl_data = array(
|
||||
'id' => $serendipity['POST']['authorid'],
|
||||
'authorid' => $serendipity['POST']['authorid'],
|
||||
'username' => $_POST['username'],
|
||||
'realname' => $_POST['realname'],
|
||||
'email' => $_POST['email']
|
||||
);
|
||||
serendipity_updatePermalink($pl_data, 'author');
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_users_edit', $pl_data);
|
||||
printf('<div class="serendipityAdminMsgSuccess">' . MODIFIED_USER . '</div>', $_POST['realname']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($serendipity['GET']['adminAction'] != 'delete') {
|
||||
?>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><strong><?php echo USER; ?></strong></td>
|
||||
<td width="100" align="center"><strong><?php echo USER_LEVEL ?></strong></td>
|
||||
<td width="200"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<?php
|
||||
if (serendipity_checkPermission('adminUsersMaintainOthers')) {
|
||||
$users = serendipity_fetchUsers('');
|
||||
} elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
|
||||
$users = serendipity_fetchUsers('', serendipity_getGroups($serendipity['authorid'], true));
|
||||
} else {
|
||||
$users = serendipity_fetchUsers($serendipity['authorid']);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
foreach($users as $user) {
|
||||
if ($user['userlevel'] < $serendipity['serendipityUserlevel'] || $user['authorid'] == $serendipity['authorid'] || $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN ) {
|
||||
if ( $user['userlevel'] >= USERLEVEL_ADMIN ) {
|
||||
$img = serendipity_getTemplateFile('admin/img/user_admin.png');
|
||||
} elseif ( $user['userlevel'] >= USERLEVEL_CHIEF ) {
|
||||
$img = serendipity_getTemplateFile('admin/img/user_chief.png');
|
||||
} else {
|
||||
$img = serendipity_getTemplateFile('admin/img/user_editor.png');
|
||||
}
|
||||
?>
|
||||
<div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo ($i++ % 2) ? 'even' : 'uneven' ?>">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<?php /* TODO: Add username to list once tom figures out how to fix uneven rowstyles */ ?>
|
||||
<td><img src="<?php echo $img ?>" alt="" style="border: 0px none ; vertical-align: bottom; display: inline;" /> <?php echo htmlspecialchars($user['realname']); ?></td>
|
||||
<td width="100" align="center"><?php echo $user['userlevel']; ?></td>
|
||||
<td width="200" align="right"> [<a href="?serendipity[adminModule]=users&serendipity[adminAction]=edit&serendipity[userid]=<?php echo $user['authorid'] ?>"><?php echo EDIT ?></a>]
|
||||
- [<a href="?serendipity[adminModule]=users&serendipity[adminAction]=delete&serendipity[userid]=<?php echo $user['authorid'] ?>"><?php echo DELETE ?></a>]</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</tr>
|
||||
<?php if ( !isset($_POST['NEW']) && serendipity_checkPermission('adminUsersCreateNew')) { ?>
|
||||
<tr>
|
||||
<td colspan="3" align="right">
|
||||
<form action="?serendipity[adminModule]=users" method="post">
|
||||
<input type="submit" name="NEW" value="<?php echo CREATE_NEW_USER; ?>" class="serendipityPrettyButton" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
if ( ($serendipity['GET']['adminAction'] == 'edit' && serendipity_checkPermission('adminUsersDelete')) || (isset($_POST['NEW']) && serendipity_checkPermission('adminUsersCreateNew')) ) {
|
||||
?>
|
||||
<br />
|
||||
<br />
|
||||
<hr noshade="noshade">
|
||||
<form action="?serendipity[adminModule]=users" method="post">
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<div>
|
||||
<h3>
|
||||
<?php
|
||||
if ($serendipity['GET']['adminAction'] == 'edit') {
|
||||
$user = serendipity_fetchUsers($serendipity['GET']['userid']);
|
||||
$group_intersect = serendipity_intersectGroup($user[0]['authorid']);
|
||||
|
||||
if ($user[0]['userlevel'] >= $serendipity['serendipityUserlevel'] && $user[0]['authorid'] != $serendipity['authorid'] && !serendipity_checkPermission('adminUsersMaintainOthers')) {
|
||||
echo '<strong>' . CREATE_NOT_AUTHORIZED . '</strong><br />';
|
||||
echo EDIT;
|
||||
$from = array();
|
||||
} elseif (serendipity_checkPermission('adminUsersMaintainOthers') ||
|
||||
(serendipity_checkPermission('adminUsersMaintainSame') && $group_intersect)) {
|
||||
echo EDIT;
|
||||
$from = &$user[0];
|
||||
unset($from['password']);
|
||||
echo '<input type="hidden" name="serendipity[user]" value="' . $from['authorid'] . '" />';
|
||||
} else {
|
||||
echo '<strong>' . CREATE_NOT_AUTHORIZED . '</strong><br />';
|
||||
echo EDIT;
|
||||
$from = array();
|
||||
}
|
||||
} else {
|
||||
echo CREATE;
|
||||
$from = array();
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
|
||||
<?php
|
||||
$config = serendipity_parseTemplate(S9Y_CONFIG_USERTEMPLATE);
|
||||
if (!empty($serendipity['GET']['userid'])) {
|
||||
$from['groups'] = serendipity_getGroups($serendipity['GET']['userid']);
|
||||
} else {
|
||||
$from['groups'] = array();
|
||||
}
|
||||
|
||||
serendipity_printConfigTemplate($config, $from, true, false);
|
||||
|
||||
if ($serendipity['GET']['adminAction'] == 'edit') { ?>
|
||||
<input type="submit" name="SAVE_EDIT" value="<?php echo SAVE; ?>" class="serendipityPrettyButton" />
|
||||
<?php } else { ?>
|
||||
<input type="submit" name="SAVE_NEW" value="<?php echo CREATE_NEW_USER; ?>" class="serendipityPrettyButton" />
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
} elseif ($serendipity['GET']['adminAction'] == 'delete' && serendipity_checkPermission('adminUsersDelete')) {
|
||||
$user = serendipity_fetchUsers($serendipity['GET']['userid']);
|
||||
$group_intersect = serendipity_intersectGroup($user[0]['authorid']);
|
||||
|
||||
if (serendipity_checkPermission('adminUsersMaintainOthers') ||
|
||||
(serendipity_checkPermission('adminUsersMaintainSame') && $group_intersect)) {
|
||||
?>
|
||||
<form action="?serendipity[adminModule]=users" method="post">
|
||||
<div>
|
||||
<?php printf(DELETE_USER, $serendipity['GET']['userid'], $user[0]['realname']); ?>
|
||||
<br /><br />
|
||||
<?php echo serendipity_setFormToken(); ?>
|
||||
<input type="hidden" name="serendipity[user]" value="<?php echo $serendipity['GET']['userid']; ?>" />
|
||||
<input type="submit" name="DELETE_YES" value="<?php echo DUMP_IT; ?>" class="serendipityPrettyButton" />
|
||||
<input type="submit" name="NO" value="<?php echo NOT_REALLY; ?>" class="serendipityPrettyButton" />
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
Reference in New Issue
Block a user