Populating missing files from this 'branch'.
git-svn-id: https://develop.svn.wordpress.org/trunk@8 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
28d75c72a5
commit
267bca49b8
99
b2-include/b2.css
Normal file
99
b2-include/b2.css
Normal file
@ -0,0 +1,99 @@
|
||||
body {
|
||||
margin-top: 0px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
margin-bottom: 0px;
|
||||
background-color: #FFFFFF}
|
||||
body, td {
|
||||
color: #000000;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica;
|
||||
font-size: 10pt;
|
||||
}
|
||||
a {
|
||||
background-color: transparent;
|
||||
color: #0000FF;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
a:hover {
|
||||
color: #FF3300;
|
||||
text-decoration: underline;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.panelbody {
|
||||
/* empty style - for you to customize it.
|
||||
this style applies to b2's interface, the part where the sections are displayed */
|
||||
}
|
||||
.table {
|
||||
color: #000000;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica;
|
||||
font-size: 10pt;
|
||||
}
|
||||
.tabletoprow {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica;
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
}
|
||||
.search {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
color: #000066;
|
||||
background-color: #ffeecc;
|
||||
background-image: url("../b2-img/b2button.gif");
|
||||
}
|
||||
.quicktags {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
color: #000000;
|
||||
background-color: #cccccc;
|
||||
background-image: url("../b2-img/b2button2.gif");
|
||||
}
|
||||
|
||||
.menutop {
|
||||
color: #999999;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica;
|
||||
font-size: 10px;
|
||||
background-color: #DDEEFF;
|
||||
}
|
||||
a.menutop {
|
||||
background-color: transparent;
|
||||
color: #3366CC;
|
||||
font-weight: normal;
|
||||
border-width: 0px;
|
||||
}
|
||||
a.menutop:hover {
|
||||
color: #FF9900;
|
||||
text-decoration: underline;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.menutoptitle {
|
||||
font-family: Arial, Verdana, Geneva, Arial, Helvetica;
|
||||
color: #BBCCDD;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.b2menutop {
|
||||
color: #333333;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica;
|
||||
font-size: 10px;
|
||||
}
|
||||
a.b2menutop {
|
||||
background-color: transparent;
|
||||
color: #0066ff;
|
||||
font-weight: lighter;
|
||||
}
|
||||
a.b2menutop:hover {
|
||||
color: #ff9900;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
xmp { /* Just in case */
|
||||
font-family: Verdana, Geneva, Arial, Helvetica;
|
||||
font-size: 10pt;
|
||||
}
|
||||
form { margin: 0; padding: 0; } /* thanks #mozilla */
|
148
b2-include/b2edit.form.php
Normal file
148
b2-include/b2edit.form.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
echo $tabletop;
|
||||
|
||||
switch($action) {
|
||||
case "post":
|
||||
$submitbutton_text = "Blog this !";
|
||||
$toprow_title = "New Post";
|
||||
$form_action = "post";
|
||||
$form_extra = "";
|
||||
if ($use_pingback) {
|
||||
$form_pingback = '<input type="checkbox" class="checkbox" name="post_pingback" value="1" checked="checked" tabindex="7" id="pingback" /><label for="pingback"> PingBack the URLs in this post</label><br />';
|
||||
} else {
|
||||
$form_pingback = '';
|
||||
}
|
||||
if ($use_trackback) {
|
||||
$form_trackback = '<br /><br /><label for="trackback"><b>TrackBack</b> an URL:</label><br /><input type="text" name="trackback_url" style="width: 415px" id="trackback" />';
|
||||
} else {
|
||||
$form_trackback = '';
|
||||
}
|
||||
$colspan = 3;
|
||||
break;
|
||||
case "edit":
|
||||
$submitbutton_text ="Edit this !";
|
||||
$toprow_title = "Editing Post #".$postdata["ID"];
|
||||
$form_action = "editpost";
|
||||
$form_extra = "\" />\n<input type=\"hidden\" name=\"post_ID\" value=\"$post";
|
||||
$colspan = 2;
|
||||
$form_pingback = '<input type="hidden" name="post_pingback" value="0" />';
|
||||
$form_trackback = '';
|
||||
break;
|
||||
case "editcomment":
|
||||
$submitbutton_text ="Edit this !";
|
||||
$toprow_title = "Editing Comment #".$commentdata["comment_ID"];
|
||||
$form_action = "editedcomment";
|
||||
$form_extra = "\" />\n<input type=\"hidden\" name=\"comment_ID\" value=\"$comment\" />\n<input type=\"hidden\" name=\"comment_post_ID\" value=\"".$commentdata["comment_post_ID"];
|
||||
$colspan = 3;
|
||||
$form_pingback = '<input type="hidden" name="post_pingback" value="0" />';
|
||||
$form_trackback = '';
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form name="post" action="b2edit.php" method="POST">
|
||||
<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
|
||||
<input type="hidden" name="action" value="<?php echo $form_action.$form_extra ?>" />
|
||||
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td<?php
|
||||
|
||||
if ($action != "editcomment") {
|
||||
|
||||
// this is for everything but comment editing
|
||||
?>>
|
||||
<table height="60" align="left" cellpadding="0" cellspacing="0">
|
||||
<td height="60" width="190">
|
||||
<label for="title"><b>Title :</b></label><br />
|
||||
<input type="text" name="post_title" size="20" tabindex="1" style="width: 170px;" value="<?php echo $edited_post_title; ?>" id="title" />
|
||||
</td>
|
||||
<td>
|
||||
<label for="category"><b>Category :</b></label><br /><?php dropdown_categories(); ?>
|
||||
</td>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
} else {
|
||||
|
||||
// this is for comment editing
|
||||
?> colspan="2"> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<label for="name"><b>Name :</b></label><br />
|
||||
<input type="text" name="newcomment_author" size="20" value="<?php echo format_to_edit($commentdata["comment_author"]) ?>" tabindex="1" id="name" /></td>
|
||||
<td>
|
||||
<label for="email"><b>E-mail :</b></label><br />
|
||||
<input type="text" name="newcomment_author_email" size="20" value="<?php echo format_to_edit($commentdata["comment_author_email"]) ?>" tabindex="2" id="email" /></td>
|
||||
<td>
|
||||
<label for="URL"><b>URL :</b></label><br />
|
||||
<input type="text" name="newcomment_author_url" size="20" value="<?php echo format_to_edit($commentdata["comment_author_url"]) ?>" tabindex="3" id="URL" />
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="<?php echo $colspan; ?>">
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<td valign="bottom">
|
||||
<?php
|
||||
if ($action != 'editcomment') {
|
||||
echo '<label for="content"><b>Post :</b></label>';
|
||||
} else {
|
||||
echo '<br /><label for="content"><b>Comment :</b></label>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td valign="bottom" align="right">
|
||||
<?php if ($use_quicktags) include($b2inc.'/b2quicktags.php'); ?>
|
||||
</td>
|
||||
</table>
|
||||
|
||||
<textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual" id="content"><?php echo $content ?></textarea><br />
|
||||
|
||||
<input type="checkbox" class="checkbox" name="post_autobr" value="1" <?php
|
||||
if ($autobr)
|
||||
echo " checked" ?> tabindex="7" id="autobr" /><label for="autobr"> Auto-BR (converts line-breaks into <br /> tags)</label><br />
|
||||
|
||||
<?php echo $form_pingback ?>
|
||||
|
||||
<?php if ($use_preview) { ?>
|
||||
<input type="button" value="preview" onclick="preview(this.form);" class="search" tabindex="8" />
|
||||
<?php } ?>
|
||||
|
||||
<input type="submit" name="submit" value="<?php echo $submitbutton_text ?>" class="search" style="font-weight: bold;" tabindex="5" />
|
||||
|
||||
<?php if ($use_spellchecker) { ?>
|
||||
<!--<input type = "button" value = "Spell Check" onclick="var f=document.forms[0]; doSpell( 'en', f.post_content, '<?php echo $spellchecker_url ?>/sproxy.cgi', true);" class="search" tabindex="5" />-->
|
||||
<input type="button" value="Spellcheck" onclick="DoSpell
|
||||
('post','content','');" class="search" tabindex="9"/>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( ($use_fileupload) && ($user_level >= $fileupload_minlevel) && ((ereg(" ".$user_login." ", $fileupload_allowedusers)) || (trim($fileupload_allowedusers)=="")) ) { ?>
|
||||
<input type="button" value="upload a file/image" onclick="launchupload();" class="search" tabindex="10" />
|
||||
<?php }
|
||||
|
||||
echo $form_trackback;
|
||||
|
||||
// if the level is 5+, allow user to edit the timestamp - not on 'new post' screen though
|
||||
#if (($user_level > 4) && ($action != "post"))
|
||||
if ($user_level > 4) {
|
||||
touch_time(($action=="edit"));
|
||||
}
|
||||
?>
|
||||
<script language="JavaScript">
|
||||
<!--
|
||||
// document.blog.post_content.focus();
|
||||
//-->
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo $tablebottom ?>
|
||||
</form>
|
380
b2-include/b2edit.showposts.php
Normal file
380
b2-include/b2edit.showposts.php
Normal file
@ -0,0 +1,380 @@
|
||||
<?php
|
||||
|
||||
echo $tabletop;
|
||||
require_once('b2config.php');
|
||||
|
||||
if (!$posts) {
|
||||
if ($posts_per_page) {
|
||||
$posts=$posts_per_page;
|
||||
} else {
|
||||
$posts=10;
|
||||
$posts_per_page=$posts;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!empty($poststart)) && (!empty($postend)) && ($poststart == $postend)) {
|
||||
$p=$poststart;
|
||||
$poststart=0;
|
||||
$postend=0;
|
||||
}
|
||||
|
||||
if (!$poststart) {
|
||||
$poststart=0;
|
||||
$postend=$posts;
|
||||
}
|
||||
|
||||
$nextXstart=$postend;
|
||||
$nextXend=$postend+$posts;
|
||||
|
||||
$previousXstart=($poststart-$posts);
|
||||
$previousXend=$poststart;
|
||||
if ($previousXstart < 0) {
|
||||
$previousXstart=0;
|
||||
$previousXend=$posts;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top" width="200">
|
||||
Show posts: </td>
|
||||
<td>
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<td colspan="2" align="center"><!-- show next/previous X posts -->
|
||||
<form name="previousXposts" method="get"><?php
|
||||
if ($previousXstart > 0) {
|
||||
?>
|
||||
<input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
|
||||
<input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
|
||||
<input type="submit" name="submitprevious" class="search" value="< <?php echo $posts ?>" /><?php
|
||||
}
|
||||
?></form></td><td><form name="nextXposts" method="get">
|
||||
<input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
|
||||
<input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
|
||||
<input type="submit" name="submitnext" class="search" value="<?php echo $posts ?> >" /></form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" width="200"><!-- show X first/last posts -->
|
||||
<form name="showXfirstlastposts" method="get">
|
||||
<input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
|
||||
<select name="order"> <option value="DESC" <?php
|
||||
if (!isset($order))
|
||||
$order="DESC";
|
||||
$i = $order;
|
||||
if ($i == "DESC")
|
||||
echo " selected";
|
||||
?>>last posts</option>
|
||||
<option value="ASC" <?php
|
||||
if ($i == "ASC")
|
||||
echo " selected";
|
||||
?>>first posts</option>
|
||||
</select> <input type="submit" name="submitfirstlast" class="search" value="OK" />
|
||||
</form>
|
||||
</td>
|
||||
<td valign="top"><!-- show post X to post X -->
|
||||
<form name="showXfirstlastposts" method="get">
|
||||
<input type="text" name="poststart" value="<?php echo $poststart ?>" style="width:40px;" /?> to <input type="text" name="postend" value="<?php echo $postend ?>" style="width:40px;" /?> <select name="order">
|
||||
<option value="DESC" <?php
|
||||
$i = $order;
|
||||
if ($i == "DESC")
|
||||
echo " selected";
|
||||
?>>from the end</option>
|
||||
<option value="ASC" <?php
|
||||
if ($i == "ASC")
|
||||
echo " selected";
|
||||
?>>from the start</option>
|
||||
</select> <input type="submit" name="submitXtoX" class="search" value="OK" /></form>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo $tablebottom ?>
|
||||
|
||||
<br />
|
||||
|
||||
<?php echo $tabletop ?>
|
||||
<table width="100%">
|
||||
<td valign="top" width="33%">
|
||||
<form name="searchform" action="b2edit.php" method="get">
|
||||
<input type="hidden" name="a" value="s" />
|
||||
<input onFocus="this.value='';" onBlur="if (this.value=='') {this.value='search...';}" type="text" name="s" value="search..." size="7" style="width: 100px;" />
|
||||
<input type="submit" name="submit" value="search" class="search" />
|
||||
</form>
|
||||
</td>
|
||||
<td valign="top" width="33%" align="center">
|
||||
<form name="viewcat" action="b2edit.php" method="get">
|
||||
<select name="cat" style="width:140px;">
|
||||
<option value="all">All Categories</option>
|
||||
<?php
|
||||
$query="SELECT * FROM $tablecategories";
|
||||
$result=mysql_query($query);
|
||||
$querycount++;
|
||||
$width = ($mode=="sidebar") ? "100%" : "170px";
|
||||
while($row = mysql_fetch_object($result)) {
|
||||
echo "<option value=\"".$row->cat_ID."\"";
|
||||
if ($row->cat_ID == $postdata["Category"])
|
||||
echo " selected";
|
||||
echo ">".$row->cat_name."</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="submit" name="submit" value="View" class="search" />
|
||||
</form>
|
||||
</td>
|
||||
<td valign="top" width="33%" align="right">
|
||||
<form name="viewarc" action="b2edit.php" method="get">
|
||||
<?php
|
||||
|
||||
if ($archive_mode == "monthly") {
|
||||
echo "<select name=\"m\" style=\"width:120px;\">";
|
||||
$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts ORDER BY post_date DESC";
|
||||
$querycount++;
|
||||
$arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
|
||||
while($arc_row = mysql_fetch_array($arc_result)) {
|
||||
$arc_year = $arc_row["YEAR(post_date)"];
|
||||
$arc_month = $arc_row["MONTH(post_date)"];
|
||||
echo "<option value=\"$arc_year".zeroise($arc_month,2)."\">";
|
||||
echo $month[zeroise($arc_month,2)]." $arc_year";
|
||||
echo "</option>\n";
|
||||
}
|
||||
} elseif ($archive_mode == "daily") {
|
||||
echo "<select name=\"d\" style=\"width:120px;\">";
|
||||
$archive_day_date_format = "Y/m/d";
|
||||
$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) FROM $tableposts ORDER BY post_date DESC";
|
||||
$querycount++;
|
||||
$arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
|
||||
while($arc_row = mysql_fetch_array($arc_result)) {
|
||||
$arc_year = $arc_row["YEAR(post_date)"];
|
||||
$arc_month = $arc_row["MONTH(post_date)"];
|
||||
$arc_dayofmonth = $arc_row["DAYOFMONTH(post_date)"];
|
||||
echo "<option value=\"$arc_year".zeroise($arc_month,2).zeroise($arc_dayofmonth,2)."\">";
|
||||
echo mysql2date($archive_day_date_format, $arc_year.zeroise($arc_month,2).zeroise($arc_dayofmonth,2)." 00:00:00");
|
||||
echo "</option>\n";
|
||||
}
|
||||
} elseif ($archive_mode == "weekly") {
|
||||
echo "<select name=\"w\" style=\"width:120px;\">";
|
||||
if (!isset($start_of_week)) {
|
||||
$start_of_week = 1;
|
||||
}
|
||||
$archive_week_start_date_format = "Y/m/d";
|
||||
$archive_week_end_date_format = "Y/m/d";
|
||||
$archive_week_separator = " - ";
|
||||
$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM $tableposts ORDER BY post_date DESC";
|
||||
$querycount++;
|
||||
$arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
|
||||
$arc_w_last = '';
|
||||
while($arc_row = mysql_fetch_array($arc_result)) {
|
||||
$arc_year = $arc_row["YEAR(post_date)"];
|
||||
$arc_w = $arc_row["WEEK(post_date)"];
|
||||
if ($arc_w != $arc_w_last) {
|
||||
$arc_w_last = $arc_w;
|
||||
$arc_ymd = $arc_year."-".zeroise($arc_row["MONTH(post_date)"],2)."-" .zeroise($arc_row["DAYOFMONTH(post_date)"],2);
|
||||
$arc_week = get_weekstartend($arc_ymd, $start_of_week);
|
||||
$arc_week_start = date($archive_week_start_date_format, $arc_week['start']);
|
||||
$arc_week_end = date($archive_week_end_date_format, $arc_week['end']);
|
||||
echo "<option value=\"$arc_w\">";
|
||||
echo $arc_week_start.$archive_week_separator.$arc_week_end;
|
||||
echo "</option>\n";
|
||||
}
|
||||
}
|
||||
} elseif ($archive_mode == "postbypost") {
|
||||
echo '<input type="hidden" name="more" value="1" />';
|
||||
echo '<select name="p" style="width:120px;">';
|
||||
$requestarc = " SELECT ID,post_date,post_title FROM $tableposts ORDER BY post_date DESC";
|
||||
$querycount++;
|
||||
$resultarc = mysql_query($requestarc);
|
||||
while($row=mysql_fetch_object($resultarc)) {
|
||||
if ($row->post_date != "0000-00-00 00:00:00") {
|
||||
echo "<option value=\"".$row->ID."\">";
|
||||
if (strip_tags($row->post_title)) {
|
||||
echo strip_tags(stripslashes($row->post_title));
|
||||
} else {
|
||||
echo $row->ID;
|
||||
}
|
||||
echo "</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "</select>";
|
||||
?>
|
||||
<input type="submit" name="submit" value="View" class="search" />
|
||||
</form>
|
||||
</td>
|
||||
|
||||
</table>
|
||||
<br />
|
||||
|
||||
<table cellspacing="0" cellpadding="5" border="0" width="100%">
|
||||
<?php
|
||||
// these lines are b2's "motor", do not alter nor remove them
|
||||
include("blog.header.php");
|
||||
|
||||
while($row = mysql_fetch_object($result)) {
|
||||
$posts_per_page = 10;
|
||||
start_b2(); ?>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<b><?php the_time('Y/m/d @ H:i:s'); ?></b> [ <a href="b2edit.php?p=<?php echo $id ?>&c=1"><?php comments_number('no comment', '1 comment', "% comments") ?><?php trackback_number('', ', 1 trackback', ', % trackbacks') ?><?php pingback_number('', ', 1 pingback', ', % pingbacks') ?></a>
|
||||
<?php
|
||||
if (($user_level > $authordata[13]) or ($user_login == $authordata[1])) {
|
||||
echo " - <a href=\"b2edit.php?action=edit&post=".$postdata["ID"];
|
||||
if ($m)
|
||||
echo "&m=$m";
|
||||
echo "\">Edit</a>";
|
||||
echo " - <a href=\"b2edit.php?action=delete&post=".$postdata["ID"]."\" onclick=\"return confirm('You are about to delete this post \'".$row->post_title."\'\\n \'Cancel\' to stop, \'OK\' to delete.')\">Delete</a> ";
|
||||
}
|
||||
?>
|
||||
]
|
||||
<br />
|
||||
<font color="#999999"><b><a href="<?php permalink_single($blogfilename); ?>" title="permalink"><?php the_title() ?></a></b> by <b><?php the_author() ?> (<a href="javascript:profile(<?php the_author_ID() ?>)"><?php the_author_nickname() ?></a>)</b>, in <b><?php the_category() ?></b></font><br />
|
||||
<?php permalink_anchor(); ?>
|
||||
<?php
|
||||
if ($safe_mode)
|
||||
echo "<xmp>";
|
||||
the_content();
|
||||
if ($safe_mode)
|
||||
echo "</xmp>";
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
|
||||
// comments
|
||||
if (($withcomments) or ($c)) {
|
||||
|
||||
$queryc = "SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date";
|
||||
$resultc = mysql_query($queryc);
|
||||
if ($resultc) {
|
||||
?>
|
||||
|
||||
<a name="comments"></a>
|
||||
<p><b><font color="#ff3300">::</font> comments</b></p>
|
||||
|
||||
<?php
|
||||
while($rowc = mysql_fetch_object($resultc)) {
|
||||
$commentdata = get_commentdata($rowc->comment_ID);
|
||||
?>
|
||||
|
||||
<!-- comment -->
|
||||
<p>
|
||||
<b><?php comment_author() ?> ( <?php comment_author_email_link() ?> / <?php comment_author_url_link() ?> )</b> (IP: <?php comment_author_IP() ?>)
|
||||
<br />
|
||||
<?php comment_text() ?>
|
||||
<br />
|
||||
<?php comment_date('Y/m/d') ?> @ <?php comment_time() ?><br />
|
||||
<?php
|
||||
if (($user_level > $authordata[13]) or ($user_login == $authordata[1])) {
|
||||
echo "[ <a href=\"b2edit.php?action=editcomment&comment=".$commentdata["comment_ID"]."\">Edit</a>";
|
||||
echo " - <a href=\"b2edit.php?action=deletecomment&p=".$postdata["ID"]."&comment=".$commentdata["comment_ID"]."\">Delete</a> ]";
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<!-- /comment -->
|
||||
|
||||
|
||||
<?php //end of the loop, don't delete
|
||||
}
|
||||
|
||||
if ($comment_error)
|
||||
echo "<p><font color=\"red\">Error: please fill the required fields (name & comment)</font></p>";
|
||||
?>
|
||||
|
||||
<p><b><font color="#ff3300">::</font> leave a comment</b></p>
|
||||
|
||||
|
||||
<!-- form to add a comment -->
|
||||
|
||||
<form action="b2comments.post.php" method="post">
|
||||
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
|
||||
<input type="hidden" name="redirect_to" value="<?php echo $HTTP_SERVER_VARS["REQUEST_URI"]; ?>" />
|
||||
<input type="text" name="author" class="textarea" value="<?php echo $user_nickname ?>" size="20" tabindex="1" /><br />
|
||||
<input type="text" name="email" class="textarea" value="<?php echo $user_email ?>" size="20" tabindex="2" /><br />
|
||||
<input type="text" name="url" class="textarea" value="<?php echo $user_url ?>" size="20" tabindex="3" /><br />
|
||||
<textarea cols="40" rows="4" name="comment" tabindex="4" class="textarea">comment</textarea><br />
|
||||
<input type="checkbox" name="comment_autobr" value="1" checked tabindex="6" class="checkbox" /> Auto-BR (line-breaks become <br> tags)<br />
|
||||
<input type="submit" name="submit" class="buttonarea" value="ok" tabindex="5" />
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<!-- /form -->
|
||||
|
||||
|
||||
<?php // if you delete this the sky will fall on your head
|
||||
}
|
||||
}
|
||||
?>
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php echo $tablebottom ?>
|
||||
<br />
|
||||
<?php echo $tabletop ?>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top" width="200">
|
||||
Show posts: </td>
|
||||
<td>
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<td colspan="2" align="center"><!-- show next/previous X posts -->
|
||||
<form name="previousXposts" method="get"><?php
|
||||
if ($previousXstart > -1) {
|
||||
?>
|
||||
<input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
|
||||
<input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
|
||||
<input type="submit" name="submitprevious" class="search" value="< Previous <?php echo $posts ?>" /><?php
|
||||
}
|
||||
?></form></td><td><form name="nextXposts" method="get">
|
||||
<input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
|
||||
<input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
|
||||
<input type="submit" name="submitnext" class="search" value="Next <?php echo $posts ?> >" /></form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" width="200"><!-- show X first/last posts -->
|
||||
<form name="showXfirstlastposts" method="get">
|
||||
<input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
|
||||
<select name="order"> <option value="DESC" <?php
|
||||
$i = $order;
|
||||
if ($i == "DESC")
|
||||
echo " selected";
|
||||
?>>last posts</option>
|
||||
<option value="ASC" <?php
|
||||
if ($i == "ASC")
|
||||
echo " selected";
|
||||
?>>first posts</option>
|
||||
</select> <input type="submit" name="submitfirstlast" class="search" value="OK" />
|
||||
</form>
|
||||
</td>
|
||||
<td valign="top"><!-- show post X to post X -->
|
||||
<form name="showXfirstlastposts" method="get">
|
||||
<input type="text" name="poststart" value="<?php echo $poststart ?>" style="width:40px;" /?> to <input type="text" name="postend" value="<?php echo $postend ?>" style="width:40px;" /?> <select name="order">
|
||||
<option value="DESC" <?php
|
||||
$i = $order;
|
||||
if ($i == "DESC")
|
||||
echo " selected";
|
||||
?>>from the end</option>
|
||||
<option value="ASC" <?php
|
||||
if ($i == "ASC")
|
||||
echo " selected";
|
||||
?>>from the start</option>
|
||||
</select> <input type="submit" name="submitXtoX" class="search" value="OK" /></form>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo $tablebottom ?>
|
23
b2-include/b2footer.php
Normal file
23
b2-include/b2footer.php
Normal file
@ -0,0 +1,23 @@
|
||||
</div>
|
||||
</td></table>
|
||||
<?php
|
||||
if ($debug=="1") {
|
||||
echo "<p>$querycount queries - ".number_format(timer_stop(),3)." seconds";
|
||||
}
|
||||
?>
|
||||
<p> </p>
|
||||
<div align="center" style="width: 100%" class="tabletoprow"><b><span style="color:#333333">b</span><span style="color:#ff9900">2</span></b> <?php echo $b2_version ?> - ©2001-2002 <a href="mailto:m@tidakada.com?subject=b2">michel v</a> - <a href="http://tidakada.com">tidakada.com</a></div>
|
||||
|
||||
<!-- this is for the spellchecker -->
|
||||
<form name="SPELLDATA"><div>
|
||||
<input name="formname" type="hidden" value="">
|
||||
<input name="messagebodyname" type="hidden" value="">
|
||||
<input name="subjectname" type="hidden" value="">
|
||||
<input name="companyID" type="hidden" value="">
|
||||
<input name="language" type="hidden" value="">
|
||||
<input name="opener" type="hidden" value="">
|
||||
<input name="formaction" type="hidden" value="">
|
||||
</div></form>
|
||||
|
||||
</body>
|
||||
</html>
|
1264
b2-include/b2functions.php
Normal file
1264
b2-include/b2functions.php
Normal file
File diff suppressed because it is too large
Load Diff
67
b2-include/b2menutop.php
Normal file
67
b2-include/b2menutop.php
Normal file
@ -0,0 +1,67 @@
|
||||
<img src="b2-img/blank.gif" width="1" height="5" alt="" border="0" />
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr height="15">
|
||||
|
||||
<td height="15" width="20"><img src="b2-img/blank.gif" width="1" height="1" alt="" /></td>
|
||||
|
||||
<td rowspan="3" width="50" valign="top"><a href="http://cafelog.com/"><img src="b2-img/b2minilogo.png" width="50" height="50" border="0" alt="visit b2's website" style="border-width:1px; border-color: #999999; border-style: dashed" /></a></td>
|
||||
|
||||
<td><img src="b2-img/blank.gif" width="1" height="1" alt="" /></td>
|
||||
<td width="150" style="text-align: right; padding-rightt: 6px;">
|
||||
<span style="color: #b0b0b0; font-family: verdana, arial, helvetica; font-size: 10px;">logged in as : <b><?php echo $user_login; ?></b></span>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td class="menutop" width="20">
|
||||
</td>
|
||||
|
||||
<td class="menutop"<?php if ($is_NS4) { echo " width=\"500\""; } ?>>
|
||||
<div class="menutop"<?php if ($is_NS4) { echo " width=\"500\""; } ?>>
|
||||
|
||||
|
||||
<?php if ($is_NS4) { echo $HTTP_USER_AGENT; } ?>
|
||||
|
||||
|
||||
<?php $sep = " | "; ?>
|
||||
<a href="b2edit.php" class="menutop" style="-font-weight: bold;">Post / Edit</a><?php echo $sep ?><a href="javascript:profile(<?php echo $user_ID ?>)" class="menutop">My Profile</a><?php echo $sep ?><a href="b2team.php" class="menutop">Team</a><?php
|
||||
|
||||
if ($pagenow != "b2profile.php") {
|
||||
|
||||
$menu = file($b2inc."/b2menutop.txt");
|
||||
$i=0;
|
||||
$j=$menu[0];
|
||||
while ($j != "") {
|
||||
$k = explode("\t",$j);
|
||||
if ($user_level >= $k[0]) {
|
||||
echo "$sep<a href=\"".$k[1]."\" class=\"menutop\">".trim($k[2])."</a>";
|
||||
}
|
||||
$i=$i+1;
|
||||
$j=$menu[$i];
|
||||
if (trim($j) == "***")
|
||||
$j="";
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td width="150" class="menutop" align="right" bgcolor="#FF9900">
|
||||
<a href="<?php echo $siteurl."/".$blogfilename; ?>" class="menutop">View site</a>
|
||||
<?php echo $sep; ?>
|
||||
<a href="b2login.php?action=logout" class="menutop">Logout</a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td> </td>
|
||||
<td style="padding-left: 6px;"><span class="menutoptitle">:: <?php echo $title; ?></span></td>
|
||||
<td> </td>
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
14
b2-include/b2menutop.txt
Normal file
14
b2-include/b2menutop.txt
Normal file
@ -0,0 +1,14 @@
|
||||
3 b2options.php Options
|
||||
3 b2categories.php Categories
|
||||
3 b2template.php Template
|
||||
***
|
||||
(Everything after the '***' is a comment.)
|
||||
|
||||
|
||||
To add sections to the menu, use this syntax:
|
||||
|
||||
the minimum level the user needs to access the section: between 0 and 10
|
||||
+tab
|
||||
+the URL of the section's file
|
||||
+tab
|
||||
+the title of this section
|
190
b2-include/b2quicktags.js
Normal file
190
b2-include/b2quicktags.js
Normal file
@ -0,0 +1,190 @@
|
||||
// b2 quick tags
|
||||
// - authorized adaptation of the 'bbCode control code' by subBlue design ( www.subBlue.com )
|
||||
|
||||
// Define the quick tags
|
||||
bbcode = new Array();
|
||||
bbtags = new Array('<b>','</b>','<i>','</i>','<u>','</u>','<strike>','</strike>','<blockquote>','</blockquote>','<p>','</p>','<li>','</li>','<img src="" border="0" alt="" />','','<a href="">','</a>');
|
||||
imageTag = false;
|
||||
|
||||
// Replacement for arrayname.length property
|
||||
function getarraysize(thearray) {
|
||||
for (i = 0; i < thearray.length; i++) {
|
||||
if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
|
||||
return i;
|
||||
}
|
||||
return thearray.length;
|
||||
}
|
||||
|
||||
// Replacement for arrayname.push(value) not implemented in IE until version 5.5
|
||||
// Appends element to the array
|
||||
function arraypush(thearray,value) {
|
||||
thearray[ getarraysize(thearray) ] = value;
|
||||
}
|
||||
|
||||
// Replacement for arrayname.pop() not implemented in IE until version 5.5
|
||||
// Removes and returns the last element of an array
|
||||
function arraypop(thearray) {
|
||||
thearraysize = getarraysize(thearray);
|
||||
retval = thearray[thearraysize - 1];
|
||||
delete thearray[thearraysize - 1];
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
function checkForm(formObj) {
|
||||
|
||||
formErrors = false;
|
||||
|
||||
if (formObj.content.value.length < 2) {
|
||||
formErrors = "You must enter a message!";
|
||||
}
|
||||
|
||||
if (formErrors) {
|
||||
alert(formErrors);
|
||||
return false;
|
||||
} else {
|
||||
bbstyle(formObj, -1);
|
||||
//formObj.preview.disabled = true;
|
||||
//formObj.submit.disabled = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function emoticon(theSmilie) {
|
||||
if ((parseInt(navigator.appVersion) >= 4) && (navigator.appName == "Microsoft Internet Explorer"))
|
||||
theSelection = document.selection.createRange().text; // Get text selection
|
||||
|
||||
if (theSelection) {
|
||||
// Add tags around selection
|
||||
document.selection.createRange().text = theSelection + theSmilie + ' ';
|
||||
formObj.content.focus();
|
||||
theSelection = '';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
document.post.content.value += ' ' + theSmilie + ' ';
|
||||
document.post.content.focus();
|
||||
}
|
||||
|
||||
|
||||
function bbfontstyle(formObj, bbopen, bbclose) {
|
||||
if ((parseInt(navigator.appVersion) >= 4) && (navigator.appName == "Microsoft Internet Explorer")) {
|
||||
theSelection = document.selection.createRange().text;
|
||||
if (!theSelection) {
|
||||
formObj.content.value += bbopen + bbclose;
|
||||
formObj.content.focus();
|
||||
return;
|
||||
}
|
||||
document.selection.createRange().text = bbopen + theSelection + bbclose;
|
||||
formObj.content.focus();
|
||||
return;
|
||||
} else {
|
||||
formObj.content.value += bbopen + bbclose;
|
||||
formObj.content.focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function bbstyle(formObj, bbnumber) {
|
||||
|
||||
donotinsert = false;
|
||||
theSelection = false;
|
||||
bblast = 0;
|
||||
|
||||
if (bbnumber == -1) { // Close all open tags & default button names
|
||||
while (bbcode[0]) {
|
||||
butnumber = arraypop(bbcode) - 1;
|
||||
formObj.content.value += bbtags[butnumber + 1];
|
||||
buttext = eval('formObj.addbbcode' + butnumber + '.value');
|
||||
eval('formObj.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
|
||||
}
|
||||
formObj.content.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((parseInt(navigator.appVersion) >= 4) && (navigator.appName == "Microsoft Internet Explorer"))
|
||||
theSelection = document.selection.createRange().text; // Get text selection
|
||||
|
||||
if (theSelection) {
|
||||
// Add tags around selection
|
||||
document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
|
||||
formObj.content.focus();
|
||||
theSelection = '';
|
||||
return;
|
||||
}
|
||||
|
||||
// Find last occurance of an open tag the same as the one just clicked
|
||||
for (i = 0; i < bbcode.length; i++) {
|
||||
if (bbcode[i] == bbnumber+1) {
|
||||
bblast = i;
|
||||
donotinsert = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (donotinsert) { // Close all open tags up to the one just clicked & default button names
|
||||
while (bbcode[bblast]) {
|
||||
butnumber = arraypop(bbcode) - 1;
|
||||
formObj.content.value += bbtags[butnumber + 1];
|
||||
buttext = eval('formObj.addbbcode' + butnumber + '.value');
|
||||
eval('formObj.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
|
||||
imageTag = false;
|
||||
}
|
||||
formObj.content.focus();
|
||||
return;
|
||||
} else { // Open tags
|
||||
|
||||
if (imageTag && (bbnumber != 14)) { // Close image tag before adding another
|
||||
formObj.content.value += bbtags[15];
|
||||
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
|
||||
formObj.addbbcode14.value = "image"; // Return button back to normal state
|
||||
imageTag = false;
|
||||
}
|
||||
|
||||
// Open tag
|
||||
formObj.content.value += bbtags[bbnumber];
|
||||
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
|
||||
arraypush(bbcode,bbnumber+1);
|
||||
eval('formObj.addbbcode'+bbnumber+'.value += "*"');
|
||||
formObj.content.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// swirlee's bblink hack, slightly corrected
|
||||
function bblink(formObj, bbnumber) {
|
||||
current_url = prompt("URL:","http://");
|
||||
var re = new RegExp ('http%3A//', 'gi') ;
|
||||
var current_url = current_url.replace(re, 'http://') ;
|
||||
if((current_url == 'null') || (current_url == "http://")) {
|
||||
current_url = "";
|
||||
exit;
|
||||
}
|
||||
if(bbnumber == 16) {
|
||||
current_link_text = unescape(prompt("Link text:","link"));
|
||||
if((current_link_text == null) || (current_link_text == "") || (current_link_text == "link")) {
|
||||
link_text = 'link';
|
||||
} else {
|
||||
link_text = current_link_text;
|
||||
}
|
||||
final_link = '<a href="' + current_url + '">' + current_link_text + '</a>';
|
||||
if (final_link != '<a href="">null</a>') {
|
||||
formObj.content.value += final_link;
|
||||
}
|
||||
}
|
||||
if(bbnumber == 14) {
|
||||
current_alt = prompt("ALTernate text:","ALT");
|
||||
if((current_alt == null) || (current_alt == "") || (current_alt == "ALT")) {
|
||||
alttag = ' alt=""';
|
||||
} else {
|
||||
alttag = ' alt="' + current_alt + '"';
|
||||
}
|
||||
final_image = '<img src="' + current_url + '" border="0"' + alttag + ' />';
|
||||
if (final_image != '<img src="" border="0" alt="" />') {
|
||||
formObj.content.value += final_image;
|
||||
}
|
||||
}
|
||||
}
|
33
b2-include/b2quicktags.php
Normal file
33
b2-include/b2quicktags.php
Normal file
@ -0,0 +1,33 @@
|
||||
<script src="<?php echo $b2inc ?>/b2quicktags.js" language="JavaScript" type="text/javascript">
|
||||
</script><table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr align="center" valign="middle">
|
||||
<td>
|
||||
<input type="button" class="quicktags" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onClick="bbstyle(this.form,0)" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" class="quicktags" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onClick="bbstyle(this.form,2)" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" class="quicktags" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onClick="bbstyle(this.form,4)" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" class="quicktags" accesskey="s" name="addbbcode6" value="strike" style="text-decoration: line-through;width: 50px" onClick="bbstyle(this.form,6)" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" class="quicktags" accesskey="p" name="addbbcode10" value="<p>" style="width: 40px" onClick="bbstyle(this.form,10)" />
|
||||
</td>
|
||||
<?php if (basename($HTTP_SERVER_VARS["SCRIPT_FILENAME"]) != "b2bookmarklet.php") { ?><td>
|
||||
<input type="button" class="quicktags" accesskey="l" name="addbbcode12" value="<li>" style="width: 40px" onClick="bbstyle(this.form,12)" />
|
||||
</td><?php } ?>
|
||||
<?php if (basename($HTTP_SERVER_VARS["SCRIPT_FILENAME"]) != "b2bookmarklet.php") { ?><td>
|
||||
<input type="button" class="quicktags" accesskey="q" name="addbbcode8" value="b-quote" style="width: 60px" onClick="bbstyle(this.form,8)" />
|
||||
</td><?php } ?>
|
||||
<td>
|
||||
<input type="button" class="quicktags" accesskey="m" name="addbbcode14" value="image" title="insert an image" style="width: 40px" onClick="bblink(this.form,14)" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" class="quicktags" accesskey="h" name="addbbcode16" value="link" title="insert a link" style="text-decoration: underline; width: 40px" onClick="bblink(this.form,16)" />
|
||||
</td><td>
|
||||
<input type="button" class="quicktags" accesskey="c" name="closetags" value="X" title="Close all tags" style="width: 30px; font-weigh: bolder;" onClick="bbstyle(document.post,-1)" /></td>
|
||||
</tr>
|
||||
</table>
|
1219
b2-include/b2template.functions.php
Normal file
1219
b2-include/b2template.functions.php
Normal file
File diff suppressed because it is too large
Load Diff
276
b2-include/b2vars.php
Normal file
276
b2-include/b2vars.php
Normal file
@ -0,0 +1,276 @@
|
||||
<?php
|
||||
|
||||
/* This file sets various arrays and variables for use in b2 */
|
||||
|
||||
#b2 version
|
||||
$b2_version = '0.6.1';
|
||||
|
||||
#BBcode search and replace arrays
|
||||
$b2_bbcode['in'] = array(
|
||||
'#\[b](.+?)\[/b]#is', // Formatting tags
|
||||
'#\[i](.+?)\[/i]#is',
|
||||
'#\[u](.+?)\[/u]#is',
|
||||
'#\[s](.+?)\[/s]#is',
|
||||
'#\[color=(.+?)](.+?)\[/color]#is',
|
||||
'#\[size=(.+?)](.+?)\[/size]#is',
|
||||
'#\[font=(.+?)](.+?)\[/font]#is',
|
||||
'#\[img](.+?)\[/img]#is', // Image
|
||||
'#\[url](.+?)\[/url]#is', // URL
|
||||
'#\[url=(.+?)](.+?)\[/url]#is',
|
||||
# '#\[email](.+?)\[/email]#eis', // E-mail
|
||||
# '#\[email=(.+?)](.+?)\[/email]#eis'
|
||||
);
|
||||
$b2_bbcode['out'] = array(
|
||||
'<strong>$1</strong>', // Formatting tags
|
||||
'<em>$1</em>',
|
||||
'<span style="text-decoration:underline">$1</span>',
|
||||
'<span style="text-decoration:line-through">$1</span>',
|
||||
'<span style="color:$1">$2</span>',
|
||||
'<span style="font-size:$1px">$2</span>',
|
||||
'<span style="font-family:$1">$2</span>',
|
||||
'<img src="$1" alt="" />', // Image
|
||||
'<a href="$1">$1</a>', // URL
|
||||
'<a href="$1" title="$2">$2</a>',
|
||||
# "'<a href=\"mailto:'.antispambot('\\1').'\">'.antispambot('\\1').'</a>'", // E-mail
|
||||
# '<a href="mailto:$1">$2</a>'
|
||||
);
|
||||
|
||||
#GreyMatter formatting search and replace arrays
|
||||
$b2_gmcode['in'] = array(
|
||||
'#\\*\*(.+?)\\*\*#is', // **bold**
|
||||
'#\\\\(.+?)\\\\#is', // \\italic\\
|
||||
'#\__(.+?)\__#is' // __underline__
|
||||
);
|
||||
$b2_gmcode['out'] = array(
|
||||
'<strong>$1</strong>',
|
||||
'<em>$1</em>',
|
||||
'<span style="text-decoration:underline">$1</span>'
|
||||
);
|
||||
|
||||
#Translation of HTML entities and special characters
|
||||
$b2_htmltrans = array_flip(get_html_translation_table(HTML_ENTITIES));
|
||||
$b2_htmltrans['<'] = '<'; # preserve HTML
|
||||
$b2_htmltrans['>'] = '>'; # preserve HTML
|
||||
$b2_htmltransbis = array(
|
||||
'–' => '–', '—' => '—', '‘' => '‘', '’' => '’',
|
||||
'“' => '“', '”' => '”', '•' => '•', '€' => '€',
|
||||
'<' => '<', # preserve fake HTML
|
||||
'>' => '>', # preserve fake HTML
|
||||
'&sp;' => ' ', '!' => '!', '"' => '"', '#' => '#', '$' => '$', '%' => '%', '&' => '&', ''' => ''', '(' => '(', ')' => ')',
|
||||
'*' => '*', '+' => '+', ',' => ',', '‐' => '-', '−' => '-', '.' => '.', '/' => '/', ':' => ':', ';' => ';', '<' => '<',
|
||||
'=' => '=', '>' => '>', '?' => '?', '@' => '@', '[' => '[', '\' => '\', ']' => ']', 'ˆ' => '^', '_' => '_', '―' => '_',
|
||||
'`' => '`', '{' => '{', '|' => '|', '}' => '}', '˜' => '~', '‚' => '‚', '„' => '„',
|
||||
'&ldots;' => '…', 'Š' => 'Š', '‹' => '‹', 'Œ' => 'Œ', '‘' => '‘', '’' => '‘', '’' => '’',
|
||||
'“' => '“', '”' => '“', '”' => '”', '•' => '•', '–' => '–', '&endash;' => '–', '—' => '—', '&emdash;' => '—', '˜' => '˜', '™' => '™',
|
||||
'š' => 'š', '›' => '›', 'œ' => 'œ', 'Ÿ' => 'Ÿ', ' ' => ' ', '¡' => '¡', '¢' => '¢', '£' => '£', '¤' => '¤', '¥' => '¥',
|
||||
'¦' => '¦', '&brkbar;' => '¦', '§' => '§', '¨' => '¨', '¨' => '¨', '©' => '©', 'ª' => 'ª', '«' => '«', '¬' => '¬', '­' => '­',
|
||||
'®' => '®', '¯' => '¯', '&hibar;' => '¯', '°' => '°', '±' => '±', '²' => '²', '³' => '³', '´' => '´', 'µ' => 'µ', '¶' => '¶',
|
||||
'·' => '·', '¸' => '¸', '¹' => '¹', 'º' => 'º', '»' => '»', '¼' => '¼', '½' => '½', '½' => '½', '¾' => '¾', '¿' => '¿',
|
||||
'À' => 'À', 'Á' => 'Á', 'Â' => 'Â', 'Ã' => 'Ã', 'Ä' => 'Ä', 'Å' => 'Å', 'Æ' => 'Æ', 'Ç' => 'Ç', 'È' => 'È', 'É' => 'É',
|
||||
'Ê' => 'Ê', 'Ë' => 'Ë', 'Ì' => 'Ì', 'Í' => 'Í', 'Î' => 'Î', 'Ï' => 'Ï', 'Ð' => 'Ð', 'Ñ' => 'Ñ', 'Ò' => 'Ò', 'Ó' => 'Ó',
|
||||
'Ô' => 'Ô', 'Õ' => 'Õ', 'Ö' => 'Ö', '×' => '×', 'Ø' => 'Ø', 'Ù' => 'Ù', 'Ú' => 'Ú', 'Û' => 'Û', 'Ü' => 'Ü', 'Ý' => 'Ý',
|
||||
'Þ' => 'Þ', 'ß' => 'ß', 'à' => 'à', 'á' => 'á', 'â' => 'â', 'ã' => 'ã', 'ä' => 'ä', 'å' => 'å', 'æ' => 'æ', 'ç' => 'ç',
|
||||
'è' => 'è', 'é' => 'é', 'ê' => 'ê', 'ë' => 'ë', 'ì' => 'ì', 'í' => 'í', 'î' => 'î', 'ï' => 'ï', 'ð' => 'ð', 'ñ' => 'ñ',
|
||||
'ò' => 'ò', 'ó' => 'ó', 'ô' => 'ô', 'õ' => 'õ', 'ö' => 'ö', '÷' => '÷', 'ø' => 'ø', 'ù' => 'ù', 'ú' => 'ú', 'û' => 'û',
|
||||
'ü' => 'ü', 'ý' => 'ý', 'þ' => 'þ', 'ÿ' => 'ÿ', 'Œ' => 'Œ', 'œ' => 'œ', 'Š' => 'Š', 'š' => 'š', 'Ÿ' => 'Ÿ', 'ƒ' => 'ƒ',
|
||||
'ˆ' => 'ˆ', '˜' => '˜', 'Α' => 'Α', 'Β' => 'Β', 'Γ' => 'Γ', 'Δ' => 'Δ', 'Ε' => 'Ε', 'Ζ' => 'Ζ', 'Η' => 'Η', 'Θ' => 'Θ',
|
||||
'Ι' => 'Ι', 'Κ' => 'Κ', 'Λ' => 'Λ', 'Μ' => 'Μ', 'Ν' => 'Ν', 'Ξ' => 'Ξ', 'Ο' => 'Ο', 'Π' => 'Π', 'Ρ' => 'Ρ', 'Σ' => 'Σ',
|
||||
'Τ' => 'Τ', 'Υ' => 'Υ', 'Φ' => 'Φ', 'Χ' => 'Χ', 'Ψ' => 'Ψ', 'Ω' => 'Ω', 'α' => 'α', 'β' => 'β', 'γ' => 'γ', 'δ' => 'δ',
|
||||
'ε' => 'ε', 'ζ' => 'ζ', 'η' => 'η', 'θ' => 'θ', 'ι' => 'ι', 'κ' => 'κ', 'λ' => 'λ', 'μ' => 'μ', 'ν' => 'ν', 'ξ' => 'ξ',
|
||||
'ο' => 'ο', 'π' => 'π', 'ρ' => 'ρ', 'ς' => 'ς', 'σ' => 'σ', 'τ' => 'τ', 'υ' => 'υ', 'φ' => 'φ', 'χ' => 'χ', 'ψ' => 'ψ',
|
||||
'ω' => 'ω', 'ϑ' => 'ϑ', 'ϒ' => 'ϒ', 'ϖ' => 'ϖ', ' ' => ' ', ' ' => ' ', ' ' => ' ', '‌' => '‌', '‍' => '‍', '‎' => '‎',
|
||||
'‏' => '‏', '–' => '–', '—' => '—', '‘' => '‘', '’' => '’', '‚' => '‚', '“' => '“', '”' => '”', '„' => '„', '†' => '†',
|
||||
'‡' => '‡', '•' => '•', '…' => '…', '‰' => '‰', '′' => '′', '″' => '″', '‹' => '‹', '›' => '›', '‾' => '‾', '⁄' => '⁄',
|
||||
'€' => '€', 'ℑ' => 'ℑ', '℘' => '℘', 'ℜ' => 'ℜ', '™' => '™', 'ℵ' => 'ℵ', '←' => '←', '↑' => '↑', '→' => '→', '↓' => '↓',
|
||||
'↔' => '↔', '↵' => '↵', '⇐' => '⇐', '⇑' => '⇑', '⇒' => '⇒', '⇓' => '⇓', '⇔' => '⇔', '∀' => '∀', '∂' => '∂', '∃' => '∃',
|
||||
'∅' => '∅', '∇' => '∇', '∈' => '∈', '∉' => '∉', '∋' => '∋', '∏' => '∏', '∑' => '∑', '−' => '−', '∗' => '∗', '√' => '√',
|
||||
'∝' => '∝', '∞' => '∞', '∠' => '∠', '∧' => '∧', '∨' => '∨', '∩' => '∩', '∪' => '∪', '∫' => '∫', '∴' => '∴', '∼' => '∼',
|
||||
'≅' => '≅', '≈' => '≈', '≠' => '≠', '≡' => '≡', '≤' => '≤', '≥' => '≥', '⊂' => '⊂', '⊃' => '⊃', '⊄' => '⊄', '⊆' => '⊆',
|
||||
'⊇' => '⊇', '⊕' => '⊕', '⊗' => '⊗', '⊥' => '⊥', '⋅' => '⋅', '⌈' => '⌈', '⌉' => '⌉', '⌊' => '⌊', '⌋' => '⌋', '⟨' => '〈',
|
||||
'⟩' => '〉', '◊' => '◊', '♠' => '♠', '♣' => '♣', '♥' => '♥', '♦' => '♦'
|
||||
);
|
||||
$b2_htmltrans = array_merge($b2_htmltrans,$b2_htmltransbis);
|
||||
|
||||
#Translation of invalid Unicode references range to valid range
|
||||
$b2_htmltranswinuni = array(
|
||||
'€' => '€', // the Euro sign
|
||||
'' => '',
|
||||
'‚' => '‚', // these are Windows CP1252 specific characters
|
||||
'ƒ' => 'ƒ', // they would look weird on non-Windows browsers
|
||||
'„' => '„',
|
||||
'…' => '…',
|
||||
'†' => '†',
|
||||
'‡' => '‡',
|
||||
'ˆ' => 'ˆ',
|
||||
'‰' => '‰',
|
||||
'Š' => 'Š',
|
||||
'‹' => '‹',
|
||||
'Œ' => 'Œ',
|
||||
'' => '',
|
||||
'Ž' => 'ž',
|
||||
'' => '',
|
||||
'' => '',
|
||||
'‘' => '‘',
|
||||
'’' => '’',
|
||||
'“' => '“',
|
||||
'”' => '”',
|
||||
'•' => '•',
|
||||
'–' => '–',
|
||||
'—' => '—',
|
||||
'˜' => '˜',
|
||||
'™' => '™',
|
||||
'š' => 'š',
|
||||
'›' => '›',
|
||||
'œ' => 'œ',
|
||||
'' => '',
|
||||
'ž' => '',
|
||||
'Ÿ' => 'Ÿ'
|
||||
);
|
||||
|
||||
# these are used for b2's interface design
|
||||
$tabletop = "\t<table cellspacing=\"0\" cellpadding=\"1\" width=\"85%\" border=\"0\" bgcolor=\"#cccccc\" align=\"center\">\n\t<td align=\"left\">\n\t\t<table cellspacing=\"0\" cellpadding=\"15\" width=\"100%\" border=\"0\"bgcolor=\"#ffffff\" align=\"center\">\n\t\t<td align=\"left\">\n";
|
||||
$tablebottom = "\t\t</td>\n\t</table>\n\t</td>\n\t</table>\n";
|
||||
$blankline = '<img src="b2-img/blank.gif" width="10" height="5" border="0" /><br />';
|
||||
|
||||
# on which page are we ?
|
||||
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
|
||||
$pagenow = explode('/', $PHP_SELF);
|
||||
$pagenow = trim($pagenow[(sizeof($pagenow)-1)]);
|
||||
$pagenow = explode('?', $pagenow);
|
||||
$pagenow = $pagenow[0];
|
||||
if (($querystring_start == '/') && ($pagenow != 'b2edit.php')) {
|
||||
$pagenow = $siteurl.'/'.$blogfilename;
|
||||
}
|
||||
|
||||
# browser detection
|
||||
$is_lynx = 0; $is_gecko = 0; $is_winIE = 0; $is_macIE = 0; $is_opera = 0; $is_NS4 = 0;
|
||||
if (!isset($HTTP_USER_AGENT)) {
|
||||
$HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
|
||||
}
|
||||
if (preg_match('/Lynx/', $HTTP_USER_AGENT)) {
|
||||
$is_lynx = 1;
|
||||
} elseif (preg_match('/Gecko/', $HTTP_USER_AGENT)) {
|
||||
$is_gecko = 1;
|
||||
} elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Win/', $HTTP_USER_AGENT))) {
|
||||
$is_winIE = 1;
|
||||
} elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Mac/', $HTTP_USER_AGENT))) {
|
||||
$is_macIE = 1;
|
||||
} elseif (preg_match('/Opera/', $HTTP_USER_AGENT)) {
|
||||
$is_opera = 1;
|
||||
} elseif ((preg_match('/Nav/', $HTTP_USER_AGENT) ) || (preg_match('/Mozilla\/4\./', $HTTP_USER_AGENT))) {
|
||||
$is_NS4 = 1;
|
||||
}
|
||||
$is_IE = (($is_macIE) || ($is_winIE));
|
||||
|
||||
# browser-specific javascript corrections
|
||||
$b2_macIE_correction['in'] = array(
|
||||
'/\%uFFD4/', '/\%uFFD5/', '/\%uFFD2/', '/\%uFFD3/',
|
||||
'/\%uFFA5/', '/\%uFFD0/', '/\%uFFD1/', '/\%uFFBD/',
|
||||
'/\%uFF83%uFFC0/', '/\%uFF83%uFFC1/', '/\%uFF83%uFFC6/', '/\%uFF83%uFFC9/',
|
||||
'/\%uFFB9/', '/\%uFF81%uFF8C/', '/\%uFF81%uFF8D/', '/\%uFF81%uFFDA/',
|
||||
'/\%uFFDB/'
|
||||
);
|
||||
$b2_macIE_correction['out'] = array(
|
||||
'‘', '’', '“', '”',
|
||||
'•', '–', '—', 'Ω',
|
||||
'β', 'γ', 'θ', 'λ',
|
||||
'π', '′', '″', '∠',
|
||||
'€'
|
||||
);
|
||||
$b2_gecko_correction['in'] = array(
|
||||
'/\‘/', '/\’/', '/\“/', '/\â€<C3A2>/',
|
||||
'/\•/', '/\–/', '/\—/', '/\Ω/',
|
||||
'/\β/', '/\γ/', '/\θ/', '/\λ/',
|
||||
'/\Ï€/', '/\′/', '/\″/', '/\âˆ/',
|
||||
'/\€/', '/\ /'
|
||||
);
|
||||
$b2_gecko_correction['out'] = array(
|
||||
'&8216;', '’', '“', '”',
|
||||
'•', '–', '—', 'Ω',
|
||||
'β', 'γ', 'θ', 'λ',
|
||||
'π', '′', '″', '∠',
|
||||
'€', ' '
|
||||
);
|
||||
|
||||
# server detection
|
||||
$is_Apache = strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache') ? 1 : 0;
|
||||
$is_IIS = strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Microsoft-IIS') ? 1 : 0;
|
||||
|
||||
# if the config file does not provide the smilies array, let's define it here
|
||||
if (!isset($b2smiliestrans)) {
|
||||
$b2smiliestrans = array(
|
||||
':)' => 'icon_smile.gif',
|
||||
':D' => 'icon_biggrin.gif',
|
||||
':-D' => 'icon_biggrin.gif',
|
||||
':grin:' => 'icon_biggrin.gif',
|
||||
':)' => 'icon_smile.gif',
|
||||
':-)' => 'icon_smile.gif',
|
||||
':smile:' => 'icon_smile.gif',
|
||||
':(' => 'icon_sad.gif',
|
||||
':-(' => 'icon_sad.gif',
|
||||
':sad:' => 'icon_sad.gif',
|
||||
':o' => 'icon_surprised.gif',
|
||||
':-o' => 'icon_surprised.gif',
|
||||
':eek:' => 'icon_surprised.gif',
|
||||
'8O' => 'icon_eek.gif',
|
||||
'8-O' => 'icon_eek.gif',
|
||||
':shock:' => 'icon_eek.gif',
|
||||
':?' => 'icon_confused.gif',
|
||||
':-?' => 'icon_confused.gif',
|
||||
':???:' => 'icon_confused.gif',
|
||||
'8)' => 'icon_cool.gif',
|
||||
'8-)' => 'icon_cool.gif',
|
||||
':cool:' => 'icon_cool.gif',
|
||||
':lol:' => 'icon_lol.gif',
|
||||
':x' => 'icon_mad.gif',
|
||||
':-x' => 'icon_mad.gif',
|
||||
':mad:' => 'icon_mad.gif',
|
||||
':P' => 'icon_razz.gif',
|
||||
':-P' => 'icon_razz.gif',
|
||||
':razz:' => 'icon_razz.gif',
|
||||
':oops:' => 'icon_redface.gif',
|
||||
':cry:' => 'icon_cry.gif',
|
||||
':evil:' => 'icon_evil.gif',
|
||||
':twisted:' => 'icon_twisted.gif',
|
||||
':roll:' => 'icon_rolleyes.gif',
|
||||
':wink:' => 'icon_wink.gif',
|
||||
';)' => 'icon_wink.gif',
|
||||
';-)' => 'icon_wink.gif',
|
||||
':!:' => 'icon_exclaim.gif',
|
||||
':?:' => 'icon_question.gif',
|
||||
':idea:' => 'icon_idea.gif',
|
||||
':arrow:' => 'icon_arrow.gif',
|
||||
':|' => 'icon_neutral.gif',
|
||||
':-|' => 'icon_neutral.gif',
|
||||
':neutral:' => 'icon_neutral.gif',
|
||||
':mrgreen:' => 'icon_mrgreen.gif',
|
||||
);
|
||||
}
|
||||
|
||||
# sorts the smilies' array
|
||||
if (!function_exists('smiliescmp')) {
|
||||
function smiliescmp ($a, $b) {
|
||||
if (strlen($a) == strlen($b)) {
|
||||
return strcmp($a, $b);
|
||||
}
|
||||
return (strlen($a) > strlen($b)) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
uksort($b2smiliestrans, 'smiliescmp');
|
||||
|
||||
# generates smilies' search & replace arrays
|
||||
foreach($b2smiliestrans as $smiley => $img) {
|
||||
$b2_smiliessearch[] = $smiley;
|
||||
$smiley_masked = '';
|
||||
for ($i = 0; $i < strlen($smiley); $i = $i + 1) {
|
||||
$smiley_masked .= substr($smiley, $i, 1).chr(160);
|
||||
}
|
||||
$b2_smiliesreplace[] = "<img src='$smilies_directory/$img' alt='$smiley_masked' />";
|
||||
}
|
||||
|
||||
# sets curly quotes on or off from the config
|
||||
if (isset($use_smartquotes) && ($use_smartquotes)) {
|
||||
add_filter('all', 'phpcurlme');
|
||||
}
|
||||
|
||||
?>
|
55
b2-include/b2verifauth.php
Normal file
55
b2-include/b2verifauth.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
require_once('b2config.php');
|
||||
|
||||
/* connecting the db */
|
||||
$connexion = @mysql_connect($server,$loginsql,$passsql) or die("Can't connect to the database<br>".mysql_error());
|
||||
mysql_select_db("$base");
|
||||
|
||||
/* checking login & pass in the database */
|
||||
function veriflog() {
|
||||
global $HTTP_COOKIE_VARS;
|
||||
global $tableusers,$tablesettings,$tablecategories,$tableposts,$tablecomments;
|
||||
|
||||
if (!empty($HTTP_COOKIE_VARS["cafeloguser"])) {
|
||||
$user_login = $HTTP_COOKIE_VARS["cafeloguser"];
|
||||
$user_pass_md5 = $HTTP_COOKIE_VARS["cafelogpass"];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!($user_login != ""))
|
||||
return false;
|
||||
if (!$user_pass_md5)
|
||||
return false;
|
||||
|
||||
$query = " SELECT user_login, user_pass FROM $tableusers WHERE user_login = '$user_login' ";
|
||||
$result = @mysql_query($query) or die("Query: $query<br /><br />Error: ".mysql_error());
|
||||
|
||||
$lines = mysql_num_rows($result);
|
||||
if ($lines<1) {
|
||||
return false;
|
||||
} else {
|
||||
$res=mysql_fetch_row($result);
|
||||
if ($res[0]==$user_login && md5($res[1])==$user_pass_md5) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if ( $user_login!="" && $user_pass!="" && $id_session!="" && $adresse_ip==$REMOTE_ADDR) {
|
||||
# if ( !(veriflog()) AND !(verifcookielog()) ) {
|
||||
if (!(veriflog())) {
|
||||
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, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
if (!empty($HTTP_COOKIE_VARS["cafeloguser"])) {
|
||||
$error="<b>Error</b>: wrong login or password";
|
||||
}
|
||||
include("b2login.php");
|
||||
exit();
|
||||
}
|
||||
#}
|
||||
?>
|
680
b2-include/class.POP3.php
Normal file
680
b2-include/class.POP3.php
Normal file
@ -0,0 +1,680 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* mail_fetch/setup.php
|
||||
*
|
||||
* Copyright (c) 1999-2002 The SquirrelMail Project Team
|
||||
*
|
||||
* Copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
|
||||
* Modified by Philippe Mingo 2001 mingo@rotedic.com
|
||||
* An RFC 1939 compliant wrapper class for the POP3 protocol.
|
||||
*
|
||||
* Licensed under the GNU GPL. For full terms see the file COPYING.
|
||||
*
|
||||
* pop3 class
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
class POP3 {
|
||||
var $ERROR = ''; // Error string.
|
||||
|
||||
var $TIMEOUT = 60; // Default timeout before giving up on a
|
||||
// network operation.
|
||||
|
||||
var $COUNT = -1; // Mailbox msg count
|
||||
|
||||
var $BUFFER = 512; // Socket buffer for socket fgets() calls.
|
||||
// Per RFC 1939 the returned line a POP3
|
||||
// server can send is 512 bytes.
|
||||
|
||||
var $FP = ''; // The connection to the server's
|
||||
// file descriptor
|
||||
|
||||
var $MAILSERVER = ''; // Set this to hard code the server name
|
||||
|
||||
var $DEBUG = FALSE; // set to true to echo pop3
|
||||
// commands and responses to error_log
|
||||
// this WILL log passwords!
|
||||
|
||||
var $BANNER = ''; // Holds the banner returned by the
|
||||
// pop server - used for apop()
|
||||
|
||||
var $RFC1939 = TRUE; // Set by noop(). See rfc1939.txt
|
||||
//
|
||||
|
||||
var $ALLOWAPOP = FALSE; // Allow or disallow apop()
|
||||
// This must be set to true
|
||||
// manually
|
||||
|
||||
function POP3 ( $server = '', $timeout = '' ) {
|
||||
settype($this->BUFFER,"integer");
|
||||
if( !empty($server) ) {
|
||||
// Do not allow programs to alter MAILSERVER
|
||||
// if it is already specified. They can get around
|
||||
// this if they -really- want to, so don't count on it.
|
||||
if(empty($this->MAILSERVER))
|
||||
$this->MAILSERVER = $server;
|
||||
}
|
||||
if(!empty($timeout)) {
|
||||
settype($timeout,"integer");
|
||||
$this->TIMEOUT = $timeout;
|
||||
set_time_limit($timeout);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function update_timer () {
|
||||
set_time_limit($this->TIMEOUT);
|
||||
return true;
|
||||
}
|
||||
|
||||
function connect ($server, $port = 110) {
|
||||
// Opens a socket to the specified server. Unless overridden,
|
||||
// port defaults to 110. Returns true on success, false on fail
|
||||
|
||||
// If MAILSERVER is set, override $server with it's value
|
||||
|
||||
if(!empty($this->MAILSERVER))
|
||||
$server = $this->MAILSERVER;
|
||||
|
||||
if(empty($server)){
|
||||
$this->ERROR = _("POP3 connect:") . ' ' . _("No server specified");
|
||||
unset($this->FP);
|
||||
return false;
|
||||
}
|
||||
|
||||
$fp = fsockopen("$server", $port, $errno, $errstr);
|
||||
|
||||
if(!$fp) {
|
||||
$this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$errno] [$errstr]";
|
||||
unset($this->FP);
|
||||
return false;
|
||||
}
|
||||
|
||||
socket_set_blocking($fp,-1);
|
||||
$this->update_timer();
|
||||
$reply = fgets($fp,$this->BUFFER);
|
||||
$reply = $this->strip_clf($reply);
|
||||
if($this->DEBUG)
|
||||
error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
|
||||
if(!$this->is_ok($reply)) {
|
||||
$this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$reply]";
|
||||
unset($this->FP);
|
||||
return false;
|
||||
}
|
||||
$this->FP = $fp;
|
||||
$this->BANNER = $this->parse_banner($reply);
|
||||
$this->RFC1939 = $this->noop();
|
||||
if($this->RFC1939) {
|
||||
$this->ERROR = _("POP3: premature NOOP OK, NOT an RFC 1939 Compliant server");
|
||||
$this->quit();
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
|
||||
function noop () {
|
||||
|
||||
if(!isset($this->FP)) {
|
||||
$this->ERROR = _("POP3 noop:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
} else {
|
||||
$cmd = "NOOP";
|
||||
$reply = $this->send_cmd( $cmd );
|
||||
return( $this->is_ok( $reply ) );
|
||||
}
|
||||
}
|
||||
|
||||
function user ($user = "") {
|
||||
// Sends the USER command, returns true or false
|
||||
|
||||
if( empty($user) ) {
|
||||
$this->ERROR = _("POP3 user:") . ' ' . _("no login ID submitted");
|
||||
return false;
|
||||
} elseif(!isset($this->FP)) {
|
||||
$this->ERROR = _("POP3 user:") . ' ' . _("connection not established");
|
||||
return false;
|
||||
} else {
|
||||
$reply = $this->send_cmd("USER $user");
|
||||
if(!$this->is_ok($reply)) {
|
||||
$this->ERROR = _("POP3 user:") . ' ' . _("Error ") . "[$reply]";
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function pass ($pass = "") {
|
||||
// Sends the PASS command, returns # of msgs in mailbox,
|
||||
// returns false (undef) on Auth failure
|
||||
|
||||
if(empty($pass)) {
|
||||
$this->ERROR = _("POP3 pass:") . ' ' . _("No password submitted");
|
||||
return false;
|
||||
} elseif(!isset($this->FP)) {
|
||||
$this->ERROR = _("POP3 pass:") . ' ' . _("connection not established");
|
||||
return false;
|
||||
} else {
|
||||
$reply = $this->send_cmd("PASS $pass");
|
||||
if(!$this->is_ok($reply)) {
|
||||
$this->ERROR = _("POP3 pass:") . ' ' . _("authentication failed ") . "[$reply]";
|
||||
$this->quit();
|
||||
return false;
|
||||
} else {
|
||||
// Auth successful.
|
||||
$count = $this->last("count");
|
||||
$this->COUNT = $count;
|
||||
$this->RFC1939 = $this->noop();
|
||||
if(!$this->RFC1939) {
|
||||
$this->ERROR = _("POP3 pass:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant");
|
||||
$this->quit();
|
||||
return false;
|
||||
} else
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function apop ($login,$pass) {
|
||||
// Attempts an APOP login. If this fails, it'll
|
||||
// try a standard login. YOUR SERVER MUST SUPPORT
|
||||
// THE USE OF THE APOP COMMAND!
|
||||
// (apop is optional per rfc1939)
|
||||
|
||||
if(!isset($this->FP)) {
|
||||
$this->ERROR = _("POP3 apop:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
} elseif(!$this->ALLOWAPOP) {
|
||||
$retVal = $this->login($login,$pass);
|
||||
return $retVal;
|
||||
} elseif(empty($login)) {
|
||||
$this->ERROR = _("POP3 apop:") . ' ' . _("No login ID submitted");
|
||||
return false;
|
||||
} elseif(empty($pass)) {
|
||||
$this->ERROR = _("POP3 apop:") . ' ' . _("No password submitted");
|
||||
return false;
|
||||
} else {
|
||||
$banner = $this->BANNER;
|
||||
if( (!$banner) or (empty($banner)) ) {
|
||||
$this->ERROR = _("POP3 apop:") . ' ' . _("No server banner") . ' - ' . _("abort");
|
||||
$retVal = $this->login($login,$pass);
|
||||
return $retVal;
|
||||
} else {
|
||||
$AuthString = $banner;
|
||||
$AuthString .= $pass;
|
||||
$APOPString = md5($AuthString);
|
||||
$cmd = "APOP $login $APOPString";
|
||||
$reply = $this->send_cmd($cmd);
|
||||
if(!$this->is_ok($reply)) {
|
||||
$this->ERROR = _("POP3 apop:") . ' ' . _("apop authentication failed") . ' - ' . _("abort");
|
||||
$retVal = $this->login($login,$pass);
|
||||
return $retVal;
|
||||
} else {
|
||||
// Auth successful.
|
||||
$count = $this->last("count");
|
||||
$this->COUNT = $count;
|
||||
$this->RFC1939 = $this->noop();
|
||||
if(!$this->RFC1939) {
|
||||
$this->ERROR = _("POP3 apop:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant");
|
||||
$this->quit();
|
||||
return false;
|
||||
} else
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function login ($login = "", $pass = "") {
|
||||
// Sends both user and pass. Returns # of msgs in mailbox or
|
||||
// false on failure (or -1, if the error occurs while getting
|
||||
// the number of messages.)
|
||||
|
||||
if( !isset($this->FP) ) {
|
||||
$this->ERROR = _("POP3 login:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
} else {
|
||||
$fp = $this->FP;
|
||||
if( !$this->user( $login ) ) {
|
||||
// Preserve the error generated by user()
|
||||
return false;
|
||||
} else {
|
||||
$count = $this->pass($pass);
|
||||
if( (!$count) || ($count == -1) ) {
|
||||
// Preserve the error generated by last() and pass()
|
||||
return false;
|
||||
} else
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function top ($msgNum, $numLines = "0") {
|
||||
// Gets the header and first $numLines of the msg body
|
||||
// returns data in an array with each returned line being
|
||||
// an array element. If $numLines is empty, returns
|
||||
// only the header information, and none of the body.
|
||||
|
||||
if(!isset($this->FP)) {
|
||||
$this->ERROR = _("POP3 top:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
}
|
||||
$this->update_timer();
|
||||
|
||||
$fp = $this->FP;
|
||||
$buffer = $this->BUFFER;
|
||||
$cmd = "TOP $msgNum $numLines";
|
||||
fwrite($fp, "TOP $msgNum $numLines\r\n");
|
||||
$reply = fgets($fp, $buffer);
|
||||
$reply = $this->strip_clf($reply);
|
||||
if($this->DEBUG) {
|
||||
@error_log("POP3 SEND [$cmd] GOT [$reply]",0);
|
||||
}
|
||||
if(!$this->is_ok($reply))
|
||||
{
|
||||
$this->ERROR = _("POP3 top:") . ' ' . _("Error ") . "[$reply]";
|
||||
return false;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$MsgArray = array();
|
||||
|
||||
$line = fgets($fp,$buffer);
|
||||
while ( !ereg("^\.\r\n",$line))
|
||||
{
|
||||
$MsgArray[$count] = $line;
|
||||
$count++;
|
||||
$line = fgets($fp,$buffer);
|
||||
if(empty($line)) { break; }
|
||||
}
|
||||
|
||||
return $MsgArray;
|
||||
}
|
||||
|
||||
function pop_list ($msgNum = "") {
|
||||
// If called with an argument, returns that msgs' size in octets
|
||||
// No argument returns an associative array of undeleted
|
||||
// msg numbers and their sizes in octets
|
||||
|
||||
if(!isset($this->FP))
|
||||
{
|
||||
$this->ERROR = _("POP3 pop_list:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
}
|
||||
$fp = $this->FP;
|
||||
$Total = $this->COUNT;
|
||||
if( (!$Total) or ($Total == -1) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if($Total == 0)
|
||||
{
|
||||
return array("0","0");
|
||||
// return -1; // mailbox empty
|
||||
}
|
||||
|
||||
$this->update_timer();
|
||||
|
||||
if(!empty($msgNum))
|
||||
{
|
||||
$cmd = "LIST $msgNum";
|
||||
fwrite($fp,"$cmd\r\n");
|
||||
$reply = fgets($fp,$this->BUFFER);
|
||||
$reply = $this->strip_clf($reply);
|
||||
if($this->DEBUG) {
|
||||
@error_log("POP3 SEND [$cmd] GOT [$reply]",0);
|
||||
}
|
||||
if(!$this->is_ok($reply))
|
||||
{
|
||||
$this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]";
|
||||
return false;
|
||||
}
|
||||
list($junk,$num,$size) = explode(" ",$reply);
|
||||
return $size;
|
||||
}
|
||||
$cmd = "LIST";
|
||||
$reply = $this->send_cmd($cmd);
|
||||
if(!$this->is_ok($reply))
|
||||
{
|
||||
$reply = $this->strip_clf($reply);
|
||||
$this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]";
|
||||
return false;
|
||||
}
|
||||
$MsgArray = array();
|
||||
$MsgArray[0] = $Total;
|
||||
for($msgC=1;$msgC <= $Total; $msgC++)
|
||||
{
|
||||
if($msgC > $Total) { break; }
|
||||
$line = fgets($fp,$this->BUFFER);
|
||||
$line = $this->strip_clf($line);
|
||||
if(ereg("^\.",$line))
|
||||
{
|
||||
$this->ERROR = _("POP3 pop_list:") . ' ' . _("Premature end of list");
|
||||
return false;
|
||||
}
|
||||
list($thisMsg,$msgSize) = explode(" ",$line);
|
||||
settype($thisMsg,"integer");
|
||||
if($thisMsg != $msgC)
|
||||
{
|
||||
$MsgArray[$msgC] = "deleted";
|
||||
}
|
||||
else
|
||||
{
|
||||
$MsgArray[$msgC] = $msgSize;
|
||||
}
|
||||
}
|
||||
return $MsgArray;
|
||||
}
|
||||
|
||||
function get ($msgNum) {
|
||||
// Retrieve the specified msg number. Returns an array
|
||||
// where each line of the msg is an array element.
|
||||
|
||||
if(!isset($this->FP))
|
||||
{
|
||||
$this->ERROR = _("POP3 get:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->update_timer();
|
||||
|
||||
$fp = $this->FP;
|
||||
$buffer = $this->BUFFER;
|
||||
$cmd = "RETR $msgNum";
|
||||
$reply = $this->send_cmd($cmd);
|
||||
|
||||
if(!$this->is_ok($reply))
|
||||
{
|
||||
$this->ERROR = _("POP3 get:") . ' ' . _("Error ") . "[$reply]";
|
||||
return false;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$MsgArray = array();
|
||||
|
||||
$line = fgets($fp,$buffer);
|
||||
while ( !ereg("^\.\r\n",$line))
|
||||
{
|
||||
$MsgArray[$count] = $line;
|
||||
$count++;
|
||||
$line = fgets($fp,$buffer);
|
||||
if(empty($line)) { break; }
|
||||
}
|
||||
return $MsgArray;
|
||||
}
|
||||
|
||||
function last ( $type = "count" ) {
|
||||
// Returns the highest msg number in the mailbox.
|
||||
// returns -1 on error, 0+ on success, if type != count
|
||||
// results in a popstat() call (2 element array returned)
|
||||
|
||||
$last = -1;
|
||||
if(!isset($this->FP))
|
||||
{
|
||||
$this->ERROR = _("POP3 last:") . ' ' . _("No connection to server");
|
||||
return $last;
|
||||
}
|
||||
|
||||
$reply = $this->send_cmd("STAT");
|
||||
if(!$this->is_ok($reply))
|
||||
{
|
||||
$this->ERROR = _("POP3 last:") . ' ' . _("Error ") . "[$reply]";
|
||||
return $last;
|
||||
}
|
||||
|
||||
$Vars = explode(" ",$reply);
|
||||
$count = $Vars[1];
|
||||
$size = $Vars[2];
|
||||
settype($count,"integer");
|
||||
settype($size,"integer");
|
||||
if($type != "count")
|
||||
{
|
||||
return array($count,$size);
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
function reset () {
|
||||
// Resets the status of the remote server. This includes
|
||||
// resetting the status of ALL msgs to not be deleted.
|
||||
// This method automatically closes the connection to the server.
|
||||
|
||||
if(!isset($this->FP))
|
||||
{
|
||||
$this->ERROR = _("POP3 reset:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
}
|
||||
$reply = $this->send_cmd("RSET");
|
||||
if(!$this->is_ok($reply))
|
||||
{
|
||||
// The POP3 RSET command -never- gives a -ERR
|
||||
// response - if it ever does, something truely
|
||||
// wild is going on.
|
||||
|
||||
$this->ERROR = _("POP3 reset:") . ' ' . _("Error ") . "[$reply]";
|
||||
@error_log("POP3 reset: ERROR [$reply]",0);
|
||||
}
|
||||
$this->quit();
|
||||
return true;
|
||||
}
|
||||
|
||||
function send_cmd ( $cmd = "" )
|
||||
{
|
||||
// Sends a user defined command string to the
|
||||
// POP server and returns the results. Useful for
|
||||
// non-compliant or custom POP servers.
|
||||
// Do NOT includ the \r\n as part of your command
|
||||
// string - it will be appended automatically.
|
||||
|
||||
// The return value is a standard fgets() call, which
|
||||
// will read up to $this->BUFFER bytes of data, until it
|
||||
// encounters a new line, or EOF, whichever happens first.
|
||||
|
||||
// This method works best if $cmd responds with only
|
||||
// one line of data.
|
||||
|
||||
if(!isset($this->FP))
|
||||
{
|
||||
$this->ERROR = _("POP3 send_cmd:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(empty($cmd))
|
||||
{
|
||||
$this->ERROR = _("POP3 send_cmd:") . ' ' . _("Empty command string");
|
||||
return "";
|
||||
}
|
||||
|
||||
$fp = $this->FP;
|
||||
$buffer = $this->BUFFER;
|
||||
$this->update_timer();
|
||||
fwrite($fp,"$cmd\r\n");
|
||||
$reply = fgets($fp,$buffer);
|
||||
$reply = $this->strip_clf($reply);
|
||||
if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
|
||||
return $reply;
|
||||
}
|
||||
|
||||
function quit() {
|
||||
// Closes the connection to the POP3 server, deleting
|
||||
// any msgs marked as deleted.
|
||||
|
||||
if(!isset($this->FP))
|
||||
{
|
||||
$this->ERROR = _("POP3 quit:") . ' ' . _("connection does not exist");
|
||||
return false;
|
||||
}
|
||||
$fp = $this->FP;
|
||||
$cmd = "QUIT";
|
||||
fwrite($fp,"$cmd\r\n");
|
||||
$reply = fgets($fp,$this->BUFFER);
|
||||
$reply = $this->strip_clf($reply);
|
||||
if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
|
||||
fclose($fp);
|
||||
unset($this->FP);
|
||||
return true;
|
||||
}
|
||||
|
||||
function popstat () {
|
||||
// Returns an array of 2 elements. The number of undeleted
|
||||
// msgs in the mailbox, and the size of the mbox in octets.
|
||||
|
||||
$PopArray = $this->last("array");
|
||||
|
||||
if($PopArray == -1) { return false; }
|
||||
|
||||
if( (!$PopArray) or (empty($PopArray)) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $PopArray;
|
||||
}
|
||||
|
||||
function uidl ($msgNum = "")
|
||||
{
|
||||
// Returns the UIDL of the msg specified. If called with
|
||||
// no arguments, returns an associative array where each
|
||||
// undeleted msg num is a key, and the msg's uidl is the element
|
||||
// Array element 0 will contain the total number of msgs
|
||||
|
||||
if(!isset($this->FP)) {
|
||||
$this->ERROR = _("POP3 uidl:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
}
|
||||
|
||||
$fp = $this->FP;
|
||||
$buffer = $this->BUFFER;
|
||||
|
||||
if(!empty($msgNum)) {
|
||||
$cmd = "UIDL $msgNum";
|
||||
$reply = $this->send_cmd($cmd);
|
||||
if(!$this->is_ok($reply))
|
||||
{
|
||||
$this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]";
|
||||
return false;
|
||||
}
|
||||
list ($ok,$num,$myUidl) = explode(" ",$reply);
|
||||
return $myUidl;
|
||||
} else {
|
||||
$this->update_timer();
|
||||
|
||||
$UIDLArray = array();
|
||||
$Total = $this->COUNT;
|
||||
$UIDLArray[0] = $Total;
|
||||
|
||||
if ($Total < 1)
|
||||
{
|
||||
return $UIDLArray;
|
||||
}
|
||||
$cmd = "UIDL";
|
||||
fwrite($fp, "UIDL\r\n");
|
||||
$reply = fgets($fp, $buffer);
|
||||
$reply = $this->strip_clf($reply);
|
||||
if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
|
||||
if(!$this->is_ok($reply))
|
||||
{
|
||||
$this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]";
|
||||
return false;
|
||||
}
|
||||
|
||||
$line = "";
|
||||
$count = 1;
|
||||
$line = fgets($fp,$buffer);
|
||||
while ( !ereg("^\.\r\n",$line)) {
|
||||
if(ereg("^\.\r\n",$line)) {
|
||||
break;
|
||||
}
|
||||
list ($msg,$msgUidl) = explode(" ",$line);
|
||||
$msgUidl = $this->strip_clf($msgUidl);
|
||||
if($count == $msg) {
|
||||
$UIDLArray[$msg] = $msgUidl;
|
||||
}
|
||||
else
|
||||
{
|
||||
$UIDLArray[$count] = 'deleted';
|
||||
}
|
||||
$count++;
|
||||
$line = fgets($fp,$buffer);
|
||||
}
|
||||
}
|
||||
return $UIDLArray;
|
||||
}
|
||||
|
||||
function delete ($msgNum = "") {
|
||||
// Flags a specified msg as deleted. The msg will not
|
||||
// be deleted until a quit() method is called.
|
||||
|
||||
if(!isset($this->FP))
|
||||
{
|
||||
$this->ERROR = _("POP3 delete:") . ' ' . _("No connection to server");
|
||||
return false;
|
||||
}
|
||||
if(empty($msgNum))
|
||||
{
|
||||
$this->ERROR = _("POP3 delete:") . ' ' . _("No msg number submitted");
|
||||
return false;
|
||||
}
|
||||
$reply = $this->send_cmd("DELE $msgNum");
|
||||
if(!$this->is_ok($reply))
|
||||
{
|
||||
$this->ERROR = _("POP3 delete:") . ' ' . _("Command failed ") . "[$reply]";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// *********************************************************
|
||||
|
||||
// The following methods are internal to the class.
|
||||
|
||||
function is_ok ($cmd = "") {
|
||||
// Return true or false on +OK or -ERR
|
||||
|
||||
if( empty($cmd) )
|
||||
return false;
|
||||
else
|
||||
return( ereg ("^\+OK", $cmd ) );
|
||||
}
|
||||
|
||||
function strip_clf ($text = "") {
|
||||
// Strips \r\n from server responses
|
||||
|
||||
if(empty($text))
|
||||
return $text;
|
||||
else {
|
||||
$stripped = str_replace("\r",'',$text);
|
||||
$stripped = str_replace("\n",'',$stripped);
|
||||
return $stripped;
|
||||
}
|
||||
}
|
||||
|
||||
function parse_banner ( $server_text ) {
|
||||
$outside = true;
|
||||
$banner = "";
|
||||
$length = strlen($server_text);
|
||||
for($count =0; $count < $length; $count++)
|
||||
{
|
||||
$digit = substr($server_text,$count,1);
|
||||
if(!empty($digit)) {
|
||||
if( (!$outside) && ($digit != '<') && ($digit != '>') )
|
||||
{
|
||||
$banner .= $digit;
|
||||
}
|
||||
if ($digit == '<')
|
||||
{
|
||||
$outside = false;
|
||||
}
|
||||
if($digit == '>')
|
||||
{
|
||||
$outside = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$banner = $this->strip_clf($banner); // Just in case
|
||||
return "<$banner>";
|
||||
}
|
||||
|
||||
} // End class
|
||||
|
||||
?>
|
1149
b2-include/xmlrpc.inc
Normal file
1149
b2-include/xmlrpc.inc
Normal file
File diff suppressed because it is too large
Load Diff
309
b2-include/xmlrpcs.inc
Normal file
309
b2-include/xmlrpcs.inc
Normal file
@ -0,0 +1,309 @@
|
||||
<?php
|
||||
// by Edd Dumbill (C) 1999-2001
|
||||
// <edd@usefulinc.com>
|
||||
// $Id$
|
||||
|
||||
|
||||
# additional fixes for case of missing xml extension file by Michel Valdrighi <m@tidakada.com>
|
||||
|
||||
|
||||
// Copyright (c) 1999,2000,2001 Edd Dumbill.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// * Neither the name of the "XML-RPC for PHP" nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// XML RPC Server class
|
||||
// requires: xmlrpc.inc
|
||||
|
||||
// listMethods: either a string, or nothing
|
||||
$_xmlrpcs_listMethods_sig=array(array($xmlrpcArray, $xmlrpcString),
|
||||
array($xmlrpcArray));
|
||||
$_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch';
|
||||
function _xmlrpcs_listMethods($server, $m) {
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
$v=new xmlrpcval();
|
||||
$dmap=$server->dmap;
|
||||
$outAr=array();
|
||||
for(reset($dmap); list($key, $val)=each($dmap); ) {
|
||||
$outAr[]=new xmlrpcval($key, "string");
|
||||
}
|
||||
$dmap=$_xmlrpcs_dmap;
|
||||
for(reset($dmap); list($key, $val)=each($dmap); ) {
|
||||
$outAr[]=new xmlrpcval($key, "string");
|
||||
}
|
||||
$v->addArray($outAr);
|
||||
return new xmlrpcresp($v);
|
||||
}
|
||||
|
||||
$_xmlrpcs_methodSignature_sig=array(array($xmlrpcArray, $xmlrpcString));
|
||||
$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
|
||||
function _xmlrpcs_methodSignature($server, $m) {
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
|
||||
$methName=$m->getParam(0);
|
||||
$methName=$methName->scalarval();
|
||||
if (ereg("^system\.", $methName)) {
|
||||
$dmap=$_xmlrpcs_dmap; $sysCall=1;
|
||||
} else {
|
||||
$dmap=$server->dmap; $sysCall=0;
|
||||
}
|
||||
// print "<!-- ${methName} -->\n";
|
||||
if (isset($dmap[$methName])) {
|
||||
if ($dmap[$methName]["signature"]) {
|
||||
$sigs=array();
|
||||
$thesigs=$dmap[$methName]["signature"];
|
||||
for($i=0; $i<sizeof($thesigs); $i++) {
|
||||
$cursig=array();
|
||||
$inSig=$thesigs[$i];
|
||||
for($j=0; $j<sizeof($inSig); $j++) {
|
||||
$cursig[]=new xmlrpcval($inSig[$j], "string");
|
||||
}
|
||||
$sigs[]=new xmlrpcval($cursig, "array");
|
||||
}
|
||||
$r=new xmlrpcresp(new xmlrpcval($sigs, "array"));
|
||||
} else {
|
||||
$r=new xmlrpcresp(new xmlrpcval("undef", "string"));
|
||||
}
|
||||
} else {
|
||||
$r=new xmlrpcresp(0,
|
||||
$xmlrpcerr["introspect_unknown"],
|
||||
$xmlrpcstr["introspect_unknown"]);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
$_xmlrpcs_methodHelp_sig=array(array($xmlrpcString, $xmlrpcString));
|
||||
$_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string';
|
||||
function _xmlrpcs_methodHelp($server, $m) {
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
|
||||
$methName=$m->getParam(0);
|
||||
$methName=$methName->scalarval();
|
||||
if (ereg("^system\.", $methName)) {
|
||||
$dmap=$_xmlrpcs_dmap; $sysCall=1;
|
||||
} else {
|
||||
$dmap=$server->dmap; $sysCall=0;
|
||||
}
|
||||
// print "<!-- ${methName} -->\n";
|
||||
if (isset($dmap[$methName])) {
|
||||
if ($dmap[$methName]["docstring"]) {
|
||||
$r=new xmlrpcresp(new xmlrpcval($dmap[$methName]["docstring"]),
|
||||
"string");
|
||||
} else {
|
||||
$r=new xmlrpcresp(new xmlrpcval("", "string"));
|
||||
}
|
||||
} else {
|
||||
$r=new xmlrpcresp(0,
|
||||
$xmlrpcerr["introspect_unknown"],
|
||||
$xmlrpcstr["introspect_unknown"]);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
$_xmlrpcs_dmap=array(
|
||||
"system.listMethods" =>
|
||||
array("function" => "_xmlrpcs_listMethods",
|
||||
"signature" => $_xmlrpcs_listMethods_sig,
|
||||
"docstring" => $_xmlrpcs_listMethods_doc),
|
||||
"system.methodHelp" =>
|
||||
array("function" => "_xmlrpcs_methodHelp",
|
||||
"signature" => $_xmlrpcs_methodHelp_sig,
|
||||
"docstring" => $_xmlrpcs_methodHelp_doc),
|
||||
"system.methodSignature" =>
|
||||
array("function" => "_xmlrpcs_methodSignature",
|
||||
"signature" => $_xmlrpcs_methodSignature_sig,
|
||||
"docstring" => $_xmlrpcs_methodSignature_doc)
|
||||
);
|
||||
|
||||
$_xmlrpc_debuginfo="";
|
||||
function xmlrpc_debugmsg($m) {
|
||||
global $_xmlrpc_debuginfo;
|
||||
$_xmlrpc_debuginfo=$_xmlrpc_debuginfo . $m . "\n";
|
||||
}
|
||||
|
||||
class xmlrpc_server {
|
||||
var $dmap=array();
|
||||
|
||||
function xmlrpc_server($dispMap, $serviceNow=1) {
|
||||
global $HTTP_RAW_POST_DATA;
|
||||
// dispMap is a despatch array of methods
|
||||
// mapped to function names and signatures
|
||||
// if a method
|
||||
// doesn't appear in the map then an unknown
|
||||
// method error is generated
|
||||
$this->dmap=$dispMap;
|
||||
if ($serviceNow) {
|
||||
$this->service();
|
||||
}
|
||||
}
|
||||
|
||||
function serializeDebug() {
|
||||
global $_xmlrpc_debuginfo;
|
||||
if ($_xmlrpc_debuginfo!="")
|
||||
return "<!-- DEBUG INFO:\n\n" .
|
||||
$_xmlrpc_debuginfo . "\n-->\n";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function service() {
|
||||
$r=$this->parseRequest();
|
||||
$payload="<?xml version=\"1.0\"?>\n" .
|
||||
$this->serializeDebug() .
|
||||
$r->serialize();
|
||||
Header("Content-type: text/xml\r\nContent-length: " .
|
||||
strlen(trim($payload)));
|
||||
print trim($payload);
|
||||
}
|
||||
|
||||
function verifySignature($in, $sig) {
|
||||
for($i=0; $i<sizeof($sig); $i++) {
|
||||
// check each possible signature in turn
|
||||
$cursig=$sig[$i];
|
||||
if (sizeof($cursig)==$in->getNumParams()+1) {
|
||||
$itsOK=1;
|
||||
for($n=0; $n<$in->getNumParams(); $n++) {
|
||||
$p=$in->getParam($n);
|
||||
// print "<!-- $p -->\n";
|
||||
if ($p->kindOf() == "scalar") {
|
||||
$pt=$p->scalartyp();
|
||||
} else {
|
||||
$pt=$p->kindOf();
|
||||
}
|
||||
// $n+1 as first type of sig is return type
|
||||
if ($pt != $cursig[$n+1]) {
|
||||
$itsOK=0;
|
||||
$pno=$n+1; $wanted=$cursig[$n+1]; $got=$pt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($itsOK)
|
||||
return array(1);
|
||||
}
|
||||
}
|
||||
return array(0, "Wanted ${wanted}, got ${got} at param ${pno})");
|
||||
}
|
||||
|
||||
function parseRequest($data="") {
|
||||
global $_xh,$HTTP_RAW_POST_DATA;
|
||||
global $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $xmlrpc_defencoding,
|
||||
$_xmlrpcs_dmap;
|
||||
|
||||
|
||||
|
||||
if ($data=="") {
|
||||
$data=$HTTP_RAW_POST_DATA;
|
||||
}
|
||||
$parser = xml_parser_create($xmlrpc_defencoding);
|
||||
|
||||
$_xh[$parser]=array();
|
||||
$_xh[$parser]['st']="";
|
||||
$_xh[$parser]['cm']=0;
|
||||
$_xh[$parser]['isf']=0;
|
||||
$_xh[$parser]['params']=array();
|
||||
$_xh[$parser]['method']="";
|
||||
|
||||
// decompose incoming XML into request structure
|
||||
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
|
||||
xml_set_element_handler($parser, "xmlrpc_se", "xmlrpc_ee");
|
||||
xml_set_character_data_handler($parser, "xmlrpc_cd");
|
||||
xml_set_default_handler($parser, "xmlrpc_dh");
|
||||
if (!xml_parse($parser, $data, 1)) {
|
||||
// return XML error as a faultCode
|
||||
$r=new xmlrpcresp(0,
|
||||
$xmlrpcerrxml+xml_get_error_code($parser),
|
||||
sprintf("XML error: %s at line %d",
|
||||
xml_error_string(xml_get_error_code($parser)),
|
||||
xml_get_current_line_number($parser)));
|
||||
xml_parser_free($parser);
|
||||
} else {
|
||||
xml_parser_free($parser);
|
||||
$m=new xmlrpcmsg($_xh[$parser]['method']);
|
||||
// now add parameters in
|
||||
$plist="";
|
||||
for($i=0; $i<sizeof($_xh[$parser]['params']); $i++) {
|
||||
//print "<!-- " . $_xh[$parser]['params'][$i]. "-->\n";
|
||||
$plist.="$i - " . $_xh[$parser]['params'][$i]. " \n";
|
||||
eval('$m->addParam(' . $_xh[$parser]['params'][$i]. ");");
|
||||
}
|
||||
// uncomment this to really see what the server's getting!
|
||||
// xmlrpc_debugmsg($plist);
|
||||
// now to deal with the method
|
||||
$methName=$_xh[$parser]['method'];
|
||||
if (ereg("^system\.", $methName)) {
|
||||
$dmap=$_xmlrpcs_dmap; $sysCall=1;
|
||||
} else {
|
||||
$dmap=$this->dmap; $sysCall=0;
|
||||
}
|
||||
if (isset($dmap[$methName]['function'])) {
|
||||
// dispatch if exists
|
||||
if (isset($dmap[$methName]['signature'])) {
|
||||
$sr=$this->verifySignature($m,
|
||||
$dmap[$methName]['signature'] );
|
||||
}
|
||||
if ( (!isset($dmap[$methName]['signature']))
|
||||
|| $sr[0]) {
|
||||
// if no signature or correct signature
|
||||
if ($sysCall) {
|
||||
eval('$r=' . $dmap[$methName]['function'] .
|
||||
'($this, $m);');
|
||||
} else {
|
||||
eval('$r=' . $dmap[$methName]['function'] .
|
||||
'($m);');
|
||||
}
|
||||
} else {
|
||||
$r=new xmlrpcresp(0,
|
||||
$xmlrpcerr["incorrect_params"],
|
||||
$xmlrpcstr["incorrect_params"].": ". $sr[1]);
|
||||
}
|
||||
} else {
|
||||
// else prepare error response
|
||||
$r=new xmlrpcresp(0,
|
||||
$xmlrpcerr["unknown_method"],
|
||||
$xmlrpcstr["unknown_method"]);
|
||||
}
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function echoInput() {
|
||||
global $HTTP_RAW_POST_DATA;
|
||||
|
||||
// a debugging routine: just echos back the input
|
||||
// packet as a string value
|
||||
|
||||
$r=new xmlrpcresp;
|
||||
$r->xv=new xmlrpcval( "'Aha said I: '" . $HTTP_RAW_POST_DATA, "string");
|
||||
print $r->serialize();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user