cvs: php4 /pear/Forum/frontend forum.php index.php list.php post.php read.php
| From: | Morgan Christiansson | Date: | Fri, 05 Oct 2001 22:14:27 +0000 |
| Subject: | cvs: php4 /pear/Forum/frontend forum.php index.php list.php post.php read.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-936@lists.php.net to get a copy of this message | ||
mog Fri Oct 5 18:14:27 2001 EDT
Added files:
/php4/pear/Forum/frontend forum.php index.php list.php post.php
read.php
Log:
Initial PEAR/Forum checkin
Index: php4/pear/Forum/frontend/forum.php
+++ php4/pear/Forum/frontend/forum.php
<?PHP
# User configurable options:
# This needs to be set to whereever the PEAR/Forum lib is.
$FORUM["LIB"] = "Forum/lib";
include("$FORUM[LIB]/forum.php");
$FORUM["LIST_FILE"]="list.php";
$FORUM["READ_FILE"]="read.php";
$FORUM["POST_FILE"]="post.php";
$FORUM["SEARCH_FILE"]="search.php";
$FORUM["DOWN_FILE"]="down.php";
$FORUM["VIOLATION_FILE"]="violation.php";
$FORUM["USER_FILE"]="user.php";
$FORUM["INDEX_FILE"]="index.php";
$FORUM["LOGIN_FILE"]="login.php";
# End user configurable options.
# look in lib/config.php for more options.
# Parse $QUERY_STRING.
# All the paramaters in are passed as a comma
# delimited string rather than using GET variables.
$FORUM_GET_VARS=explode(",",current(explode("&",$HTTP_SERVER_VARS["QUERY_STRING"])));
/**
* Nice little function to give us a standard way to make URLs.
* This makes use of the new func_get_args so we can have as many
* arguments passed in as we want.
*
* @param int $type Type of URL
*/
function forum_get_url(){
GLOBAL $FORUM;
$args=func_get_args();
$type=array_shift($args);
switch ($type){
case FORUM_LIST:
$args=implode(",",$args);
return "$FORUM[HTTP_PATH]/$FORUM[LIST_FILE]?$args";
case FORUM_READ:
$end=array_pop($args);
$args=implode(",",$args);
return "$FORUM[HTTP_PATH]/$FORUM[READ_FILE]?$args#$end";
case FORUM_POST:
$args=implode(",",$args);
return "$FORUM[HTTP_PATH]/$FORUM[POST_FILE]?$args";
case FORUM_SEARCH:
$args=implode(",",$args);
if($args) $args=",$args";
return "$FORUM[HTTP_PATH]/$FORUM[SEARCH_FILE]?$args";
case FORUM_DOWN:
$args=implode(",",$args);
if($args) $args=",$args";
return "$FORUM[HTTP_PATH]/$FORUM[DOWN_FILE]?$args";
case FORUM_VIOLATION:
$args=implode(",",$args);
if($args) $args=",$args";
return "$FORUM[HTTP_PATH]/$FORUM[VIOLATION_FILE]?$args";
case FORUM_USER:
$args=implode(",",$args);
return "$FORUM[HTTP_PATH]/$FORUM[USER_FILE]?$args";
case FORUM_INDEX:
$args=implode(",",$args);
if($args) $args="?$args";
return "$FORUM[HTTP_PATH]/$FORUM[INDEX_FILE]?$args";
case FORUM_LOGIN:
return "$FORUM[HTTP_PATH]/$FORUM[LOGIN_FILE]";
default:
trigger_error("Unhandled page type: $type",E_USER_ERROR);
}
}
?>
Index: php4/pear/Forum/frontend/index.php
+++ php4/pear/Forum/frontend/index.php
<?PHP
include("./forum.php");
$index = forum_start(FORUM_INDEX);
if(!empty($skin)) {
// here we use basename() cause $index->get_settings() doesn't do this.
// it is extremely important that no outside var's skip basename() !
$index->skindir = basename($skin);
}
$index->get_settings(); // load skin.
include($index->skin->dir."/header.tpl.php");
$index->display();
include($index->skin->dir."/footer.tpl.php");
?>
Index: php4/pear/Forum/frontend/list.php
+++ php4/pear/Forum/frontend/list.php
<?PHP
include("./forum.php");
if(empty($FORUM_GET_VARS[0])) {
header("Location: $FORUM[HTTP_PATH]/");
exit;
}
// The collapse GET variable must have higher priority than the collapse cookie
if(isset($collapse) && $collapse == "1") {
SetCookie("collapse","1",time()+60*60*24*30); //keep cookie for 30 days
print 'SetCookie("collapse","1",time()+60*60*24*30); //keep cookie for 30
days';
} else {
SetCookie("collapse","0",time()+60*60*24*30); //keep cookie for 30 days
print 'SetCookie("collapse","0",time()+60*60*24*30); //keep cookie for 30
days';
}
my_var_dump($HTTP_COOKIE_VARS);
my_var_dump($collapse);
// forum_start load's any include files needed and returns a class
$list = forum_start(FORUM_LIST);
/*
if(!empty($skin)) {
// here we use basename() cause $list->get_settings() doesn't do this.
// it is extremely important that no outside var's skip basename() !
$list->skindir = basename($skin);
}
*/
$list->forum_id =& $FORUM_GET_VARS[0];
if(!empty($FORUM_GET_VARS[1])) {
settype($FORUM_GET_VARS[1],"int");
$list->offset =& $FORUM_GET_VARS[1];
}
$list->get_settings();
if(isset($collapse) && $collapse == "1") {
print "COLLAPSE";
$list->collapse=1;
} else {
print "EXPLODE";
$list->collapse=0;
}
$list->float=1;
include($list->skin->dir."/header.tpl.php");
$list->display();
include($list->skin->dir."/footer.tpl.php");
?>
Index: php4/pear/Forum/frontend/post.php
+++ php4/pear/Forum/frontend/post.php
<?PHP
include("./forum.php");
$post = forum_start(FORUM_POST);
$post->forum_id =& $FORUM_GET_VARS[0];
$post->parent_id =& $FORUM_GET_VARS[1];
if($REQUEST_METHOD=="POST") {
$post->body=$HTTP_POST_VARS["BODY"];
$post->author=$HTTP_POST_VARS["AUTHOR"];
$post->email=$HTTP_POST_VARS["EMAIL"];
$post->subject=$HTTP_POST_VARS["SUBJECT"];
$post->email_reply=FALSE;
// can't hurt to set these 2 here too,
// not required cause they were set above with FORUM_GET_VARS.
$post->forum_id=$HTTP_POST_VARS["FORUM_ID"];
$post->message_id=$HTTP_POST_VARS["PARENT_ID"];
$post->get_settings();
if(is_array($ERR=$post->post())) { // post() returns array on error.
my_var_dump($ERR);
include($post->skin->dir."/header.tpl.php");
$post->display();
} else {
header("Location: ".phorum_get_url(FORUM_LIST,$post->forum_id));
exit;
}
} else {
$post->get_settings();
include($post->skin->dir."/header.tpl.php");
$post->display();
}
include($post->skin->dir."/footer.tpl.php");
?>
Index: php4/pear/Forum/frontend/read.php
+++ php4/pear/Forum/frontend/read.php
<?PHP
include("./forum.php");
$read = forum_start(FORUM_READ);
$read->forum_id =& $FORUM_GET_VARS[0];
$read->thread_id =& $FORUM_GET_VARS[1];
$read->get_settings();
// $ForumName comes from Phorum 3.x and is used in header.tpl.php Phorum3 skin
$ForumName = $read->settings["name"];
include($read->skin->dir."/header.tpl.php");
$read->display();
include($read->skin->dir."/footer.tpl.php");
?>