'.$row['categoryname'].'';
if ($cata == $row['categoryname']){
$query2 = "SELECT * FROM categorys WHERE subgroupof = '".$cata."' GROUP BY categoryname ORDER BY categoryname";
$result2 = mysql_query($query2) or die(mysql_error());
echo '
';
}
if ($row['categoryname'] == $_GET['cat']){
$query2 = "SELECT * FROM categorys WHERE subgroupof = '".$_GET['cat']."' GROUP BY categoryname ORDER BY categoryname";
$result2 = mysql_query($query2) or die(mysql_error());
echo '
Sorry, could not log you in. Wrong login information.
';
}
}
else
{
//If all went right the Web form appears and users can log in
echo '";
}
}
} 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"]);
$password = combo_hash($password);
$q = "INSERT INTO `dbusers` (`username`,`passw`,`email`) "
."VALUES ('".$username."', "
." '".$password."', "
."'".$email."')";
$r = mysql_query($q);
if ( !mysql_insert_id() )
{
die("Error: User not added to database.");
}
else
{
echo "
Thanks for registering!
";
}
} else {
echo '";
}
} elseif ($_GET['action'] == 'logout' ){
##session_start();
##session_unset();
session_destroy();
echo 'Thank you for your stay. Click here to return to the index. ';
} elseif ($_GET['action'] == 'submit' ) {
if ($_SESSION["valid_user"]) {
?>
By '.$row['creator'].' in '.$row['category'].'';
echo ' '.$row['description'].'
';
echo 'Approve -- Delete';
}
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 = '';
}
// Should we show the PREVIOUS PAGE link?
if($current_page > 1) {
$previous_page = $current_page - 1;
$output = ' page="'. $previous_page .'" title="Previous Page">';
}
// Current Page Number
$output = '[ '. $current_page .' ]';
// Should we show the NEXT PAGE link?
if($current_page < $this->pages) {
$next_page = $current_page + 1;
$output = '';
}
// Should we show the LAST PAGE link?
if($current_page < $this->pages - 1) {
$output = ' pages .'" title="Last Page">';
}
// Return the output.
return $output;
}
}
$display = new display;
echo $display->pagination($articles_in_db, $articles_per_page, $current_page, "index.php");
}
if ($_GET['action'] == 'trash' ) {
mysql_query("UPDATE tutorials SET approved='tra' WHERE ID = '{$_GET["id"]}';");
echo "Tutorial added to trash!";
}
if ($_GET['action'] == 'approve' ) {
mysql_query("UPDATE tutorials SET approved='yes' WHERE ID = '{$_GET["id"]}';");
echo "Tutorial approved!";
}
if ($_GET['action'] == 'delete' ) {
$id = $_GET["id"];
mysql_query("DELETE FROM tutorials WHERE ID = '".$id."';");
echo "The tutorial has been deleted.";
}
if ($_GET['action'] == 'logout' ) {
session_start();
session_unset();
session_destroy();
echo 'Thank you for your stay. Click here to return to the index. ';
}
}
//ROOT ONLY
if ($_SESSION["valid_user"] === $rootadmin) {
if ($_GET['action'] == 'modchange' ) {
echo $_POST['mods'];
$modarray = explode("\n", $_POST['mods']);
foreach ($modarray as &$value) {
$value = substr("$value", 0, -1);
}
$mods = implode("' , '", $modarray);
$articles2 = file('constants.php');
$data = fopen("constants.php", "w");
$articles2['2'] = "\$modarray = array('$mods');\n";
$articles2 = implode('',$articles2);
fwrite($data,$articles2);
fclose($data);
echo "Options Changed";
}
if ($_GET['action'] == 'categorymod' ) {
echo "
Bellow are the categorys that exist at the moment, to delete one, click the delete button (But, this will mean all tutorials under that category will
no longer be displayed, you can change their categorys using My PHP admin) or to add a new one, click the add button
";
$query = "SELECT * FROM categorys";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo "
Click here to add a new category';
}
if (isset($_GET["deleteid"])) {
$id = $_GET["deleteid"];
mysql_query("DELETE FROM categorys WHERE ID = '".$id."';");
echo 'The category has been deleted.';
}
if ($_GET['action'] == 'options' ) {
?>
All the options availible are bellow.
All the mods are listed bellow, to add one, write each name on a new line, the admin doesnt need to be in the list.
Create a category
';
}
}
//Others
if (!isset($_GET["action"])){
?>
Update - 20th May
As usual, I have updated our code yet again, the new features include: