window.location='http://www.faerytaleonline.com/faerytale.html';"; } if($_POST["pageaction"] == "flogin") { if(ereg('[^A-Za-z0-9]', $fusername) || strlen($fusername) > 10 || ereg('[^A-Za-z0-9]', $fpassword) || strlen($fpassword > 10)) $msg = "Incorrect username and/or password"; else { $fpassword = sql_quote($fpassword); $sql = "SELECT user_id,username,firstname,email FROM ft_users WHERE username='".sql_quote($fusername)."' AND password='".md5($fpassword)."' AND disabled=0"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $user_user_id = $row["user_id"]; $user_username = $row["username"]; $user_firstname = $row["firstname"]; $user_email = $row["email"]; } //if($user_id && $password_found == $password && $user_id != 0) if($user_user_id && $user_user_id > 0) { $_SESSION["user_id"] = $user_user_id; $_SESSION["username"] = $user_username; $_SESSION["firstname"] = $user_firstname; $_SESSION["email"] = $user_email; //mail("ilumino@gmail.com","logout test 1", $_SESSION["username"]."\n".$_SESSION["user_id"]."\n".$_SESSION["firstname"]."\n".$_SESSION["email"]."\n".$_SESSION["active"]."\n".$_SESSION["created"]."\n".$_GET["pageaction"]=="logout"); } else $msg = "Incorrect username and/or password"; } } if($_POST["pageaction"] == "add") { //print_r($_POST); //$previewBox = //"
$content
"; if(!$date) {$error=true; $errmsg = "Please submit with a valid event date. ";} else if(!$content) {$error=true; $errmsg = "Please submit your entry with text. ";} else { //Double check for spoofing $sql = "SELECT location_src_id,date,real_date,audience FROM ft_chat WHERE id='$event_id'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $location_src_id = $row["location_src_id"]; $founddate = $row["date"]; $event_timestamp = $row["real_date"]; $audience = $row["audience"]; } $check_time_diff = time() - $event_timestamp; //echo $audience."
"; if($founddate != $date) {$error=true; $errmsg = "Please submit with a valid event date. ";} else if(!strstr($audience,"-".$post_avatar_id."-")) {$error=true; $errmsg = "You cannot write about this event. ";} //else if($check_time_diff <= 259200)//three days // {$error=true; $errmsg = "This event cannot be written about yet. ";} else { $story_timestamp = time(); $sql = "INSERT INTO ft_tales (avatar_id,event_id,location_id,event_timestamp,story_timestamp,date,title,content,approved,user_id) VALUES ('".sql_quote($post_avatar_id)."','".sql_quote($event_id)."','$location_src_id','$event_timestamp','$story_timestamp','".sql_quote($date)."','".sql_quote($title)."','".sql_quote($content)."','0','".$_SESSION["user_id"]."')"; mysql_query($sql); $errmsg = "Your story has been submitted successfully. It will be posted after it has been approved. "; } } } if($_POST["pageaction"] == "approve") { if($_SESSION['moderator']) { $asql = "UPDATE ft_tales SET approved=1 WHERE id='$storyId'"; mysql_query($asql); } } //----CHECK IF LOGGED IN----// if($_SESSION["username"]) { //----GET THIS USER'S CHARACTERS----// /*$sql = "SELECT id,birth_name,location_id,deceased FROM ft_avatar WHERE user_id='".$_SESSION["user_id"]."'"; //$sql = "SELECT id,birth_name,location_id,deceased FROM ft_avatar WHERE user_id='".$_SESSION["fuser_id"]."'"; $result = mysql_query($sql); while($row=mysql_fetch_array($result)) { $birth_name = $row["birth_name"]; $avatar_id = $row["id"]; $deceased = $row["deceased"]; $deceasedmsg = ""; if($deceased) $deceasedmsg = "(deceased)"; $charList .= ""; } */ $sql = "SELECT characters FROM ft_users WHERE user_id = '".$_SESSION["user_id"]."'"; $result = mysql_query($sql); while($row=mysql_fetch_array($result)) { $characters = $row["characters"]; } $charList0 = explode("|",$characters); for($x=0;$x<=sizeof($charList0)-1;$x++) { if($charList0[$x]) { $sql = "SELECT id,birth_name,location_id,deceased FROM ft_avatar WHERE id='".$charList0[$x]."'"; $result = mysql_query($sql); while($row=mysql_fetch_array($result)) { $birth_name = $row["birth_name"]; $avatar_id = $row["id"]; $deceased = $row["deceased"]; $deceasedmsg = ""; if($deceased) $deceasedmsg = "(deceased)"; $charList .= ""; } } } unset($avatar_id); if($charId) { //$fsql = "SELECT id,birth_name,location_id,deceased FROM ft_avatar WHERE user_id='".$_SESSION["user_id"]."' AND id='".sql_quote($charId)."'"; $fsql = "SELECT id,birth_name,location_id,deceased FROM ft_avatar WHERE id='".sql_quote($charId)."'"; $fresult = mysql_query($fsql); while($frow=mysql_fetch_array($fresult)) { $birth_name = $frow["birth_name"]; $avatar_id = $frow["id"]; $portrait = $frow["portrait"]; $deceased = $frow["deceased"]; //$charList .= ""; } } //for($loop=0;$loop<=sizeof($char_list)-1;$loop++) // { //MAKE SURE THEY WEREN'T DECEASED FOR THIS MESSAGE $deathmsg = ""; if($deceased) { $death_date = ""; $dsql = "SELECT real_date FROM ft_chat WHERE sender_id='$avatar_id' AND event=1 AND (message LIKE '%died%' OR message LIKE '%was killed%' OR message LIKE '%killed by%' OR message LIKE '%death%')"; $dresult = mysql_query($dsql); while($drow=mysql_fetch_array($dresult)) {$death_date = $drow["real_date"];} //THIS IS FOR ROSE AND DIRAN BECAUSE THEY DIDN'T DIE TRADITIONALLY if($avatar_id==26 || $avatar_id==28) $death_date = "1253143209"; $deathmsg = "AND real_date <= $death_date"; } //echo "death: ".$death_date." "."real: ".$real_date."
"; if($search && ($field == "date" || $field == "content") ) { if($field == "content") $field2 = "message"; else $field2 = "date"; //echo (substr($search, -1)); //if( (substr($search, -1) == "*") && (substr($search, 0,1) == "*") ) // { $searchmsg = str_replace ("*", "", $search); $searchmsg = "%".$searchmsg."%";}//$search = str_replace ("*", "", $search); if (substr($search, -1) == "-") { $searchmsg = str_replace ("-", "", $search); $searchmsg = $searchmsg."%";}//$search = str_replace ("*", "", $search); else if (substr($search, 0,1) == "-") { $searchmsg = str_replace ("-", "", $search); $searchmsg = "%".$searchmsg;} else $searchmsg = "%".$search."%"; $searchmsg = sql_quote($searchmsg); $field2 = sql_quote($field2); $searchtext = "AND `$field2` LIKE '$searchmsg'"; } //------PAGINATOR CODE--------// $page = $_GET["page"]; $delimiter = 20; //if($searchtext) //$Query = "SELECT * FROM ft_chat WHERE event=1 AND audience LIKE '%-".$avatar_id."-%' $searchtext $deathmsg ORDER BY id ASC ";// AND message NOT LIKE '%has foraged%' AND message NOT LIKE '%walks%' //else if($avatar_id) $Query = "SELECT * FROM ft_chat WHERE event=1 AND audience LIKE '%-".$avatar_id."-%' AND (message LIKE '%constructed%' OR message LIKE '%project%' OR message LIKE '%birth%' OR message LIKE '%died%' OR message LIKE '%kill%' OR message LIKE '%arrived%' OR message LIKE '%attacks%' OR message LIKE '%mate%' OR message LIKE '%death%' OR message LIKE '%travel%' OR message LIKE '%light%' OR message LIKE '%broken%') $searchtext $deathmsg ORDER BY id ASC ";// AND message NOT LIKE '%has foraged%' AND message NOT LIKE '%walks%' else $Query = "SELECT * FROM ft_chat WHERE event=1 AND audience = 'asdfasadd3423f'"; //if($_SESSION["username"] == "second") $result = mysql_query($Query); //echo mysql_num_rows($result); $rowcount = mysql_num_rows($result); $pages = $rowcount/$delimiter; if($rowcount%$delimiter > 0) $pages += 1; //$Query = "SELECT cID, iDescription, iName, iPhone, iPosted, numweeks, upgrade FROM items WHERE iDescription LIKE '%$key%' "; $Query = $Query . "LIMIT $delimiter "; if($page > floor($pages)) $page = floor($pages); if (isset($page) && $page != 1) { $offset = ($page*$delimiter)-$delimiter; $Query = $Query."OFFSET ".$offset; } else $page = 1; if ($page > 1) { $ppage = $page - 1; $nav = " "; } for ($i=1; $i <= $pages; $i++) { //$middle = " $i "; $backstep = $page - 10; $forwardstep = $page + 10; if($i >= $backstep && $i <= $forwardstep) { if($page == $i) $nav .= " $i "; else $nav .= " $i "; } } if ( ($page < floor($pages))) { $npage = $page + 1; //$right = "next page >>"; $nav .= "of ".floor($pages)." "; $nav .= ""; } //----------------------------// //echo $Query; //----VIEW OF COMPLETE STORY--// //$sql = "SELECT * FROM ft_chat WHERE message NOT LIKE '%has foraged%' AND message NOT LIKE '%walks%' AND event=1 AND audience LIKE '%-$char_list-%'ORDER BY id DESC LIMIT 20"; $result = mysql_query($Query); while($row=mysql_fetch_array($result)) { $event_id = $row["id"]; $event = $row["event"]; $location_src_id = $row["location_src_id"]; $rawdate = $row["date"]; $name = get_name($avatar_id,'avatar',$row["sender_id"]); $message = $row["message"]; $receiver_id=$row["receiver_id"]; $real_date = $row["real_date"]; $audience = $row["audience"]; $post_avatar_id = ""; $editable = false; //for($n=0;$n<=sizeof($char_list)-1;$n++) // { if(strstr($audience,"-".$avatar_id."-")); $editable = true; $post_avatar_id = $avatar_id; // } $name = get_name($post_avatar_id,'avatar',$row["sender_id"]); $target_name = get_name($post_avatar_id,'avatar',$receiver_id); $location_name = get_name($post_avatar_id,'location',$location_src_id); if($editable) { //GET AUDIENCE MEMBERS unset($audience_split); $audience_split = explode("-",$audience); $name_list = ""; for($x=0;$x<=sizeof($audience_split)-1;$x++) { if($audience_split[$x] && $audience_split[$x] != 10) $name_list .= get_name($post_avatar_id,"avatar",$audience_split[$x]).", "; } //$name_list .= $birth_name; $name_list = substr_replace($name_list,"",-2); //remove comma $time_diff = time() - $real_date; //if($time_diff > 1209600)//two weeks //if($time_diff > 604800)//one week //if($time_diff > 259200)//three days //{ if($search && $field2 == "message") { $message = str_ireplace($search, "$search",$message); } $date = $rawdate."  "; if(strstr($message,"constructed")) $list .= "".$birth_name." ($location_name): ".$date."".$message." "; else if(strstr($message,"project") || strstr($message,"died") || strstr($message,"death") || strstr($message,"kill") || strstr($message,"arrives") || strstr($message,"mate") || strstr($message,"travel") || strstr($message,"broken") || strstr($message,"flash of light") || strstr($message,"attacked by a creature") || strstr($message,"fled") || strstr($message,"making any progress") || strstr($message,"tame") || strstr($message,"tamed")) $list .= "".$birth_name." ($location_name): ".$date."".$name." ".$message." "; else if(strstr($message,"attacks")) $list .= "".$birth_name." ($location_name): ".$date."".$name." ".$message.$target_name." "; else if(strstr($message,"light")) $list .= "".$date."".$message.""; else if(strstr($message,"birth")) { //find the name of this child. $baby_name = ""; if($receiver_id) { $baby_name = get_name($avatar_id,"avatar",$receiver_id); $baby_name = "which you call, ".$baby_name.""; } $list .= "".$birth_name." ($location_name): ".$date."".$name." ".$message." ".$baby_name." "; } $list .= ""; //----GET THE STORIES----// $sql2 = "SELECT date,content,user_id FROM ft_tales WHERE event_id='$event_id' AND approved=1 ORDER BY id ASC"; $result2 = mysql_query($sql2); while($row2=mysql_fetch_array($result2)) { $found_user_id = $row2["user_id"]; $sql3 = "SELECT username FROM ft_users WHERE user_id='$found_user_id'"; $result3 = mysql_query($sql3); while($row3=mysql_fetch_array($result3)) {$username=$row3["username"];} $date = $row2["date"]; $content = $row2["content"]; $list .= ""; } $list .= "  
"; $list .= ""; //} //else // $list .= "-Pending Event-"; } } /* onclick = 'document.getElementById(\"dateValue\").value = document.getElementById(\"".$write."\").value; document.getElementById(\"writeValue\").value = document.getElementById(\"".$write."\").value; document.getElementById(\"saveFrm\").submit;' if(strstr($message,"project")) $chat_value .= "".$date."".$message.""; //else if(strstr($message,"foraged")) // $chat_value .= "".$date."".$name." ".$message.""; else if(strstr($message,"resources!") || strstr($message,"empty handed")) $chat_value .= "".$date."".$name." ".$message.""; else if(strstr($message,"mate") || strstr($message,"eats some food") || strstr($message,"disassemble")) $chat_value .= "".$date."".$name." ".$message.""; else if(strstr($message,"birth")) $chat_value .= "".$date."".$name." ".$message.""; else if(strstr($message,"died")) $chat_value .= "".$date."".$name." ".$message.""; else if(strstr($message,"killed") || strstr($message,"death")) $chat_value .= "".$date."".$name." ".$message.""; else if(strstr($message,"freezing") || strstr($message,"sweating")) $chat_value .= "".$date."".$message.""; else if(strstr($message,"walks") || strstr($message,"travels") || strstr($message,"leaves") || strstr($message,"arrives")) $chat_value .= "".$date."".$name." ".$message.""; else if(strstr($message,"attacks")) $chat_value .= "".$date."".$name." ".$message.$target_name.""; */ //} $loginValue = ' Welcome, '.$_SESSION["firstname"].'  [Logout]
View:  
'; } else { if($search && ($field == "date" || $field == "content") ) { if (substr($search, -1) == "-") { $searchmsg = str_replace ("-", "", $search); $searchmsg = $searchmsg."%";}//$search = str_replace ("*", "", $search); else if (substr($search, 0,1) == "-") { $searchmsg = str_replace ("-", "", $search); $searchmsg = "%".$searchmsg;} else $searchmsg = "%".$search."%"; $searchmsg = sql_quote($searchmsg); $field = sql_quote($field); $searchtext = "AND `$field` LIKE '$searchmsg'"; } if($getNew) { $getNow = date(time()) - 604800; $newSearch = "AND story_timestamp >= '$getNow'"; } if($charId && $charId > 0) { $fsql = "SELECT id FROM ft_avatar WHERE id='".sql_quote($charId)."'"; //echo $fsql; $fresult = mysql_query($fsql); while($frow=mysql_fetch_array($fresult)) { $avatar_id = $frow["id"]; $avatarSearch = "AND avatar_id='$avatar_id'"; //$charList .= ""; } } if($areaId && $areaId > 0) { $locationSearch = "AND location_id='$areaId'"; } //------PAGINATOR CODE--------// $page = $_GET["page"]; $delimiter = 20; if($_SESSION['moderator']) $Query = "SELECT * FROM ft_tales WHERE approved=0 $searchtext $avatarSearch $locationSearch ORDER BY event_timestamp ASC "; else $Query = "SELECT * FROM ft_tales WHERE approved=1 $searchtext $avatarSearch $locationSearch $newSearch ORDER BY event_timestamp ASC "; $result = mysql_query($Query); //echo mysql_num_rows($result); $rowcount = mysql_num_rows($result); $pages = $rowcount/$delimiter; if($rowcount%$delimiter > 0) $pages += 1; //$Query = "SELECT cID, iDescription, iName, iPhone, iPosted, numweeks, upgrade FROM items WHERE iDescription LIKE '%$key%' "; $Query = $Query . "LIMIT $delimiter "; if($page > floor($pages)) $page = floor($pages); if (isset($page) && $page != 1) { $offset = ($page*$delimiter)-$delimiter; $Query = $Query."OFFSET ".$offset; } else $page = 1; if ($page > 1) { $ppage = $page - 1; $nav = " "; } for ($i=1; $i <= $pages; $i++) { //$middle = " $i "; $backstep = $page - 10; $forwardstep = $page + 10; if($i >= $backstep && $i <= $forwardstep) { if($page == $i) $nav .= " $i "; else $nav .= " $i "; } } if ( ($page < floor($pages))) { $npage = $page + 1; //$right = "next page >>"; $nav .= "of ".floor($pages)." "; $nav .= ""; } //----------------------------// $loginValue = '
'.$msg.'
Username:Password:
Not an author yet? Click here to sign-up.
'; //echo $_SESSION["moderator"]; //----GET THE STORIES----// //$sql2 = "SELECT date,content FROM ft_tales WHERE approved=1 ORDER BY id ASC"; $result2 = mysql_query($Query); while($row2=mysql_fetch_array($result2)) { $event_id = $row2["event_id"]; $event_location = $row2["location_id"]; $author_id = $row2["avatar_id"]; $storyId = $row2["id"]; $story_timestamp = $row2["story_timestamp"]; $date = $row2["date"]; $content = $row2["content"]; /*$sql3 = "SELECT portrait FROM ft_avatar WHERE id='$author_id'"; $result3 = mysql_query($sql3); while($row3=mysql_fetch_array($result3)) {$portrait = $row3["portrait"];} $portImg = ""; if($portrait) $portImg = ""; */ if($search && $field == "content") { $content = str_ireplace($search, "$search",$content); } $approve = ""; if($_SESSION['moderator']) { $publishDate = date("m-d-Y G:i",$story_timestamp); $approve = "
 $publishDate"; } $story_time_diff = ""; $story_time_diff = time() - $story_timestamp; if($story_time_diff < 604800) $date = $date."  New!"; if(!$charId) //$date = $date."  "; $date = $date."  "; if(!$areaId) //$date = $date."  "; $date = $date."  "; $list .= "$date$approve$portImg
$content
 "; } } //-------------------------// ?>
Show/Hide
Show the stories for this person
Show the stories for this location
Previous Page
Next Page
Search for 

The Faery Tale

Rules and Guidelines
Page:  
Show New!