【php开源代码栏目提醒】:网学会员为广大网友收集整理了,uploadadmin.php,希望对大家有所帮助!
<?php if ($index_refer <> 1) { exit; } ?>
<?php include ("checklogin.php"); ?>
<?php
// function to read mysql dump
function parse_mysql_dump($url, $ignoreerrors = false) {
$file_content = file($url);
//print_r($file_content);
$query = "";
foreach($file_content as $sql_line) {
$tsl = trim($sql_line);
if (($sql_line != "") && (substr($tsl, 0, 2) != "--") && (substr($tsl, 0, 1) != "#")) {
$query .= $sql_line;
if(preg_match("/;\s*$/", $sql_line)) {
$result = mysql_query($query);
if (!$result && !$ignoreerrors) die(mysql_error());
$query = "";
}
}
}
}
// admin check
if (IsAdmin() == false) {
PutWindow ($txt['general1'], $txt['general2'], "warning.gif", "50");
exit;
}
echo "<div align=center>[<a href=index.php?page=admin>".$txt['general4']."</a>]</div><br><br>";
// ok, let's do the updating/deleting/moving here
// upload a screenshot for the category
if ($action == "upload_pricelist") {
$target_path = $brands_dir."/";
$target_path = $target_path."pricelist.sql";
if (strtoupper(substr($_FILES['uploadedfile']['name'], -3)) == "SQL") {
// delete previous pricelist if it exists
if (file_exists($target_path)) {
unlink($target_path);
}
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo basename( $_FILES['uploadedfile']['name']).$txt['uploadadmin1'].$target_path."<br>";
// now read the temp file and put it's values into the database
parse_mysql_dump($target_path, TRUE);
unlink($target_path);
echo "<br><b>dump added to database..</b><br><br>";
}
else{
echo $txt['uploadadmin2'];
}
}
else { echo $txt['uploadadmin3']; }
exit;
}
echo "<table width=100% border=0 bgcolor=".$tb_bordercolor." cellpadding=2 cellspacing=1>";
echo "<tr><td align=left bgcolor=".$tb_title_bgcolor.">";
echo " <img src=".$gfx_dir."/arrow.gif border=0 align=absmiddle>";
echo " <font color=".$tb_title_textcolor."><b>".$txt['uploadadmin4']."</b>";
echo "</td></tr>";
echo "<tr><td bgcolor=".$tb_cell_bgcolor." align=left>";
echo "<form enctype=multipart/form-data action=index.php?page=uploadadmin method=POST>";
echo "<input type=hidden name=action value=upload_pricelist>";
//echo "<input type=hidden name=MAX_FILE_SIZE value=500000>";
echo $txt['uploadadmin5']." <input name=uploadedfile type=file><br>";
echo "<input type=submit value=\"".$txt['uploadadmin6']."\">";
echo "</form>";
echo "</td></tr></table>";
?>
上一篇:
upload.php
下一篇:
西班牙语医院科室名称