| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- Lib::loadClass('RouteBase');
- class Route_Config extends RouteBase {
- public function handleAuth() {
- if (!User::logged()) {
- throw new HttpException('Unauthorized', 401);
- }
- }
- public function defaultAction() {
- SE_Layout::gora();
- ?>
- <div class="container">
- <h1>Config</h1>
- ...
- </div>
- <?php
- SE_Layout::dol();
- }
- public function reinstallAction() {
- $this->reinstall();
- die('OK');
- }
- public function runAction() {
- $msgId = V::get('_msgId', 0, $_REQUEST, 'int');
- if ($msgId > 0) {
- $this->runByMessageId($msgId);
- }
- $jsonData = new stdClass();
- $jsonData->type = 'success';
- $jsonData->msg = 'Gotowe';
- echo json_encode($jsonData);
- exit;
- }
- public function reinstall() {
- $sqlList = array();
- //$sqlList['RemoveTable'] = "DROP TABLE IF EXISTS `CRM_CONFIG`";
- $sqlList['InstallTable'] = <<<SQL
- CREATE TABLE IF NOT EXISTS `CRM_CONFIG` (
- `ID` int(11) NOT NULL AUTO_INCREMENT,
- `CONF_KEY` varchar(64) NOT NULL,
- `CONF_VAL` text NOT NULL,
- PRIMARY KEY (`ID`),
- UNIQUE KEY `CONF_KEY` (`CONF_KEY`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
- SQL;
- $db = DB::getDB();
- if ($db->has_errors()) {
- throw new Exception("DB Errors: " . implode("\n<br>", $db->get_errors()));
- }
- foreach ($sqlList as $sqlName => $sql) {
- $res = $db->query($sql);
- if ($db->has_errors()) {
- throw new Exception("DB Errors at sql '{$sqlName}': " . implode("\n<br>", $db->get_errors()));
- }
- }
- }
- }
|