function processAdminCommand($cmd, $pageID) { global $modulesMgr, $structureMgr, $authenticationMgr, $permissionsMgr, $cacheMgr, $templatesMgr; $res = ""; $userGroupID = $authenticationMgr->getUserGroup(); switch ($cmd) { case "editPage": $res .= navi($pageID, false); $res .= editPage($pageID); break; case "editDict": $res .= editDict(); break; case "addDictValue": $res .= addDictValue(); break; case "updateDictValues": $res .= updateDictValues(); break; case "delDictValue": $res .= delDictValue(); break; case "updatePage": updatePage(); break; //we always exit in prev. function case "delPage": if ($userGroupID == 5) { delPage(_get("pageID")); } break; //we always exit in prev. function case "addPage": $res .= navi(_get("pageID"), true); $res .= editPage(-1); break; case "updChildren": //first we should handle group movements $cmds = _postByPattern("/cmd\\d+/"); $cmdsFound = false; if (count($cmds) > 0) { foreach ($cmds as $cmdkey => $curcmd) { if ($curcmd) { $cmdsFound = true; switch ($curcmd) { case "movePages": if ($userGroupID == 5) { movePages($pageID); } break; case "moveToTheTop": if ($userGroupID == 5) { moveToTheTop($pageID); } break; case "moveToTheBottom": if ($userGroupID == 5) { moveToTheBottom($pageID); } break; case "delPages": if ($userGroupID == 5) { delPages($pageID); } break; } break; } } } if (!$cmdsFound) { //no cmds found, just update children updateChildren(); } break; case "modparams": global $modulesMgr; $ms = $modulesMgr->modules(); $dicts = array(); foreach ($ms as $mname => $m) { $d = GetCfg($mname . ".dictionaries"); if ($d) { $dicts[$mname] = $d; } } $res .= "<h4>Справочники</h4>"; foreach ($dicts as $mname => $dict) { $res .= GetCfg($mname . ".ModuleName") . ": "; $r1 = ""; foreach ($dict as $dname => $d) { if ($r1) { $r1 .= ", "; } $r1 .= "<a href=/admin/?cmd=editDict&moduleName={$mname}&dict={$dname}>{$d['0']}</a>"; } $res .= "{$r1}<br>\n"; } break; case "cards": $act = _get('act'); $cardAdmin = new CardsAdminHandler(); if (isset($act) && $act != '') { $res .= $cardAdmin->handleRequest($act); } else { $res .= $cardAdmin->getList(); } break; case "users": $handler = new UsersAdminHandler(); $res .= $handler->getContent(); if ($handler->location != '') { header('Location: ' . $handler->location); } break; case "mails": $handler = new MailsAdminHandler(); $act = _get('act'); if ($act == "send") { $handler->sendToMail(); } else { $res .= $handler->getContent(); } break; case "banner": $handler = new BannerAdminHandler(); $act = _get('act'); $banID = _get('banID'); switch ($act) { case "save": $handler->saveBanner(); break; case "delete": $handler->deleteBanner($banID); break; default: $res .= $handler->getContent($banID); break; } break; case "vote": $handler = new VoteAdminHandler(); $act = _get('act'); $qID = _get('qID'); switch ($act) { case "save": $handler->saveVote(); break; case "delete": $handler->deleteVote($qID); break; default: $res .= $handler->getContent($qID); break; } break; case "actCar": $pms_sID = _get('pms_sID'); $ModuleName = _get('ModuleName'); $DataType = _get('DataType'); $refCmd = _get('refCmd'); $cmd = _get('cmd'); $act = _get('act'); switch ($act) { case 'del': $carID = _get('carID'); delCar($carID, $pms_sID, $ModuleName, $DataType, $refCmd); break; case 'add': $carName = _get('carName'); addCar($carName, $pms_sID, $ModuleName, $DataType, $refCmd); break; } break; default: $res .= navi($pageID, false); $res .= "Unknown command: {$cmd}<br><br>\n"; } return $res; }
} $car_plate = $color = $car_plate_error = $color_error = $saved = ""; //salvestamine if (isset($_POST["create"])) { if (empty($_POST["car_plate"])) { $car_plate_error = "See väli on kohustuslik"; } else { $car_plate = cleanInput($_POST["car_plate"]); } if (empty($_POST["color"])) { $color_error = "See väli on kohustuslik"; } else { $color = cleanInput($_POST["color"]); } if ($color_error == "" && $car_plate_error == "") { addCar($car_plate, $color); $saved = "Salvestatud andmebaasi"; } } function cleanInput($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <p> Tere, <?php echo $_SESSION["user_email"];