admin_profile.php
来自「BLOG HOSTER---PHP & MYSQL Create Blogs 」· PHP 代码 · 共 749 行 · 第 1/2 页
PHP
749 行
<?
$page = "admin_profile.php";
include "admin_header.php";
if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = "main"; }
if($task == "dosave") {
$field_website = $_POST['field_website'];
$field_screenname = $_POST['field_screenname'];
$field_gender = $_POST['field_gender'];
$field_birthday = $_POST['field_birthday'];
$field_city = $_POST['field_city'];
$field_state = $_POST['field_state'];
$field_country = $_POST['field_country'];
$field_interests = $_POST['field_interests'];
$categories_on = $_POST['categories_on'];
$allow_avatars = $_POST['allow_avatars'];
$avatar_filesize = $_POST['avatar_filesize'];
$avatar_width = $_POST['avatar_width'];
$avatar_height = $_POST['avatar_height'];
$show_memberlist = $_POST['show_memberlist'];
$show_userstats = $_POST['show_userstats'];
if(!is_numeric($avatar_filesize) | !is_numeric($avatar_width) | !is_numeric($avatar_height) | (int)$avatar_filesize != $avatar_filesize | (int)$avatar_width != $avatar_width | (int)$avatar_height != $avatar_height) {
echo $head;
echo "
$admin_profile90
";
echo $foot;
exit();
}
mysql_query("UPDATE bhost_admin SET field_website='$field_website', field_screenname='$field_screenname', field_gender='$field_gender', field_birthday='$field_birthday', field_city='$field_city', field_state='$field_state', field_country='$field_country', field_interests='$field_interests', categories_on='$categories_on', allow_avatars='$allow_avatars', avatar_filesize='$avatar_filesize', avatar_width='$avatar_width', avatar_height='$avatar_height', show_memberlist='$show_memberlist', show_userstats='$show_userstats'");
$custom_fields = mysql_query("SHOW COLUMNS FROM bhost_profile FROM `$mysql_database`");
while($custom = mysql_fetch_assoc($custom_fields)) {
if($custom[Field] != "p_id" & $custom[Field] != "u_id") {
$var = "field_".$custom[Field];
$required = $_POST[$var];
if($required == "3" & substr($custom[Field], -2) != "_3") {
$new_column = substr($custom[Field], 0, -2)."_3";
mysql_query("ALTER TABLE bhost_profile CHANGE $custom[Field] $new_column $custom[Type]");
} elseif($required == "2" & substr($custom[Field], -2) != "_2") {
$new_column = substr($custom[Field], 0, -2)."_2";
mysql_query("ALTER TABLE bhost_profile CHANGE $custom[Field] $new_column $custom[Type]");
} elseif($required == "1" & substr($custom[Field], -2) != "_1") {
$new_column = substr($custom[Field], 0, -2)."_1";
mysql_query("ALTER TABLE bhost_profile CHANGE $custom[Field] $new_column $custom[Type]");
} elseif($required == "0" & substr($custom[Field], -2) != "_0") {
$new_column = substr($custom[Field], 0, -2)."_0";
mysql_query("ALTER TABLE bhost_profile CHANGE $custom[Field] $new_column $custom[Type]");
}
}
}
echo $head;
echo "
<h2>$admin_profile1</h2>
$admin_profile2
<br><br>
<form action='admin_profile.php' method='POST'>
<input type='submit' class='button' value='$admin_profile3'>
<input type='hidden' name='task' value='main'>
</form>
";
echo $foot;
exit();
}
if($task == "addcat") {
echo $head;
echo "
<h2>$admin_profile68</h2>
<form action='admin_profile.php' method='POST'>
$admin_profile69<br><br>
$admin_profile70<br>
<input type='text' name='name' size='30' maxlength='30'><br><br>
<input class='button' type='submit' value='$admin_profile71'>
<input type='hidden' name='task' value='doaddcat'>
</form>
";
echo $foot;
exit();
}
if($task == "doaddcat") {
$name = str_replace("'", "'", $_POST['name']);
if(str_replace(" ", "", $name) == "") {
echo $head;
echo "<b>$admin_profile72</b><br>$admin_profile73";
echo $foot;
exit;
}
mysql_query("INSERT INTO bhost_categories (name) VALUES ('$name')");
header("Location: admin_profile.php");
exit();
}
if($task == "editcat") {
if(isset($_GET['wc_id'])) { $wc_id = $_GET['wc_id']; } else { $wc_id = 0; }
$category = mysql_query("SELECT * FROM bhost_categories WHERE wc_id='$wc_id'");
if(mysql_num_rows($category) != 1) { header("Location: admin_profile.php"); exit(); }
$category_info = mysql_fetch_assoc($category);
echo $head;
echo "
<h2>$admin_profile74</h2>
<form action='admin_profile.php' method='POST'>
$admin_profile75<br><br>
$admin_profile70<br>
<input type='text' name='name' size='30' maxlength='30' value='$category_info[name]'><br><br>
<input class='button' type='submit' value='$admin_profile76'>
<input type='hidden' name='task' value='doeditcat'>
<input type='hidden' name='wc_id' value='$wc_id'>
</form>
";
echo $foot;
exit();
}
if($task == "doeditcat") {
$name = str_replace("'", "'", $_POST['name']);
$wc_id = $_POST['wc_id'];
if(str_replace(" ", "", $name) == "") {
echo $head;
echo "<b>$admin_profile72</b><br>$admin_profile73";
echo $foot;
exit;
}
mysql_query("UPDATE bhost_categories SET name='$name' WHERE wc_id='$wc_id'");
header("Location: admin_profile.php");
exit();
}
if($task == "deletecat") {
if(isset($_GET['wc_id'])) { $wc_id = $_GET['wc_id']; } else { $wc_id = 0; }
$category = mysql_query("SELECT * FROM bhost_categories WHERE wc_id='$wc_id'");
if(mysql_num_rows($category) != 1) { header("Location: admin_profile.php"); exit(); }
$category_info = mysql_fetch_assoc($category);
echo $head;
echo "
<h2>$admin_profile77</h2>
$admin_profile78
<br><br>
<table cellpadding='0' cellspacing='0'>
<form action='admin_profile.php' method='POST'>
<tr>
<td>
<input class='button' type='submit' value='$admin_profile79'>
</td>
<input type='hidden' name='task' value='dodeletecat'>
<input type='hidden' name='wc_id' value='$wc_id'>
</form>
<form action='admin_profile.php' method='POST'>
<td>
<input class='button' type='submit' value='$admin_profile25'>
</td>
<input type='hidden' name='task' value='main'>
</form>
</tr></table>
";
echo $foot;
exit();
}
if($task == "dodeletecat") {
$wc_id = $_POST['wc_id'];
mysql_query("DELETE FROM bhost_categories WHERE wc_id='$wc_id'");
header("Location: admin_profile.php");
exit();
}
if($task == "addcustom") {
echo $head;
echo "
<h2>$admin_profile4</h2>
<form action='admin_profile.php' method='POST'>
$admin_profile5<br><br>
$admin_profile6<br>
<input type='text' name='custom_field' maxlength='50'><br><br>
$admin_profile7<br>
<select name='type'>
<option value='varchar(255)'>$admin_profile8</option>
<option value='text'>$admin_profile9</option>
</select><br><br>
$admin_profile10<br>
<select name='required' style='width: 200px;'>
<option value='3'>$admin_profile11</option>
<option value='2'>$admin_profile12</option>
<option value='1'>$admin_profile13</option>
<option value='0'>$admin_profile14</option>
</select><br><br>
$admin_profile80<br>
<textarea name='tip' rows='7' cols='40'></textarea><br><br>
<input class='button' type='submit' value='$admin_profile15'>
<input type='hidden' name='task' value='doadd'>
</form>
";
echo $foot;
exit();
}
if($task == "doadd") {
$custom_field = $_POST['custom_field'];
$custom_name = $custom_field;
$type = $_POST['type'];
$required = $_POST['required'];
$tip = $_POST['tip'];
if(str_replace(" ", "", $custom_field) == "") {
echo $head;
echo "<b>$admin_profile16</b><br>$admin_profile17";
echo $foot;
exit;
}
if(preg_match("/[^a-z,A-Z,0-9,\s]/", $custom_field)) {
echo $head;
echo "<b>$admin_profile16</b><br>$admin_profile18";
echo $foot;
exit;
}
if(str_replace(" ", "", $type) == "") {
echo $head;
echo "<b>$admin_profile16</b><br>$admin_profile19";
echo $foot;
exit;
}
$custom = str_replace(" ", "_", $custom_field);
$custom3 = $custom."_3";
$custom2 = $custom."_2";
$custom1 = $custom."_1";
$custom0 = $custom."_0";
if(mysql_num_rows(mysql_query("SHOW COLUMNS FROM bhost_profile FROM `$mysql_database` LIKE '$custom3'")) != 0 | mysql_num_rows(mysql_query("SHOW COLUMNS FROM bhost_profile FROM `$mysql_database` LIKE '$custom2'")) != 0 | mysql_num_rows(mysql_query("SHOW COLUMNS FROM bhost_profile FROM `$mysql_database` LIKE '$custom1'")) != 0 | mysql_num_rows(mysql_query("SHOW COLUMNS FROM bhost_profile FROM `$mysql_database` LIKE '$custom0'")) != 0) {
echo $head;
echo "<b>$admin_profile16</b><br>$admin_profile20";
echo $foot;
exit;
}
if(str_replace(" ", "", $tip) == "") { $tip = ""; }
$tip = str_replace("\n", "<br>", $tip);
$custom_field = str_replace(" ", "_", $custom_field);
$custom_field = $custom_field."_".$required;
mysql_query("ALTER TABLE bhost_profile ADD $custom_field $type NOT NULL");
mysql_query("INSERT INTO bhost_tips (title, tip) VALUES ('$custom_name', '$tip')");
$tip_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_tips WHERE title='$custom_name' AND tip='$tip' ORDER BY tip_id DESC LIMIT 1"));
mysql_query("UPDATE bhost_profile SET $custom_field='$tip_info[tip_id]' WHERE u_id='0'");
header("Location: admin_profile.php");
exit();
}
if($task == "editcustom") {
$cf = $_GET['cf'];
$custom = mysql_fetch_assoc(mysql_query("SHOW COLUMNS FROM bhost_profile FROM `$mysql_database` LIKE '$cf'"));
if($custom[Field] == "p_id" & $custom[Field] == "u_id") { exit(); }
$custom_field = $custom[Field];
$custom_name = str_replace("_", " ", substr($custom[Field], 0, -2));
$custom_required = substr($custom[Field], -2);
$custom_type = $custom[Type];
$tips = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_profile WHERE u_id='0'"));
$tip_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_tips WHERE tip_id='$tips[$custom_field]'"));
echo $head;
echo "
<h2>$admin_profile82</h2>
<form action='admin_profile.php' method='POST'>
<br><br>
$admin_profile6<br>
<input type='text' name='custom_field' maxlength='50' value='$custom_name' DISABLED><br><br>
$admin_profile7<br>
<select name='type' DISABLED>
<option value='varchar(255)'"; if($custom_type == "varchar(255)") { echo " SELECTED"; } echo ">$admin_profile8</option>
<option value='text'"; if($custom_type == "text") { echo " SELECTED"; } echo ">$admin_profile9</option>
</select><br><br>
$admin_profile10<br>
<select name='required' style='width: 200px;'>
<option value='3'"; if($custom_required == "_3") { echo " SELECTED"; } echo ">$admin_profile11</option>
<option value='2'"; if($custom_required == "_2") { echo " SELECTED"; } echo ">$admin_profile12</option>
<option value='1'"; if($custom_required == "_1") { echo " SELECTED"; } echo ">$admin_profile13</option>
<option value='0'"; if($custom_required == "_0") { echo " SELECTED"; } echo ">$admin_profile14</option>
</select><br><br>
$admin_profile80<br>
<textarea name='tip' rows='7' cols='40'>".str_replace("<br>", "\n", $tip_info[tip])."</textarea><br><br>
<input class='button' type='submit' value='$admin_profile83'>
<input type='hidden' name='task' value='doeditcustom'>
<input type='hidden' name='cf' value='$cf'>
</form>
";
echo $foot;
exit();
}
if($task == "doeditcustom") {
$custom = mysql_fetch_assoc(mysql_query("SHOW COLUMNS FROM bhost_profile FROM `$mysql_database` LIKE '$cf'"));
if($custom[Field] == "p_id" & $custom[Field] == "u_id") { exit(); }
$required = $_POST['required'];
$tip = $_POST['tip'];
if(str_replace(" ", "", $tip) == "") { $tip = ""; }
$tip = str_replace("\n", "<br>", $tip);
$tips = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_profile WHERE u_id='0'"));
$custom_field = $custom[Field];
if($required == "3") {
$new_column = substr($custom[Field], 0, -2)."_3";
mysql_query("ALTER TABLE bhost_profile CHANGE $custom[Field] $new_column $custom[Type]");
mysql_query("UPDATE bhost_tips SET tip='$tip' WHERE tip_id='$tips[$custom_field]'") or die(mysql_error());
} elseif($required == "2") {
$new_column = substr($custom[Field], 0, -2)."_2";
mysql_query("ALTER TABLE bhost_profile CHANGE $custom[Field] $new_column $custom[Type]");
mysql_query("UPDATE bhost_tips SET tip='$tip' WHERE tip_id='$tips[$custom_field]'") or die(mysql_error());
} elseif($required == "1") {
$new_column = substr($custom[Field], 0, -2)."_1";
mysql_query("ALTER TABLE bhost_profile CHANGE $custom[Field] $new_column $custom[Type]");
mysql_query("UPDATE bhost_tips SET tip='$tip' WHERE tip_id='$tips[$custom_field]'") or die(mysql_error());
} elseif($required == "0") {
$new_column = substr($custom[Field], 0, -2)."_0";
mysql_query("ALTER TABLE bhost_profile CHANGE $custom[Field] $new_column $custom[Type]");
mysql_query("UPDATE bhost_tips SET tip='$tip' WHERE tip_id='$tips[$custom_field]'") or die(mysql_error());
}
header("Location: admin_profile.php");
exit();
}
if($task == "delete") {
$cf = $_GET['cf'];
if($cf == "p_id" | $cf == "u_id") { exit(); }
if(mysql_num_rows(mysql_query("SHOW COLUMNS FROM bhost_profile FROM `$mysql_database` LIKE '$cf'")) == 0) { exit(); }
$custom_name = str_replace("_", " ", substr($cf, 0, -2));
echo $head;
echo "
<h2>$admin_profile21</h2>
$admin_profile22 \"<b>$custom_name</b>\"?
$admin_profile23
<br><br>
<table cellpadding='0' cellspacing='0'>
<form action='admin_profile.php' method='POST'>
<tr>
<td>
<input class='button' type='submit' value='$admin_profile24'>
</td>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?