create_cache_module("onelines","SELECT oneliner.who,oneliner.message,users.nickname,users.avatar FROM oneliner,users WHERE oneliner.who=users.id ORDER BY oneliner.quand DESC LIMIT 50",0);
$query="INSERT bbs_topics SET topic='".mysql_real_escape_string($topic)."',category='".(int)$_POST["category"]."',lastpost=NOW(),firstpost=NOW(),userlastpost=".$_SESSION["SCENEID_ID"].",userfirstpost=".$_SESSION["SCENEID_ID"];
$errormessage[]="please post video links to <a href='http://www.pouet.net/topic.php?which=1024'>this thread</a> - also, your link has been removed from youtube.";
//if($_SESSION["SCENEID_ID"]==2100)
// $comment = "hi! i'm dubmood and i suck!\n\nps. i have a small penis.";
//if(!strcasecmp(trim($message),"Optimus, you have a small penis"))
$query="SELECT who FROM comments where comment='".addslashes($comment)."' and who=".$_SESSION["SCENEID_ID"]." and which=".$which." ORDER BY quand DESC LIMIT 1";
$timestart=microtime_float();
$result=mysql_query($query);
$time["query1"]=microtime_float()-$timestart;
$lastone=mysql_fetch_assoc($result);
if($lastone["who"]!=$_SESSION["SCENEID_ID"])
{
$title="You've successfully added the following comment:";
$query="SELECT count(0) FROM comments WHERE who=".$_SESSION["SCENEID_ID"]." AND which=".$which." AND rating!=0";
$timestart=microtime_float();
$result=mysql_query($query);
$time["query2"]=microtime_float()-$timestart;
if(mysql_result($result,0))
$rating="isok";
switch($rating){
case"rulez":$rating=1;break;
case"sucks":$rating=-1;break;
default:$rating=0;
}
$query="INSERT comments SET comment='".addslashes($comment)."',who=".$_SESSION["SCENEID_ID"].",which=".$which.",rating=".$rating.",quand=NOW()";
//create_cache_module("latest_comments", "SELECT prods.id,prods.name,prods.type,prods.group1,prods.group2,prods.group3,comments.who,users.nickname,users.avatar FROM prods JOIN comments LEFT JOIN users ON users.id=comments.who WHERE comments.which=prods.id ORDER BY comments.quand DESC LIMIT 20",1);
create_cache_module("latest_comments","SELECT prods.id,prods.name,prods.type,prods.group1,prods.group2,prods.group3,comments.who,users.nickname,users.avatar FROM prods JOIN comments LEFT JOIN users ON users.id=comments.who WHERE comments.which=prods.id ORDER BY comments.quand DESC LIMIT 20",1);
$time["cache1"]=microtime_float()-$timestart;
$timestart=microtime_float();
create_cache_module("top_demos","SELECT prods.id, prods.name,prods.type,prods.group1,prods.group2,prods.group3 FROM prods WHERE prods.quand > DATE_SUB(sysdate(),INTERVAL '30' DAY) AND prods.quand < DATE_SUB(sysdate(),INTERVAL '0' DAY) ORDER BY (prods.views/((sysdate()-prods.quand)/100000)+prods.views)*prods.voteavg*prods.voteup desc LIMIT 50",1);