View Single Post
  #4  
Old 5th May 2008, 10:28
snakebite snakebite is offline
Senior Member
 
Join Date: Apr 2008
Default
Posts: 47
Default Re: [Help request] For stylesheets manager
probably you took it from the first post...but the code in the first post didnt work :)

so here is the one that works finely

Code:
<?php
ob_start();
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
if (get_user_class() < UC_SYSOP) {
die("Access denied.");
}
mysql_connect($mysql_host,$mysql_user,$mysql_pass);
mysql_select_db($mysql_db);
stdhead("Stylesheets");
print("<h1>Stylesheets</h1>\n");
print("</br>");
print("<table width=70% border=1 cellspacing=0 cellpadding=2><tr><td align=center>\n");

///////////////////// D E L E T E T H E M E \\\\\\\\\\\\\\\\\\\\\\\\\\\\

$sure = $_GET['sure'];
if($sure == "yes") {
$delid = $_GET['delid'];
$query = "DELETE FROM stylesheets WHERE id=" .sqlesc($delid) . " LIMIT 1";
$sql = mysql_query($query);
echo("theme succesfully deleted! [ Back ]");
end_frame();
stdfoot();
die();
}
$delid = $_GET['delid'];
$name = $_GET['cat'];
if($delid > 0) {
echo("Are you sure you would like to delete this theme? ($name) ( Y / N )");
end_frame();
stdfoot();
die();

}

///////////////////// E D I T A T H E M E \\\\\\\\\\\\\\\\\\\\\\\\\\\\
$edited = $_GET['edited'];
if($edited == 1) {
$id = $_GET['id'];
$name = $_GET['name'];
$uri = $_GET['uri'];
$query = "UPDATE stylesheets SET
name = '$name',
uri = '$uri' WHERE id=".sqlesc($id);
$sql = mysql_query($query);
if($sql) {
echo("<table class=main cellspacing=0 cellpadding=5 width=50%>");
echo("<tr><td><div align='center'>Well done! Your theme has been edited succesfully! [ Back ]</div></tr>");
echo("</table>");
end_frame();
stdfoot();
die();
}
}

$editid = $_GET['editid'];
$name = $_GET['name'];
$uri = $_GET['uri'];
if($editid > 0) {
echo("<form name='form1' method='get' action='" . $_SERVER['PHP_SELF'] . "'>");
echo("<table class=main cellspacing=0 cellpadding=5 width=50%>");
echo("<div align='center'><input type='hidden' name='edited' value='1'>Now editing theme "$name"</div>");
echo("
");
echo("<input type='hidden' name='id' value='$editid'<table class=main cellspacing=0 cellpadding=5 width=50%>");
echo("<tr><td>Name: </td><td align='right'><input type='text' size=50 name='name' value='$name'></td></tr>");
echo("<tr><td>uri: </td><td align='right'><input type='text' size=50 name='uri' value='$uri'></td></tr>");
echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>");
echo("</table></form>");
end_frame();
stdfoot();
die();
}

///////////////////// A D D A N E W T H E M E \\\\\\\\\\\\\\\\\\\\\\\\\\\\
$add = $_GET['add'];
if($add == 'true') {
$name = $_GET['name'];
$uri = $_GET['uri'];
$query = "INSERT INTO stylesheets SET
name = '$name',
uri = '$uri'";
$sql = mysql_query($query);
if($sql) {
$success = TRUE;
} else {
$success = FALSE;
}
}
print("Add A New theme!");
print("
");
print("
");
echo("<form name='form1' method='get' action='" . $_SERVER['PHP_SELF'] . "'>");
echo("<table class=main cellspacing=0 cellpadding=5 width=50%>");
echo("<tr><td>Name: </td><td align='right'><input type='text' size=50 name='name'></td></tr>");
echo("<tr><td>uri: </td><td align='right'><input type='text' size=50 name='uri'><input type='hidden' name='add' value='true'></td></tr>");
echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>");
echo("</table>");
if($success == TRUE) {
print("Success!");
}
echo("
");
echo("</form>");

///////////////////// E X I S T I N G C A T E G O R I E S \\\\\\\\\\\\\\\\\\\\\\\\\\\\

print("Existing stylesheets:");
print("
");
print("
");
echo("<table class=main cellspacing=0 cellpadding=5>");
echo("<td>ID:</td><td>Name:</td><td>URI:</td><td>Edit:</td><td>Delete:</td>");
$query = "SELECT * FROM stylesheets WHERE 1=1";
$sql = mysql_query($query);
while ($row = mysql_fetch_array($sql)) {
$id = $row['id'];
$name = $row['name'];
$uri = $row['uri'];
echo("<tr><td>$id </td> <td>$name</td> <td>$uri</td> <td><div align='center'>[img]$BASEURL/pic/multipage.gif[/img]</div></td> <td><div align='center'>[img]$BASEURL/pic/warned2.gif[/img]</div></td></tr>");
}

end_frame();
end_frame();
stdfoot();

?>
__________________
Go here! ----> "HERE"
Reply With Quote