📄 sqladmin.php
字号:
// , the guy wants to download a ing image
if ($_POST[$key . "_upload_web"] != "http://") {
//i have to be very carefully here, if the image is not a valid link, then
//everithing get messed.
$image = @GetFileContents($_POST[$key . "_upload_web"]);
$name = $_POST[$key . "_temp"] != "" ? $_POST[$key . "_temp"] : $val["file"]["default"] . time() . $val["file"]["ext"];
SaveFileContents( $_CONF["path"] . $_CONF["upload"] . "tmp/" . $name , $image);
chmod ($_CONF["path"] . $_CONF["upload"] . "tmp/" . $name , 0777);
// generate the tn image
if ($val["tn"]["generate"] == "true") {
@$base->image->Resize(
$_CONF["path"] . $_CONF["upload"] . "tmp/" . $name ,
$_CONF["path"] . $_CONF["upload"] . "tmp/" . $val["tn"]["preffix"] . $name ,
$val["tn"]["width"]
);
$_POST["tn_" . $key] = "1";
}
//setting the temp variable
$_fields["values"][$key . "_temp"] = $name;
$_POST[$key . "_temp"] = $name;
$_POST[$key . "_file"] = basename($_POST[$key . "_upload_web"]);
$_POST[$key] = "1";
}
break;
case "-1":
// echo "<pre style=\"background-color:white\">";
// print_r($_POST);
// die;
//trying to remove the tmp image is exists
if (file_exists($_CONF["path"] . $_CONF["upload"] . "tmp/" . $_POST[$key . "_temp"]) && is_file($_CONF["path"] . $_CONF["upload"] . "tmp/" . $_POST[$key . "_temp"]))
@unlink($_CONF["path"] . $_CONF["upload"] . "tmp/" . $_POST[$key . "_temp"]);
//removing the original image too if exists
else
@unlink($_CONF["path"] . $_CONF["upload"] . $val["path"] . $val["file"]["default"] . $_POST[$val["file"]["field"]] . $val["file"]["ext"]);
$_fields["values"][$key . "_radio_type"] = 0;
$_POST[$key] = 0;
$_fields["values"][$key . "_temp"] = "";
$_POST[$key . "_temp"] = "";
$_POST[$key . "_file"] = "";
break;
}
//hm ... checking if that IS A REAL IMAGE
if ($_POST[$key . "_temp"] && !$file) {
$img = @GetImageSize($_CONF["path"] . $_CONF["upload"] . "tmp/" . $_POST[$key . "_temp"]);
if (!is_array($img)) {
//removing the image, maybe in future return the er a proper answer
//echo "MOHHHHH";
@unlink($_CONF["path"] . $_CONF["upload"] . "tmp/" . $_POST[$key . "_temp"]);
$_POST[$key . "_temp"] = "";
$_POST[$key] = 0;
}
}
break;
}
}
}
if (!is_array($fields = $this->form->Validate($this->forms["forms"][$_GET["type"]] , $_POST))) {
//adding to database
if (!$_POST[$this->forms["forms"]["add"]["table_uid"]]) {
$id = $this->db->QueryInsert($this->tables[$this->forms["forms"]["add"]["table"]] , $_POST);
$_POST[$this->forms["forms"]["add"]["table_uid"]] = $id;
} else {
$this->db->QueryUpdate($this->tables[$this->forms["forms"]["edit"]["table"]] , $_POST , "`" . $this->forms["forms"]["edit"]["table_uid"] . "`='" . $_POST[$this->forms["forms"]["edit"]["table_uid"]] . "'" );
$id = $_POST[$this->forms["forms"]["edit"]["table_uid"]];
}
//data stored, taking care of uploade files/images, etc
if (is_array($form["fields"])) {
foreach ($form["fields"] as $key => $val) {
switch ($val["type"]) {
case "upload":
case "image":
//checking if is really e file, else if no tmp is set then it can be the folder where are stored the values
if (is_file($_CONF["path"] . $_CONF["upload"] . "tmp/" . $_POST[$key . "_temp"])) {
//moving the image stored in temp variable
rename(
$_CONF["path"] . $_CONF["upload"] . "tmp/" . $_POST[$key . "_temp"] ,
$_CONF["path"] . $_CONF["upload"] . $val["path"] . $val["file"]["default"] . $_POST[$val["file"]["field"]] . $val["file"]["ext"]
);
// generate the tn image
if ($val["tn"]["generate"] == "true") {
rename(
$_CONF["path"] . $_CONF["upload"] . "tmp/" . $val["tn"]["preffix"] . $_POST[$key . "_temp"] ,
$_CONF["path"] . $_CONF["upload"] . $val["path"] . $val["tn"]["preffix"] . $val["file"]["default"] . $_POST[$val["file"]["field"]] . $val["file"]["ext"]
);
}
//setting the image as true
$_POST[$key] = 1;
//updateing the database
$this->db->QueryUpdate($this->tables[$this->forms["forms"]["edit"]["table"]] , $_POST , "`" . $this->forms["forms"]["edit"]["table_uid"] . "`='" . $_POST[$this->forms["forms"]["edit"]["table_uid"]] . "'" );
}
break;
default:
if (is_array($val["file"]))
SaveFileContents($_CONF["path"] . $_CONF["upload"] . $val["file"]["path"] . $val["file"]["default"] . $_POST[$val["file"]["field"]] . $val["file"]["ext"] , $_POST[$key] );
break;
}
}
}
if (!$_GET["type"]) {
$_GET["type"] = $_POST[$this->forms["forms"]["table_uid"]] ? "edit" : "add";
}
$this->templates["generic_form"]->blocks["Temp"]->input = $this->forms["forms"][$_GET["type"]]["redirect"];
//replacing the values
//die($this->templates["generic_form"]->blocks["Temp"]->Replace($_POST));
if ($redirect == true) {
header("Location: " . CryptLink($this->templates["generic_form"]->blocks["Temp"]->Replace(array_merge($_GET,$_POST))));
exit;
} else {
return true;
}
}
} else {
die("ARGH!!!");
//redirecting to list page
header("Location:" . str_replace("&action=store" , "" , $_SERVER["REQUEST_URI"]));
exit;
}
if (is_array($_fields["values"]))
$fields["values"] = array_merge($fields["values"], $_fields["values"]);
return $this->form->Show($this->forms["forms"][$_GET["type"]] , $fields);
}
/**
* description
*
* @param
*
* @return
*
* @access
*/
function RestoreURI($section) {
if (is_array($_GET)) {
foreach ($_GET as $key => $val) {
$out[$key] = $key . "=" . $val;
}
$out[$this->forms["uridata"]["action"]] = $this->forms["uridata"]["action"] . "=" . $this->forms["uridata"][$section];
unset($out[$this->forms["table_uid"]]);
return CryptLink($_SERVER["SCRIPT_NAME"] . "?" . implode("&" , $out));
//return $_
}
}
/**
* description
*
* @param
*
* @return
*
* @access
*/
function DoEvents($section = "" , $extra = "" , $values = "") {
global $base , $_CONF;
if (is_array($extra)) {
$this->extra = array_merge($this->extra , $extra);
}
switch ($_GET[$this->forms["uridata"]["action"]]) {
case $this->forms["uridata"]["delete"]:
//searching for element
$data = $this->db->QFetchArray("SELECT * FROM `" . $this->tables[$this->forms["forms"]["edit"]["table"]] . "` WHERE `" . $this->forms["forms"]["edit"]["table_uid"] . "`='" . $_GET[$this->forms["forms"]["edit"]["table_uid"]] . "'" );
//checking if this is a valid data
if (is_array($data)) {
$this->db->Query("DELETE FROM `" . $this->tables[$this->forms["forms"]["edit"]["table"]] . "` WHERE `" . $this->forms["forms"]["edit"]["table_uid"] . "`='" . $_GET[$this->forms["forms"]["edit"]["table_uid"]] . "'" );
}
header("Location:" . $_SERVER["HTTP_REFERER"]/*$this->RestoreURI("list")*/);
exit;
break;
case $this->forms["uridata"]["store"]:
return $this->StoreRecord();
break;
case $this->forms["uridata"]["add"]:
return $this->form->Show($this->forms["forms"]["add"] , $fields , $this->extra["add"]);
break;
case $this->forms["uridata"]["edit"]:
//searching for element
$data = $values["edit"] ? $values["edit"] : $this->db->QFetchArray("SELECT * FROM `" . $this->tables[$this->forms["forms"]["edit"]["table"]] . "` WHERE `" . $this->forms["forms"]["edit"]["table_uid"] . "`='" . $_GET[$this->forms["forms"]["edit"]["table_uid"]] . "'" );
//checking if this is a valid data
if (is_array($data)) {
$fields["values"] = $data;
return $this->form->Show($this->forms["forms"]["edit"] , $fields , $this->extra["edit"]);
}
header("Location:" . $this->RestoreURI("list"));
exit;
break;
case $this->forms["uridata"]["details"]:
//searching for element
$data = $this->db->QFetchArray("SELECT * FROM `" . $this->tables[$this->forms["forms"]["edit"]["table"]] . "` WHERE `" . $this->forms["forms"]["edit"]["table_uid"] . "`='" . $_GET[$this->forms["forms"]["edit"]["table_uid"]] . "'" );
//checking if this is a valid data
if (is_array($data)) {
$fields["values"] = $data;
return $this->form->Show($this->forms["forms"]["details"] , $fields, $this->extra["details"]);
}
header("Location:" . $this->RestoreURI("list"));
exit;
break;
case $this->forms["uridata"]["search"]:
case $this->forms["uridata"]["list"]:
default:
return $this->FormList($values["list"]);
break;
}
}
}
/*
History
*/
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -