public function index()
    {
        $schedulerList = Scheduler::getList(true);
        $formName = 'SchedulerManager_index';
        $id = 'SchedulerManager_table';
        $js = "\$().ready ( function () {\n";
        $valid = Validator::factory($formName);
        $html = Tag::table(['id' => $id]) . Tag::tr() . Tag::th() . 'Upd' . Tag::_th() . Tag::th() . 'Del' . Tag::_th() . Tag::th() . 'Command' . Tag::_th() . Tag::th() . 'Start Date' . Tag::_th() . Tag::th() . 'Cron' . Tag::_th() . Tag::th() . 'Active' . Tag::_th() . Tag::th() . 'Last Run' . Tag::_th() . Tag::_tr();
        if (count($schedulerList) == 0) {
            $html .= Tag::tr() . Tag::td(['colspan' => 20]) . 'No Scheduled Tasks' . Tag::_td() . Tag::_tr();
        } else {
            $js .= <<<JS
                \$('input[type=checkbox][name^=fldUpd]').shiftClick();

JS;
            $rowIdx = 0;
            foreach ($schedulerList as $idx => $schedulerItem) {
                $row = '_' . $idx;
                $valid->addExists('fldCommand' . $row, 'Command must exist')->addExists('fldCron' . $row, 'Interval must exist');
                $js .= <<<JS
                    \$( '#fldStartDate{$row}' ).datetimepicker({
                        dateFormat: 'yy-mm-dd',
                        timeFormat: 'HH:mm'
                    });
JS;
                $lastRun = $schedulerItem->lastRun == '' ? '*Never*' : $schedulerItem->lastRun;
                $html .= Tag::tr() . Tag::td() . Tag::checkBox('fldUpd[]', $idx, false, ['id' => 'U' . $rowIdx]) . Tag::_td() . Tag::td() . Tag::linkButton('?' . Response::factory()->set('fldID', $idx)->action(__CLASS__ . '->deleteItem()'), 'Delete', ['onClick' => "confirm('Are you sure?')"]) . Tag::_td() . Tag::td(['width' => '100%', 'nowrap' => 'nowrap']) . Tag::text('fldCommand' . $row, $schedulerItem->cmd, ['style' => 'width:100%;', 'onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . Tag::text('fldStartDate' . $row, $schedulerItem->start, ['id' => 'fldStartDate' . $row, 'size' => '18', 'onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . Tag::text('fldCron' . $row, $schedulerItem->cron, ['onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . Lists::select('fldActive' . $row, ['Yes', 'No'], ['default' => $schedulerItem->active, 'onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . $lastRun . Tag::_td() . Tag::_tr();
                $rowIdx++;
            }
        }
        $html .= Tag::_table();
        $js .= '});';
        return JS::libraryWithDependancies(JS::JQUERY_UI_DATETIME) . JS::library('jquery.shiftclick.js') . JS::javaScript($js) . $valid->toHtml() . Widget::styleTable('#' . $id) . Tag::form(['name' => $formName, 'onSubmit' => $valid->onSubmit()]) . $html . Response::factory()->action(__CLASS__ . '->save()')->toHidden() . Tag::submit('Save') . Tag::linkButton('?' . Response::factory()->action(__CLASS__ . '->newItem()'), 'New Item') . Tag::_form();
    }
Beispiel #2
0
    public function recentAlarms()
    {
        $sql = <<<SQL
            SELECT *
            FROM tblModJackAlert
            WHERE fldStatus='new'
            ORDER BY fldTimeStamp
            LIMIT 50
SQL;
        $html = '<h2>Recent Alerts</h2>';
        $tab = new DBTable(DB::DEF, $sql, null, DB::FETCH_ASSOC);
        if ($tab->isEmpty()) {
            $html .= "There are no alerts at the moment";
        } else {
            $html .= Tag::table() . Tag::tr() . Tag::th() . 'Type' . Tag::_th() . Tag::th() . 'Description' . Tag::_th() . Tag::th() . 'Time' . Tag::_th() . Tag::th() . 'Actions' . Tag::_th() . Tag::_tr();
            $resp = MenuUtils::responseObject()->action(__CLASS__ . '->recentAlarmsAck()');
            foreach ($tab as $row) {
                $style = ['class' => $row['fldType'] . '_row'];
                $html .= Tag::tr($style) . Tag::td($style) . Tag::e($row['fldType']) . Tag::_td() . Tag::td($style) . Tag::e($row['fldDescription']) . Tag::_td() . Tag::td($style) . Tag::e($row['fldTimeStamp']) . Tag::_td() . Tag::td($style) . Tag::linkButton('?' . $resp->set('fldModJackAlertID', $row['fldModJackAlertID'])->toUrl(), 'Ack') . Tag::_td() . Tag::_tr();
            }
            $html .= Tag::_table();
        }
        return $html;
    }
Beispiel #3
0
 public function index()
 {
     if (!$this->ok) {
         return 'Invalid table: ' . $this->tableName;
     }
     $html = $this->controller();
     $paginationHtml = $this->paginator->toHtml();
     $html .= Tag::form(['action' => $this->formAction, 'onSubmit' => "if (!checkIfADelete('{$this->delTag}')) return false; return true;"]) . Tag::table(array_merge(['id' => 'CRUD' . $this->suffix], $this->styles[self::TABLE_C])) . Tag::tr();
     if ($this->canDelete) {
         $js = "\$().ready(function() { \$('input[type=checkbox][name^={$this->delTag}]').shiftClick(); });";
         $html .= JS::library('jquery.shiftclick.js') . JS::javaScript($js) . Tag::th() . Tag::hTag('span', ['title' => 'Click here to Toggle all the Delete checkboxes']) . 'D' . Tag::_hTag('span') . Tag::br() . Tag::checkBox('_dcheck', 'Y', false, ['onClick' => "toggleAll(this,'{$this->delTag}','{$this->submitId}')", 'title' => 'Toggle all the Delete checkboxes.']) . Tag::_th();
     }
     if ($this->canUpdate) {
         $js = "\$().ready(function() { \$('input[type=checkbox][name^={$this->updTag}]').shiftClick(); });";
         $html .= JS::library('jquery.shiftclick.js') . JS::javaScript($js) . Tag::th() . Tag::hTag('span', ['title' => 'Click here to Toggle all the Update checkboxes']) . 'U' . Tag::_hTag('span') . Tag::br() . Tag::checkBox('_ucheck', 'Y', false, ['onClick' => "toggleAll(this,'{$this->updTag}','{$this->submitId}')", 'title' => 'Toggle all the Update checkboxes.']) . Tag::_th();
     }
     foreach ($this->columnTitles as $colName => $title) {
         if (isset($this->displayType[$colName])) {
             if (is_string($this->displayType[$colName])) {
                 $type = $this->displayType[$colName];
             } else {
                 $type = $this->displayType[$colName][0];
             }
         } else {
             $type = self::DISPLAY;
         }
         if (!in_array($type, [self::HIDDEN, self::NONE])) {
             $html .= Tag::th() . $this->columnator->toHtml($colName, $title) . Tag::_th();
         }
     }
     foreach ($this->extraCols as $title => $col) {
         $html .= Tag::th();
         if (isset($this->columnTitles[$title])) {
             $html .= $this->columnator->toHtml($title, $this->columnTitles[$title]);
         } else {
             $html .= $title;
         }
         $html .= Tag::_th();
     }
     $html .= Tag::_tr() . "\n";
     $tab = $this->createSQLResult();
     $this->calculateColumnWidths($tab);
     foreach ($tab as $idx => $row) {
         $html .= Tag::tr();
         if ($this->canDelete) {
             $html .= Tag::td(['align' => 'center']) . Tag::checkBox("{$this->delTag}[{$idx}]", $row[$this->primaryKey], false, ['id' => "{$this->delTag}_{$idx}", 'onClick' => "showSubmit('{$this->submitId}')", 'title' => 'Toggle to delete this row.']) . Tag::_td();
         }
         if ($this->canUpdate) {
             $html .= Tag::td(['align' => 'center']) . Tag::checkBox("{$this->updTag}[{$idx}]", $row[$this->primaryKey], false, ['id' => "{$this->updTag}_{$idx}", 'onClick' => "showSubmit('{$this->submitId}')", 'title' => 'Toggle to update this row.']) . Tag::_td();
         }
         foreach ($row as $key => $value) {
             $html .= $this->renderValue($idx, $key, $value);
         }
         foreach ($this->extraCols as $col) {
             $html .= Tag::td() . call_user_func_array($col, [$idx, $row[$this->primaryKey]]) . Tag::_td();
         }
         $html .= Tag::_tr() . "\n";
     }
     $this->resp->set($this->action, 'applyChanges');
     $html .= Tag::_table() . $this->resp->toHidden() . Tag::submit('Apply Changes', ['style' => 'display: none', 'id' => $this->submitId, 'title' => 'Click here to apply the changes to this table']) . Tag::_form();
     return self::header() . Widget::styleTable('#CRUD' . $this->suffix) . ($this->topPage ? $paginationHtml : '') . $html . ($this->bottomPage ? $paginationHtml : '') . $this->insertForm();
 }
Beispiel #4
0
    public function editAccount()
    {
        $resp = new Response();
        $uid = G::get('fldUserID');
        $html = '';
        $props = [];
        $jsUrl = Cfg::get('js_url');
        $jQuery = <<<JS
            \$().ready(function() {
                \$('a.facebox').facebox({closeImage:   '{$jsUrl}/images/closelabel.png',
                                        loadingImage: '{$jsUrl}/images/loading.gif'

                });
            });
JS;
        $userSql = DB::driver() == DB::MYSQL ? self::USER_SQL_MYSQL : self::USER_SQL_SQLITE;
        if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) {
            $uid = Request::get('fldUserID', G::get('fldUserID'));
            $props['where'] = ['fldUserID' => G::get('fldUserID')];
            $html .= Tag::form() . $resp->action(sprintf('%s->%s()', __CLASS__, __FUNCTION__))->toHidden() . Tag::table() . Tag::tr() . Tag::th() . 'User to edit' . Tag::_th() . Tag::td() . Lists::select('fldUserID', $userSql, ['onChange' => 'submit()', 'default' => $uid]) . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
        }
        $formName = 'Admin_editAccount';
        $valid = Validator::factory($formName)->addEqual('fldPassword', 'fldPassword_CHK', 'Your passwords do not match')->addLength('fldPassword', 'Password must be at least 6 characters', 6, null, true)->addExists('fldFirstName', 'You must enter your first name')->addExists('fldLastName', 'You must enter your last name');
        $row = DB::oneRow(DB::DEF, 'SELECT * FROM tblUser WHERE fldUserID=?', $uid);
        $html .= '<h2>Edit User Account</h2>' . $valid->toHtml() . Tag::form(['name' => $formName, 'onSubmit' => $valid->onSubmit()]) . $resp->action(sprintf('%s->%sSave()', __CLASS__, __FUNCTION__))->set('fldUserID', $uid)->toHidden() . Tag::table();
        $html .= Tag::tr() . Tag::td() . Tag::table() . Tag::tr() . Tag::td() . 'User Name/Email' . Tag::_td() . Tag::td() . Tag::text('fldUser', $row['fldUser']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Old Password' . Tag::_td() . Tag::td() . Tag::password('fldPassword_OLD') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Password' . Tag::_td() . Tag::td() . Tag::password('fldPassword') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Confirm Password' . Tag::_td() . Tag::td() . Tag::password('fldPassword_CHK') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Title' . Tag::_td() . Tag::td() . Tag::text('fldSalutation', $row['fldSalutation']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'First Name' . Tag::_td() . Tag::td() . Tag::text('fldFirstName', $row['fldFirstName']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Last Name' . Tag::_td() . Tag::td() . Tag::text('fldLastName', $row['fldLastName']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Time Zone' . Tag::_td() . Tag::td() . Lists::select('fldTimeZone', self::TZ_SQL, ['default' => $row['fldTimeZone']]) . Tag::_td() . Tag::_tr();
        if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) {
            $html .= Tag::tr() . Tag::td() . 'Security Level' . Tag::_td() . Tag::td() . Lists::select('fldLevel', self::LEVEL_SQL, ['default' => $row['fldLevel']]) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Login Fails' . Tag::_td() . Tag::td() . Tag::text('fldFails', $row['fldFails']) . Tag::_td() . Tag::_tr();
        } else {
            $html .= Tag::tr() . Tag::td() . 'Security Level' . Tag::_td() . Tag::td() . Privileges::getSecurityLevel($row['fldLevel']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Login Fails' . Tag::_td() . Tag::td() . $row['fldFails'] . Tag::_td() . Tag::_tr();
        }
        $html .= Tag::tr() . Tag::td(['colspan' => 2]) . Tag::submit('Save') . Tag::_td() . Tag::_tr();
        if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) {
            $html .= Tag::tr() . Tag::td(['colspan' => 2]) . Tag::hRef('ajax.php?' . $resp->action(__CLASS__ . '->newUser()')->toUrl(), 'Create New User', ['class' => 'facebox']) . Tag::_td() . Tag::_tr();
        }
        $html .= Tag::_table() . Tag::_td() . Tag::td(['valign' => 'top', 'align' => 'center']) . Tag::table() . Tag::tr() . Tag::td(['valign' => 'top', 'align' => 'center']) . Gravatar::icon($row['fldUser'], 128) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . Tag::linkButton(Gravatar::getURL(), 'Change Picture', ['target' => '_blank', 'title' => 'your gravatar is associated with your email address ' . $row['fldUser'] . ' (up to 24 hrs to change)']) . Tag::_td() . Tag::_tr();
        if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN')) && $uid != G::get('fldUserID')) {
            $name = $row['fldFirstName'] . ' ' . $row['fldLastName'];
            $html .= Tag::tr() . Tag::td() . Tag::linkButton('?' . $resp->action(__CLASS__ . '->loginAs()')->set('fldUser', $row['fldUser'])->toUrl(), 'Login as this User', ['title' => "Login as this user ({$name})"]) . Tag::_td() . Tag::_tr();
        }
        $html .= Tag::_table() . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
        return JS::library(JS::JQUERY) . JS::libraryWithDependancies(JS::FACEBOX) . JS::javaScript($jQuery) . $html;
    }
Beispiel #5
0
    public static function errorHandler($errno, $errstr, $errfile, $errline)
    {
        if (!preg_match('/^.*\\/3rdparty\\/.*$/', $errfile)) {
            self::$log->error("{$errno}-{$errstr}: {$errfile}({$errline})");
        }
        switch ($errno) {
            case E_STRICT:
            case E_USER_WARNING:
                return;
            default:
                if (self::get('debug')) {
                    $errMsg = sprintf('(!) Fatal error: %s in %s on line: %s', $errstr, $errfile, $errline);
                    $html = Tag::table(['cellpadding' => 3, 'cellspacing' => 0, 'border' => 1]) . Tag::tr(['bgcolor' => 'silver']) . Tag::th(['colspan' => 4, 'align' => 'left']) . $errMsg . Tag::_th() . Tag::_tr() . Tag::tr(['bgcolor' => 'silver']) . Tag::th() . 'Stk' . Tag::_th() . Tag::th() . 'File' . Tag::_th() . Tag::th() . 'Line' . Tag::_th() . Tag::th() . 'Function' . Tag::_th() . Tag::_tr();
                    foreach (debug_backtrace() as $idx => $row) {
                        if ($idx == 0) {
                            continue;
                        }
                        if (isset($row['file'])) {
                            $file = basename($row['file']);
                            $title = $row['file'];
                        } else {
                            $file = '&nbsp;';
                            $title = ' ';
                        }
                        $line = isset($row['line']) ? $row['line'] : '&nbsp;';
                        $function = $row['function'];
                        if (isset($row['class'])) {
                            $function = $row['class'] . $row['type'] . $function;
                        }
                        $style = $idx % 2 == 0 ? [] : ['bgcolor' => 'yellow'];
                        $html .= Tag::tr($style) . Tag::td() . $idx . Tag::_td() . Tag::td(['title' => $title]) . $file . Tag::_td() . Tag::td() . $line . Tag::_td() . Tag::td() . $function . Tag::_td() . Tag::_tr();
                    }
                    $html .= Tag::_table();
                    $html = str_replace(["\n", "'"], ['', "\\'"], $html);
                    $url = self::siteUrl() . '/ajax.php?' . Response::factory()->action('\\Jackbooted\\Html\\WebPage->blank()')->toUrl();
                    $js = <<<JS
                    \$().ready(function() {
                        newWindow = window.open ( '{$url}','Error Output','height=300,width=700');
                        var tmp = newWindow.document;
                        tmp.write ( '<html><head><title>{$errMsg}</title>' );
                        tmp.write ( '<style type="text/css">' );
                        tmp.write ( '</style>');
                        tmp.write ( '</head><body>');
                        tmp.write ( '{$html}' );
                        tmp.write ( '</body></html>');
                        tmp.close();
                    });
JS;
                    echo JS::library(JS::JQUERY) . JS::javaScript($js) . $errMsg;
                }
                break;
        }
    }