I'm rewriting my community builder with some killer features as well as speeding up the code by a huge percentage.
Unfortunately, I've got school and can't devote my full attention to it.
If you know pdo and want to partner up, let me know.
This is a sample from my script.
Its just a test, but mostly, that's the way it will be.
Template designers are welcome. There is to be a pc and wap version.PHP Code:<?php
$t = microtime(true);
require_once( 'require.php' );
$template_values = array( );
list($flood_control) = getSet( 'flood_control' );
$cookie_name= md5( SALT.getUA().$_SITE->id.'flood_control' );
$cookie_value= $flood_control + time() ;
if ( !isLoggedIn() ) die( 'Forbidden' );
if ( isset($_GET['sf']) )
{
$fid= $_GET['sf'];
$return = 'forum.php?sf='.$fid;
$table = 'site_forum_subthreads';
$parent = 'site_forum_forums';
$column= 'subforum';
}
else if ( isset($_GET['mf']) )
{
$fid= $_GET['mf'];
$return = 'forum.php?mf='.$fid;
$table = 'site_forum_threads';
$parent = 'site_forum_forums';
$column= 'forum';
}
else die( 'forbidden' );
try
{
$forum_check = DB::getInstance()->prepare( "SELECT title, access FROM $parent WHERE id = ? AND site = ?" );
$forum_check->execute( array($fid, $_SITE->id) );
$forum_check = $forum_check->fetch( PDO::FETCH_OBJ );
if ( !$forum_check ) die ( 'Error 404: Page not found' );
else if ( $_ACCESS < $forum_check->access ) $die( 'Forbidden' );
}
catch(PDOException $e)
{
Log::addEntry( $e->getMessage(), 'mysql' );
//redirect to error page
}
if ( isset($_POST['add']) )
{
if ( empty($_POST['title']) || empty($_POST['body']) ) $_ERROR = 'All fields are required';
else if ( isset ($_COOKIE[$cookie_name]) && (time() < $_COOKIE[$cookie_name] ) ) $template_values['_ERROR']['message'] = "You have to wait for $flood_control seconds before you can post again.";
else
{
try
{
$title = utf8_htmlentities( trim($_POST['title']) );
$body = utf8_htmlentities( trim($_POST['body']) );
$insert_query = DB::getInstance()->prepare( "INSERT into $table ($column, title, body, user, username) VALUES ( ?, ?, ?, ?, ?)" );
$insert_query->execute( array($fid, $title, $body, $_SESSION['site_user_id'], $_SESSION['site_user_username'] ) );
$_SUCCESS = 'Your thread has been successfully posted';
header( 'Location: '.MY_SITE_URL.'/m/site/forum/'.$return.'&msg='.urlencode($_SUCCESS) );
setcookie($cookie_name, $cookie_value);//flood control cookie
DB::close();
exit();
}
catch(PDOException $e)
{
Log::addEntry( $e->getMessage(), 'mysql' );
$template_values['_ERROR']['message'] = 'There was an error, please try again.<br />If this continues, please contact the <a href="mailto:sfroelich01@gmail.com">webmaster</a>.';
}
}
}//end of post check
$template_values['title'] = $_SITE->sitename.' | New Thread - '.$forum_check->title;
$template_values['return_url'] = $return;
$template = new PclTemplate();
$template->parseString('
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><!--(token:title)--></title>
<link href="../../css/main.css" rel="stylesheet" type="text/css" media="handheld,screen" />
<link href="../../css/forum.css" rel="stylesheet" type="text/css" media="handheld,screen" />
</head>
<body>
<div class="container">
<div class=" header">
<table>
<tr>
<td class="left"><a href="../../s/index.php"><img src="../../images/logo.png" alt="Logo" /></a></td>
</tr>
</table>
<!-- end .header-->
</div>
<!--(if:_ERROR)-->
<div class=\"error\"><!--(token:message)--></div>
<!--(endif)-->
<div class="content">
<div class="form-panel">
<form action="" method="post" name="thread_form" class="thread_form">
<label for="thread_title">Title</label><br />
<input name="title" type="text" id="thread_title" accesskey="1" tabindex="1" size="" maxlength="" required="required" /><br />
<label for="thread_body">Body</label><br />
<textarea name="body" type="" id="thread_body" accesskey="2" tabindex="2" required="required" ></textarea><br />
<input name="add" type="submit" value="Add" accesskey="3" tabindex="3" />
<a href="<!--(token:return_url)-->">Cancel</a>
</form>
<!--end .form-panel-->
</div>
<!-- end .content-->
</div>
<div class="blank footer">
<!-- end .footer-->
</div>
<!-- end .container-->
</div>
</body>
</html>');
echo $template->generate( $template_values, 'string' );
echo microtime(true) - $t;
?>
Last edited by frostymarvelous; 07-02-11 at 19:20.
I can make templates, logos and anything related to graphics. viz., Buttons etc.
and can provide you some ideas too, work too..
pm me
we can partner up mate.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks