Example #1
0
 public function reset()
 {
     $resp = MenuUtils::responseObject();
     $html = '';
     $html .= '<H4>***WARNING*** You are about to reset configuration</h4>' . Tag::form() . $resp->action(sprintf('%s->%sSave()', __CLASS__, __FUNCTION__))->toHidden() . Tag::table() . Tag::tr() . Tag::td() . 'Please type "RESET CONFIG" without the quotes for finalise reset.' . Tag::_td() . Tag::td() . Tag::text('fldConfirm') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2]) . Tag::submit('Confirm Reset') . Tag::linkButton('?' . $resp->action(__CLASS__ . '->resetCancelled()'), 'Cancel Reset') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
     return $html;
 }
Example #2
0
    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();
    }
Example #3
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;
    }
Example #4
0
 public function forgotPassword()
 {
     // Initialise the $msg and $action and $disclaimer variables
     $formName = 'FancyLogin_forgotPassword';
     $valid = Validator::factory($formName, 'FP')->addExists('fldEmail', 'Email field is empty. Please insert valid email and resubmit')->addEmail('fldEmail', 'Email is in valid format. Must be of the form a@b.com');
     $html = $valid->toHtml() . Tag::form(['id' => $formName, 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . Response::factory()->set(self::ACTION, __CLASS__ . '->sendPW()')->toHidden() . Tag::table(['align' => 'center', 'border' => 0, 'cellspacing' => 0, 'cellpadding' => 2]) . Tag::tr() . Tag::td() . 'Email' . Tag::_td() . Tag::td() . Tag::text('fldEmail') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2, 'align' => 'center']) . 'Your Password will be reset and sent to you via email you have provided' . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2, 'align' => 'center']) . Tag::submit('Send Password') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
     return $html;
 }
Example #5
0
    public function editJSONEditForm($currentConfigKey)
    {
        $json = json_encode(Config::get($currentConfigKey));
        $js = <<<JS
            var json = {$json};
            main.load(json);
            main.resize();
            var pageDirty = false;
            \$().ready(function() {
                window.onbeforeunload = function () {
                    if ( ! pageDirty ) return;
                    return 'Changes have been made on this page and will be discarded.'
                };
                \$('textarea.jsonformatter-textarea').change( function() {
                    pageDirty = true;
                });
                \$('div.jsoneditor-value').change( function() {
                    pageDirty = true;
                });
                \$('#fldCfgValue').val( editor.get() );
            });

            function submitClicked () {
                var button = \$('#editJSONEditFormButton').attr('disabled',true);

                var orig = \$('#fldCfgValue').val();
                var ed   = editor.get();    // JSON Editor, RHS fields labels
                var form = formatter.get(); // Formatted Text Editor LHS

                if ( orig == ed && orig == form ) {
                    pageDirty = false;
                    alert( 'No changes, nothing to save' );
                    button.attr('disabled',false );
                    return false;
                }
                else if ( orig != ed && orig == form ) {
                    if ( confirm( 'Looks like you have made changes in the JSON Editor on right pane and not copied to Formatted Text Editor on left pane. Ok to save changes?' ) ) {
                        pageDirty = false;
                        \$('#fldCfgValue').val( ed );
                        \$('#editJSONEditForm').submit();
                        return true;
                    }
                    else {
                        button.attr('disabled',false );
                        return false;
                    }
                }
                else if ( orig == ed && orig != form ) {
                    if ( confirm( 'Looks like you have made changes in the Formatted Text Editor on left pane and not copied to the JSON Editor on right pane. Ok to save?' ) ) {
                        pageDirty = false;
                        \$('#fldCfgValue').val( form );
                        \$('#editJSONEditForm').submit();
                        return true;
                    }
                    else {
                        button.attr('disabled',false );
                        return false;
                    }
                }
                else if ( orig != ed && orig != form ) {
                    if ( ed == form ) {
                        pageDirty = false;
                        \$('#fldCfgValue').val( ed );
                        \$('#editJSONEditForm').submit();
                        return true;
                    }
                    else {
                        alert( 'You have changed both the JSON Editor on right pane and the Formatted Text Editor on left pane and they are inconsistent. ' +
                               'Please press one of the arrow buttons to fix and re-submit' );
                        button.attr('disabled',false );
                        return false;
                    }
                }
            }

            \$('body')
                .on( 'focus', '[contenteditable]', function() {
                    var t = \$(this);
                    t.data('before', t.html());
                    return t;
                })
                .on( 'blur keyup paste input', '[contenteditable]', function() {
                    var t = \$(this);
                    if (t.data('before') !== t.html() ) {
                        t.data('before', t.html());
                        t.trigger('change');
                    }
                    return t;
                });
JS;
        return JS::library(JS::JQUERY) . JS::library('jsoneditor.css') . JS::library('interface.css') . JS::library('jsoneditor.js') . JS::library('interface.js') . Tag::div(['id' => 'auto']) . Tag::div(['id' => 'contents', 'height' => '100%']) . Tag::table(['border' => '0', 'height' => '100%', 'width' => '100%']) . Tag::tr() . Tag::td(['valign' => 'top', 'width' => '45%', 'height' => '100%']) . Tag::hTag('b') . '&nbsp;&nbsp;&nbsp;&nbsp;Formatted Text Editor' . Tag::_hTag('b') . Tag::div(['id' => 'jsonformatter']) . Tag::_div() . Tag::_td() . Tag::td(['valign' => 'top', 'width' => '10%', 'align' => 'center']) . Tag::div(['id' => 'splitter']) . Tag::_div() . Tag::_td() . Tag::td(['valign' => 'top', 'width' => '45%', 'height' => '100%']) . Tag::hTag('b') . '&nbsp;&nbsp;&nbsp;&nbsp;JSON Editor' . Tag::_hTag('b') . Tag::div(['id' => 'jsoneditor']) . Tag::_div() . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_div() . Tag::_div() . Tag::form(['id' => 'editJSONEditForm'], false) . MenuUtils::responseObject()->set('fldCfgKey', $currentConfigKey)->action(__CLASS__ . '->saveConfig()')->toHidden() . Tag::textArea('fldCfgValue', '', ['id' => 'fldCfgValue', 'style' => 'display: none;']) . '<b>Currently editing : <i>' . $currentConfigKey . '</i></b> ' . Tag::button('Save', ['onClick' => 'submitClicked();', 'id' => 'editJSONEditFormButton']) . Tag::_form() . JS::javaScript($js);
    }
Example #6
0
 /** Creates a Dual Select windows
  * @param string $lName Left Column name
  * @param array $lList Left Column name
  * @param string $rName Right Column name
  * @param array $rList Right Column name
  * @param int $ht Height
  * @returns String The Html pf a dual select
  */
 public static function dualSelect($lName, $lList, $rName, $rList, $ht = 8)
 {
     $title = array("title" => "Select items is the left list to move to the selected list. " . "Move items in the right list to remove from the selected list. " . "Select buttons in the moddle to move all the items in the list");
     $msg = "";
     $msg .= Tag::table($title);
     $msg .= Tag::tr();
     $msg .= Tag::td("align=center");
     $msg .= "Out of List<br>";
     $msg .= Lists::select($lName, $lList, "onChange=\"selMove ( '{$lName}','{$rName}',false );\" Size={$ht} Multiple");
     $msg .= Tag::_td();
     $msg .= Tag::td("valign=middle");
     $msg .= "<br>" . Tag::button(">>", "onClick=\"selMove ( '{$lName}','{$rName}',true );\"");
     $msg .= "<br>" . Tag::button("<<", "onClick=\"selMove ( '{$rName}','{$lName}',true );\"");
     $msg .= Tag::_td();
     $msg .= Tag::td("align=center");
     $msg .= "In the List<br>";
     $msg .= Lists::select($rName, $rList, "onChange=\"selMove ( '{$rName}','{$lName}',false );\" Size={$ht} Multiple");
     $msg .= Tag::hidden($rName . "Result");
     $msg .= Tag::_td();
     $msg .= Tag::_tr();
     $msg .= Tag::_table();
     return $msg;
 }
Example #7
0
 private function renderValue($rowIdx, $colName, $value)
 {
     $html = '';
     $name = $this->gridTag . '[' . $rowIdx . '][' . $colName . ']';
     $autoUpdateJS = "autoUpdate({$rowIdx},'{$this->updTag}','{$this->delTag}','{$this->submitId}');";
     $id = $this->gridTag . '_' . $rowIdx . '_' . $colName;
     $updClickAttrib = ['onClick' => $autoUpdateJS, 'id' => $id];
     $updCheckAttrib = ['onChange' => $autoUpdateJS, 'id' => $id];
     $type = $this->getColumnType($colName);
     switch ($type) {
         case self::NONE:
             break;
         case self::DISPLAY:
             $html .= $value == '' ? '&nbsp;' : Tag::e($value);
             break;
         case self::HIDDEN:
             $this->resp->set($name, $value);
             break;
         case self::RADIO:
             $dispList = isset($this->displayType[$colName][1]) ? $this->displayType[$colName][1] : null;
             $updCheckAttrib['default'] = $value;
             $html .= Tag::table() . Tag::tr() . Tag::td(['nowrap' => 'nowrap']) . implode(Tag::_td() . Tag::td(['nowrap' => 'nowrap']), Lists::radio($name, $dispList, $updCheckAttrib)) . Tag::_td() . Tag::_tr() . Tag::_table();
             break;
         case self::SELECT:
             $dispList = isset($this->displayType[$colName][1]) ? $this->displayType[$colName][1] : null;
             $blankLine = isset($this->displayType[$colName][2]) ? $this->displayType[$colName][2] : false;
             $updCheckAttrib['default'] = $value;
             $updCheckAttrib['hasBlank'] = $blankLine;
             $html .= Lists::select($name, $dispList, $updCheckAttrib);
             break;
         case self::CHECKBOX:
             $checkValue = isset($this->displayType[$colName][1]) ? $this->displayType[$colName][1] : 'YES';
             $html .= Tag::checkBox($name, $checkValue, $value == $checkValue, $updClickAttrib);
             break;
         case self::TIMESTAMP:
             $attribs = array_merge($updCheckAttrib, $this->cellAttributes[$colName]);
             $attribs['value'] = strftime('%Y-%m-%d %H:%M:%S', (int) $value);
             $attribs['size'] = strlen($attribs['value']) + 1;
             $html .= Tag::text($name, $attribs);
             break;
         case self::ENCTEXT:
             $value = Cryptography::de((string) $value);
             // Fall through to output text field
         // Fall through to output text field
         case self::TEXT:
         default:
             $updCheckAttrib['value'] = (string) $value;
             $html .= Tag::text($name, array_merge($updCheckAttrib, $this->cellAttributes[$colName]));
             break;
     }
     if (!in_array($type, [self::HIDDEN, self::NONE])) {
         $html = Tag::td() . $html . Tag::_td();
     }
     return $html;
 }
Example #8
0
 public function forgotPassword()
 {
     // Initialise the $msg and $action and $disclaimer variables
     $formName = 'Login_forgotPassword';
     $valid = Validator::factory($formName, 'FP')->addExists('fldEmail', 'Email field is empty. Please insert valid email and resubmit')->addEmail('fldEmail', 'Email is in valid format. Must be of the form a@b.com');
     $html = '<h2>Password Reset</h2>' . $valid->toHtml() . Tag::form(['id' => $formName, 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . Response::factory()->action(__CLASS__ . '->sendPW()')->toHidden() . Tag::table() . Tag::tr() . Tag::td() . 'Email' . Tag::_td() . Tag::td() . Tag::text('fldEmail', ['title' => 'Your Password will be reset and sent to you via email you have provided']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['align' => 'left']) . Tag::submit('Reset PW') . Tag::_td() . Tag::td(['align' => 'right']) . Tag::linkButton('?' . Response::factory()->action(__CLASS__ . '->index()')->toUrl(), 'Back to Login') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
     return $html;
 }
Example #9
0
 public function newUser()
 {
     $formName = 'Admin_newUser';
     $valid = Validator::factory($formName)->addExists('fldEmail', 'Email field is empty. Please insert valid email and resubmit')->addEmail('fldEmail', 'Email needs to exist and be correct format')->addExists('fldFirstName', 'First Name must exist')->addExists('fldCaptcha', 'You must enter Captcha Code')->addExists('fldLastName', 'Last Name must exist');
     $html = $valid->toHtml() . Tag::form(['id' => $formName, 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . Response::factory()->action(__CLASS__ . '->newUserSave()')->toHidden() . Tag::table() . Tag::tr() . Tag::td() . 'Email:' . Tag::_td() . Tag::td() . Tag::text('fldEmail', Request::get('fldEmail')) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'First&nbsp;Name:' . Tag::_td() . Tag::td() . Tag::text('fldFirstName', Request::get('fldFirstName')) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Last&nbsp;Name:' . Tag::_td() . Tag::td() . Tag::text('fldLastName', Request::get('fldLastName')) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2]) . Tag::submit('Create Account') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
     return $html;
 }
Example #10
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;
        }
    }