Example #1
0
    /**
     * class constructor
     *
     * @param string
     */
    public function __construct($title = '', $skipAuth = false)
    {
        parent::__construct($title);
        $config = new Config();
        $this->_skipAuth = $skipAuth;
        if (!$skipAuth) {
            $auth = new Auth();
            $this->_auth = $auth;
        }
        // Only allow reset to authenticated users and only if the config allows it.
        $this->_resetOk = $config->getResetOk() && ($skipAuth || $auth->isAuthorized());
        $header = <<<HTML
  <link rel="stylesheet" href="css/main.css" />
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <script>
    \$( function() {
      \$( ".datepicker" ).datepicker( { dateFormat: 'yy-mm-dd' } );
    } ) ;
  </script>
  <script src="js/common.js"></script>
  <script src="js/ajaxApplicationStatus.js"></script>
  <script src="js/ajaxCompany.js"></script>
  <script src="js/ajaxContact.js"></script>
  <script src="js/oldValidation.js"></script>

HTML;
        $this->setHead($header);
        $this->setMeta(array("Cache-Control: no-cache, must-revalidate", "Expires: Sat, 26 Oct 2013 05:00:00 GMT", 'Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'));
        $this->setStyles('');
        $this->setTop($this->_getTop());
        $this->setBottom('<!-- EndOfPage -->');
        if (!$skipAuth && !$auth->isAuthorized()) {
            $this->setBody($auth->getLoginPage());
            $this->displayPage();
            exit;
        }
    }
Example #2
0
// Be sure to specify these in apply order. The reset script will automatically
// reverse the order for safe removal.
$controllerNames = array('VersionController', 'AuthTicketController', 'ApplicationStatusController', 'ApplicationStatusSummaryController', 'CompanyController', 'ContactController', 'JobController', 'KeywordController', 'NoteController', 'SearchController', 'JobKeywordMapController');
$controllers = array();
try {
    $config = new Config();
    $page = new PJSWebPage($config->getTitle() . " - Reset DB", true);
    $body = "<ul>\n";
    $dbc = new DBConnection("admin", null, null, null, null, null, 'mysqli', true);
    if (!$dbc->getCreatedDb()) {
        // Database exists. Don't allow reset if the user is not logged in.
        $auth = new Auth();
        if (!$auth->isAuthorized()) {
            throw new Exception("User must be logged in to reset the database!");
        }
        if ("1" !== $config->getResetOk()) {
            throw new Exception("Reset capability is turned off! See config.xml");
        }
    }
    $dbh = $dbc->getConnection();
    foreach (array_reverse($controllerNames) as $controllerName) {
        $controller = new $controllerName('write');
        $controllers[$controllerName] = $controller;
        if (method_exists($controller, 'dropTriggers')) {
            $body .= "<li>Dropping Triggers: {$controllerName}</li>\n";
            $controller->dropTriggers();
        }
    }
    foreach ($controllers as $controllerName => $controller) {
        $body .= "<li>Dropping Tables: {$controllerName}</li>\n";
        $controller->dropTable();