\n";
include("bottom.phtml");
exit;
}
if($_GET["build"]) {
//These _POST if's set the form up if there are no values a default plain set is given
if(!$_POST["background"])
$background = "#fff";
else
$background = $_POST["background"];
if(!$_POST["textcolour"])
$textcolour = "#000";
else
$textcolour = $_POST["textcolour"];
if(!$_POST["navheadb"])
$navheadb = "#ffffff";
else
$navheadb = $_POST["navheadb"];
if(!$_POST["navlista"])
$navlista = "#000";
else
$navlista = $_POST["navlista"];
if(!$_POST["navlistavisited"])
$navlistavisited = "#3e3e3e";
else
$navlistavisited = $_POST["navlistavisited"];
if(!$_POST["navheadbtext"])
$navheadbtext = "#000";
else
$navheadbtext = $_POST["navheadbtext"];
if (!$_POST["titlestripe"])
$titlestripe = "#fff";
else
$titlestripe = $_POST["titlestripe"];
//Hnadle the incoming files and save them appropriatley
if ($_FILES['logo']) {
//HTTP POST Image upload handler
if (is_uploaded_file($_FILES['logo']['tmp_name'])) {
if (strncasecmp($_FILES['logo']['type'],"image/",6) == 0 && $_FILES['logo']['size'] <= 512000) {
/* MIME type confirmed, handle image, save it, edit db */
$ext = strrchr($_FILES['logo']['name'],".");
$file = sprintf("%s%s%s",$uploadpath,"logo",$ext);
$logourl = sprintf("%s%s%s",$uploadimgurl,"logo",$ext);
move_uploaded_file($_FILES['logo']['tmp_name'],$file);
echo "File uploaded
\n";
} else {
echo "Images and files less than 512000 bytes only please\n
\n";
}
}
}
if ($_FILES['goat']) {
//HTTP POST Image upload handler
if (is_uploaded_file($_FILES['goat']['tmp_name'])) {
if (strncasecmp($_FILES['goat']['type'],"image/",6) == 0 && $_FILES['goat']['size'] <= 512000) {
/* MIME type confirmed, handle image, save it, edit db */
$ext = strrchr($_FILES['goat']['name'],".");
$file = sprintf("%s%s%s",$uploadpath,"goat",$ext);
$goaturl = sprintf("%s%s%s",$uploadimgurl,"goat",$ext);
move_uploaded_file($_FILES['goat']['tmp_name'],$file);
echo "File uploaded
\n";
} else {
echo "Images and files less than 512000 bytes only please\n
\n";
}
}
}
if ($_FILES['strip']) {
//HTTP POST Image upload handler
if (is_uploaded_file($_FILES['strip']['tmp_name'])) {
if (strncasecmp($_FILES['strip']['type'],"image/",6) == 0 && $_FILES['strip']['size'] <= 512000) {
/* MIME type confirmed, handle image, save it, edit db */
$ext = strrchr($_FILES['strip']['name'],".");
$file = sprintf("%s%s%s",$uploadpath,"strip",$ext);
$stripurl = sprintf("%s%s%s",$uploadimgurl,"strip",$ext);
move_uploaded_file($_FILES['strip']['tmp_name'],$file);
echo "File uploaded
\n";
} else {
echo "Images and files less than 512000 bytes only please\n
\n";
}
}
}
if ($_FILES['navgrad']) {
//HTTP POST Image upload handler
if (is_uploaded_file($_FILES['navgrad']['tmp_name'])) {
if (strncasecmp($_FILES['navgrad']['type'],"image/",6) == 0 && $_FILES['navgrad']['size'] <= 512000) {
/* MIME type confirmed, handle image, save it, edit db */
$ext = strrchr($_FILES['navgrad']['name'],".");
$file = sprintf("%s%s%s",$uploadpath,"navgrad",$ext);
$navgradurl = sprintf("%s%s%s",$uploadimgurl,"navgrad",$ext);
move_uploaded_file($_FILES['navgrad']['tmp_name'],$file);
echo "File uploaded
\n";
} else {
echo "Images and files less than 512000 bytes only please\n
\n";
}
}
}
$dark = $navheadb;
$template = fopen("css/skins/template.css","r");
$writetheme = fopen("css/skins/$theme.css","w+");
if ($template && $writetheme) {
while(!feof($template)) {
$buf = fgets($template,512);
if(strstr($buf,"&navheadbtext")) {
$writebuf = sprintf("color: %s;\n",$navheadbtext);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&navheadb")) {
if($navgradurl)
$writebuf = sprintf("background: %s url(%s) repeat-y;\n",$navheadb,$navgradurl);
else
$writebuf = sprintf("background: %s;\n",$navheadb);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&background")) {
$writebuf = sprintf("background-color: %s;\n",$background);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&textcolour")) {
$writebuf = sprintf("color: %s;\n",$textcolour);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&navlistavisited")) {
$writebuf = sprintf("color: %s;\n",$navlistavisited);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&navlista")) {
$writebuf = sprintf("color: %s;\n",$navlista);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&Menustrip")) {
if($stripurl)
$writebuf = sprintf("background: %s url(%s);\n",$navheadb,$stripurl);
else
$writebuf = sprintf("background: %s;\n",$navheadb);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&titlestripe")) {
$writebuf = sprintf("background: %s;\n",$titlestripe);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&dark")) {
$writebuf = sprintf("background: %s;\n",$dark);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&topbotstripefont")) {
$writebuf = sprintf("color: %s;\n",$topbotstripefont);
fwrite($writetheme,$writebuf);
} elseif(strstr($buf,"&topbotstripeurl")) {
$writebuf = sprintf("color: %s;\n",$topbotstripeurl);
fwrite($writetheme,$writebuf);
} else
fwrite($writetheme,$buf);
}
$writescript = fopen("inc/skins/$theme.inc","w+");
if($writescript) {
fwrite($writescript,"\n");
fclose($writescript);
} else
echo "Writing include file failed, try again or theme will not function properly";
fclose($template);
fclose($writetheme);
$db = mysql_connect($sqlhost,$sqluser,$sqlpass);
mysql_select_db("channel",$db);
if($_GET["edit"] || $_POST["edit"]) {
$sql = "UPDATE skins SET modified=NOW() where name='$theme'";
mysql_query($sql,$db);
$sql = "INSERT INTO log (modified,user,message) VALUES (NOW(),'$themenick','updated the theme $theme')";
mysql_query($sql,$db);
} else {
$sql = "INSERT INTO skins (name,owner,modified) VALUES ('$theme','$themenick',NOW())";
mysql_query($sql,$db);
mysql_error($db);
$sql = "INSERT INTO log (modified,user,message) VALUES (NOW(),'$themenick','created a new theme named $theme')";
mysql_query($sql,$db);
}
mysql_close($db);
} else
echo "Failed to write theme files!\n";
}
include("top.phtml");
//This set of conditionals checks if a theme name was given, if not halt script
if ($_GET["theme"])
$theme = $_GET["theme"];
if ($_POST["theme"])
$theme = $_POST["theme"];
if (!$theme) {
blitzed_title("Theme Builder by CrazySpence © 2004");
echo <<
EOT;
$db = mysql_connect($sqlhost,$sqluser,$sqlpass);
mysql_select_db("channel",$db);
$sql = "SELECT name FROM skins WHERE owner='$themenick'";
$result = mysql_query($sql);
if ($result)
blitzed_title("Edit your existing themes:");
while($row = mysql_fetch_array($result)) {
printf("%s\n
\n",$row["name"],$row["name"],$row["name"]);
}
mysql_close($db);
include("bottom.phtml");
exit;
}
$themeedit = $theme;
$uploadpath = "/home/spencep/niagara.spenced.com/images/skins/$theme/";
$uploadimgurl = "http://niagara.spenced.com/images/skins/$theme/";
blitzed_title("Theme Builder by CrazySpence © 2004");
if($_GET["new"]) {
$theme = str_replace(" ","",$theme);
$db = mysql_connect($sqlhost,$sqluser,$sqlpass);
mysql_select_db("channel",$db);
$sql = "SELECT name FROM skins where name='$theme'";
$result = mysql_query($sql);
if($row = mysql_fetch_array($result)) {
echo "Theme by that name exists already\n
\n
\n";
echo <<
EOT;
include("bottom.phtml");
mysql_close($db);
exit;
}
$background = "#fff";
$textcolour = "#000";
$navheadb = "#ffffff";
$navlista = "#000";
$navlistavisited = "#3e3e3e";
$navheadbtext = "#000";
$titlestripe = "#fff";
$incpath = sprintf("inc/skins/%s.inc",$theme);
if (!is_file($incpath))
touch($incpath);
if (!is_dir("images/skins/$theme/"))
mkdir("images/skins/$theme/",0755);
mysql_close($db);
}
//Include the values for the form
$incpath = sprintf("inc/skins/%s.inc",$theme);
if(file_exists($incpath)) {
Require $incpath;
}
echo <<
EOT;
if($edit) {
echo "";
}
echo <<
EOT;
include("bottom.phtml");
?>