exported from svn

This commit is contained in:
Jeena 2013-10-07 14:46:08 +02:00
commit 03995d3bc6
85 changed files with 14765 additions and 0 deletions

149
scripts/JlogUpdater.php Normal file
View file

@ -0,0 +1,149 @@
<?php
class JlogUpdater
{
/**
* Existing versions of Jlog as array
* version -> next version in history
*
* @var array
*/
var $versions = array(
'1.0.2' => '1.1.0',
'1.1.0' => '1.1.1',
'1.1.1' => '1.1.2',
'1.1.2' => '1.1.3'
);
function JlogUpdater()
{
require_once(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."settings.class.php");
}
function getOldVersion()
{
return JLOG_INSTALLED_VERSION;
}
function getNewVersion()
{
return JLOG_SOFTWARE_VERSION;
}
function isUp2Date()
{
if (version_compare($this->getOldVersion(), $this->getNewVersion(), '<')) {
return false;
}
return true;
}
function prepareForm($l)
{
$html = '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post">'
. '<p>' . $l['admin']['e_admin_password'] . ': '
. '<input type="password" name="jlog_password" value="" />'
. '</p>';
$version = $this->getOldVersion();
while (isset($this->versions[$version])) {
$class = $this->_loadUpdateClass($version, $this->versions[$version]);
$html .= sprintf("<h2>Update <var>%s</var> &#x2192; <var>%s</var></h2>\n", $version, $this->versions[$version]);
$html .= $class->getForm($l);
$version = $this->versions[$version];
}
$html .= '<p><input type="submit" name="update" value="' . $l['admin']['update_start'] . '" /></p>';
$html .= '</form>';
return $html;
}
function performUpdate($l)
{
if (JLOG_AMDIN_PASSWORD !== md5($_POST['jlog_password']) and JLOG_ADMIN_PASSWORD !== md5(utf8_decode($_POST['jlog_password']))) {
return '<p>' . $l['admin']['login_false_pw'] . '</p>';
}
require_once(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."settings.class.php");
// read current settings from environment
$settings = new Settings($l);
$settings->importDataByConstants();
$error = false;
$html = '';
$version = $this->getOldVersion();
while (isset($this->versions[$version])) {
$class = $this->_loadUpdateClass($version, $this->versions[$version]);
$html .= sprintf("<h2>Update <var>%s</var> &#x2192; <var>%s</var></h2>\n", $version, $this->versions[$version]);
$result = $class->performUpdate($l, $settings);
if ($result === true) {
// we know that update class ran successfully
$result = $this->_updateVersionNumber($settings, $this->versions[$version]);
// check if errors occured
if (!empty($result)) {
$this->_renderErrors($result);
break;
}
else {
$html .= '<p>' . $l['admin']['update_successfull_part'] . '</p>';
}
}
else {
$html .= $this->_renderErrors($result);
break;
}
$version = $this->versions[$version];
}
if ($error) {
$html .= '<p>' . $l['admin']['update_failure'] . '</p>';
}
else {
$html .= '<p>' . $l['admin']['update_successfull'] . '</p>';
}
return $html;
}
function _getUpdateFile($oldver, $newver)
{
$oldver = str_replace('.', '', $oldver);
$newver = str_replace('.', '', $newver);
return "{$oldver}To{$newver}.php";
}
function _getUpdateClass($oldver, $newver)
{
$oldver = str_replace('.', '', $oldver);
$newver = str_replace('.', '', $newver);
return "JlogUpdate_{$oldver}To{$newver}";
}
function _loadUpdateClass($oldver, $newver)
{
$file = $this->_getUpdateFile($oldver, $newver);
$class = $this->_getUpdateClass($oldver, $newver);
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'update' . DIRECTORY_SEPARATOR . $file);
return new $class();
}
function _renderErrors($errors)
{
$html = '<ul class="error">';
foreach ($errors as $error) {
$html .= '<li>' . $error . '</li>';
}
$html .= '</ul>';
return $html;
}
function _updateVersionNumber($settings, $newver)
{
$settings->setValue('jlog_installed_version', $newver);
$settings->setValue('jlog_installed_url', JLOG_SOFTWARE_URL);
$settings->setValue('jlog_installed_phpv', JLOG_SOFTWARE_PHPV);
$settings->setValue('jlog_installed_mysqlv', JLOG_SOFTWARE_MYSQLV);
// rewrite settings.inc.php
return $settings->do_settings();
}
}
// eof

172
scripts/bbcode.php Normal file
View file

@ -0,0 +1,172 @@
<?php
require_once JLOG_BASEPATH.'/scripts/stringparser_bbcode.class.php';
// Zeilenumbrüche verschiedener Betriebsysteme vereinheitlichen
function convertlinebreaks ($text) {
return preg_replace ("/\015\012|\015|\012/", "\n", $text);
}
// Alles bis auf Neuezeile-Zeichen entfernen
function bbcode_stripcontents ($text) {
return preg_replace ("/[^\n]/", '', $text);
}
// Sonderzeichen behandeln
function special_character($text) {
return str_replace("&amp;#", "&#", $text);
}
function do_bbcode_url ($action, $attributes, $content, $params, $node_object) {
// get URL by parameters
$url = isset($attributes['default']) ? $attributes['default'] : $content;
// validate URL
if($action == 'validate') {
// Due to Bug #146 we will only allow specific protocolls in the url
// currently, these are: HTTP, FTP, News and Mailto - or relative URLs
// starting with a slash
if(preg_match('#^(http://|ftp://|news:|mailto:|/)#i', $url)) return true;
// Some people just write www.example.org, skipping the http://
// We're going to be gentle a prefix this link with the protocoll.
// However, example.org (without www) will not be recognized
elseif(substr($url, 0, 4) == 'www.') return true;
// all other links will be ignored
return true;
}
// generate link
else {
// prefix URL with http:// if the protocoll was skipped
if(substr($url, 0, 4) == 'www.') {
$url = 'http://' . $url;
}
// in case a relative url is given without a link text, we display
// the full URI as link text, not just the relative path
if(!isset($attributes['default']) AND substr($url, 0, 1) == '/') {
$content = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://')
. $_SERVER['HTTP_HOST']
. $url;
}
// build link
return '<a href="' . htmlspecialchars($url) . '">' . $content . '</a>';
}
}
// Funktion zum Einbinden von Bildern
function do_bbcode_img ($action, $attributes, $content, $params, $node_object) {
if ($action == 'validate') {
if (isset($attributes['caption'])) {
$node_object->setFlag('paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
if ($node_object->_parent->type() == STRINGPARSER_NODE_ROOT OR
in_array($node_object->_parent->_codeInfo['content_type'], array('block', 'list', 'listitem'))) {
return true;
}
else return false;
}
else return true;
}
$title = empty($attributes["title"]) ? "" : " title='".htmlspecialchars($attributes["title"])."'";
if (isset($attributes['class']) AND isset($attributes['caption'])) $class_caption = " class='img ".htmlspecialchars($attributes['class'])."'";
elseif (isset($attributes['class'])) $class = " class='".htmlspecialchars($attributes['class'])."'";
elseif (isset($attributes['caption'])) $class_caption = " class='img'"; // bugfix by Sebastian Kochendörfer #215
if (strpos($content, "http://") === 0) return "<img src='".htmlspecialchars($content)."'".$class." alt='".htmlspecialchars($attributes['alt'])."'".$title." />";
else {
list($img_width, $img_height, $img_type, $img_attr) = @getimagesize(JLOG_BASEPATH.'/img'.DIRECTORY_SEPARATOR.htmlspecialchars($content));
$img = "<img src='".JLOG_PATH."/img/".htmlspecialchars($content)."'".$class." alt='".htmlspecialchars($attributes['alt'])."' style='width: ".$img_width."px;'".$title." />";
}
if(isset($attributes['caption'])) {
return "\n<dl".$class_caption." style='width: ".$img_width."px;'>\n <dt>".$img."</dt>\n <dd>".htmlspecialchars($attributes['caption'])."</dd>\n</dl>\n";
}
else return $img;
}
// Funktion zum Einbinden von HTML Code, welcher vom Browser interpretiert wird
function do_bbcode_html($action, $attributes, $content, $params, $node_object) {
if ($action == 'validate') return true;
return $content;
}
$bbcode = new StringParser_BBCode ();
$bbcode->addFilter (STRINGPARSER_FILTER_PRE, 'convertlinebreaks');
$bbcode->addFilter (STRINGPARSER_FILTER_POST, 'special_character');
$bbcode->addParser (array ('block', 'inline', 'link', 'listitem'), 'htmlspecialchars');
$bbcode->addParser (array ('block', 'inline', 'link', 'listitem'), 'nl2br');
$bbcode->addParser ('list', 'bbcode_stripcontents');
$bbcode->setRootParagraphHandling (true);
$bbcode->addCode ('b', 'simple_replace', null, array ('start_tag' => '<strong>', 'end_tag' => '</strong>'),
'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('i', 'simple_replace', null, array ('start_tag' => '<em>', 'end_tag' => '</em>'),
'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('headline', 'simple_replace', null, array('start_tag' => '<h3>', 'end_tag' => '</h3>'),
'block', array('block'), array('inline', 'link'));
$bbcode->addCode ('quote', 'simple_replace', null, array('start_tag' => '<blockquote>', 'end_tag' => '</blockquote>'),
'block', array('block', 'listitem'), array('inline', 'link'));
$bbcode->addCode ('url', 'usecontent?', 'do_bbcode_url', array ('usecontent_param' => 'default'),
'link', array ('listitem', 'block', 'inline'), array ('link'));
$bbcode->addCode ('img', 'usecontent', 'do_bbcode_img', array (),
'image', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('html', 'usecontent', 'do_bbcode_html', array (),
'html', array ('listitem', 'block', 'inline', 'link'), array ('image'));
$bbcode->addCode ('list', 'simple_replace', null, array ('start_tag' => '<ul>', 'end_tag' => '</ul>'),
'list', array ('block', 'listitem'), array ());
$bbcode->addCode ('olist', 'simple_replace', null, array ('start_tag' => '<ol>', 'end_tag' => '</ol>'),
'list', array ('block', 'listitem'), array ());
$bbcode->addCode ('*', 'simple_replace', null, array ('start_tag' => '<li>', 'end_tag' => '</li>'),
'listitem', array ('list', 'olist' ), array ());
$bbcode->setCodeFlag ('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
$bbcode->setCodeFlag ('*', 'paragraphs', false);
$bbcode->setCodeFlag ('list', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
$bbcode->setCodeFlag ('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('list', 'closetag.after.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('olist', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
$bbcode->setCodeFlag ('olist', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('olist', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('headline', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
$bbcode->setCodeFlag ('headline', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('headline', 'closetag.after.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('html', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('html', 'closetag.after.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('quote', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
$bbcode->setCodeFlag ('quote', 'paragraphs', true);
$bbcode->setCodeFlag ('quote', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('quote', 'closetag.after.newline', BBCODE_NEWLINE_DROP);
// BBCode for comments
$bbcomments = new StringParser_BBCode ();
$bbcomments->addFilter (STRINGPARSER_FILTER_PRE, 'convertlinebreaks');
$bbcomments->addFilter (STRINGPARSER_FILTER_POST, 'special_character');
$bbcomments->addParser (array ('block', 'inline', 'link'), 'htmlspecialchars');
$bbcomments->addParser (array ('block', 'inline', 'link'), 'nl2br');
$bbcomments->setRootParagraphHandling (true);
$bbcomments->addCode ('b', 'simple_replace', null, array ('start_tag' => '<strong>', 'end_tag' => '</strong>'),
'inline', array ('block', 'inline', 'link'), array ());
$bbcomments->addCode ('i', 'simple_replace', null, array ('start_tag' => '<em>', 'end_tag' => '</em>'),
'inline', array ('block', 'inline', 'link'), array ());
$bbcomments->addCode ('url', 'usecontent?', 'do_bbcode_url', array ('usecontent_param' => 'default'),
'link', array ('block', 'inline'), array ('link'));
$bbcomments->addCode ('quote', 'simple_replace', null, array('start_tag' => '<blockquote>', 'end_tag' => '</blockquote>'),
'block', array('block'), array('inline', 'link'));
$bbcomments->setCodeFlag ('quote', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
$bbcomments->setCodeFlag ('quote', 'paragraphs', true);
$bbcomments->setCodeFlag ('quote', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
$bbcomments->setCodeFlag ('quote', 'closetag.after.newline', BBCODE_NEWLINE_DROP);
// eof

View file

@ -0,0 +1,250 @@
<?php
$categories = new Categories($l);
class Categories {
var $categories = array();
var $l = array();
function Categories($l) {
$this->l = $l;
$this->get_categories();
}
function get($id, $data) {
return $this->categories[$id][$data];
}
function get_id($url) {
foreach($this->categories AS $cat) {
if($cat['url'] == $url) return $cat['id'];
}
}
function get_categories() {
if(!defined("JLOG_UPDATE") AND !defined("JLOG_LOGIN")) {
$sql = "SELECT id, name, url, description FROM ".JLOG_DB_CATEGORIES;
$cat = new Query($sql);
if($cat->error()) {
echo "<pre>\n";
echo $cat->getError();
echo "</pre>\n";
die();
}
while($c = $cat->fetch()) {
$this->categories[$c['id']] =
array('id' => $c['id'], 'name' => $c['name'], 'url' => $c['url'], 'description' => $c['description'] );
}
}
}
function get_assigned_categories($id) {
$sql = "SELECT cat_id FROM ".JLOG_DB_CATASSIGN." WHERE content_id = '".$id."'";
$assigned = new Query($sql);
if($assigned->error()) {
echo "<pre>\n";
echo $assigned->getError();
echo "</pre>\n";
die();
}
$ids = array();
while($a = $assigned->fetch()) {
$ids[] = $a['cat_id'];
}
return $ids;
}
function output_select($catassign) {
// $catassign is an array which contains all assigned ids
if(count($this->categories) > 0) {
$output = " <p><label for='categories'>".$this->l['admin']['categories']."</label><br />\n"
." <select id='categories' name='categories[]' size='4' multiple='multiple'>\n"
." <option value='no_categories'>".$this->l['admin']['no_categories']."</option>\n";
foreach($this->categories AS $id => $data) {
if(is_array($catassign)) if(in_array($id, $catassign)) $selected = " selected='selected'";
else unset($selected);
$output .= " <option".$selected." value='".$id."'>".$data['name']."</option>\n";
}
$output .= " </select>\n </p>";
return $output;
}
}
function output_rss($id) {
$ids = $this->get_assigned_categories($id);
if(is_array($ids)) {
foreach($ids AS $i) {
$output .= " <category>".$this->get($i, 'name')."</category>\n";
}
}
return $output;
}
function output_assigned_links($ids) {
if(!is_array($ids)) $ids = $this->get_assigned_categories($ids);
if(is_array($ids)) {
foreach($ids as $id) {
$output .= $this->link($id)." ";
}
}
if(isset($output)) return " <span title='".$this->l['content_cat_linklist']."' class='catlinklist'>&raquo; ".$output."</span>";
}
function output_whole_list($_before = " <ul id='categorieslist'>\n", $_after = " </ul>\n", $before = " <li>", $after = "</li>\n") {
if(is_array($this->categories) AND count($this->categories)) {
$output = $_before;
foreach($this->categories AS $id => $tmp) {
$output .= $before.$this->link($id).$after;
}
$output .= $_after;
return $output;
}
else return false;
}
function link($id) {
if(JLOG_CLEAN_URL) return "<a title='".$this->l['content_cat_link']."' href='".JLOG_PATH."/cat/".$this->categories[$id]['url']."/'>".$this->categories[$id]['name']."</a>";
else return "<a title='".$this->l['content_cat_link']."' href='".JLOG_PATH."/archive.php?cat=".$this->categories[$id]['url']."'>".$this->categories[$id]['name']."</a>";
}
function output_whole_list_admin() {
$output = "
<table>
<tr>
<th>".$this->l['admin']['change']."</th>
<th>".$this->l['admin']['delete']."</th>
<th>".$this->l['admin']['cat_name']."</th>
</tr>";
foreach($this->categories AS $id => $tmp) {
$output .= "
<tr>
<td><a href='".add_session_id_to_url("?action=change&amp;id=".$id)."'><img src='".JLOG_PATH."/img/JLOG_edit.png' alt='".$this->l['admin']['change']."' /></a></td>
<td><a href='".add_session_id_to_url("?action=trash&amp;id=".$id)."'><img src='".JLOG_PATH."/img/JLOG_trash.png' alt='".$this->l['admin']['delete']."' /></a></td>
<td>".$this->link($id)."</td>
</tr>\n";
}
$output .= " </table>\n";
return $output;
}
function output_form($form_input = "", $action = 'new', $legend) {
$output = "
<form id='entryform' action='?action=".$action."' method='POST'>
<fieldset><legend>".$legend."</legend>
<p><label for='name'>".$this->l['admin']['cat_name']."</label><br />
<input id='name' name='name' class='long' maxlength='255' size='60' type='text' value='".$form_input['name']."' /></p>
<p><label for='url'>".$this->l['admin']['cat_url']."</label><br />
<input id='url' name='url' class='long' maxlength='100' size='60' type='text' value='".$form_input['url']."' />
<input name='id' type='hidden' value='".$form_input['id']."' /></p>
<p><label for='description'>".$this->l['admin']['cat_description']."</label><br />
<textarea id='description' name='description' class='short'>".$form_input['description']."</textarea></p>
<p><input type='submit' name='form_submit' value='".$this->l['admin']['submit']."' />
<a href='".add_session_id_to_url("categories.php")."'>".$this->l['admin']['cancel']."</a>
".add_session_id_input_tag()."</p>
</fieldset>
</form>";
return $output;
}
function new_cat($form_input) {
$form_input = escape_for_mysql($form_input);
$sql = "INSERT INTO ".JLOG_DB_CATEGORIES." (name, url, description) VALUES
('".$form_input['name']."',
'".$form_input['url']."',
'".$form_input['description']."');";
$new = new Query($sql);
if($new->error()) {
echo "<pre>\n";
echo $new->getError();
echo "</pre>\n";
die();
}
}
function change_cat($form_input) {
$form_input = escape_for_mysql($form_input);
$sql = "UPDATE ".JLOG_DB_CATEGORIES."
SET
name = '".$form_input['name']."',
url = '".$form_input['url']."',
description = '".$form_input['description']."'
WHERE
id = '".$form_input['id']."' LIMIT 1;";
$change = new Query($sql);
if($change->error()) {
echo "<pre>\n";
echo $change->getError();
echo "</pre>\n";
die();
}
}
function trash_cat($id) {
$sql = "DELETE FROM ".JLOG_DB_CATEGORIES." WHERE id = '".escape_for_mysql($id)."' LIMIT 1";
$trash = new Query($sql);
if($trash->error()) {
echo "<pre>\n";
echo $trash->getError();
echo "</pre>\n";
die();
}
$sql = "DELETE FROM ".JLOG_DB_CATASSIGN." WHERE cat_id = '".escape_for_mysql($id)."' LIMIT 1";
$trash = new Query($sql);
if($trash->error()) {
echo "<pre>\n";
echo $trash->getError();
echo "</pre>\n";
die();
}
}
function validate($form_input) {
if(empty($form_input['name'])) $errors[] = $this->l['admin']['cat_noname'];
if(empty($form_input['url'])) $errors[] = $this->l['admin']['no_url'];
elseif(!preg_match("/^[a-z0-9\-_\.,]+$/", $form_input['url'])) $errors[] = $this->l['admin']['false_url_letters'];
else {
$sql = "SELECT id FROM ".JLOG_DB_CATEGORIES." WHERE url = '".escape_for_mysql($form_input['url'])."';";
$check_url = new Query($sql);
if($check_url->error()) {
echo "<pre>\n";
echo $check_url->getError();
echo "</pre>\n";
die();
}
if($check_url->numRows() > 0) {
$c = $check_url->fetch();
if($c['id'] != $form_input['id']) $errors[] = $this->l['admin']['cat_duplicate'];
}
}
return $errors;
}
}
?>

141
scripts/comments.php Normal file
View file

@ -0,0 +1,141 @@
<?php
function com_form_output($com_form) {
$com_form = array_htmlspecialchars($com_form);
global $l, $plugins;
if(!isset($com_form['content'])) $com_form['content'] = "";
$output = "
<form method='post' action='#entryform' id='entryform'>
<fieldset><legend>".$l['comments_entryform']."</legend>
<p class='xmp'>
<span>".$l['comments_bbcode']."
<a onclick=\"jlog_learnbb('".JLOG_PATH."'); return false;\" href='".JLOG_PATH."/learn_bb.php'>BBcode</a>?
</span>
<br id='bbcode' />
<textarea rows='8' cols='30' name='content'>".$com_form['content']."</textarea>
</p>
<p>
<input class='userdata' type='text' name='name' value='".$com_form['name']."'
onfocus=\"if(this.value &amp;&amp; this.value=='".$l['comments_name']."')this.value=''\"
onblur=\"if(this.value=='') this.value='".$l['comments_name']."'\" />
<input class='userdata' type='text' name='city' value='".$com_form['city']."'
onfocus=\"if(this.value &amp;&amp; this.value=='".$l['comments_city']."')this.value=''\"
onblur=\"if(this.value=='') this.value='".$l['comments_city']."'\" /><br />
<input class='userdata' type='text' name='email' value='".$com_form['email']."'
onfocus=\"if(this.value &amp;&amp; this.value=='".$l['comments_email']."')this.value=''\"
onblur=\"if(this.value=='') this.value='".$l['comments_email']."'\" />
<input class='userdata' type='text' name='homepage' value='".$com_form['homepage']."' />
</p>
<p class='checkbox'>
<input type='checkbox' id='mail_by_comment' name='mail_by_comment' ";
if(isset($com_form['mail_by_comment']) AND $com_form['mail_by_comment'] == 1) $output .= "checked='checked'";
$output .= " value='1' /> <label for='mail_by_comment'>".$l['comments_mail_by_comment']."</label>&nbsp;";
if(defined('JLOG_ADMIN')) $output .= "\n <input type='hidden' value='".$com_form['id']."' name='id' />\n";
else {
$output .= " <input type='checkbox' id='cookie' name='cookie' ";
if(isset($com_form['cookie']) AND $com_form['cookie'] == 1) $output .= "checked='checked'";
$output .= " value='1' /> <label for='cookie'>".$l['comments_save_data']."</label>\n";
}
$output .= " <input type='hidden' value='".$com_form['sid']."' name='sid' />
</p>
<p>
<input class='send' type='submit' name='form_submitted' value='".$l['comments_preview']."' onclick=\"this.form.action = '#preview'\" />
<input class='send' type='submit' name='form_submitted' value='".$l['comments_send']."' />";
if(defined("JLOG_ADMIN")) $output .= add_session_id_input_tag();
$output .= "
</p>
</fieldset>
</form>\n
";
### Plugin Hook
$output = $plugins->callHook('commentForm', $output, $com_form);
return $output;
}
function com_javascript_variables() {
global $l;
return "
<script type='text/javascript'>
jlog_l_comments_show = '".$l['comments_show']."';
jlog_l_comments_hide = '".$l['comments_hide']."';
jlog_l_comments_bold = '".$l['comments_bold']."';
jlog_l_comments_italic = '".$l['comments_italic']."';
jlog_l_comments_quote = '".$l['comments_quote']."';
jlog_l_comments_url = '".$l['comments_url']."';
jlog_l_comments_plz_format_txt = '".$l['comments_plz_format_txt']."';
jlog_l_comments_url_href = '".$l['comments_url_href']."';
jlog_l_comments_url_node = '".$l['comments_url_node']."';
</script>
";
}
function com_check_errors($com_form) {
global $l;
if(empty($com_form['sid'])) $errors[] = $l['comments_no_sid'];
if(isset($com_form['email']) AND $com_form['email'] != "" AND !preg_match("/^[^@]+@.+\.\D{2,6}$/", $com_form['email']) AND $com_form['email'] != $l['comments_email']) $errors[] = $l['comments_false_mail'];
if(empty($com_form['content'])) $errors[] = $l['comments_notext'];
if(isset($errors)) return $errors;
}
function com_clean_data($data) {
global $l;
if(empty($data['name']) OR $data['name'] == $l['comments_name']) $data['name'] = "";
if(empty($data['city']) OR $data['city'] == $l['comments_city']) $data['city'] = "";
if(empty($data['email']) OR $data['email'] == $l['comments_email']) $data['email'] = "";
if(empty($data['homepage']) OR $data['homepage'] == $l['comments_homepage']) $data['homepage'] = "";
if(empty($data['date'])) $data['date'] = time();
return $data;
}
function set_cookie($data) {
$userdaten = array( $data['name'],
$data['city'],
$data['email'],
$data['homepage'] );
$cookielife = time() + 42 * 24 * 60 * 60;
$path = parse_url(JLOG_PATH);
if(!isset($path['path'])) $path['path'] = "";
setcookie("jlog_userdata", urlencode(serialize($userdaten)), $cookielife, $path['path']."/");
}
function trash_cookie() {
$cookielife = time() - 3600;
setcookie("jlog_userdata", '', $cookielife, "/");
}
function new_sid() {
list($usec, $sec) = explode(' ', microtime());
mt_srand((float) $sec + ((float) $usec * 100000));
return $_SERVER["REMOTE_ADDR"]."-".time()."-".mt_rand(1000,9999);
}
// Funcitons
function do_comment($data, $nr) {
global $l, $bbcomments, $plugins;
$meta = array_htmlspecialchars($data);
$comment = "
<li id='c".$data['id']."'>
<p class='meta'><a class='permalink' title='".$l['comments_permalink']."' href='#c".$data['id']."'>".$nr."</a> <cite>";
if(!empty($meta['homepage'])) $comment .= "<a title='".$meta['homepage']."' href='".$meta['homepage']."'>";
if(!empty($meta['name'])) $comment .= $meta['name'];
else $comment .= $l['comments_anonym'];
if(!empty($meta['homepage'])) $comment .= "</a>";
$comment .= "</cite>";
if(!empty($meta['city'])) $comment .= " ".$l['comments_from']." ".$meta['city'];
$comment .= " ".$l['comments_posted']." ".strftime(JLOG_DATE_COMMENT, $data['date']).":</p>\n".$bbcomments->parse($data['content'])."</li>";
### Plugin Hook
$comment = $plugins->callHook('showComment', $comment, $data, $nr);
return $comment;
}
?>

View file

@ -0,0 +1,71 @@
<?php
// call database class
class Query {
// Variablen
var $_sql = "";
var $_result = 0;
var $_errno = 0;
var $_error = "";
//Konstruktor
function Query($sql)
{
// Query in der Klasse speichern
$this->_sql = trim($sql);
$this->_result = mysql_query($this->_sql);
if(!$this->_result) {
$this->_errno = mysql_errno();
$this->_error = mysql_error();
}
}
//Methoden
function error()
{
// Result-ID in einer tmp-Variablen speichern
$tmp = $this->_result;
// Variable in boolean umwandeln
$tmp = (bool)$tmp;
// Variable invertieren
$tmp = !$tmp;
// und zurückgeben
return $tmp;
}
function getError() {
if($this->error()) {
$str = "request:\n".$this->_sql."\n";
$str .= "response:\n".$this->_error."\n";
$str .= "Errorcode: ".$this->_errno;
}
else $str = "No error.";
return $str;
}
function getErrno() {
return $this->_errno;
}
function fetch() {
if($this->error()) {
echo "An Error has occurred, please check your MySQL-Query.";
$return = null;
}
else $return = mysql_fetch_assoc($this->_result);
return $return;
}
function numRows() {
if($this->error()) {
$return = -1;
}
else $return = mysql_num_rows($this->_result);
return $return;
}
function free() {
// Speicher freimachen
mysql_free_result($this->_result);
}
}
?>

121
scripts/do_template.php Normal file
View file

@ -0,0 +1,121 @@
<?php
if(ereg('gzip', getenv('HTTP_ACCEPT_ENCODING')) &&
!ini_get('zlib.output_compression'))
{
ob_start('ob_gzhandler');
}
else ob_start();
$handle = fopen (JLOG_BASEPATH.'personal'.DIRECTORY_SEPARATOR.'template.tpl', "r");
$_body = "";
while (!feof($handle)) $_body .= fgets($handle);
fclose ($handle);
$handle = fopen (JLOG_BASEPATH.'personal'.DIRECTORY_SEPARATOR.'subcurrent.inc', "r");
$c['subnav_current'] = "";
while (!feof($handle)) $c['subnav_current'] .= fgets($handle);
fclose ($handle);
// Aditional Header Data
header("Content-Type: text/html; charset=UTF-8");
if(!isset($c['meta']['aditionalheader'])) $c['meta']['aditionalheader'] = "";
$c['meta']['aditionalheader'] .= ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n";
if(isset($c['meta']['robots'])) $c['meta']['aditionalheader'] .= ' <meta name="robots" content="'.$c['meta']['robots'].'" />'."\n";
if(isset($c['meta']['keywords'])) $c['meta']['aditionalheader'] .= ' <meta name="KeyWords" content="'.htmlspecialchars(strip_tags($c['meta']['keywords']), ENT_QUOTES).'" />'."\n";
if(isset($c['meta']['description'])) $c['meta']['aditionalheader'] .= ' <meta name="Description" content="'.htmlspecialchars(strip_tags(trim($c['meta']['description']), ENT_QUOTES)).'" />'."\n";
if(isset($c['meta']['date'])) $c['meta']['aditionalheader'] .= ' <meta name="date" content="'.$c['meta']['date'].'" />';
if(isset($c['meta']['pingback'])) {
$c['meta']['aditionalheader'] .= "\n".' <link rel="pingback" href="'.JLOG_PATH.'/xmlrpc.php" />';
header("X-Pingback: ".JLOG_PATH."/xmlrpc.php");
}
$c['meta']['aditionalheader'] .=
' <meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="Jlog v'.JLOG_SOFTWARE_VERSION.'" />
<link rel="start" href="'.JLOG_PATH.'/" title="'.$l['meta_start'].'" />
<link rel="search" href="'.JLOG_PATH.'/search.php" title="'.$l['meta_search'].'" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0 - Summaries" href="'.JLOG_PATH.'/personal/rss.xml" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0 - Full Posts" href="'.JLOG_PATH.'/personal/rss-full.xml" />
<script type="text/javascript" src="'.JLOG_PATH.'/scripts/javascripts.js"></script>';
// do this on admincenter
if(defined('JLOG_ADMIN')) {
// turn off cashing
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") ." GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Cache-Control: post-check=0, pre-check=0", FALSE);
// include admin.css
$c['meta']['aditionalheader'] .= "\n ".'<link rel="stylesheet" href="'.JLOG_PATH.'/personal/css/admin.css" type="text/css" />';
$c['main'] = "<div id='admin'>".$c['main']."</div>";
}
$_search = array (
"<jlog:language />",
"<jlog:website />",
"<jlog:title />",
"<jlog:aditional-header />",
"<jlog:homelink />",
"<jlog:skipcontent />",
"<jlog:home />",
"<jlog:slogan-h />",
"<jlog:slogan />",
"<jlog:search-h />",
"<jlog:searchstring />",
"<jlog:search />",
"<jlog:categorieslist-h />",
"<jlog:current-h />",
"<jlog:subcurrent />",
"<jlog:archive-more />",
"<jlog:archivelink />",
"<jlog:archive />",
"<jlog:sub-info />",
"<jlog:rss-info />",
"<jlog:rss-link />",
"<jlog:copyright />",
"<jlog:content />",
"<jlog:powered />"
);
$_replace = array (
$l['language'],
htmlspecialchars(JLOG_WEBSITE, ENT_QUOTES),
htmlspecialchars($c['meta']['title']),
$c['meta']['aditionalheader'],
JLOG_PATH,
$l['content_skip'],
$l['meta_start'],
$l['subnav_aboutpage'],
JLOG_DESCRIPTION,
$l['content_search_topic'],
'', // bugfix
$l['content_search'],
$l['content_categorieslist_h'],
$l['subnav_current'],
$c['subnav_current'],
$l['content_archive'],
archive(),
$l['content_archivelink'],
$l['subnav_info'],
$l['subnav_rss'],
"<a href='".JLOG_PATH."/personal/rss-full.xml'><img src='".JLOG_PATH."/img/JLOG_rss-full.png' alt='XML - Fullpost' /></a> <a href='".JLOG_PATH."/personal/rss.xml'><img src='".JLOG_PATH."/img/JLOG_rss-summary.png' alt='XML - Summary' /></a>",
"&copy;&nbsp;".date('Y')." ".JLOG_PUBLISHER.", ".$l['subnav_copyright'],
$c['main'],
$l['subnav_powered']." <a href='".JLOG_SOFTWARE_URL."' title='version ".JLOG_SOFTWARE_VERSION."'>Jlog</a>"
);
$body = str_replace($_search, $_replace, $_body);
$jlogTemplateTags = new JLOG_Tags($body);
if(($categorieslist_tag = $jlogTemplateTags->getTag('categorieslist')) !== false) {
if(strlen($categorieslist_class = $jlogTemplateTags->getAttributeValue('categorieslist', 'class'))>0) $categorieslist_class = ' class="'.$categorieslist_class.'"';
if( $categorieslist = $categories->output_whole_list("\n ".'<ul'.$categorieslist_class.'>'."\n")) {
$body = str_replace($categorieslist_tag, $categorieslist, $body );
}
else $body = str_replace($categorieslist_tag, '', $body );
}
$body = $plugins->callHook('body', $body, $jlogTemplateTags);

313
scripts/general.func.php Normal file
View file

@ -0,0 +1,313 @@
<?php
// get weblog link
function blog($date, $url, $section = 'weblog') {
if($section == 'weblog' OR $section == 'comment') {
$y = date("Y", $date);
$m = date("m", $date);
if(JLOG_CLEAN_URL === true) $permalink = JLOG_PATH."/".$y."/".$m."/".$url;
else $permalink = JLOG_PATH."/log.php?y=".$y."&amp;m=".$m."&amp;url=".$url;
}
else {
if(JLOG_CLEAN_URL === true) $permalink = JLOG_PATH."/".$url;
else $permalink = JLOG_PATH."/page.php?url=".$url;
}
### Plugin Hook
global $plugins;
$permalink = $plugins->callHook('permalink', $permalink, $date, $url, $section);
return $permalink;
}
function archive() {
if(JLOG_CLEAN_URL === true) return JLOG_PATH."/archive";
else return JLOG_PATH."/archive.php";
}
// get year links
class Year_Links {
function Year_Links($get, $start, $page, $l, $cat="") {
$date = getdate();
$this->_now = $date['year'];
$this->_start = $start;
$this->_page = $page;
$this->_l = $l;
if(JLOG_CLEAN_URL === true) {
if($cat != "") {
list($tmp, $cat) = explode("=", $cat);
$this->cat = "/cat/".$cat;
}
}
elseif($cat !== "") $this->cat = $cat."&amp;";
if($get >= $this->_start OR $get <= $this->_now AND preg_match("[0-9]", $get)) $this->year = $get;
else $this->year = $this->_now;
}
function get_linklist() {
for($y = $this->_start; $y <= $this->_now; $y++) {
if($y != $this->_start) $years_links .= " | ";
if($y == $this->year) $years_links .= " <strong>".$y."</strong>";
else {
if(JLOG_CLEAN_URL === true) $years_links .= " <a href='".JLOG_PATH.$this->cat."/".$y."/'>".$y."</a>\n";
else $years_links .= " <a href='".$this->_page.(strpos($this->_page, '?') === false ? "?" : "&amp;").$this->cat."y=".$y."'>".$y."</a>\n";
}
}
return $this->_l['content_choose_year'].$years_links;
}
function get_admin_linklist() {
for($y = $this->_start; $y <= $this->_now; $y++) {
if($y != $this->_start) $years_links .= " | ";
if($y == $this->year) $years_links .= " <strong>".$y."</strong>";
else $years_links .= " <a href='".$this->_page.(strpos($this->_page, '?') === false ? "?" : "&amp;")."y=".$y."'>".$y."</a>\n";
}
return $this->_l['content_choose_year'].$years_links;
}
// get selected year
function get_selected_year() {
return $this->year;
}
}
// kill Magic Quotes
function strip($_data) {
if (!get_magic_quotes_gpc()) return $_data;
else {
if (is_array($_data)) foreach($_data as $key => $val) $_data[$key] = strip($val);
else $_data = stripslashes($_data);
return $_data;
}
}
// escape input for mysql
function escape_for_mysql($_data) {
if (is_array($_data)) foreach($_data as $key => $val) $_data[$key] = escape_for_mysql($val);
else $_data = mysql_escape_string($_data);
return $_data;
}
// htmlspecialchars a whole array
function array_htmlspecialchars($_data) {
if (is_array($_data)) foreach($_data as $key => $val) $_data[$key] = array_htmlspecialchars($val);
else $_data = htmlspecialchars($_data, ENT_QUOTES);
return $_data;
}
// Fehler ausgeben
function error_output($errors, $id = "", $headline = false) {
global $l;
$error = "";
if($headline === false) $headline = $l["error"];
if(isset($errors)) {
if(strlen($headline) > 0) $error = "\n<h3 id='".$id."' class='error'>".$headline."</h3>";
$error .= "\n <ul class='error'>\n";
foreach($errors AS $f) $error .= " <li>".$f."</li>\n";
$error .= " </ul>\n";
}
return $error;
}
// Aus der Datenbank löschen (wird beim Kommentarlöschen gebraucht)
function trash($id, $table) {
$sql = "DELETE FROM ".$table." WHERE id = '".$id."' LIMIT 1";
$trash = new Query($sql);
if($trash->error()) {
echo "<pre>\n";
echo $trash->getError();
echo "</pre>\n";
die();
}
return true;
}
// output a teaser
function do_teaser($data, $cc, $pre = '<h2>', $post = '</h2>') {
global $l, $bbcode, $categories, $plugins;
if(empty($data['date_url'])) $data['date_url'] = $data['date']; # fix for search.php
$output = "\n <div class='teaser'>\n";
if($data['teaserpic'] != "") {
list($img_width, $img_height, $img_type, $img_attr) = @getimagesize(JLOG_BASEPATH.'img'.DIRECTORY_SEPARATOR.'t_'.$data['teaserpic']);
$output .= " <a title='".$l['content_permalink']."' href='".blog($data['date_url'], $data['url'], $data['section'])."'><img class='teaserpic' src='".JLOG_PATH."/img/t_".$data['teaserpic']."' style='width: ".$img_width."px; height: ".$img_height."px;' alt='' /></a>\n";
}
$output .= " ".$pre."<a title='".$l['content_permalink']."' href='".blog($data['date_url'], $data['url'], $data['section'])."'>".htmlspecialchars($data['topic'], ENT_QUOTES)."</a>".$post."
<p class='date meta'>".$l['content_posted']." ".strftime(JLOG_DATE, $data['date']).$categories->output_assigned_links($data['id'])."</p>";
$output .= $bbcode->parse($data['teaser']);
$output .=" <p class='meta'><a title='".$l['content_more_title']."' href='".blog($data['date_url'], $data['url'], $data['section'])."'>".$l['content_more']."</a>";
if($data['section'] == 'weblog') {
if(isset($cc[$data['id']]) AND $cc[$data['id']] != 0) $tmp_comments = " <a title='".$l['content_comments_title']."' href='".blog($data['date'], $data['url'])."#comments'>".$l['content_comments']." (".$cc[$data['id']].")</a>";
elseif($data['comments'] === '0') $tmp_comments = $l['comments_teaser_closed'];
else $tmp_comments = " <a href='".blog($data['date'], $data['url'])."#comments'>".$l['content_comment_plz']."</a>";
$output .= " | ".$tmp_comments;
}
$output .= "</p>\n </div>\n";
### Plugin Hook
$output = $plugins->callHook('doTeaser', $output, $data, $cc, $pre, $post);
return $output;
}
function do_entry($data, $cc = NULL, $section = 'weblog', $pre = '<h2>', $post = '</h2>') {
global $l, $bbcode, $categories, $plugins;
$output = "
<div class='mainitem'>
".$pre."<a title='".$l['content_permalink']."' href='".blog($data['date'], $data['url'], $section)."'>".htmlspecialchars($data['topic'], ENT_QUOTES)."</a>".$post."\n";
if($data['teaserpic'] != "" AND $data['teaserpiconblog'] == 1) {
list($img_width, $img_height, $img_type, $img_attr) = @getimagesize(JLOG_BASEPATH.'img'.DIRECTORY_SEPARATOR.'t_'.$data['teaserpic']);
$output .= "<a title='".$l['content_permalink']."' href='".blog($data['date'], $data['url'], $section)."'><img class='teaserpic' src='".JLOG_PATH."/img/t_".$data['teaserpic']."' style='width: ".$img_width."px; height: ".$img_height."px;' alt='' /></a>";
}
if($section == 'weblog' OR ($cat = $categories->output_assigned_links($data['id'])) != "") {
$output .= " <p class='date meta'>";
if($section == 'weblog') $output .= $l['content_posted']." ".strftime(JLOG_DATE, $data['date']);
$output .= $categories->output_assigned_links($data['id'])."</p>";
}
$output .= $bbcode->parse($data['content']);
$path_parts = pathinfo($_SERVER['SCRIPT_NAME']);
if($data['section'] == 'weblog' AND $path_parts['basename'] != 'log.php') {
if(isset($cc[$data['id']]) AND $cc[$data['id']] != 0) $tmp_comments = " <a title='".$l['content_comments_title']."' href='".blog($data['date'], $data['url'])."#comments'>".$l['content_comments']." (".$cc[$data['id']].")</a>";
elseif($data['comments'] === '0') $tmp_comments = $l['comments_teaser_closed'];
else $tmp_comments = "<a href='".blog($data['date'], $data['url'])."#comments'>".$l['content_comment_plz']."</a>";
$output .=" <p class='meta'>".$tmp_comments."</p>";
}
if($section == 'weblog') $output .= ' <hr />';
$output .= " </div>\n";
### Plugin Hook
$output = $plugins->callHook('doEntry', $output, $data, $cc, $section);
return $output;
}
function count_comments() {
// -- Kommentare zählen
$sql = "SELECT reference, COUNT(*) as count FROM ".JLOG_DB_COMMENTS." WHERE type <> 'pingback' GROUP BY reference";
$comments = new Query($sql);
if($comments->error()) {
echo "<pre>\n";
echo $comments->getError();
echo "</pre>\n";
die();
}
// -- Anzahl der jeweiligen Kommentare
$com = array();
while($c = $comments->fetch()) $com[$c['reference']] = $c['count'];
### Plugin Hook
global $plugins;
$com = $plugins->callHook('countComments', $com);
return $com;
}
if (!function_exists('is_a')) {
function is_a($object, $class)
{
if (!is_object($object)) {
return false;
}
if (get_class($object) == strtolower($class)) {
return true;
} else {
return is_subclass_of($object, $class);
}
}
}
if (!function_exists("stripos")) {
function stripos($str,$needle,$offset=0) {
return strpos( strtolower($str), strtolower($needle), $offset );
}
}
if(!function_exists('str_ireplace')){
function str_ireplace($search, $replace, $subject){
if(is_array($search)){
array_walk($search, create_function('&$pat, $key', '"/".preg_quote($pat, "/")."/i"'));
}
else{
$search = '/'.preg_quote($search, '/').'/i';
}
return preg_replace($search, $replace, $subject);
}
}
if ( !function_exists('file_put_contents') && !defined('FILE_APPEND') ) {
define('FILE_APPEND', 1);
function file_put_contents($n, $d, $flag = false) {
$mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
$f = @fopen($n, $mode);
if ($f === false) {
return 0;
} else {
if (is_array($d)) $d = implode($d);
$bytes_written = fwrite($f, $d);
fclose($f);
return $bytes_written;
}
}
}
function my_serialize_cfg($arg) {
if(is_string($arg)) return "'".preg_replace("/'/","\\'",$arg)."'";
elseif(is_integer($arg)) return (string)$arg;
elseif(is_float($arg)) return (string)$arg;
elseif(is_null($arg)) return 'NULL';
elseif(is_bool($arg)) {
if($arg) return 'true';
else return 'false';
}
elseif(is_array($arg)) {
$retval = 'Array(';
foreach($arg as $key => $value) {
$retval .= my_serialize_cfg($key).' => '.my_serialize_cfg($value).',';
}
$retval .= ')';
return $retval;
}
else die("unsupported type! ".gettype($arg));
}
class JLOG_Tags {
var $tree = array();
function JLOG_Tags($body) {
preg_match_all('/<jlog:([a-z]\w+)\s?([^>]*)\/?>(<\/(\1):(\2)>)?/ims', $body, $this->tree);
}
function getTag($tagname) {
if(($tagnr = array_search($tagname, $this->tree[1])) !== false) return $this->tree[0][$tagnr];
else return false;
}
function getAttributeValue($tagname, $attribute) {
$pattern = '/(?:^|\s)([a-z]\w+)(?:=)(?:(?:\'([^\']+)\')|(?:"([^"]*)")|([^\s,]+))/i';
if(($tagnr = array_search($tagname, $this->tree[1])) !== false) {
preg_match_all($pattern, $this->tree[2][ $tagnr ], $matches, PREG_SET_ORDER);
$a = count($matches);
for($i=0;$i<$a;$i++) {
if($matches[$i][1] == $attribute) return $matches[$i][3];
}
}
else return;
}
}
?>

817
scripts/ixr-library.inc.php Normal file
View file

@ -0,0 +1,817 @@
<?php
/*
IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002
Version 1.61 - Simon Willison, 11th July 2003 (htmlentities -> htmlspecialchars)
Site: http://scripts.incutio.com/xmlrpc/
Manual: http://scripts.incutio.com/xmlrpc/manual.php
Made available under the Artistic License: http://www.opensource.org/licenses/artistic-license.php
*/
class IXR_Value {
var $data;
var $type;
function IXR_Value ($data, $type = false) {
$this->data = $data;
if (!$type) {
$type = $this->calculateType();
}
$this->type = $type;
if ($type == 'struct') {
/* Turn all the values in the array in to new IXR_Value objects */
foreach ($this->data as $key => $value) {
$this->data[$key] = new IXR_Value($value);
}
}
if ($type == 'array') {
for ($i = 0, $j = count($this->data); $i < $j; $i++) {
$this->data[$i] = new IXR_Value($this->data[$i]);
}
}
}
function calculateType() {
if ($this->data === true || $this->data === false) {
return 'boolean';
}
if (is_integer($this->data)) {
return 'int';
}
if (is_double($this->data)) {
return 'double';
}
// Deal with IXR object types base64 and date
if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
return 'date';
}
if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
return 'base64';
}
// If it is a normal PHP object convert it in to a struct
if (is_object($this->data)) {
$this->data = get_object_vars($this->data);
return 'struct';
}
if (!is_array($this->data)) {
return 'string';
}
/* We have an array - is it an array or a struct ? */
if ($this->isStruct($this->data)) {
return 'struct';
} else {
return 'array';
}
}
function getXml() {
/* Return XML for this value */
switch ($this->type) {
case 'boolean':
return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
break;
case 'int':
return '<int>'.$this->data.'</int>';
break;
case 'double':
return '<double>'.$this->data.'</double>';
break;
case 'string':
return '<string>'.htmlspecialchars($this->data).'</string>';
break;
case 'array':
$return = '<array><data>'."\n";
foreach ($this->data as $item) {
$return .= ' <value>'.$item->getXml()."</value>\n";
}
$return .= '</data></array>';
return $return;
break;
case 'struct':
$return = '<struct>'."\n";
foreach ($this->data as $name => $value) {
$return .= " <member><name>$name</name><value>";
$return .= $value->getXml()."</value></member>\n";
}
$return .= '</struct>';
return $return;
break;
case 'date':
case 'base64':
return $this->data->getXml();
break;
}
return false;
}
function isStruct($array) {
/* Nasty function to check if an array is a struct or not */
$expected = 0;
foreach ($array as $key => $value) {
if ((string)$key != (string)$expected) {
return true;
}
$expected++;
}
return false;
}
}
class IXR_Message {
var $message;
var $messageType; // methodCall / methodResponse / fault
var $faultCode;
var $faultString;
var $methodName;
var $params;
// Current variable stacks
var $_arraystructs = array(); // The stack used to keep track of the current array/struct
var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
var $_currentStructName = array(); // A stack as well
var $_param;
var $_value;
var $_currentTag;
var $_currentTagContents;
// The XML parser
var $_parser;
function IXR_Message ($message) {
$this->message = $message;
}
function parse() {
// first remove the XML declaration
$this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
if (trim($this->message) == '') {
return false;
}
$this->_parser = xml_parser_create();
// Set XML parser to take the case of tags in to account
xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
// Set XML parser callback functions
xml_set_object($this->_parser, $this);
xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
xml_set_character_data_handler($this->_parser, 'cdata');
if (!xml_parse($this->_parser, $this->message)) {
/* die(sprintf('XML error: %s at line %d',
xml_error_string(xml_get_error_code($this->_parser)),
xml_get_current_line_number($this->_parser))); */
return false;
}
xml_parser_free($this->_parser);
// Grab the error messages, if any
if ($this->messageType == 'fault') {
$this->faultCode = $this->params[0]['faultCode'];
$this->faultString = $this->params[0]['faultString'];
}
return true;
}
function tag_open($parser, $tag, $attr) {
$this->currentTag = $tag;
switch($tag) {
case 'methodCall':
case 'methodResponse':
case 'fault':
$this->messageType = $tag;
break;
/* Deal with stacks of arrays and structs */
case 'data': // data is to all intents and puposes more interesting than array
$this->_arraystructstypes[] = 'array';
$this->_arraystructs[] = array();
break;
case 'struct':
$this->_arraystructstypes[] = 'struct';
$this->_arraystructs[] = array();
break;
}
}
function cdata($parser, $cdata) {
$this->_currentTagContents .= $cdata;
}
function tag_close($parser, $tag) {
$valueFlag = false;
switch($tag) {
case 'int':
case 'i4':
$value = (int)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'double':
$value = (double)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'string':
$value = (string)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'dateTime.iso8601':
$value = new IXR_Date(trim($this->_currentTagContents));
// $value = $iso->getTimestamp();
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'value':
// "If no type is indicated, the type is string."
if (trim($this->_currentTagContents) != '') {
$value = (string)$this->_currentTagContents;
$this->_currentTagContents = '';
$valueFlag = true;
}
break;
case 'boolean':
$value = (boolean)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'base64':
$value = base64_decode($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
/* Deal with stacks of arrays and structs */
case 'data':
case 'struct':
$value = array_pop($this->_arraystructs);
array_pop($this->_arraystructstypes);
$valueFlag = true;
break;
case 'member':
array_pop($this->_currentStructName);
break;
case 'name':
$this->_currentStructName[] = trim($this->_currentTagContents);
$this->_currentTagContents = '';
break;
case 'methodName':
$this->methodName = trim($this->_currentTagContents);
$this->_currentTagContents = '';
break;
}
if ($valueFlag) {
/*
if (!is_array($value) && !is_object($value)) {
$value = trim($value);
}
*/
if (count($this->_arraystructs) > 0) {
// Add value to struct or array
if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
// Add to struct
$this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
} else {
// Add to array
$this->_arraystructs[count($this->_arraystructs)-1][] = $value;
}
} else {
// Just add as a paramater
$this->params[] = $value;
}
}
}
}
class IXR_Server {
var $data;
var $callbacks = array();
var $message;
var $capabilities;
function IXR_Server($callbacks = false, $data = false) {
$this->setCapabilities();
if ($callbacks) {
$this->callbacks = $callbacks;
}
$this->setCallbacks();
$this->serve($data);
}
function serve($data = false) {
if (!$data) {
global $HTTP_RAW_POST_DATA;
if (!$HTTP_RAW_POST_DATA) {
die('XML-RPC server accepts POST requests only.');
}
$data = $HTTP_RAW_POST_DATA;
}
$this->message = new IXR_Message($data);
if (!$this->message->parse()) {
$this->error(-32700, 'parse error. not well formed');
}
if ($this->message->messageType != 'methodCall') {
$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
}
$result = $this->call($this->message->methodName, $this->message->params);
// Is the result an error?
if (is_a($result, 'IXR_Error')) {
$this->error($result);
}
// Encode the result
$r = new IXR_Value($result);
$resultxml = $r->getXml();
// Create the XML
$xml = <<<EOD
<methodResponse>
<params>
<param>
<value>
$resultxml
</value>
</param>
</params>
</methodResponse>
EOD;
// Send it
$this->output($xml);
}
function call($methodname, $args) {
if (!$this->hasMethod($methodname)) {
return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
}
$method = $this->callbacks[$methodname];
// Perform the callback and send the response
if (count($args) == 1) {
// If only one paramater just send that instead of the whole array
$args = $args[0];
}
// Are we dealing with a function or a method?
if (substr($method, 0, 5) == 'this:') {
// It's a class method - check it exists
$method = substr($method, 5);
if (!method_exists($this, $method)) {
return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
}
// Call the method
$result = $this->$method($args);
} else {
// It's a function - does it exist?
if (!function_exists($method)) {
return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
}
// Call the function
$result = $method($args);
}
return $result;
}
function error($error, $message = false) {
// Accepts either an error object or an error code and message
if ($message && !is_object($error)) {
$error = new IXR_Error($error, $message);
}
$this->output($error->getXml());
}
function output($xml) {
$xml = '<?xml version="1.0"?>'."\n".$xml;
$length = strlen($xml);
header('Connection: close');
header('Content-Length: '.$length);
header('Content-Type: text/xml');
header('Date: '.date('r'));
echo $xml;
exit;
}
function hasMethod($method) {
return in_array($method, array_keys($this->callbacks));
}
function setCapabilities() {
// Initialises capabilities array
$this->capabilities = array(
'xmlrpc' => array(
'specUrl' => 'http://www.xmlrpc.com/spec',
'specVersion' => 1
),
'faults_interop' => array(
'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
'specVersion' => 20010516
),
'system.multicall' => array(
'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
'specVersion' => 1
),
);
}
function getCapabilities($args) {
return $this->capabilities;
}
function setCallbacks() {
$this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
$this->callbacks['system.listMethods'] = 'this:listMethods';
$this->callbacks['system.multicall'] = 'this:multiCall';
}
function listMethods($args) {
// Returns a list of methods - uses array_reverse to ensure user defined
// methods are listed before server defined methods
return array_reverse(array_keys($this->callbacks));
}
function multiCall($methodcalls) {
// See http://www.xmlrpc.com/discuss/msgReader$1208
$return = array();
foreach ($methodcalls as $call) {
$method = $call['methodName'];
$params = $call['params'];
if ($method == 'system.multicall') {
$result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
} else {
$result = $this->call($method, $params);
}
if (is_a($result, 'IXR_Error')) {
$return[] = array(
'faultCode' => $result->code,
'faultString' => $result->message
);
} else {
$return[] = array($result);
}
}
return $return;
}
}
class IXR_Request {
var $method;
var $args;
var $xml;
function IXR_Request($method, $args) {
$this->method = $method;
$this->args = $args;
$this->xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>{$this->method}</methodName>
<params>
EOD;
foreach ($this->args as $arg) {
$this->xml .= '<param><value>';
$v = new IXR_Value($arg);
$this->xml .= $v->getXml();
$this->xml .= "</value></param>\n";
}
$this->xml .= '</params></methodCall>';
}
function getLength() {
return strlen($this->xml);
}
function getXml() {
return $this->xml;
}
}
class IXR_Client {
var $server;
var $port;
var $path;
var $useragent;
var $response;
var $message = false;
var $debug = false;
// Storage place for an error message
var $error = false;
function IXR_Client($server, $path = false, $port = 80) {
if (!$path) {
// Assume we have been given a URL instead
$bits = parse_url($server);
$this->server = $bits['host'];
$this->port = isset($bits['port']) ? $bits['port'] : 80;
$this->path = isset($bits['path']) ? $bits['path'] : '/';
// Make absolutely sure we have a path
if (!$this->path) {
$this->path = '/';
}
} else {
$this->server = $server;
$this->path = $path;
$this->port = $port;
}
$this->useragent = 'The Incutio XML-RPC PHP Library';
}
function query() {
$args = func_get_args();
$method = array_shift($args);
$request = new IXR_Request($method, $args);
$length = $request->getLength();
$xml = $request->getXml();
$r = "\r\n";
$request = "POST {$this->path} HTTP/1.0$r";
$request .= "Host: {$this->server}$r";
$request .= "Content-Type: text/xml$r";
$request .= "User-Agent: {$this->useragent}$r";
$request .= "Content-length: {$length}$r$r";
$request .= $xml;
// Now send the request
if ($this->debug) {
echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
}
$fp = @fsockopen($this->server, $this->port);
if (!$fp) {
$this->error = new IXR_Error(-32300, 'transport error - could not open socket');
return false;
}
fputs($fp, $request);
$contents = '';
$gotFirstLine = false;
$gettingHeaders = true;
while (!feof($fp)) {
$line = fgets($fp, 4096);
if (!$gotFirstLine) {
// Check line for '200'
if (strstr($line, '200') === false) {
$this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
return false;
}
$gotFirstLine = true;
}
if (trim($line) == '') {
$gettingHeaders = false;
}
if (!$gettingHeaders) {
$contents .= trim($line)."\n";
}
}
if ($this->debug) {
echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
}
// Now parse what we've got back
$this->message = new IXR_Message($contents);
if (!$this->message->parse()) {
// XML error
$this->error = new IXR_Error(-32700, 'parse error. not well formed');
return false;
}
// Is the message a fault?
if ($this->message->messageType == 'fault') {
$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
return false;
}
// Message must be OK
return true;
}
function getResponse() {
// methodResponses can only have one param - return that
return $this->message->params[0];
}
function isError() {
return (is_object($this->error));
}
function getErrorCode() {
return $this->error->code;
}
function getErrorMessage() {
return $this->error->message;
}
}
class IXR_Error {
var $code;
var $message;
function IXR_Error($code, $message) {
$this->code = $code;
$this->message = $message;
}
function getXml() {
$xml = <<<EOD
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>{$this->code}</int></value>
</member>
<member>
<name>faultString</name>
<value><string>{$this->message}</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
EOD;
return $xml;
}
}
class IXR_Date {
var $year;
var $month;
var $day;
var $hour;
var $minute;
var $second;
function IXR_Date($time) {
// $time can be a PHP timestamp or an ISO one
if (is_numeric($time)) {
$this->parseTimestamp($time);
} else {
$this->parseIso($time);
}
}
function parseTimestamp($timestamp) {
$this->year = date('Y', $timestamp);
$this->month = date('Y', $timestamp);
$this->day = date('Y', $timestamp);
$this->hour = date('H', $timestamp);
$this->minute = date('i', $timestamp);
$this->second = date('s', $timestamp);
}
function parseIso($iso) {
$this->year = substr($iso, 0, 4);
$this->month = substr($iso, 4, 2);
$this->day = substr($iso, 6, 2);
$this->hour = substr($iso, 9, 2);
$this->minute = substr($iso, 12, 2);
$this->second = substr($iso, 15, 2);
}
function getIso() {
return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;
}
function getXml() {
return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
}
function getTimestamp() {
return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
}
}
class IXR_Base64 {
var $data;
function IXR_Base64($data) {
$this->data = $data;
}
function getXml() {
return '<base64>'.base64_encode($this->data).'</base64>';
}
}
class IXR_IntrospectionServer extends IXR_Server {
var $signatures;
var $help;
function IXR_IntrospectionServer() {
$this->setCallbacks();
$this->setCapabilities();
$this->capabilities['introspection'] = array(
'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
'specVersion' => 1
);
$this->addCallback(
'system.methodSignature',
'this:methodSignature',
array('array', 'string'),
'Returns an array describing the return type and required parameters of a method'
);
$this->addCallback(
'system.getCapabilities',
'this:getCapabilities',
array('struct'),
'Returns a struct describing the XML-RPC specifications supported by this server'
);
$this->addCallback(
'system.listMethods',
'this:listMethods',
array('array'),
'Returns an array of available methods on this server'
);
$this->addCallback(
'system.methodHelp',
'this:methodHelp',
array('string', 'string'),
'Returns a documentation string for the specified method'
);
}
function addCallback($method, $callback, $args, $help) {
$this->callbacks[$method] = $callback;
$this->signatures[$method] = $args;
$this->help[$method] = $help;
}
function call($methodname, $args) {
// Make sure it's in an array
if ($args && !is_array($args)) {
$args = array($args);
}
// Over-rides default call method, adds signature check
if (!$this->hasMethod($methodname)) {
return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
}
$method = $this->callbacks[$methodname];
$signature = $this->signatures[$methodname];
$returnType = array_shift($signature);
// Check the number of arguments
if (count($args) != count($signature)) {
// print 'Num of args: '.count($args).' Num in signature: '.count($signature);
return new IXR_Error(-32602, 'server error. wrong number of method parameters');
}
// Check the argument types
$ok = true;
$argsbackup = $args;
for ($i = 0, $j = count($args); $i < $j; $i++) {
$arg = array_shift($args);
$type = array_shift($signature);
switch ($type) {
case 'int':
case 'i4':
if (is_array($arg) || !is_int($arg)) {
$ok = false;
}
break;
case 'base64':
case 'string':
if (!is_string($arg)) {
$ok = false;
}
break;
case 'boolean':
if ($arg !== false && $arg !== true) {
$ok = false;
}
break;
case 'float':
case 'double':
if (!is_float($arg)) {
$ok = false;
}
break;
case 'date':
case 'dateTime.iso8601':
if (!is_a($arg, 'IXR_Date')) {
$ok = false;
}
break;
}
if (!$ok) {
return new IXR_Error(-32602, 'server error. invalid method parameters');
}
}
// It passed the test - run the "real" method call
return parent::call($methodname, $argsbackup);
}
function methodSignature($method) {
if (!$this->hasMethod($method)) {
return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
}
// We should be returning an array of types
$types = $this->signatures[$method];
$return = array();
foreach ($types as $type) {
switch ($type) {
case 'string':
$return[] = 'string';
break;
case 'int':
case 'i4':
$return[] = 42;
break;
case 'double':
$return[] = 3.1415;
break;
case 'dateTime.iso8601':
$return[] = new IXR_Date(time());
break;
case 'boolean':
$return[] = true;
break;
case 'base64':
$return[] = new IXR_Base64('base64');
break;
case 'array':
$return[] = array('array');
break;
case 'struct':
$return[] = array('struct' => 'struct');
break;
}
}
return $return;
}
function methodHelp($method) {
return $this->help[$method];
}
}
class IXR_ClientMulticall extends IXR_Client {
var $calls = array();
function IXR_ClientMulticall($server, $path = false, $port = 80) {
parent::IXR_Client($server, $path, $port);
$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
}
function addCall() {
$args = func_get_args();
$methodName = array_shift($args);
$struct = array(
'methodName' => $methodName,
'params' => $args
);
$this->calls[] = $struct;
}
function query() {
// Prepare multicall, then call the parent::query() method
return parent::query('system.multicall', $this->calls);
}
}
?>

332
scripts/javascripts.js Normal file
View file

@ -0,0 +1,332 @@
// TODO: I'd like to have an extra "js" directory for all JavaScripts
// a theme needs.
/*
* Jlogs not minified version of JavaScript
*/
function jlog_bbcode(insText, aTag, eTag) {
if (!insText) { return ''; }
return aTag + insText + eTag;
}
function jlog_bbcode_link(insText, aTag, eTag) {
var url = new RegExp('^(http://|https://|www.|ftp://|news:|mailto:).');
var www = new RegExp('^(www.).');
var mail = new RegExp('^[^@]+@[^@]+\.[a-zA-Z]+$');
var http = new RegExp('^(http://)$');
var node, href;
if((url.test(insText)) || (mail.test(insText))) {
href = insText;
if (mail.test(href)) { href = 'mailto:' + insText; }
if (www.test(href)) { href = 'http://' + href; }
node = prompt(jlog_l_comments_url_node);
if((node !== null) && (node !== '')) { insText = '[url=' + href + ']' + node + eTag; }
else if(node === '') { insText = aTag + href + eTag; }
}
else {
node = insText;
if(node === '') { node = prompt(jlog_l_comments_url_node, insText); }
href = prompt(jlog_l_comments_url_href, 'http://');
if (http.test(href)) { return insText; }
if (www.test(href)) { href = 'http://' + href; }
if(((node !== null) && (node !== '')) && ((href !== null) && (href !== ''))) {
insText = '[url=' + href + ']' + node + eTag;
}
else if((href !== null) && (href !== '')) { insText = aTag + href + eTag; }
}
return insText;
}
function jlog_bbcode_list(o_insText, aTag, eTag) {
var insText = o_insText.replace(/(\n|\r|\r\n)(?=(.+))/g, '$1[*]');
return '[list]\n[*]' + insText + eTag + '\n';
}
function jlog_bbcode_insert(aTag, eTag, completeText) {
var input = document.forms.entryform.elements.content;
input.focus();
var insText;
/* für Internet Explorer und Opera >= 8 */
if(typeof document.selection != 'undefined') {
/* Einfügen des Formatierungscodes */
var range = document.selection.createRange();
insText = range.text;
if (aTag === '[url]') { range.text = jlog_bbcode_link(insText, aTag, eTag); }
else if(eTag === '[/list]') { range.text = jlog_bbcode_list(insText, aTag, eTag); }
else { range.text = jlog_bbcode(insText, aTag, eTag); }
/* Anpassen der Cursorposition */
range = document.selection.createRange();
if (insText.length === 0) {
range.move('character', -eTag.length);
} else {
range.moveStart('character', insText.length);
}
range.select();
}
/* für neuere auf Gecko basierende Browser */
else if(typeof input.selectionStart != 'undefined')
{
/* Einfügen des Formatierungscodes */
var start = input.selectionStart;
var end = input.selectionEnd;
insText = input.value.substring(start, end);
if(aTag === '[url]') { insText = jlog_bbcode_link(insText, aTag, eTag); }
else if(eTag === '[/list]') { insText = jlog_bbcode_list(insText, aTag, eTag); }
else { insText = jlog_bbcode(insText, aTag, eTag); }
input.value = input.value.substr(0, start) + insText + input.value.substr(end);
/* Anpassen der Cursorposition */
var pos;
if (insText.length === 0) {
pos = start + aTag.length + eTag.length;
} else {
pos = start + insText.length;
}
input.selectionStart = pos;
input.selectionEnd = pos;
}
/* für die übrigen Browser */
else
{
/* Einfügen des Formatierungscodes */
if(aTag === '[url]') { insText = jlog_bbcode_link('', aTag, eTag); }
else if(eTag === '[/list]') { insText = jlog_bbcode_list('', aTag, eTag); }
else { insText = jlog_bbcode(prompt(jlog_l_comments_plz_format_txt), aTag, eTag); }
input.value += insText;
}
}
function jlog_bbcode_img(jfilename) {
var jclass = '';
var jalt = '';
if ( document.getElementById("class").value !== '') {
jclass = ' class=\"' + document.getElementById("class").value + '\"';
}
if ( document.getElementById("alt").value !== '') {
jalt = ' alt=\"' + document.getElementById("alt").value + '\"';
}
var jimg = '[img' + jclass + jalt + ']' + jfilename + '[/img]';
opener.parent.jlog_insertAtCursor(jimg);
window.close();
}
// from http://www.alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript/
function jlog_insertAtCursor(insText) {
//IE and Opera support
var field = document.forms.entryform.elements.content;
if (document.selection) {
field.focus();
var sel = document.selection.createRange();
sel.text = insText;
}
//MOZILLA/NETSCAPE support
else if (field.selectionStart || field.selectionStart == '0') {
var startPos = field.selectionStart;
var endPos = field.selectionEnd;
field.value = field.value.substring(0, startPos) + insText + field.value.substring(endPos, field.value.length);
} else {
field.value += insText;
}
}
var show = true;
function jlog_killcomments() {
var commentslist = document.getElementById("commentslist");
var pingbacks_header = document.getElementById("pingbacks");
var pingbacks_list = document.getElementById("pingbackslist");
if (show) {
document.getElementById("hidecomments").firstChild.nodeValue = jlog_l_comments_show;
show=false;
if(pingbacks_header) { pingbacks_header.style.display = "none"; }
if(pingbacks_list) { pingbacks_list.style.display = "none"; }
document.getElementById("comments").style.display = "none";
document.getElementById("entryform").style.display = "none";
if(commentslist) { commentslist.style.display = "none"; }
}
else {
document.getElementById("hidecomments").firstChild.nodeValue = jlog_l_comments_hide;
show=true;
if(pingbacks_header) { pingbacks_header.style.display = "block"; }
if(pingbacks_list) { pingbacks_list.style.display = "block"; }
document.getElementById("comments").style.display = "block";
document.getElementById("entryform").style.display = "block";
if(commentslist) { commentslist.style.display = "block"; }
}
}
var jlog_bbcode_br;
function jlog_bbcode_do_button(titel, aTag, eTag) {
var button = document.createElement("input");
button.onclick = function() {
jlog_bbcode_insert(aTag, eTag);
return false;
};
button.className = "jlog_bbcode";
button.type = "button";
button.value = titel;
jlog_bbcode_br.parentNode.insertBefore(button, jlog_bbcode_br);
}
/* from http://www.kryogenix.org/code/browser/searchhi/ */
function jlog_highlightWord(node,word) {
if (node.hasChildNodes) {
for (var hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
jlog_highlightWord(node.childNodes[hi_cn],word);
}
}
if (node.nodeType == 3) {
var tempNodeVal = node.nodeValue.toLowerCase();
var tempWordVal = word.toLowerCase();
if (tempNodeVal.indexOf(tempWordVal) != -1) {
var pn = node.parentNode;
if (pn.className != "searchword") {
var nv = node.nodeValue;
var ni = tempNodeVal.indexOf(tempWordVal);
var before = document.createTextNode(nv.substr(0,ni));
var docWordVal = nv.substr(ni,word.length);
var after = document.createTextNode(nv.substr(ni+word.length));
var hiwordtext = document.createTextNode(docWordVal);
var hiword = document.createElement("span");
hiword.className = "searchword";
hiword.appendChild(hiwordtext);
pn.insertBefore(before,node);
pn.insertBefore(hiword,node);
pn.insertBefore(after,node);
pn.removeChild(node);
}
}
}
}
function jlog_searchengineSearchHighlight() {
if (!document.createElement) { return; }
var ref = document.referrer;
if (ref.indexOf('?') == -1) { return; }
var qs = ref.substr(ref.indexOf('?')+1);
var qsa = qs.split('&');
for (var i=0;i<qsa.length;i++) {
var qsip = qsa[i].split('=');
if (qsip.length == 1) { continue; }
if (qsip[0] == 'q' || qsip[0] == 'p' ) { // q= for Google, p= for Yahoo
var words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
for (var w=0;w<words.length;w++) {
jlog_highlightWord(document.getElementsByTagName("body")[0],words[w]);
}
}
}
}
function jlog_init() {
var jlog_comments;
if(document.getElementById("pingbacks")) { jlog_comments = document.getElementById("pingbacks"); }
else { jlog_comments = document.getElementById("comments"); }
if (jlog_comments) {
if (!document.getElementById || !document.createElement || !document.createTextNode) { return; }
var p = document.createElement("p");
p.className = "hidecomments";
var a = document.createElement("a");
a.id = "hidecomments";
a.href = "#";
a.onclick = function() {jlog_killcomments(); return false; };
var text = document.createTextNode(jlog_l_comments_hide);
a.appendChild(text);
p.appendChild(a);
if (jlog_comments.insertBefore) {
jlog_comments.parentNode.insertBefore(p, jlog_comments);
}
}
jlog_bbcode_br = document.getElementById("bbcode");
if(jlog_bbcode_br || (typeof(jlog_admin) !== "undefined")) {
if (jlog_bbcode_br.insertBefore) {
jlog_bbcode_do_button(jlog_l_comments_url, '[url]', '[/url]');
jlog_bbcode_do_button(jlog_l_comments_bold, '[b]', '[/b]');
jlog_bbcode_do_button(jlog_l_comments_italic, '[i]', '[/i]');
jlog_bbcode_do_button(jlog_l_comments_quote, '[quote]', '[/quote]');
if (jlog_comments) { jlog_bbcode_br.parentNode.getElementsByTagName("span")[0].style.display = "none"; }
}
if (typeof(jlog_admin) !== "undefined") {
document.getElementById("jlogteaserpic").style.display = "block";
if (jlog_bbcode_br.insertBefore) {
jlog_bbcode_do_button(jlog_l_headline, '[headline]', '[/headline]');
jlog_bbcode_do_button(jlog_l_list, '[list][*]', '[/list]');
}
}
}
if(typeof(jlog_searchpage) === "undefined") { jlog_searchengineSearchHighlight(); }
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload !== 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
};
}
}
addLoadEvent(jlog_init);
addLoadEvent( function() {
if(document.getElementById("password")) {
document.getElementById("password").focus();
}
});
var winpops;
/* Open popup to learn BBCode for comments */
function jlog_learnbb(path) {
var popurl = path + '/learn_bb.php?v=small';
winpops=window.open(popurl,'','width=400,height=300,scrollbars=yes');
}
/* Open popup to upload pictures in admincenter */
function jlog_wopen(popurl) {
winpops=window.open(popurl,'','width=350,height=350,scrollbars=yes');
}
function jlog_generate_url(topic, destination) {
if ( typeof( destination ) == 'string' ) { destination = document.getElementById( destination ); }
if ( destination.value !== '' ) { return false; }
var url = topic.toLowerCase();
while(url.search(/ä/) != -1) { url = url.replace(/ä/, "ae"); }
while(url.search(/ö/) != -1) { url = url.replace(/ö/, "oe"); }
while(url.search(/ü/) != -1) { url = url.replace(/ü/, "ue"); }
while(url.search(/ß/) != -1) { url = url.replace(/ß/, "ss"); }
while(url.search(/ /) != -1) { url = url.replace(/ /, "-"); }
while(url.search(/[^a-z0-9.,_\/-]/) != -1) { url = url.replace(/[^a-z0-9.,_/-]/, ""); }
destination.value = url;
}
/* URL fill out helper */
addLoadEvent(
function() {
var topic = document.getElementById('topic')
if ( topic ) {
topic.onchange = function() { jlog_generate_url( this.value, 'url' ); }
}
var namefield = document.getElementById('name');
if( !document.getElementById('url') || !namefield ) { return; }
else namefield.onchange = function() { jlog_generate_url( this.value, 'url' ); }
}
)

1832
scripts/jlogHTTP_Request.php Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,83 @@
<?php
// hiervon werden die Plugins abgeleitet
class JlogPlugin {
/* Hooks */
function hook_body ($t) { return $t; } // string body
function hook_commentForm ($t) { return $t; } // string with comment form output + array with form data
function hook_adminContent ($t) { return $t; } // string content
function hook_newComment ($t) { return $t; } // array form data
function hook_updateComment ($t) { return $t; } // array form data
function hook_deleteComment ($t) { return $t; } // string comment id
function hook_showComment ($t) { return $t; } // string comment output
function hook_onUpdate ($t) { return $t; } // array with all rss feeds and sub
function hook_doEntry ($t) { return $t; } // string with entry + array with data from database + string count comments + string section
function hook_doTeaser ($t) { return $t; } // string with entry + array with data from database + string count comments + string pre + string post
function hook_bbcode ($t) { return $t; } // bbcode object
function hook_bbcomments ($t) { return $t; } // bbcomments object
function hook_adminForm ($t) { return $t; } // admin formular
function hook_insertEntry ($t) { return $t; } // int id + array with form data
function hook_updateEntry ($t) { return $t; } // int id + array with form data
function hook_permalink ($t) { return $t; } // string permalink + string date + string url + string section
function hook_xmlrpcPermalink ($t) { return $t; } // string url
function hook_countComments ($t) { return $t; } // array with id and count
function hook_adminMail ($t) { return $t; } // array with mail + array blogentry
function hook_commentorMail ($t) { return $t; } // array with mail + array blogentry
function hook_commentAdminList($t) { return $t; } // string with actual tr + array with comment data
function hook_previewComment ($t) { return $t; } // same as newComment
function hook_dispatchLogin ($t) { return $t; } //
function hook_loginForm ($t) { return $t; } //
function hook_adminMenu ($t) { return $t; } // string with the admin menu html
function hook_adminList ($t) { return $t; } //
}
class JlogPluginManager {
var $plugins = array();
function JlogPluginManager($plugindirectory) {
$handle = "";
$file = "";
$this->get = strip($_GET);
if(is_dir($plugindirectory)) {
$handle = opendir($plugindirectory);
while( false !== ( $file = readdir ($handle) ) ) {
if(substr($file, -10) === '.jplug.php') {
include_once $plugindirectory.$file;
$this->register( substr($file, 0, -10) );
}
}
closedir($handle);
}
}
function register($plugin) {
$this->plugins[] = new $plugin;
}
// Aufruf $JLogPluginManagerInstanz->callHook('eins', $param1[, $param2, ...]);
// $param1 = Pflicht-Parameter, alle anderen optional
function callHook($hook) {
$hook = 'hook_' . $hook;
$parameters = func_get_args();
array_shift($parameters); // $hook entfernen
if (!isset($parameters[0]))
die('fatal error - no parameters');
$hookresult = $parameters[0];
foreach ($this->plugins as $plugin) {
$parameters[0] = $hookresult;
if($hook == 'hook_adminTitle' OR $hook == 'hook_adminContent') {
if(strtolower($this->get['jplug']) === strtolower(get_class($plugin)))
$hookresult = call_user_func_array(array($plugin, $hook), $parameters);
}
else $hookresult = call_user_func_array(array($plugin, $hook), $parameters);
}
return $hookresult;
}
}
?>

279
scripts/mail.class.php Normal file
View file

@ -0,0 +1,279 @@
<?php
/**
* Mail class
*
* This class is used for sending emails from Jlog, e.g. for notifying
* the admin about a new comment.
*
* @category Jlog
* @package Jlog_Mail
* @license GNU General Public License
*
*/
class Jlog_Mail
{
/**
* Additional headers
*
* Headers for the email in an array where the key is the
* header field and the value is the value of that header.
*
* @access private
* @var array
*/
var $_header = array();
/**
* E-Mail From
*
* @access private
* @var string
*/
var $_from = '';
/**
* E-Mail Subject
*
* @access private
* @var string
*/
var $_subject = '';
/**
* Content of the E-Mail
*
* @access private
* @var string
*/
var $_text = '';
/**
* Flag to drop mail
*
* This flag can be set, e.g. by a plugin, to make the
* send() method drop this mail
*
* @access private
* @var boolean
*/
var $_dropped = false;
/**
* Jlog_Mail() - constructor
*
*/
function Jlog_Mail()
{
$this->_from = 'no-reply@' . $_SERVER['SERVER_NAME'];
$this->_subject = 'Kein Betreff - No Subject';
$this->addHeader('MIME-Version', '1.0');
$this->addHeader('Content-Type', 'text/plain; charset=UTF-8');
$this->addHeader('Content-Transfer-Encoding', '8bit');
$this->addHeader('X-Mailer', 'Jlog with PHP ' . phpversion());
}
/**
* setFrom() - sets from value
*
* @access public
* @param string $email
* @param string $name
* @return void
*/
function setFrom($email, $name)
{
if (!empty($email) and !empty($name)) {
$this->_from = "$name <$email>";
}
}
/**
* getFrom() - gets from value
*
* @access public
* @return string
*/
function getFrom()
{
return $this->_from;
}
/**
* setSubject() - sets subject
*
* @access public
* @param string $text
* @return void
*/
function setSubject($text)
{
if (strlen($text) > 0) {
$this->_subject = $text;
}
}
/**
* getSubject() - gets subject
*
* @access public
* @return string
*/
function getSubject()
{
return $this->_subject;
}
/**
* setText() - sets content of email
*
* @access public
* @param string $text
* @return void
*/
function setText($text)
{
$this->_text = $text;
}
/**
* appendText() - appends content to the email
*
* @access public
* @param string $text
* @return void
*/
function appendText($text)
{
$this->_text .= $text;
}
/**
* getText() - gets content of email
*
* @access public
* @return string
*/
function getText()
{
return $this->_text;
}
/**
* addHeader() - adds an additional header
*
* Adds a header, by replacing any earlier headers of the same name.
* If no value is passed, the key is interpreted as a header line and
* split into key and value.
*
* @access public
* @param string $key
* @param string $value
* @return void
*/
function addHeader($key, $value = null)
{
if ($value === null) {
$data = explode(':', $key, 1);
if (count($data) !== 2) return false;
$key = $data[0];
$value = $data[1];
}
if (strlen($key) < 1 or strlen($value) < 1) return false;
$this->_header[$key] = $value;
}
/**
* unsetHeader() - deletes a header
*
* @access public
* @param string $key
* @return void
*/
function unsetHeader($key)
{
if (isset($this->_header[$key])) unset($this->_header[$key]);
}
/**
* getHeader() - gets a header
*
* @access public
* @return string|null
*/
function getHeader($key)
{
if (isset($this->_header[$key])) return $this->_header[$key];
return null;
}
/**
* getHeaders() - gets all headers
*
* @access public
* @return array
*/
function getHeaders()
{
return $this->_header;
}
/**
* getCleanHeaderString() - gets sanitized header string
*
* @access public
* @return string
*/
function getCleanHeaderString()
{
$headers = '';
foreach ($this->_header as $key => $value) {
// remove all non alpha-numeric chars, except for dash
$key = preg_replace('/[^a-zA-Z0-9-]/', '', $key);
// remove line breaks to prevent header injection
$value = str_replace(array("\r", "\n"), '', $value);
// add header
$headers .= "$key: $value\r\n";
}
return $headers;
}
/**
* dropMail() - sets drop mail flag
*
* Sets a flag that causes the send() method to skip sending this
* email, so that this mail is actualy dropped.
*
* @access public
* @return void
*/
function dropMail()
{
$this->_dropped = true;
}
/**
* send() - sends mail
*
* @access public
* @param string $to
* @return boolean
*/
function send($to)
{
if ($this->_dropped) return false;
$this->addHeader('From', $this->_from);
$safe_mode = strtolower(ini_get('safe_mode'));
if ($safe_mode == 1 or $safe_mode == 'on' or $safe_mode == 'yes') {
@mail($to, $this->_subject, $this->_text, $this->getCleanHeaderString());
}
else {
@mail($to, $this->_subject, $this->_text, $this->getCleanHeaderString(), "-f".JLOG_EMAIL);
}
return true;
}
}
// eof

91
scripts/prepend.inc.php Normal file
View file

@ -0,0 +1,91 @@
<?php
/**
* Jlog
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $HeadURL: http://jeenaparadies.net/svn/jlog/trunk/scripts/prepend.inc.php $
* $Rev: 1739 $
* $Author: driehle $
* $Date: 2008-09-03 15:53:30 +0200 (Ons, 03 Sep 2008) $
*/
// load settings and version information
error_reporting(E_ALL ^ E_NOTICE);
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."personal".DIRECTORY_SEPARATOR."settings.inc.php");
require_once(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."version.inc.php");
// these two constants did not exist in Jlog 1.0.2
if (!defined('JLOG_INSTALLED_VERSION')) {
define('JLOG_INSTALLED_VERSION', '1.0.2');
}
if (!defined('JLOG_LANGUAGE')) {
define('JLOG_LANGUAGE', 'de');
}
// redirect to update-script if new jlog version was installed
if(version_compare(JLOG_INSTALLED_VERSION, JLOG_SOFTWARE_VERSION, '<')
AND substr($_SERVER['SCRIPT_FILENAME'], -17) !== '/admin/update.php')
{
header('Location: ' . JLOG_PATH . '/admin/update.php');
exit;
}
// define constants for names of tables in database
define("JLOG_DB_CONTENT", JLOG_DB_PREFIX."content");
define("JLOG_DB_COMMENTS", JLOG_DB_PREFIX."comments");
define("JLOG_DB_CATASSIGN", JLOG_DB_PREFIX."catassign");
define("JLOG_DB_CATEGORIES", JLOG_DB_PREFIX."categories");
define("JLOG_DB_ATTRIBUTES", JLOG_DB_PREFIX."attributes");
// we need these files on every page
require_once(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang.'.JLOG_LANGUAGE.'.inc.php');
require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'database.class.php');
require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'bbcode.php');
require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'general.func.php');
require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'comments.php');
// additionaly, when in admin-mode, we need this file
if(defined('JLOG_ADMIN')) require_once(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang-admin.'.JLOG_LANGUAGE.'.inc.php');
// connect to database
$connect = @mysql_connect(JLOG_DB_URL, JLOG_DB_USER, JLOG_DB_PWD);
if ($connect == FALSE) {
mail(JLOG_EMAIL, $l['admin']['e_db'], $l['admin']['e_db_is']."\n".mysql_error());
die("<strong>".$l['db_error']."</strong><br />".$l['plz_try_again'].".");
}
// select our database
$select = @mysql_select_db(JLOG_DB);
if ($connect == FALSE) {
mail(JLOG_EMAIL, $l['admin']['e_db'], $l['admin']['e_db_is']."\n".mysql_error());
die("<strong>".$l['db_error']."</strong><br />".$l['plz_try_again'].".");
}
// do some settings
@mysql_query("SET NAMES utf8");
@mysql_query("SET sql_mode=''");
// some more code that needs to run for every page - however, this
// code requires an established connection to the database
setlocale(LC_TIME, $l['locale']);
require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'categories.class.php');
require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'jlogPlugins.class.php');
$plugins = new JlogPluginManager(JLOG_BASEPATH.'plugins'.DIRECTORY_SEPARATOR);
// call hooks for bbcode plugins
$bbcode = $plugins->callHook('bbcode', $bbcode);
$bbcomments = $plugins->callHook('bbcomments', $bbcomments);
// eof

533
scripts/settings.class.php Normal file
View file

@ -0,0 +1,533 @@
<?php
/**
* Jlog
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $HeadURL: http://jeenaparadies.net/svn/jlog/trunk/scripts/settings.class.php $
* $Rev: 1768 $
* $Author: driehle $
* $Date: 2008-09-30 21:43:16 +0200 (Tis, 30 Sep 2008) $
*/
/**
* Settings class
*
* This class represents the current settings for Jlog and
* offers the possibility to modify these settings based on
* user's input. The configuration can be saved to disk,
* if wanted.
*
* @category Jlog
* @package Jlog_Settings
* @license GNU General Public License
*
*/
class Settings {
/**
* Assoziative array holding configuration options
*
* @access private
* @var array
*/
var $d = array();
/**
* Assoziative array holding translations according
* to the current language.
*
* @access private
* @var array
*/
var $l = array();
/**
* Settings() - class constructor
*
* @access public
* @param array $l
* @return void
*/
function Settings($l) {
// get the language array $l and put it into the class
$this->l = $l;
}
/**
* getValue() - reads configuration data
*
* This procedure returns the value for then configuration option
* specified by $key or an array of all options if $key is not
* specified or false
*
* @access public
* @param string|boolean $key
* @return mixed
*/
function getValue($key = false) {
if($key === false) return $this->d;
else return $this->d[strtolower($key)];
}
/**
* setValue() - sets configuration data
*
* @access public
* @param string|boolean $key
* @param mixed $value
* @return mixed
*/
function setValue($key, $value) {
$this->d[strtolower($key)] = $value;
}
/**
* importDataByConstants()
*
* imports data from global constats starting with JLOG_ prefix
*
* @access public
* @return void
*/
function importDataByConstants() {
# no return
// this is a blacklist of constats which are not to be written in settings.inc.php
$search = array(
'JLOG_ADMIN',
'JLOG_DB_CONTENT',
'JLOG_DB_COMMENTS',
'JLOG_DB_CATASSIGN',
'JLOG_DB_CATEGORIES',
'JLOG_DB_ATTRIBUTES',
'JLOG_UPDATE',
'JLOG_LOGIN',
'JLOG_SOFTWARE_VERSION',
'JLOG_SOFTWARE_URL',
'JLOG_SOFTWARE_PHPV',
'JLOG_SOFTWARE_MYSQLV',
'JLOG_ADMIN_PASSWORD_AGAIN'
);
// get all needed constants and put it into the class
$constants = get_defined_constants();
foreach($constants as $key => $value) {
if(!in_array($key, $search) AND strpos($key, "JLOG_") !== false) {
$this->setValue($key, $value);
}
}
}
/**
* importDataByArray() - sets configuration data
*
* Sets configuration data according to $d. If working in
* non-exclusive mode (the default), $d is merged into the current
* configuration, otherwise the current configuration is discared
* and $d is set as the new configuration.
*
* @access public
* @param array $d
* @param boolean $exclusiv
* @return void
*/
function importDataByArray($d = false, $exclusiv = false) {
// get the data from users $d array and put it into the class
if($d !== false) {
if($exclusiv) $this->d = $d;
else $this->d = array_merge($this->d, $d);
}
if(JLOG_ADMIN === true) {
$this->d['jlog_db'] = JLOG_DB;
$this->d['jlog_db_url'] = JLOG_DB_URL;
$this->d['jlog_db_user'] = JLOG_DB_USER;
$this->d['jlog_db_pwd'] = JLOG_DB_PWD;
$this->d['jlog_db_prefix'] = JLOG_DB_PREFIX;
$this->d['jlog_start_year'] = JLOG_START_YEAR;
$this->d['jlog_path'] = JLOG_PATH;
$this->d['jlog_basepath'] = JLOG_BASEPATH;
if($this->d['jlog_admin_password'] == '') {
$this->jlog_admin_password = JLOG_ADMIN_PASSWORD;
}
else {
$this->d['jlog_admin_password'] = md5($this->d['jlog_admin_password']);
$this->d['jlog_admin_password_again'] = md5($this->d['jlog_admin_password_again']);
}
$this->d['jlog_installed_version'] = JLOG_INSTALLED_VERSION;
$this->d['jlog_installed_url'] = JLOG_INSTALLED_URL;
$this->d['jlog_installed_phpv'] = JLOG_INSTALLED_PHPV;
$this->d['jlog_installed_mysqlv'] = JLOG_INSTALLED_MYSQLV;
}
else {
$this->d['jlog_admin_password'] = md5($this->d['jlog_admin_password']);
$this->d['jlog_admin_password_again'] = md5($this->d['jlog_admin_password_again']);
}
if((defined('JLOG_SETUP') AND JLOG_SETUP === true))
{
$this->d['jlog_installed_version'] = JLOG_SOFTWARE_VERSION;
$this->d['jlog_installed_url'] = JLOG_SOFTWARE_URL;
$this->d['jlog_installed_phpv'] = JLOG_SOFTWARE_PHPV;
$this->d['jlog_installed_mysqlv'] = JLOG_SOFTWARE_MYSQLV;
}
}
/**
* importSuggestedData() - preallocates configuration data
*
* Initialises the configuration with useful settings during
* the installation process.
*
* @access public
* @return void
*/
function importSuggestedData() {
// suggest some data for setup
$this->setValue('jlog_path', $this->getSuggestPath());
$this->setValue('jlog_basepath', dirname(dirname( __FILE__ )).DIRECTORY_SEPARATOR);
$date = getdate();
$this->setValue('jlog_start_year', $date['year']);
$this->setValue('jlog_max_blog_orginal', 1);
$this->setValue('jlog_max_blog_big', 4);
$this->setValue('jlog_max_blog_small', 15);
$this->setValue('jlog_sub_current', 6);
$this->setValue('jlog_date', $this->l['date_format']);
$this->setValue('jlog_date_comment', $this->l['date_format_comment']);
$this->setValue('jlog_date_subcurrent', $this->l['date_format_subcurrent']);
$this->setValue('jlog_info_by_comment', true);
$this->setValue('jlog_db_url', 'localhost');
$this->setValue('jlog_db_prefix', 'jlog_');
$this->setValue('jlog_blogservices', 'http://rpc.pingomatic.com/');
$this->setValue('jlog_language', (defined('JLOG_LANGUAGE') ? JLOG_LANGUAGE : 'de'));
}
/**
* getSuggestPath() - generate a suggestion for JLOG_PATH
*
* @access private
* @return string
*/
function getSuggestPath() {
$host = empty($_SERVER['HTTP_HOST'])
? (empty($_SERVER['SERVER_NAME'])
? $_SERVER['SERVER_ADDR']
: $_SERVER['SERVER_NAME'])
: $_SERVER['HTTP_HOST'];
$proto = (empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] == 'off')
? 'http'
: 'https';
$port = $_SERVER['SERVER_PORT'];
$uri = $proto . '://' . $host;
if ((('http' == $proto) and (80 != $port))
or (('https' == $proto) and (443 != $port)))
{
$uri .= ':' . $port;
}
$uri .= dirname($_SERVER['SCRIPT_NAME']);
return $uri;
}
/**
* defaultValue() - gets a value of an array
*
* Look for index $key in the array $array and return
* the corresponding value if it exists or the default
* value $default if it doesn't.
*
* @access public
* @param array $array
* @param mixed $key
* @param mixed $default
* @return mixed
*/
function defaultValue($array, $key, $default = '') {
if(isset($array[$key])) {
return $array[$key];
}
else {
return $default;
}
}
/**
* form_output() - generates HTML output for formular
*
* @access public
* @return string
*/
function form_output() {
# returns the filled form
$data = array_htmlspecialchars($this->d);
if(isset($data['jlog_clean_url']) AND ($data['jlog_clean_url'] === 'true' OR $data['jlog_clean_url'] === '1'))
$d['clean_url_yes'] = " checked='checked'";
else $d['clean_url_no'] = " checked='checked'";
if(isset($data['jlog_info_by_comment'])) $d['info_by_comment'] = " checked='checked'";
else $d['info_by_comment'] = "";
if(isset($data['jlog_bs_weblogs_com']) AND ($data['jlog_bs_weblogs_com'] === 'true' OR $data['jlog_bs_weblogs_com'] === '1'))
$d['bs_weblogs_com'] = " checked='checked' ";
if(defined("JLOG_ADMIN") AND JLOG_ADMIN === true) $admincenter_password = " ".$this->l['admin']['m_admin_password_admin'];
else $admincenter_password = '';
// get available languages
$dir = opendir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang');
$languages = array();
while(($file = readdir($dir)) !== false) {
if($file == '.' OR $file == '..') continue;
if(!preg_match('/lang\.([a-zA-z0-9]+)\.inc\.php/', $file, $matches)) continue;
$languages[] = $matches[1];
}
// do the form
$form = "
<form action='".$_SERVER['SCRIPT_NAME']."' method='post'>
<fieldset><legend>".$this->l['admin']['m_metadata']."</legend>
<p><label for='language'>".$this->l['admin']['m_language']."</label><br />";
if(defined("JLOG_ADMIN") AND JLOG_ADMIN === true) $form .= add_session_id_input_tag();
$form .= "<select class='userdata' id='language' name='jlog_language'>";
foreach($languages as $lang) {
$form .= "<option";
if((isset($_POST['jlog_language']) AND $lang = $_POST['jlog_language']) OR $lang == JLOG_LANGUAGE)
$form .= " selected='selected'";
$form .= ">$lang</option>";
}
$form .= "</select>
</p>
<p><label for='website'>".$this->l['admin']['m_website']."</label><br />
<input class='userdata' id='website' name='jlog_website' type='text' size='20' maxlength='255' value='".$this->defaultValue($data, 'jlog_website')."' /></p>
<p><label for='publisher'>".$this->l['admin']['m_publisher']."</label><br />
<input class='userdata' id='publisher' name='jlog_publisher' type='text' size='20' maxlength='255' value='".$this->defaultValue($data, 'jlog_publisher')."' /></p>
<p><label for='admin_password'>".$this->l['admin']['m_admin_password'].$admincenter_password."</label><br />
<input class='userdata' id='admin_password' name='jlog_admin_password' type='password' size='20' maxlength='255' /></p>
<p><label for='admin_password_again'>".$this->l['admin']['m_admin_password_again'].$admincenter_password."</label><br />
<input class='userdata' id='admin_password_again' name='jlog_admin_password_again' type='password' size='20' maxlength='255' /></p>
<p><label for='email'>".$this->l['admin']['m_email']."</label><br />
<input class='userdata' id='email' name='jlog_email' type='text' size='20' maxlength='255' value='".$this->defaultValue($data, 'jlog_email')."' /></p>
<p><label for='description'>".$this->l['admin']['m_description']."</label><br />
<textarea class='small' id='description' name='jlog_description' rows='2' cols='60'>".$this->defaultValue($data, 'jlog_description')."</textarea></p>
</fieldset>
<fieldset><legend>".$this->l['admin']['m_behavior']."</legend>
<p><label>".$this->l['admin']['m_clean_url']."</label><br />
<input id='clean_url_yes' name='jlog_clean_url' type='radio' value='true'".$d['clean_url_yes']." /><label class='nobreak' for='clean_url_yes'>".$this->l['admin']['yes']."</label>
<input id='clean_url_no' name='jlog_clean_url' type='radio' value='false'".$d['clean_url_no']." /><label class='nobreak' for='clean_url_no'>".$this->l['admin']['no']."</label></p>
<p><label for='max_blog_orginal'>".$this->l['admin']['m_max_blog_orginal']."</label><br />
<input class='short' id='max_blog_orginal' name='jlog_max_blog_orginal' type='text' maxlength='3' size='3' value='".$this->defaultValue($data, 'jlog_max_blog_orginal')."' /></p>
<p><label for='max_blog_big'>".$this->l['admin']['m_max_blog_big']."</label><br />
<input class='short' id='max_blog_big' name='jlog_max_blog_big' type='text' size='3' maxlength='3' value='".$this->defaultValue($data, 'jlog_max_blog_big')."' /></p>
<p><label for='max_blog_small'>".$this->l['admin']['m_max_blog_small']."</label><br />
<input class='short' id='max_blog_small' name='jlog_max_blog_small' type='text' size='3' maxlength='3' value='".$this->defaultValue($data, 'jlog_max_blog_small')."' /></p>
<p><label for='sub_current'>".$this->l['admin']['m_sub_current']."</label><br />
<input class='short' id='sub_current' name='jlog_sub_current' type='text' size='3' maxlength='3' value='".$this->defaultValue($data, 'jlog_sub_current')."' /></p>
<p><input id='info_by_comment' name='jlog_info_by_comment' type='checkbox' value='true'".$d['info_by_comment']."/> <label for='info_by_comment' class='nobreak'>".$this->l['admin']['m_info_by_comment']."</label></p>
<p><label for='date'>".$this->l['admin']['m_date']."</label></p>
<p><input class='userdata' id='date' name='jlog_date' type='text' value='".$this->defaultValue($data, 'jlog_date')."' size='20' /> <label for='date' class='nobreak'>".$this->l['admin']['m_date_posting']."</label></p>
<p><input class='userdata' id='date_comment' name='jlog_date_comment' type='text' value='".$this->defaultValue($data, 'jlog_date_comment')."' size='20' /> <label for='date_comment' class='nobreak'>".$this->l['admin']['m_date_comment']."</label></p>
<p><input class='userdata' id='date_subcurrent' name='jlog_date_subcurrent' type='text' value='".$this->defaultValue($data, 'jlog_date_subcurrent')."' size='20' /> <label for='date_subcurrent' class='nobreak'>".$this->l['admin']['m_date_subcurrent']."</label></p>
<p><label for='blogservices'>".$this->l['admin']['m_bs']."</label></p>
<p><textarea class='small' id='blogservices' name='jlog_blogservices' rows='2' cols='60'>".$this->defaultValue($data, 'jlog_blogservices')."</textarea></p>
</fieldset>
";
if(defined('JLOG_SETUP') AND JLOG_SETUP === true) {
$form .=
"
<fieldset><legend>".$this->l['admin']['m_database']."</legend>
<p><label for='db'>".$this->l['admin']['m_db']."</label><br />
<input class='userdata' id='db' name='jlog_db' type='text' size='20' maxlength='255' value='".$this->defaultValue($data, 'jlog_db')."' /></p>
<p><label for='db_url'>".$this->l['admin']['m_db_url']."</label><br />
<input class='userdata' id='db_url' name='jlog_db_url' type='text' size='20' maxlength='255' value='".$this->defaultValue($data, 'jlog_db_url')."' /></p>
<p><label for='db_user'>".$this->l['admin']['m_db_user']."</label><br />
<input class='userdata' id='db_user' name='jlog_db_user' type='text' size='20' maxlength='255' value='".$this->defaultValue($data, 'jlog_db_user')."' /></p>
<p><label for='db_pwd'>".$this->l['admin']['m_db_pwd']."</label><br />
<input class='userdata' id='db_pwd' name='jlog_db_pwd' type='password' size='20' maxlength='255' value='".$this->defaultValue($data, 'jlog_db_pwd')."' /></p>
<p><label for='db_prefix'>".$this->l['admin']['m_db_prefix']."</label><br />
<input class='userdata' id='db_prefix' name='jlog_db_prefix' type='text' size='20' maxlength='255' value='".$this->defaultValue($data, 'jlog_db_prefix')."' />
<input name='jlog_start_year' type='hidden' value='".$this->defaultValue($data, 'jlog_start_year', date("Y"))."' /></p>
<input name='jlog_path' type='hidden' value='".$this->defaultValue($data, 'jlog_path')."' />
<input name='jlog_basepath' type='hidden' value='".$this->defaultValue($data, 'jlog_basepath')."' />
</fieldset>
";
}
$form .= "
<p><input type='submit' class='button' value='".$this->l['admin']['submit']."' /></p>
</form>
";
return $form;
}
/**
* validate() - validates the current configuration
*
* If the current configuration is valid, an empty array is returned.
* Otherwise the returned array containes all errors, described in the
* current language.
*
* @access public
* @return array
*/
function validate() {
# if everything validate then return true
# otherwise return the $errors array
$errors = array();
// paths
if(empty($this->d['jlog_path']) OR (check_url($this->d['jlog_path'], array ('http')) === false)) $errors[] = $this->l['admin']['e_path'];
if(empty($this->d['jlog_basepath']) OR !is_dir($this->d['jlog_basepath'])) $errors[] = $this->l['admin']['e_basepath'];
if($this->d['jlog_clean_url'] != 'true') $this->d['jlog_clean_url'] = 'false';
// metadata
if(empty($this->d['jlog_website'])) $errors[] = $this->l['admin']['e_website'];
if(empty($this->d['jlog_publisher'])) $errors[] = $this->l['admin']['e_publisher'];
if(defined('JLOG_SETUP') AND JLOG_SETUP) {
if($this->d['jlog_admin_password'] == md5(""))
$errors[] = $this->l['admin']['e_admin_password'];
elseif($this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again'])
$errors[] = $this->l['admin']['e_admin_password_again'];
}
elseif(!empty($this->d['jlog_admin_password']) AND $this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again']) {
$errors[] = $this->l['admin']['e_admin_password_again'];
}
// Fix of bug #148
if(isset($this->d['jlog_admin_password_again']))
unset($this->d['jlog_admin_password_again']);
if(empty($this->d['jlog_email']) OR !strpos($this->d['jlog_email'], '@')) $errors[] = $this->l['admin']['e_email'];
if(empty($this->d['jlog_description'])) $errors[] = $this->l['admin']['e_description'];
// behavour
if(!is_numeric($this->d['jlog_max_blog_orginal']) OR intval($this->d['jlog_max_blog_orginal']) < 0) $errors[] = $this->l['admin']['e_max_blog_orginal'];
if(!is_numeric($this->d['jlog_max_blog_big']) OR intval($this->d['jlog_max_blog_big']) < 0) $errors[] = $this->l['admin']['e_max_blog_big'];
if(!is_numeric($this->d['jlog_max_blog_small']) OR intval($this->d['jlog_max_blog_small']) < 0) $errors[] = $this->l['admin']['e_max_blog_small'];
if(!is_numeric($this->d['jlog_sub_current']) OR intval($this->d['jlog_sub_current']) < 0) $errors[] = $this->l['admin']['e_sub_current'];
if(!is_numeric($this->d['jlog_start_year'])) $errors[] = $this->l['admin']['e_start_year'];
if($this->d['jlog_info_by_comment'] != 'true') $this->d['jlog_info_by_comment'] = 'false';
// database
if(empty($this->d['jlog_db'])) $errors[] = $this->l['admin']['e_db'];
if(empty($this->d['jlog_db_url'])) $errors[] = $this->l['admin']['e_db_url'];
// Fix of bug #196, prefix should only contain alphanumeric values, can be empty!
if(!preg_match('/^[a-zA-Z0-9_]*$/', $this->d['jlog_db_prefix'])) $errors[] = $this->l['admin']['e_db_prefix'];
return $errors;
}
/**
* do_settings() - save configuration
*
* Saves the current configuration to the settings.inc.php file
* in the personal folder. Return an empty array if configuration
* was saved successfully, or an array containing descriptions of
* the errors that occured otherwise.
*
* @access public
* @return array
*/
function do_settings() {
# if it's all done return true
# otherwise return the $errors array
$errors = array();
// if there is no new password set the old
if(JLOG_ADMIN AND empty($this->d['jlog_admin_password'])) $this->d['jlog_admin_password'] = JLOG_ADMIN_PASSWORD;
// remove slashes at the end of JLOG_PATH if present
$this->d['jlog_path'] = rtrim($this->d['jlog_path'], '/');
// make shure JLOG_BASEPATH ends with a slash!!
$this->d['jlog_basepath'] = rtrim($this->d['jlog_basepath'], '/\\') . DIRECTORY_SEPARATOR;
// no quotes for bolean and numbers
$no_quotes = array (
'jlog_clean_url' => 'bool',
'jlog_max_blog_orginal' => 'int',
'jlog_max_blog_big' => 'int',
'jlog_max_blog_small' => 'int',
'jlog_sub_current' => 'int',
'jlog_start_year' => 'int',
'jlog_info_by_comment' => 'bool'
);
// serialize data to file format
$file_content = '<?php' . PHP_EOL . '// generated at ' . date('Y-m-d, h:i:s') . PHP_EOL;
foreach($this->d as $key => $value) {
$output = '';
if(isset($no_quotes[$key])) {
// boolean values
if($no_quotes[$key] == 'bool') {
if($value == 'true' OR $value === true) $output = 'true';
else $output = 'false';
}
// numeric values
else {
$output = (int) $value;
}
}
// string values
else {
$output = '\'' . $this->escapeForPhp($value) . '\'';
}
$key = '\'' . $this->escapeForPhp(strtoupper($key)) . '\'';
$file_content .= 'define(' . $key . ', ' . $output . ');' . PHP_EOL;
}
$file_content .= '// eof';
// write to settings.inc.php
if(!$handle = fopen(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."settings.inc.php", "w")) $errors[] = $this->l['admin']['can_not_open']." /personal/settings.inc.php";
if(!fwrite($handle, $file_content)) $errors[] = $this->l['admin']['can_not_write']." /personal/settings.inc.php";
fclose($handle);
return $errors;
}
/**
* escapeForPhp()
*
* escapes $value so that it can be used between single quotes in a
* PHP script, single quotes are better than double qoutes, as therein no
* further substituions are performed
*
* @access public
* @param string $value
* @return string
*/
function escapeForPhp($value) {
$value = str_replace('\\', '\\\\', $value);
$value = str_replace("'", "\'", $value);
$value = str_replace("\0", '', $value);
$value = str_replace("\r\n", "'.chr(13).chr(10).'", $value);
$value = str_replace("\r", "'.chr(13).'", $value);
$value = str_replace("\n", "'.chr(10).'", $value);
return $value;
}
}
// eof

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

135
scripts/update.php Normal file
View file

@ -0,0 +1,135 @@
<?php
$now_date = getdate();
$data['rss'] = "";
$data['rss_full'] = "";
$data['sub'] = "";
if(JLOG_SUB_CURRENT < 15) $limit = "LIMIT 15";
else $limit = "LIMIT ".JLOG_SUB_CURRENT;
$sql = "SELECT id, url, topic, UNIX_TIMESTAMP(date) AS date,
teaser, teaserpic, teaserpiconblog, keywords, content,
comments, allowpingback, section
FROM ".JLOG_DB_CONTENT."
WHERE section = 'weblog'
ORDER BY date DESC
".$limit.";";
$rss_sub = new Query($sql);
if($rss_sub->error()) {
echo "<pre>\n";
echo $rss_sub->getError();
echo "</pre>\n";
die();
}
if(defined('JLOG_ADMIN') AND !defined('JLOG_COMMENTS')) {
$data['rss'] = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?" . ">
<rss version=\"2.0\">
<channel>
<title>".htmlspecialchars(JLOG_WEBSITE)."</title>
<link>".htmlspecialchars(JLOG_PATH)."</link>
<description>".htmlspecialchars(JLOG_DESCRIPTION)."</description>
<language>".$l['language']."</language>
<lastBuildDate>".date('r')."</lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>&lt;a href=&quot;".JLOG_SOFTWARE_URL."&quot;&gt;Jlog v".JLOG_SOFTWARE_VERSION."&lt;/a&gt;</generator>
<managingEditor>".htmlspecialchars(JLOG_PUBLISHER)." ".htmlspecialchars(JLOG_EMAIL)."</managingEditor>
<copyright>&amp;copy;".$now_date['year']." by ".htmlspecialchars(JLOG_PUBLISHER)."</copyright>\n\n";
$data['rss_full'] = $data['rss'];
}
$data['sub'] = "<ul class='subcurrentlist'>\n";
if(!isset($cc)) $cc = count_comments();
$sub = 0;
while ($row = $rss_sub->fetch()) {
++$sub;
if($sub <= JLOG_SUB_CURRENT) {
$tmp_comments = "";
if(isset($cc[$row['id']]) AND $cc[$row['id']] != 0) $tmp_comments = " <a class='comments' title='".$l['content_comments_title']."' href='".blog($row['date'], $row['url'])."#comments'>(".$cc[$row['id']].")</a>";
$data['sub'] .= " <li>".strftime(JLOG_DATE_SUBCURRENT, $row['date'])." <a href='".blog($row['date'], $row['url'])."'>".htmlspecialchars($row['topic'], ENT_QUOTES)."</a>".$tmp_comments."</li>\n";
}
if($sub <= 15 AND defined('JLOG_ADMIN')) {
# Kopfdaten
$data['rss'] .= " <item>\n <title>".htmlspecialchars($row['topic'], ENT_QUOTES)."</title>\n";
$data['rss_full'] .= " <item>\n <title>".htmlspecialchars($row['topic'], ENT_QUOTES)."</title>\n";
$data['rss'] .= " <guid isPermaLink=\"true\">".blog($row['date'], $row['url'])."</guid>\n";
$data['rss_full'] .= " <guid isPermaLink=\"true\">".blog($row['date'], $row['url'])."</guid>\n";
$data['rss'] .= " <pubDate>".date('r', $row['date'])."</pubDate>\n";
$data['rss_full'] .= " <pubDate>".date('r', $row['date'])."</pubDate>\n";
$data['rss'] .= " <link>".blog($row['date'], $row['url'])."</link>\n";
$data['rss_full'] .= " <link>".blog($row['date'], $row['url'])."</link>\n";
$data['rss'] .= " <comments>".blog($row['date'], $row['url'])."#comments</comments>\n";
$data['rss_full'] .= " <comments>".blog($row['date'], $row['url'])."#comments</comments>\n";
$data['rss'] .= $categories->output_rss($row['id']);
$data['rss_full'] .= $categories->output_rss($row['id']);
# Inhaltsdaten
$data['rss'] .= " <description>\n".htmlspecialchars($bbcode->parse($row['teaser']))."\n </description>\n";
$data['rss_full'] .= " <description>\n";
if($row['teaserpiconblog'] == 1) $data['rss_full'] .= htmlspecialchars("<img src='".JLOG_PATH."/personal/img/t_".$row['teaserpic']."' alt='' />");
$data['rss_full'] .= htmlspecialchars($bbcode->parse($row['content']))."\n </description>\n";
$data['rss'] .= " </item>\n\n";
$data['rss_full'] .= " </item>\n\n";
}
}
if(defined('JLOG_ADMIN') AND !defined('JLOG_COMMENTS')) {
$data['rss'] .= "</channel>\n</rss>";
$data['rss_full'] .= "</channel>\n</rss>";
}
$data['sub'] .= " </ul>";
if(defined('JLOG_ADMIN') AND !defined('JLOG_COMMENTS')) {
$file['rss'] = JLOG_BASEPATH.'personal'.DIRECTORY_SEPARATOR.'rss.xml';
$file['rss_full'] = JLOG_BASEPATH.'personal'.DIRECTORY_SEPARATOR.'rss-full.xml';
}
$file['sub'] = JLOG_BASEPATH.'personal'.DIRECTORY_SEPARATOR.'subcurrent.inc';
### Plugin Hook
if (isset($plugins) and is_object($plugins)) {
$data = $plugins->callHook('onUpdate', $data);
}
$i = 0;
foreach($file AS $d => $filename) {
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'w')) {
$errors[] .= $l['admin']['can_not_open']." ($filename)";
exit;
}
if (!fwrite($handle, $data[$d])) {
$errors[] .= $l['admin']['can_not_write']." ($filename)";
exit;
}
++$i;
fclose($handle);
} else {
$errors[] .= $l['admin']['no_wrtitenable']." ($filename)";
}
}
if(count($errors) > 0) {
$c['main'] .= error_output($errors);
}
if($i == 4 AND defined('JLOG_ADMIN') AND !defined('JLOG_COMMENTS')) $c['main'] .= "<p>".$l['admin']['rss_ok']."</p>";
unset($i);
unset($sub);
?>

View file

@ -0,0 +1,66 @@
<?php
class JlogUpdate_102To110
{
var $languages = array();
function JlogUpdate_102To110()
{
$dir = opendir(JLOG_BASEPATH.'lang');
while(($file = readdir($dir)) !== false) {
if($file == '.' OR $file == '..') continue;
if(!preg_match('/lang\.([a-zA-z0-9]+)\.inc\.php/', $file, $matches)) continue;
$this->languages[] = $matches[1];
}
}
function getForm($l)
{
$html = "<p><label for='language'>Bitte wählen Sie die gewünschte Sprache für Ihr Weblog:</label><br />
<select class='userdata' id='language' name='j110_language'>";
foreach($this->languages as $lang) {
$html .= "<option>$lang</option>";
}
$html .= "</select>
</p>
<p>Die Zeichenkodierung ihrer Template-Datei <code>personal/template.tpl</code> muss nach UTF-8 umgewandelt werden. Wenn diese Datei
beschreibbar ist (z.B.: chmod 777), wird dies vom Updatescript automatisch für sie erledigt.
Andernfalls müssen Sie die Konvertierung nachträglich manuell vornehmen.</p>
";
return $html;
}
function performUpdate($l, $settings)
{
// convert all settings to utf8
foreach($settings->d as $key => $value) {
$settings->d[$key] = utf8_encode($value);
}
// reset hash of the administrator password
$settings->d['jlog_admin_password'] = md5($_POST['password']);
// store chosen language
$lang = in_array($_POST['j110_language'], $this->languages) ? $_POST['j110_language'] : 'de';
$settings->d['jlog_language'] = $lang;
$update_errors = array();
/**
* On a correct Jlog 1.0.2 installation, the template is saved with an ISO
* encoding, so we're going to try to convert this to UTF-8
*/
$template = JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."template.tpl";
if(@file_put_contents($template, utf8_encode(@file_get_contents($template))) == false) {
$update_errors[] = 'Die Datei <code>personal/template.tpl</code> konnte nicht in UTF-8 Kodierung konvertiert werden.';
}
if(empty($update_errors)) {
return true;
}
else {
return $update_errors;
}
}
}

View file

@ -0,0 +1,14 @@
<?php
class JlogUpdate_110To111
{
function getForm($l)
{
return '<p>Keine Einstellungen notwendig.</p>';
}
function performUpdate($l, $settings)
{
return true;
}
}

View file

@ -0,0 +1,28 @@
<?php
class JlogUpdate_111To112
{
function getForm($l)
{
return '<p>Dieses Script behebt ein paar fehlerhafte Einstellungen.'
.' Es ist keine Konfiguration notwendig.</p>';
}
function performUpdate($l, $settings)
{
// in jlog versions prior to jlog 1.1.2 we had escaping problems that caused
// a lot of backslashes in front of a double quote
// so we have to replace \" or \\" or \\\" and so on by ".
$data = array(
'jlog_description' => $settings->getValue('jlog_description'),
'jlog_website' => $settings->getValue('jlog_website'),
'jlog_publisher' => $settings->getValue('jlog_publisher')
);
foreach ($data as $key => $value) {
$value = preg_replace('=\\\\+"=', '"', $value);
$settings->setValue($key, $value);
}
return true;
}
}

View file

@ -0,0 +1,15 @@
<?php
class JlogUpdate_112To113
{
function getForm($l)
{
return '<p>Bitte beachten Sie, dass nach Durchführung dieses Updates eventuell einzelne Plugins nicht mehr funktionieren.<br />'
. 'Kontaktieren Sie in einem solchen Fall den Plugin-Autor bzzgl. eines Updates für das Plugin.</p>';
}
function performUpdate($l, $settings)
{
return true;
}
}

View file

@ -0,0 +1,42 @@
<?php
/**
* This is an example file, how update classes have to look like.
*
* Since we want to support PHP 4, unfortunately we can't use
* all the new OOP functions PHP 5 offers. In future this file may
* be a abstract class that all update classes have to extend.
*/
class JlogUpdate_Example
{
/**
* You can do anything you want here
*/
function __construct()
{
}
/**
* This function should prepare parts of the form for the update
*
* It gets the language array as the first parameter and
* must return html for the update form.
*/
function getForm($l)
{
return '<p>Do not need anything to configure for this update.</p>';
}
/**
* This function has to perform the update
*
* Must return true, if everything went well, of an array of error
* messages, if something went wrong.
* The first parameter again in the language array.
*/
function performUpdate($l)
{
return true;
}
}

248
scripts/url_syntax.php Normal file
View file

@ -0,0 +1,248 @@
<?php
function check_url ($url2check, $types) {
# Be paranoid about using grouping!
$nz_digit = '[1-9]';
$nz_digits = "(?:$nz_digit\\d*)";
$digits = '(?:\d+)';
$space = '(?:%20)';
$nl = '(?:%0[Aa])';
$dot = '\.';
$plus = '\+';
$qm = '\?';
$ast = '\*';
$hex = '[a-fA-F\d]';
$alpha = '[a-zA-Z]'; # No, no locale.
$alphas = "(?:${alpha}+)";
$alphanum = '[a-zA-Z\d]'; # Letter or digit.
$xalphanum = "(?:${alphanum}|%(?:3\\d|[46]$hex|[57][Aa\\d]))";
# Letter or digit, or hex escaped letter/digit.
$alphanums = "(?:${alphanum}+)";
$escape = "(?:%$hex\{2})";
$safe = '[$\-_.+]';
$extra = "[\!*'(),]";
$national = '[{}|\\^~[\]`]';
$punctuation = '[<>#%"]';
$reserved = '[;/?:@&=]';
$uchar = "(?:${alphanum}|${safe}|${extra}|${escape})";
$xchar = "(?:${alphanum}|${safe}|${extra}|${reserved}|${escape})";
$uchar = str_replace (']|[', '', $uchar); // Make string smaller, and speed up regex.
$uchar = str_replace (']|[', '', $xchar); // Make string smaller, and speed up regex.
# URL schemeparts for ip based protocols:
$user = "(?:(?:${uchar}|[;?&=])*)";
$password = "(?:(?:${uchar}|[;?&=])*)";
$hostnumber = "(?:${digits}(?:${dot}${digits}){3})";
$toplabel = "(?:${alpha}(?:(?:${alphanum}|-)*${alphanum})?)";
$domainlabel = "(?:${alphanum}(?:(?:${alphanum}|-)*${alphanum})?)";
$hostname = "(?:(?:${domainlabel}${dot})*${toplabel})";
$host = "(?:${hostname}|${hostnumber})";
$hostport = "(?:${host}(?::${digits})?)";
$login = "(?:(?:${user}(?::${password})?\@)?${hostport})";
# The predefined schemes:
# FTP (see also RFC959)
$fsegment = "(?:(?:${uchar}|[?:\@&=])*)";
$fpath = "(?:${fsegment}(?:/${fsegment})*)";
$ftpurl = "(?:ftp://${login}(?:/${fpath}(?:;type=[AIDaid])?)?)";
# FILE
$fileurl = "(?:file://(?:${host}|localhost)?/${fpath})";
# HTTP
$hsegment = "(?:(?:${uchar}|[~;:\@&=])*)";
$search = "(?:(?:${uchar}|[;:\@&=])*)";
$hpath = "(?:${hsegment}(?:/${hsegment})*)";
$httpurl = "(?:https?://${hostport}(?:/${hpath}(?:${qm}${search})?)?)";
# GOPHER (see also RFC1436)
$gopher_plus = "(?:${xchar}*)";
$selector = "(?:${xchar}*)";
$gtype = $xchar; // Omitted parens!
$gopherurl = "(?:gopher://${hostport}(?:/${gtype}(?:${selector}" .
"(?:%09${search}(?:%09${gopher_plus})?)?)?)?)";
# MAILTO (see also RFC822)
$encoded822addr = "(?:$xchar+)";
$mailtourl = "(?:mailto:$encoded822addr)";
$mailtonpurl = $encoded822addr;
# NEWS (see also RFC1036)
$article = "(?:(?:${uchar}|[;/?:&=])+\@${host})";
$group = "(?:${alpha}(?:${alphanum}|[_.+-])*)";
$grouppart = "(?:${article}|${group}|${ast})";
$newsurl = "(?:news:${grouppart})";
# NNTP (see also RFC977)
$nntpurl = "(?:nntp://${hostport}/${group}(?:/${digits})?)";
# TELNET
$telneturl = "(?:telnet://${login}/?)";
# WAIS (see also RFC1625)
$wpath = "(?:${uchar}*)";
$wtype = "(?:${uchar}*)";
$database = "(?:${uchar}*)";
$waisdoc = "(?:wais://${hostport}/${database}/${wtype}/${wpath})";
$waisindex = "(?:wais://${hostport}/${database}${qm}${search})";
$waisdatabase = "(?:wais://${hostport}/${database})";
# $waisurl = "(?:${waisdatabase}|${waisindex}|${waisdoc})";
# Speed up: the 3 types share a common prefix.
$waisurl = "(?:wais://${hostport}/${database}" .
"(?:(?:/${wtype}/${wpath})|${qm}${search})?)";
# PROSPERO
$fieldvalue = "(?:(?:${uchar}|[?:\@&])*)";
$fieldname = "(?:(?:${uchar}|[?:\@&])*)";
$fieldspec = "(?:;${fieldname}=${fieldvalue})";
$psegment = "(?:(?:${uchar}|[?:\@&=])*)";
$ppath = "(?:${psegment}(?:/${psegment})*)";
$prosperourl = "(?:prospero://${hostport}/${ppath}(?:${fieldspec})*)";
# LDAP (see also RFC1959)
# First. import stuff from RFC 1779 (Distinguished Names).
# We've modified things a bit.
$dn_separator = "(?:[;,])";
$dn_optional_space = "(?:${nl}?${space}*)";
$dn_spaced_separator = "(?:${dn_optional_space}${dn_separator}" .
"${dn_optional_space})";
$dn_oid = "(?:${digits}(?:${dot}${digits})*)";
$dn_keychar = "(?:${xalphanum}|${space})";
$dn_key = "(?:${dn_keychar}+|(?:OID|oid)${dot}${dn_oid})";
$dn_string = "(?:${uchar}*)";
$dn_attribute = "(?:(?:${dn_key}${dn_optional_space}=" .
"${dn_optional_space})?${dn_string})";
$dn_name_component = "(?:${dn_attribute}(?:${dn_optional_space}" .
"${plus}${dn_optional_space}${dn_attribute})*)";
$dn_name = "(?:${dn_name_component}" .
"(?:${dn_spaced_separator}${dn_name_component})*" .
"${dn_spaced_separator}?)";
# RFC 1558 defines the filter syntax, but that requires a PDA to recognize.
# Since that's too powerful for Perl's REs, we allow any char between the
# parenthesis (which have to be there.)
$ldap_filter = "(?:\(${xchar}+\))";
# This is from RFC 1777. It defines an attributetype as an 'OCTET STRING',
# whatever that is.
$ldap_attr_type = "(?:${uchar}+)"; # I'm just guessing here.
# The RFCs aren't clear.
# Now we are at the grammar of RFC 1959.
$ldap_attr_list = "(?:${ldap_attr_type}(?:,${ldap_attr_type})*)";
$ldap_attrs = "(?:${ldap_attr_list}?)";
$ldap_scope = "(?:base|one|sub)";
$ldapurl = "(?:ldap://(?:${hostport})?/${dn_name}" .
"(?:${qm}${ldap_attrs}" .
"(?:${qm}${ldap_scope}(?:${qm}${ldap_filter})?)?)?)";
# RFC 2056 defines the format of URLs for the Z39.50 protocol.
$z_database = "(?:${uchar}+)";
$z_docid = "(?:${uchar}+)";
$z_elementset = "(?:${uchar}+)";
$z_recordsyntax = "(?:${uchar}+)";
$z_scheme = "(?:z39${dot}50[rs])";
$z39_50url = "(?:${z_scheme}://${hostport}" .
"(?:/(?:${z_database}(?:${plus}${z_database})*" .
"(?:${qm}${z_docid})?)?" .
"(?:;esn=${z_elementset})?" .
"(?:;rs=${z_recordsyntax}" .
"(?:${plus}${z_recordsyntax})*)?))";
# RFC 2111 defines the format for cid/mid URLs.
$url_addr_spec = "(?:(?:${uchar}|[;?:@&=])*)";
$message_id = $url_addr_spec;
$content_id = $url_addr_spec;
$cidurl = "(?:cid:${content_id})";
$midurl = "(?:mid:${message_id}(?:/${content_id})?)";
# RFC 2122 defines the Vemmi URLs.
$vemmi_attr = "(?:(?:${uchar}|[/?:@&])*)";
$vemmi_value = "(?:(?:${uchar}|[/?:@&])*)";
$vemmi_service = "(?:(?:${uchar}|[/?:@&=])*)";
$vemmi_param = "(?:;${vemmi_attr}=${vemmi_value})";
$vemmiurl = "(?:vemmi://${hostport}" .
"(?:/${vemmi_service}(?:${vemmi_param}*))?)";
# RFC 2192 for IMAP URLs.
# Import from RFC 2060.
# $imap4_astring = "";
# $imap4_search_key = "";
# $imap4_section_text = "";
$imap4_nz_number = $nz_digits;
$achar = "(?:${uchar}|[&=~])";
$bchar = "(?:${uchar}|[&=~:\@/])";
$enc_auth_type = "(?:${achar}+)";
$enc_list_mbox = "(?:${bchar}+)";
$enc_mailbox = "(?:${bchar}+)";
$enc_search = "(?:${bchar}+)";
$enc_section = "(?:${bchar}+)";
$enc_user = "(?:${achar}+)";
$i_auth = "(?:;[Aa][Uu][Tt][Hh]=(?:${ast}|${enc_auth_type}))";
$i_list_type = "(?:[Ll](?:[Ii][Ss][Tt]|[Ss][Uu][Bb]))";
$i_mailboxlist = "(?:${enc_list_mbox}?;[Tt][Yy][Pp][Ee]=${i_list_type})";
$i_uidvalidity = "(?:;[Uu][Ii][Dd][Vv][Aa][Ll][Ii][Dd][Ii][Tt][Yy]=" .
"${imap4_nz_number})";
$i_messagelist = "(?:${enc_mailbox}(?:${qm}${enc_search})?" .
"(?:${i_uidvalidity})?)";
$i_section = "(?:/;[Ss][Ee][Cc][Tt][Ii][Oo][Nn]=${enc_section})";
$i_uid = "(?:/;[Uu][Ii][Dd]=${imap4_nz_number})";
$i_messagepart = "(?:${enc_mailbox}(?:${i_uidvalidity})?${i_uid}" .
"(?:${i_section})?)";
$i_command = "(?:${i_mailboxlist}|${i_messagelist}|${i_messagepart})";
$i_userauth = "(?:(?:${enc_user}(?:${i_auth})?)|" .
"(?:${i_auth}(?:${enc_user})?))";
$i_server = "(?:(?:${i_userauth}\@)?${hostport})";
$imapurl = "(?:imap://${i_server}/(?:$i_command)?)";
# RFC 2224 for NFS.
$nfs_mark = '[\$\-_.\!~*\'(),]';
$nfs_unreserved = "(?:${alphanum}|${nfs_mark})";
$nfs_unreserved = str_replace (']|[', '', $nfs_unreserved); // Make string smaller, and speed up regex.
$nfs_pchar = "(?:${nfs_unreserved}|${escape}|[:\@&=+])";
$nfs_segment = "(?:${nfs_pchar}*)";
$nfs_path_segs = "(?:${nfs_segment}(?:/${nfs_segment})*)";
$nfs_url_path = "(?:/?${nfs_path_segs})";
$nfs_rel_path = "(?:${nfs_path_segs}?)";
$nfs_abs_path = "(?:/${nfs_rel_path})";
$nfs_net_path = "(?://${hostport}(?:${nfs_abs_path})?)";
$nfs_rel_url = "(?:${nfs_net_path}|${nfs_abs_path}|${nfs_rel_path})";
$nfsurl = "(?:nfs:${nfs_rel_url})";
$valid_types = array (
'http', 'ftp', 'news', 'nntp', 'telnet', 'gopher', 'wais', 'mailto',
'mailtonp', 'file', 'prospero', 'ldap', 'z39_50', 'cid', 'mid', 'vemmi',
'imap', 'nfs'
);
# Combining all the different URL formats into a single regex.
$valid = false;
if (!is_array ($types)) {
$types = array ($types);
}
foreach ($types as $type) {
if (!in_array ($type, $valid_types)) {
continue;
}
$re = $type.'url';
if (preg_match ('!^'.$$re.'$!i', $url2check)) {
$valid = $type;
break;
}
}
return $valid;
}
?>

31
scripts/version.inc.php Normal file
View file

@ -0,0 +1,31 @@
<?php
/**
* Jlog
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $HeadURL: http://jeenaparadies.net/svn/jlog/trunk/scripts/version.inc.php $
* $Rev: 1785 $
* $Author: driehle $
* $Date: 2009-01-13 21:58:12 +0100 (Tis, 13 Jan 2009) $
*/
define('JLOG_SOFTWARE_VERSION', '1.1.3');
define('JLOG_SOFTWARE_URL', 'http://jeenaparadies.net/projects/jlog');
define('JLOG_SOFTWARE_PHPV', '4.1.1');
define('JLOG_SOFTWARE_MYSQLV', '4.1.0');
// eof