rendered paste body<?phpinclude ('dbconnect.php');?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><!--Copyright: Daemon Pty Limited 2006, http://www.daemon.com.auCommunity: Mollio http://www.mollio.org $License: Released Under the "Common Public License 1.0", http://www.opensource.org/licenses/cpl.phpLicense: Released Under the "Creative Commons License", http://creativecommons.org/licenses/by/2.5/License: Released Under the "GNU Creative Commons License", http://creativecommons.org/licenses/GPL/2.0/--><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Tutorial Database</title><link rel="stylesheet" type="text/css" href="css/main.css" media="screen" /><link rel="stylesheet" type="text/css" href="css/print.css" media="print" /><!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="css/ie6_or_less.css" /><![endif]--><script type="text/javascript" src="js/common.js"></script></head><body id="type-b"><div id"nonFooter"><div id="wrap"> <div id="header"> <?php if ($_SESSION["valid_user"]){}else{?> <div id="site-name">Tutorial Database</div> <div id="search"><span class="caption"> <form action="?action=login&op=login" method="post"> Username:<input id="searchsite" name="username" type="text"></input> Password:<input id="searchsite" name="password" type="text"></input> <input type="submit" value="Go" class="f-submit" /> </form></span> </div> <?php }?> <ul id="nav"> <li class="first"><a href="index.php">Home</a></li> <li class="active"><a href="index.php">User Area</a> <ul> <?php if ($_SESSION["valid_user"]){}else{echo '<li class="first"><a href="index.php?action=login">Log In</a></li>';}?> <?php if ($_SESSION["valid_user"] === $rootadmin){echo '<li class="first"><a href="admin.php">Admin Control Pannel</a></li>';}?> <?php if (in_array($valid, $modarray)){echo '<li class="first"><a href="admin.php">Moderator Control Pannel</a></li>';}?> <?php if ($_SESSION["valid_user"]){}else{echo '<li class="last"><a href="index.php?action=register">Register</a></li>';}?> <?php if ($_SESSION["valid_user"]){echo '<li class="last"><a href="index.php?action=logout">Log Out</a></li>';}?> </ul> </li> </ul> </div> <div id="content-wrap"> <div id="utility"> <ul id="nav-secondary"> <li class="first"><a href="index.php">Home</a></li> <?php$query = "SELECT * FROM categorys GROUP BY categoryname ORDER BY categoryname"; $result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)){ echo '<li><A href="index.php?cat='.$row['categoryname'].'&action=cat">'.$row['categoryname'].'</a>';}?> <li class="active">Recent Tutorials <ul> <?php$query = "SELECT * FROM tutorials WHERE approved = 'yes' ORDER BY id DESC"; $result = mysql_query($query) or die(mysql_error());$i = 1;while($i <= 5 AND $row = mysql_fetch_array($result)){ echo '<li'; if ($i = 1) { echo ' class="first"'; } if ($i = 5) { echo ' class="first"'; } echo '><A href="html://'.$row['url'].'">'.$row['tutorialname'].'</a></li>';$i++;}?> </ul> </ul> </div> <div id="content"> <div id="breadcrumb"> <a href="index.php">Home</a> <?php if ($_GET['action'] == 'cat') { echo '/ <a href="index.php?cat='.$_GET['cat'].'&action=cat">'.$_GET['cat'].'</a>'; } ?> </div> <div class="featurebox"><h2>Welcome To TutorialBase</h2> Please feel free to Browse our tutorials. Just selet a catagory down the side, and take a look through our tutorials.</div> <?phpif ($_GET['action'] == 'cat' ) {$catt = mysql_real_escape_string($_GET['cat']);$query = "SELECT * FROM tutorials WHERE approved = 'yes' AND category = '".$catt."' ORDER BY id DESC LIMIT ".$start.", ".$end.""; $result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)){ echo '<h4><A href="http://'.$row['url'].'">'.$row['tutorialname'].'</a></h4><p><span class="thumbnail"><a href="http://'.$row['url'].'"><img src=http://'.$row['img'].' alt="" width="100" height="75" /></a></span> By '.$row['creator'].' in '.$row['category'].''; echo '<br>'.$row['description'].'</p>';}class display {function pagination($rows, $per_page, $current_page, $page_link) { global $core,$C; $this->pages = ceil($rows / $per_page); if($this->pages == 1) { return; } $output = "Pages: "; // Should we show the FIRST PAGE link? if($current_page > 2) { $output .= "<a href=\"". $page_link ."?page=1/\" title=\"First Page\"><<</a>"; } // Should we show the PREVIOUS PAGE link? if($current_page > 1) { $previous_page = $current_page - 1; $output .= " <a href=\"". $page_link .">page=". $previous_page ."/\" title=\"Previous Page\"><</a>"; } // Current Page Number $output .= "<strong>[ ". $current_page ." ]</strong>"; // Should we show the NEXT PAGE link? if($current_page < $this->pages) { $next_page = $current_page + 1; $output .= "<a href=\"". $page_link ."?page=". $next_page ."/\" title=\"Next Page\">></a>"; } // Should we show the LAST PAGE link? if($current_page < $this->pages - 1) { $output .= " <a href=\"". $page_link ."?page=". $this->pages ."/\" title=\"Last Page\">>></a>"; } // Return the output. return $output;}}$display = new display;echo $display->pagination($articles_in_db, $articles_per_page, $current_page, $install_adress);} elseif ($_GET['action'] == 'login' ) {if ($_SESSION["valid_user"]){ echo 'You are already loged in <a href="index.php">Click here to return to the index.</a>';} else {if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); } $username = mysql_real_escape_string($_POST["username"]);$password = mysql_real_escape_string($_POST["password"]); // Create query $q = "SELECT * FROM `dbusers` " ."WHERE username='".$username."' " ."AND passw= '".$password."' " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); // Redirect to member page echo '<div class=\"featurebox\">Thank you for loggin in. <a href="index.php">Click here to return to the index.</a><BR></div>'; } else { // Login not successfulecho "<div class=\"featurebox\">Sorry, could not log you in. Wrong login information.<BR></div>"; } }else {//If all went right the Web form appears and users can log inecho '<form action="?action=login&op=login" method="POST" class="f-wrap-1"><div class="req"><b>*</b> Indicates required field</div><fieldset><h3>Log In</h3>'; echo "<label for=\"username\"><span class=\"req\">*</span>Username: <input name=\"username\" size=\"15\"><br /></label>"; echo "<label for=\"oassword\"><span class=\"req\">*</span>Password: <input type=\"password\" name=\"password\" size=\"8\"><br /></label>"; echo "<input type=\"submit\" value=\"Login\">"; echo "</form></fieldset>"; }}} elseif ($_GET['action'] == 'register' ){if ( $_GET["op"] == "reg" ) { $bInputFlag = false; foreach ( $_POST as $field ) { if ($field == "") { $bInputFlag = false; } else { $bInputFlag = true; } } // If we had problems with the input, exit with error if ($bInputFlag == false) { die( "Problem with your registration info. " ."Please go back and try again."); }$username = mysql_real_escape_string($_POST["username"]);$password = mysql_real_escape_string($_POST["password"]);$email = mysql_real_escape_string($_POST["email"]); $q = "INSERT INTO `dbusers` (`username`,`passw`,`email`) " ."VALUES ('".$username."', " ." PASSWORD('".$password."'), " ."'".$email."')"; $r = mysql_query($q); if ( !mysql_insert_id() ) { die("Error: User not added to database."); } else { echo "<h2>Thanks for registering!</h2>";} } else { echo '<form action="?action=register&op=reg" method="POST" class="f-wrap-1"><div class="req"><b>*</b> Indicates required field</div><fieldset><h3>Log In</h3>'; echo "<label for=\"username\"><span class=\"req\">*</span>Username: <input name=\"username\" MAXLENGTH=\"16\"></label><br />\n"; echo "<label for=\"password\"><span class=\"req\">*</span>Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"></label><br />\n"; echo "<label for=\"email\"><span class=\"req\">*</span>Email Address: <input name=\"email\" MAXLENGTH=\"25\"></label><br />\n"; echo "<input type=\"submit\">\n"; echo "</form></fieldset>"; }} elseif ($_GET['action'] == 'logout' ){session_start();session_unset();session_destroy(); echo 'Thank you for your stay. <a href="index.php">Click here to return to the index.</a><BR>';} elseif ($_GET['action'] == 'submit' ) { if ($_SESSION["valid_user"]) { ?> <h3>Submit a tutorial</h3><form method="post" action="index.php?action=proccess"><fieldset><legend>Tutorial Details:</legend><p><label for="tutorialname">Tutorial Name:</label><br><input type="text" name="tutorialname" size="40"/><BR><BR><label for="creator">Author:</label><br><input type="text" name="creator" size="40"/><BR><BR><label for="thumbnail">Link to thumbnail (60x60):</label><br>http//<input type="text" name="thumbnail" size="40"/><BR><BR><label for="description">Tutorial Description:</label></ br><textarea rows="4" cols="35" name="description"></textarea><br><label for="url">Direct link to tutorial:</label><br>http://<input type="text" name="url" size="40"/><BR><BR><label for="category">category:</label><br><select name="category"><?php$query = "SELECT * FROM categorys ORDER BY categoryname"; $result = mysql_query($query) or die(mysql_error());$count = 1;while($row = mysql_fetch_array($result)){ echo '<option value="'.$count.'">'.$row['categoryname'].'</option>';$count++;}?></select><BR><BR></p><p><input type="submit" name="action" value="send" /> </p></fieldset></form> <?php } else { echo "You do not have permission to submit a tutorial. If you would like to please register for free then log in.";}} elseif ($_GET['action'] == 'proccess' ) {$tutname = mysql_real_escape_string($_POST["tutorialname"]);$creator = mysql_real_escape_string($_POST["creator"]);$img = mysql_real_escape_string($_POST["thumbnail"]);$descr = mysql_real_escape_string($_POST["description"]);$url = mysql_real_escape_string($_POST["url"]);$category = mysql_real_escape_string($_POST["category"]);mysql_query("INSERT INTO tutorials(tutorialname, creator, img, description, url, approved, category) VALUES( '".$tutname."', '".$creator."', '".$img."', '".$descr."', '".$url."', 'no', '".$category."')") or die(mysql_error()); echo "The Tutorial '".$_POST['tutorialname']." by ".$_POST['creator']." sucssessfully submitted, It will be reviewed by the moderators, and approved if they like it.";} else {$query = "SELECT * FROM tutorials WHERE approved = 'yes' ORDER BY id DESC"; $result = mysql_query($query) or die(mysql_error());$i = 1;while($i <= 5 AND $row = mysql_fetch_array($result)){ echo '<h4><A href="http://'.$row['url'].'">'.$row['tutorialname'].'</a></h4><p><span class="thumbnail"><a href="http://'.$row['url'].'"><img src=http://'.$row['img'].' alt="" width="100" height="75" /></a></span> By '.$row['creator'].' in '.$row['category'].''; echo '<br>'.$row['description'].'</p>';$i++;}}?> </div> <div id="poweredby"><a href="http://farcry.daemon.com.au/"><img src="wsimages/mollio.gif" alt="FarCry - Mollio" /></a></div><br /><br /><br /><br /><br /></div><div class="push"></div></div></div><div id="footer"></div></body></html>