-
Notifications
You must be signed in to change notification settings - Fork 3
/
admin.dbsave.php
27 lines (23 loc) · 1018 Bytes
/
admin.dbsave.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
include "inc.default.php"; // should be included in EVERY file
$oSecurity = new security(TRUE);
if (!$oSecurity->admin()) stop("admin");
$oDB = new database();
$arFields = array();
foreach ($_POST as $strKey=>$strVal) {
$arKey = explode("_", $strKey);
if (count($arKey)==3){
echo ("$(\"#" . $strKey . "\").removeClass(\"saving\").removeClass(\"changed\").attr(\"orig\", $(\"#" . $strKey . "\").find(\":input\").val()); $(\"#" . $strKey . "\").find(\":input\").remove();\n");
if (!isset($arFields[$arKey[0]])) $arFields[$arKey[0]] = array();
if (!isset($arFields[$arKey[0]][$arKey[1]])) $arFields[$arKey[0]][$arKey[1]] = array();
$arFields[$arKey[0]][$arKey[1]][] = $arKey[2] . " = '" . $oDB->escape($strVal) . "'";
}
}
foreach ($arFields as $strTable=>$arRecords) {
foreach ($arRecords as $iID=>$arFields) {
$strSQL = "update " . $strTable . " set " . implode(",", $arFields) . " where id = " . $iID . ";";
$oDB->sql($strSQL);
$oDB->execute();
}
}
?>