Config.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. Lib::loadClass('RouteBase');
  3. Lib::loadClass('UI');
  4. class Route_Config extends RouteBase {
  5. public function handleAuth() {
  6. if (!User::logged()) throw new HttpException('Unauthorized', 401);
  7. }
  8. public function defaultAction() {
  9. UI::gora();
  10. UI::startContainer();
  11. echo UI::h('h1', null, "Config");
  12. echo '...';
  13. // echo UI::h('div', [], [
  14. // UI::h('a', ['style'=>"display:block", 'href'=>$this->getLink('reinstall')], "Config.reinstall"),
  15. // UI::h('a', ['style'=>"display:block", 'href'=>Router::getRoute('Biall_ProduktToDolar')->getLink('reinstall')], "Biall_ProduktToDolar.reinstall"),
  16. // ]);
  17. UI::endContainer();
  18. UI::dol();
  19. }
  20. public function reinstallAction() {
  21. UI::gora();
  22. echo UI::h('a', ['style'=>"margin:8px 20px", 'class'=>"btn btn-xs btn-default", 'href'=>$this->getLink()], "wróć");
  23. $this->reinstall();
  24. UI::alert('info', 'OK');
  25. UI::dol();
  26. }
  27. public function runAction() {
  28. $msgId = V::get('_msgId', 0, $_REQUEST, 'int');
  29. if ($msgId > 0) {
  30. $this->runByMessageId($msgId);
  31. }
  32. $jsonData = new stdClass();
  33. $jsonData->type = 'success';
  34. $jsonData->msg = 'Gotowe';
  35. echo json_encode($jsonData);
  36. exit;
  37. }
  38. public function reinstall() {
  39. $sqlList = array();
  40. //$sqlList['RemoveTable'] = "DROP TABLE IF EXISTS `CRM_CONFIG`";
  41. $sqlList['InstallTable'] = "
  42. CREATE TABLE IF NOT EXISTS `CRM_CONFIG` (
  43. `ID` int(11) NOT NULL AUTO_INCREMENT,
  44. `CONF_KEY` varchar(64) NOT NULL,
  45. `CONF_VAL` text NOT NULL,
  46. PRIMARY KEY (`ID`),
  47. UNIQUE KEY `CONF_KEY` (`CONF_KEY`)
  48. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  49. ";
  50. foreach ($sqlList as $sqlName => $sql) {
  51. DB::getPDO()->execSql($sql);
  52. }
  53. }
  54. }