Exemplo n.º 1
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();
    }
Exemplo n.º 2
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;
 }
Exemplo n.º 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;
    }
Exemplo n.º 4
0
 /**
  * @param  $columnName
  * @param  $columnDisplay
  * @return string
  */
 public function toHtml($columnName, $columnDisplay = null)
 {
     if ($columnDisplay == null) {
         $columnDisplay = $columnName;
     }
     $savedFormVars = $this->formVars;
     $this->set(self::SORT_COL, $columnName);
     if ($this->sortColumn == $columnName) {
         $this->set(self::SORT_ORDER, $this->sortOrder == 'ASC' ? 'DESC' : 'ASC');
         $sortDirectionName = $this->sortOrder == 'ASC' ? 'Decending' : 'Ascending';
         $title = 'Click here to sort ' . $sortDirectionName . ' By ' . $columnDisplay;
         $button = $this->sortOrder == 'ASC' ? '^' : 'v';
         $url = $this->toUrl();
         $html = Tag::hTag('a', array_merge($this->attribs, ['href' => $url, 'class' => $this->styles[self::COL_LINK_CLASS], 'title' => $title])) . $columnDisplay . Tag::_hTag('a') . Tag::linkButton($url, $button, array_merge($this->attribs, ['class' => $this->styles[self::COL_BUTTON_CLASS], 'title' => $title]));
     } else {
         $this->set(self::SORT_ORDER, $this->sortOrder);
         $sortDirectionName = $this->sortOrder == 'ASC' ? 'Decending' : 'Ascending';
         $title = 'Sort ' . $sortDirectionName . ' By ' . $columnDisplay;
         $url = $this->toUrl();
         $html = Tag::hTag('a', array_merge($this->attribs, ['href' => $url, 'class' => $this->styles[self::COL_LINK_CLASS], 'title' => $title])) . $columnDisplay . Tag::_hTag('a');
     }
     $this->formVars = $savedFormVars;
     return $html;
 }
Exemplo n.º 5
0
 public function fileChecksum()
 {
     $messageArray = [];
     $dirList = PHPExt::dirSearch(Cfg::get('site_path'), '/^[^_].*$/');
     $len = strlen(Cfg::get('site_path')) + 1;
     foreach ($dirList as &$path) {
         $path = substr($path, $len);
     }
     $tab = new DBTable(DB::DEF, 'SELECT * FROM tblFileCheck');
     foreach ($tab as $row) {
         if (in_array($row['fldFileName'], $dirList)) {
             $fullPath = Cfg::get('site_path') . '/' . $row['fldFileName'];
             $fileSize = filesize($fullPath);
             $sha1 = sha1_file($fullPath);
             if ($fileSize != $row['fldSize']) {
                 $messageArray[$row['fldFileName']] = 'Mismatch file size. was: ' . $row['fldSize'] . ' now: ' . $fileSize;
             } else {
                 if ($sha1 != $row['fldCRC']) {
                     $messageArray[$row['fldFileName']] = 'Mismatch SHA1. was: ' . $row['fldCRC'] . ' now: ' . $sha1;
                 }
             }
         } else {
             $messageArray[$row['fldFileName']] = 'File deleted';
         }
     }
     $oldFileList = $tab->getColumn('fldFileName');
     foreach ($dirList as $fileName) {
         if (!in_array($fileName, $oldFileList)) {
             $messageArray[$fileName] = 'New file';
         }
     }
     $html = '';
     if (count($messageArray) != 0) {
         foreach ($messageArray as $key => $val) {
             $html .= $key . ': ' . $val . '<br/>';
         }
     } else {
         $html = 'No Changes<br/>';
     }
     $rebaseButton = Tag::linkButton('?' . Response::factory()->action(__CLASS__ . '->' . __FUNCTION__ . 'Rebase()'), 'Rebase');
     return $rebaseButton . '<br/>' . $html . $rebaseButton;
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
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;
    }