Example #1
0
 /**
  * Get the user filters
  *
  * @return array The user filters
  */
 public function getFilters()
 {
     if (App::request()->getHeaders('X-List-Filter')) {
         App::session()->getUser()->setOption('admin.user-filter', App::request()->getHeaders('X-List-Filter'));
     }
     return json_decode(App::session()->getUser()->getOptions('admin.user-filter'), true);
 }
Example #2
0
 /**
  * Edit a role
  */
 public function edit()
 {
     $param = array('id' => 'edit-role-form', 'model' => 'Role', 'reference' => array('id' => $this->roleId), 'fieldsets' => array('form' => array('nofieldset' => true, new HiddenInput(array('field' => 'removable', 'default' => 1, 'readonly' => true)), new TextInput(array('field' => 'name', 'maxlength' => 32, 'label' => Lang::get('roles.form-name-label'), 'required' => true)), new ColorInput(array('field' => 'color', 'label' => Lang::get('roles.form-color-label'), 'default' => '#000'))), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button'))), new DeleteInput(array('name' => 'delete', 'value' => Lang::get('main.delete-button'), 'notDisplayed' => $this->roleId == -1)), new ButtonInput(array('name' => 'cancel', 'value' => Lang::get('main.cancel-button'), 'onclick' => 'app.dialog("close")')))), 'onsuccess' => 'app.dialog("close"); app.load(app.getUri("list-roles"), {selector : "#admin-roles-tab"});');
     foreach (Language::getAll() as $language) {
         $param['fieldsets']['form'][] = new TextInput(array('name' => "translation[{$language->tag}]", "independant" => true, 'required' => $language->tag == LANGUAGE, "label" => Lang::get("roles.role-label-label", array('lang' => $language->tag)), "default" => Lang::exists("roles.role-" . $this->roleId . "-label") ? Lang::get("roles.role-" . $this->roleId . "-label", array(), 0, $language->tag) : ''));
     }
     $form = new Form($param);
     if (!$form->submitted()) {
         return View::make(Theme::getSelected()->getView("dialogbox.tpl"), array('icon' => 'user', 'title' => Lang::get('roles.form-title'), 'page' => $form));
     } else {
         if ($form->submitted() == "delete") {
             $form->delete(Form::NO_EXIT);
             if ($key) {
                 $key->delete();
             }
             return $form->response(Form::STATUS_SUCCESS);
         } else {
             if ($form->check()) {
                 try {
                     $roleId = $form->register(Form::NO_EXIT);
                     // Create the language key for the translations of the role name
                     foreach (App::request()->getBody('translation') as $tag => $translation) {
                         Language::getByTag($tag)->saveTranslations(array('roles' => array("role-{$roleId}-label" => $translation)));
                     }
                     return $form->response(Form::STATUS_SUCCESS);
                 } catch (Exception $e) {
                     return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : "");
                 }
             }
         }
     }
 }
 protected function formAction()
 {
     $form = new UrlForm();
     if (App::request()->isPost()) {
         $form->setValue('url', App::request()->getPostVar('url'));
         if ($form->isValid()) {
             // if URL is valid
             // find or generate short URL
             $existsUrlRecord = UrlModel::findOneByLongurl($form->getValue('url'));
             if (false !== $existsUrlRecord) {
                 // alredy exists - use it
                 $shortURI = App::alphaid()->toAlpha($existsUrlRecord->id);
             } else {
                 // not exists - create new
                 $urlRecord = new UrlModel();
                 $urlRecord->longurl = $form->getValue('url');
                 $urlRecord->save();
                 $shortURI = App::alphaid()->toAlpha($urlRecord->id);
             }
             $shortURL = App::router()->createUrl('Redirector', 'redirect', array('url' => $shortURI));
             $form->setValue('shortUrl', $shortURL);
         }
     }
     if (App::request()->isAjaxRequest()) {
         $this->setLayout('ajax');
         $this->view->form = $form->getData();
     } else {
         $this->view->form = $form;
         $this->render();
     }
 }
Example #4
0
 /**
  * POST /principal
  *
  */
 public function s003()
 {
     $error;
     try {
         $req = App::request();
         if ($req->isPost()) {
             $post = $req->post();
             if (!empty($post["nama"])) {
                 $attributes = array("nama" => $post["nama"], "aktif" => isset($post["aktif"]) ? 1 : 0);
                 $table = Principal::table();
                 if (is_null($post["gen_id"]) || $post["gen_id"] == "") {
                     $table->insert($attributes);
                 } else {
                     $where = "nama = '" . $post["gen_id"] . "'";
                     $table->update($attributes, $where);
                 }
             }
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
         ZiUtil::unique_error($error);
         App::flash('error', $post["nama"] . ' ' . ZiUtil::unique_error($error));
         // App::flash('error', 'Terjadi kesalahan pada inputan anda.');
         App::redirect('principal.a001');
     }
     App::flash('info', 'Data Tersimpan.');
     App::redirect('principal.index');
 }
Example #5
0
 /**
  * POST /uom
  *
  */
 public function s003()
 {
     $error;
     try {
         $req = App::request();
         if ($req->isPost()) {
             $post = $req->post();
             $attributes = array("uom_nama" => $post["uom_nama"], "aktif" => isset($post["aktif"]) ? 1 : 0);
             $table = UOM::table();
             if (is_null($post["gen_id"]) || $post["gen_id"] == "") {
                 $table->insert($attributes);
             } else {
                 $where = "uom_nama = '" . $post["gen_id"] . "'";
                 $table->update($attributes, $where);
             }
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
         ZiUtil::unique_error($error);
         App::flash('error', $post["uom_nama"] . ' ' . ZiUtil::unique_error($error));
         App::redirect('unitOM.a001');
     }
     App::flash('info', 'Data Tersimpan : ' . $post["uom_nama"]);
     App::redirect('unitOM.index');
 }
Example #6
0
 /**
  * 构造方法
  *
  * @param App $app
  */
 public function __construct($app)
 {
     $this->app = $app;
     $this->appConfig = $app->config();
     $this->request = $app->request();
     $this->response = $app->response();
     $app->controller = $this;
 }
Example #7
0
 public function __construct()
 {
     $parse = parse_url(\App::request()->getPathInfo());
     $this->path = isset($parse['path']) ? array_map('trim', array_filter(explode('/', trim($parse['path'], '/')))) : [];
     $this->config = (new Routes())->routesMap;
     $this->module = $this->getModule();
     $this->dir = $this->config[$this->module];
 }
Example #8
0
 /**
  * Constructor
  *
  * @param string $url The not found URL
  * @param array $details The exception details
  */
 public function __construct($url = '', $details = array())
 {
     if (!$url) {
         $url = App::request()->getFullUrl();
     }
     $details['url'] = $url;
     $message = Lang::get('main.http-error-404-message', $details);
     parent::__construct($message, $details);
 }
Example #9
0
 /**
  * Install the application
  */
 public function settings()
 {
     $form = new Form(array('id' => 'install-settings-form', 'labelWidth' => '30em', 'fieldsets' => array('global' => array('legend' => Lang::get('install.settings-global-legend', null, null, $this->language), new TextInput(array('name' => 'title', 'required' => true, 'label' => Lang::get('install.settings-title-label', null, null, $this->language), 'default' => DEFAULT_HTML_TITLE)), new TextInput(array('name' => 'rooturl', 'required' => true, 'label' => Lang::get('install.settings-rooturl-label', null, null, $this->language), 'placeholder' => 'http://', 'default' => getenv('REQUEST_SCHEME') . '://' . getenv('SERVER_NAME'))), new SelectInput(array('name' => 'timezone', 'required' => true, 'options' => array_combine(\DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers()), 'default' => DEFAULT_TIMEZONE, 'label' => Lang::get('install.settings-timezone-label')))), 'database' => array('legend' => Lang::get('install.settings-database-legend', null, null, $this->language), new TextInput(array('name' => 'db[host]', 'required' => true, 'label' => Lang::get('install.settings-db-host-label', null, null, $this->language), 'default' => 'localhost')), new TextInput(array('name' => 'db[username]', 'required' => true, 'label' => Lang::get('install.settings-db-username-label', null, null, $this->language))), new PasswordInput(array('name' => 'db[password]', 'required' => true, 'label' => Lang::get('install.settings-db-password-label', null, null, $this->language), 'pattern' => '/^.*$/')), new TextInput(array('name' => 'db[dbname]', 'required' => true, 'pattern' => '/^\\w+$/', 'label' => Lang::get('install.settings-db-dbname-label', null, null, $this->language))), new TextInput(array('name' => 'db[prefix]', 'default' => 'Hawk', 'pattern' => '/^\\w+$/', 'label' => Lang::get('install.settings-db-prefix-label', null, null, $this->language)))), 'admin' => array('legend' => Lang::get('install.settings-admin-legend', null, null, $this->language), new TextInput(array('name' => 'admin[login]', 'required' => true, 'pattern' => '/^\\w+$/', 'label' => Lang::get('install.settings-admin-login-label', null, null, $this->language))), new EmailInput(array('name' => 'admin[email]', 'required' => true, 'label' => Lang::get('install.settings-admin-email-label', null, null, $this->language))), new PasswordInput(array('name' => 'admin[password]', 'required' => true, 'label' => Lang::get('install.settings-admin-password-label', null, null, $this->language))), new PasswordInput(array('name' => 'admin[passagain]', 'required' => true, 'compare' => 'admin[password]', 'label' => Lang::get('install.settings-admin-passagain-label', null, null, $this->language)))), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('install.install-button', null, null, $this->language), 'icon' => 'cog')))), 'onsuccess' => 'location.href = data.rooturl;'));
     if (!$form->submitted()) {
         // Display the form
         $body = View::make(Plugin::current()->getView('settings.tpl'), array('form' => $form));
         return \Hawk\Plugins\Main\MainController::getInstance()->index($body);
     } else {
         // Make the installation
         if ($form->check()) {
             /**
              * Generate Crypto constants
              */
             $salt = Crypto::generateKey(24);
             $key = Crypto::generateKey(32);
             $iv = Crypto::generateKey(16);
             $configMode = 'prod';
             /**
              * Create the database and it tables
              */
             $tmpfile = tempnam(sys_get_temp_dir(), '');
             DB::add('tmp', array(array('host' => $form->getData('db[host]'), 'username' => $form->getData('db[username]'), 'password' => $form->getData('db[password]'))));
             try {
                 DB::get('tmp');
             } catch (DBException $e) {
                 return $form->response(Form::STATUS_ERROR, Lang::get('install.install-connection-error'));
             }
             try {
                 $param = array('{{ $dbname }}' => $form->getData('db[dbname]'), '{{ $prefix }}' => $form->getData('db[prefix]'), '{{ $language }}' => $this->language, '{{ $timezone }}' => $form->getData('timezone'), '{{ $title }}' => Db::get('tmp')->quote($form->getData('title')), '{{ $email }}' => Db::get('tmp')->quote($form->getData('admin[email]')), '{{ $login }}' => Db::get('tmp')->quote($form->getData('admin[login]')), '{{ $password }}' => Db::get('tmp')->quote(Crypto::saltHash($form->getData('admin[password]'), $salt)), '{{ $ip }}' => Db::get('tmp')->quote(App::request()->clientIp()));
                 $sql = strtr(file_get_contents(Plugin::current()->getRootDir() . 'templates/install.sql.tpl'), $param);
                 // file_put_contents($tmpfile, $sql);
                 Db::get('tmp')->query($sql);
                 /**
                  * Create the config file
                  */
                 $param = array('{{ $salt }}' => addcslashes($salt, "'"), '{{ $key }}' => addcslashes($key, "'"), '{{ $iv }}' => addcslashes($iv, "'"), '{{ $configMode }}' => $configMode, '{{ $rooturl }}' => $form->getData('rooturl'), '{{ $host }}' => $form->getData('db[host]'), '{{ $username }}' => $form->getData('db[username]'), '{{ $password }}' => $form->getData('db[password]'), '{{ $dbname }}' => $form->getData('db[dbname]'), '{{ $prefix }}' => $form->getData('db[prefix]'), '{{ $sessionEngine }}' => $form->getData('session'), '{{ $version }}' => $form->getData('version'));
                 $config = strtr(file_get_contents(Plugin::current()->getRootDir() . 'templates/config.php.tpl'), $param);
                 file_put_contents(INCLUDES_DIR . 'config.php', $config);
                 /**
                  * Create etc/dev.php
                  */
                 App::fs()->copy(Plugin::current()->getRootDir() . 'templates/etc-dev.php', ETC_DIR . 'dev.php');
                 /**
                  * Create etc/prod.php
                  */
                 App::fs()->copy(Plugin::current()->getRootDir() . 'templates/etc-prod.php', ETC_DIR . 'prod.php');
                 $form->addReturn('rooturl', $form->getData('rooturl'));
                 return $form->response(Form::STATUS_SUCCESS, Lang::get('install.install-success'));
             } catch (\Exception $e) {
                 return $form->response(Form::STATUS_ERROR, Lang::get('install.install-error'));
             }
         }
     }
 }
Example #10
0
 /**
  * Open a new session
  *
  * @param string $savePath Not used
  * @param string $name     The session name (defaulty 'PHPSESSID')
  */
 public function open($savePath, $name)
 {
     $this->db = App::db();
     $this->table = DB::getFullTablename('Session');
     // Update the session mtime
     if (App::request()->getCookies($name)) {
         SessionModel::getDbInstance()->update(SessionModel::getTable(), new DBExample(array('id' => App::request()->getCookies($name))), array('mtime' => time()));
     }
     // Clean expired sessions
     $this->gc(0);
 }
Example #11
0
 private function links($file)
 {
     $url = \App::request()->getBaseUrl();
     $skin = \App::user()->get()->config()->skin;
     $type = strtolower(pathinfo($file, PATHINFO_EXTENSION));
     $moduleDir = \App::router()->dir;
     $themeLink = $url . '/themes/';
     $skinLink = $themeLink . $skin . '/';
     $skinPath = THEMES_PATH . $skin . DS;
     return [[$skinPath . 'modules' . DS . $moduleDir . DS . $type . DS . $file, $skinLink . 'modules/' . $moduleDir . '/' . $type . '/' . $file], [ASSETS_PATH . 'modules' . DS . $moduleDir . DS . $type . DS . $file, $url . '/assets/modules/' . $moduleDir . '/' . $type . '/' . $file], [$skinPath . $type . DS . $file, $skinLink . $type . '/' . $file], [ASSETS_PATH . 'template' . DS . $type . DS . $file, $url . '/assets/template/' . $type . '/' . $file]];
 }
Example #12
0
 /**
  * Display the main page of the permission settings
  */
 public function index()
 {
     $permissionGroups = Permission::getAllGroupByPlugin();
     $example = isset($this->roleId) ? array('roleId' => $this->roleId) : array();
     $data = RolePermission::getListByExample(new DBExample($example));
     $values = array();
     foreach ($data as $value) {
         $values[$value->permissionId][$value->roleId] = $value->value;
     }
     $roles = isset($this->roleId) ? array(Role::getById($this->roleId)) : Role::getAll(null, array(), array(), true);
     $param = array('id' => 'permissions-form', 'fieldsets' => array('form' => array(), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button'))))));
     foreach ($roles as $role) {
         foreach ($permissionGroups as $group => $permissions) {
             if (Plugin::get($group)) {
                 foreach ($permissions as $permission) {
                     if ($role->id == Role::ADMIN_ROLE_ID) {
                         $default = 1;
                     } elseif (isset($values[$permission->id][$role->id])) {
                         $default = $values[$permission->id][$role->id];
                     } else {
                         $default = 0;
                     }
                     $param['fieldsets']['form'][] = new CheckboxInput(array('name' => "permission-{$permission->id}-{$role->id}", 'disabled' => $role->id == Role::ADMIN_ROLE_ID || $role->id == Role::GUEST_ROLE_ID && !$permission->availableForGuests, 'default' => $default, 'class' => $permission->id == Permission::ALL_PRIVILEGES_ID ? 'select-all' : '', 'nl' => false));
                 }
             }
         }
     }
     $form = new Form($param);
     if (!$form->submitted()) {
         $page = View::make(Plugin::current()->getView("permissions.tpl"), array('permissions' => $permissionGroups, 'fields' => $form->inputs, 'roles' => $roles));
         return NoSidebarTab::make(array('icon' => 'unlock-alt', 'title' => Lang::get('permissions.page-title'), 'page' => $form->wrap($page)));
     } else {
         try {
             foreach ($form->inputs as $name => $field) {
                 if (preg_match('/^permission\\-(\\d+)\\-(\\d+)$/', $name, $match)) {
                     $permissionId = $match[1];
                     $roleId = $match[2];
                     $value = App::request()->getBody($name) ? 1 : 0;
                     if ($roleId != Role::ADMIN_ROLE_ID && !($roleId == Role::GUEST_ROLE_ID && !$permission->availableForGuests)) {
                         $permission = new RolePermission();
                         $permission->set(array('roleId' => $roleId, 'permissionId' => $permissionId, 'value' => $value));
                         $permission->save();
                     }
                 }
             }
             App::logger()->info('Permissions were succesfully updated');
             return $form->response(Form::STATUS_SUCCESS, Lang::get("roles.permissions-update-success"));
         } catch (Exception $e) {
             App::logger()->error('An error occured while updating permissions');
             return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : Lang::get("roles.permissions-update-error"));
         }
     }
 }
Example #13
0
 public function index()
 {
     $req = App::request();
     if ($req->isPost()) {
         if ($this->auth->login($req->post('user'), $req->post('passwd'))) {
             App::flash('info', "Your login was successful")->redirect('home');
         } else {
             App::flash('error', 'Your username or password was wrong');
         }
     }
     App::render('auth/login');
 }
Example #14
0
 /**
  * Write log
  *
  * @param string $level   The log level : 'debug', 'info', 'notice', 'warning', 'error'
  * @param string $message The message to write
  */
 private function write($level, $message)
 {
     if (empty($this->resources[$level])) {
         $this->open($level);
     }
     $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
     $trace = (object) $trace[1];
     $request = App::request();
     $data = array('date' => date_create()->format('Y-m-d H:i:s'), 'requestId' => $request->uid, 'method' => $request->getMethod(), 'clientIp' => $request->clientIp(), 'uri' => $request->getUri(), 'file' => $trace->file, 'line' => $trace->line, 'message' => $message);
     $input = json_encode($data, JSON_UNESCAPED_SLASHES);
     fwrite($this->resources[$level], $input . PHP_EOL);
 }
Example #15
0
 public function apiJson()
 {
     $comments = file_get_contents('assets/comments.json');
     $req = App::request();
     if ($req->isPost()) {
         $post = $req->post();
         $commentsDecoded = json_decode($comments, true);
         $commentsDecoded[] = ['author' => $post['author'], 'text' => $post['text']];
         $comments = json_encode($commentsDecoded, JSON_PRETTY_PRINT);
         file_put_contents('assets/comments.json', $comments);
     }
     ZiUtil::to_json($comments);
 }
Example #16
0
 public function __construct()
 {
     $view = \App::view();
     $url = \App::request()->getBaseUrl();
     $view->setCss('editors/codemirror/theme.min.css');
     $view->embedJs('<script src="' . $url . '/assets/js/codemirror/lib/codemirror.min.js"></script>');
     $view->embedJs('<script src="' . $url . '/assets/js/codemirror/addon/hint/show-hint.min.js"></script>');
     $view->embedJs('<script src="' . $url . '/assets/js/codemirror/addon/hint/xml-hint.min.js"></script>');
     $view->embedJs('<script src="' . $url . '/assets/js/codemirror/addon/hint/html-hint.min.js"></script>');
     $view->embedJs('<script src="' . $url . '/assets/js/codemirror/mode/xml/xml.js"></script>');
     $view->embedJs('<script src="' . $url . '/assets/js/codemirror/mode/javascript/javascript.js"></script>');
     $view->embedJs('<script src="' . $url . '/assets/js/codemirror/mode/css/css.js"></script>');
     $view->embedJs('<script src="' . $url . '/assets/js/codemirror/mode/htmlmixed/htmlmixed.js"></script>');
 }
 protected function redirectAction()
 {
     $shortURI = App::request()->getQueryVar('url');
     $shortURIId = App::alphaid()->toId($shortURI);
     /** @var $urlRecord UrlModel */
     $urlRecord = UrlModel::findOneByPk($shortURIId);
     if (false !== $urlRecord && !empty($urlRecord->longurl)) {
         // TODO cache
         // TODO statictics (hits/lastuse)
         App::response()->redirectAndExit($urlRecord->longurl, 301);
         // SEO friendly redirect
     } else {
         // redirect failed
         App::response()->sendNotFoundAndExit();
     }
 }
Example #18
0
 /**
  * POST /warehouse
  *
  */
 public function s003()
 {
     $req = App::request();
     if ($req->isPost()) {
         $post = $req->post();
         $attributes = array("warehouse_nama" => $post["warehouse_nama"], "keterangan" => $post["keterangan"], "company" => "RSMM");
         $table = Warehouse::table();
         if (is_null($post["gen_id"]) || $post["gen_id"] == "") {
             $attributes["id"] = ZiUtil::GetNowID();
             $table->insert($attributes);
         } else {
             $where = "id = '" . $post["gen_id"] . "'";
             $table->update($attributes, $where);
         }
     }
     App::redirect('warehouse.index');
 }
Example #19
0
function getThemesList()
{
    $tpl_list = [];
    $dirs = glob(THEMES_PATH . '*', GLOB_ONLYDIR);
    foreach ($dirs as $val) {
        if (is_file($val . DS . 'theme.ini')) {
            $options = parse_ini_file($val . DS . 'theme.ini');
            if (isset($options['name'], $options['author'], $options['author_url'], $options['author_email'], $options['description']) && is_file($val . DS . 'theme.png')) {
                $dir = basename($val);
                $options['thumbinal'] = App::request()->getBaseUrl() . '/themes/' . $dir . '/theme.png';
                $tpl_list[$dir] = $options;
            }
        }
    }
    ksort($tpl_list);
    return $tpl_list;
}
 /**
  * @param $config array
  */
 public static function run($config)
 {
     static::$_config = $config;
     // initialize error handling
     register_shutdown_function(array('App', 'onFatalError'));
     set_exception_handler(array('App', 'onException'));
     set_error_handler(array('App', 'onError'));
     $response = App::response();
     // init response
     $response->enableBuffering();
     // start output buffering
     // initialize class Autoloader
     $autoloader = static::autoloader();
     // initialize Router
     $router = static::router();
     $parsedUrl = $router->parseRequestUrl(App::request()->getUrl());
     $controllerClassName = $parsedUrl['controller'];
     $actionMethodName = $parsedUrl['action'];
     $parameters = $parsedUrl['parameters'];
     if (!$autoloader->classDefined($controllerClassName)) {
         trigger_error('Controller "' . $controllerClassName . '" not found');
         App::response()->sendNotFoundAndExit();
     }
     /** @var $controller AppController */
     $controller = new $controllerClassName();
     $controller->setAction($actionMethodName);
     $controller->setParameters($parameters);
     // get response from action
     $actionContent = $controller->run();
     // get layout from controller
     $layout = $controller->getLayout();
     if ($layout) {
         // if layout not disabled ( @see AppController::disableLayout() )
         $layoutView = new AppView('layouts/' . $layout);
         $layoutView->title = static::$_config['applicationName'];
         $layoutView->content = $actionContent;
         // insert action response into page layout
         // render page
         echo $layoutView->render();
     }
     // send response to client
     App::response()->sendContent();
 }
Example #21
0
 public static function getResponse()
 {
     $input = trim($_REQUEST['INPUT']) ? $_REQUEST['INPUT'] : '676';
     $msisdn = isset($_REQUEST['msisdn']) ? trim($_REQUEST['msisdn']) : '2348132614337';
     $code = $_REQUEST['code'] ? $_REQUEST['code'] : '676';
     //always the same
     $sessionid = isset($_REQUEST['sessionid']) ? $_REQUEST['sessionid'] : "52277817";
     // find out what ussd code is running and map it to the right app
     /*
      * 776 is mhealth, 676 is mmarket
      */
     try {
         $content = App::putText($input, $sessionid, $msisdn, $code);
     } catch (Exception $e) {
         $content = "Service Temporarily Unavailable";
     }
     $url = "http://172.24.87.125:31110/mmarket/app.request";
     return App::request($url);
     #return $txt;
 }
Example #22
0
 /**
  * Constructor
  *
  * @param string $name the name of the upload
  */
 private function __construct($name)
 {
     $files = App::request()->getFiles();
     if (empty($files[$name])) {
         throw new UploadException();
     }
     if (is_array($files[$name]['name'])) {
         foreach ($files[$name]['name'] as $i => $data) {
             if (!is_file($files[$name]['tmp_name'][$i])) {
                 throw new UploadException();
             }
             $this->files[$i] = (object) array('basename' => $files[$name]['name'][$i], 'tmpFile' => $files[$name]['tmp_name'][$i], 'mime' => $files[$name]['type'][$i], 'size' => $files[$name]['size'][$i], 'extension' => pathinfo($files[$name]['name'][$i], PATHINFO_EXTENSION));
         }
     } else {
         if (!is_file($files[$name]['tmp_name'])) {
             throw new UploadException();
         }
         $this->files[] = (object) array('basename' => $files[$name]['name'], 'tmpFile' => $files[$name]['tmp_name'], 'mime' => $files[$name]['type'], 'size' => $files[$name]['size'], 'extension' => pathinfo($files[$name]['name'], PATHINFO_EXTENSION));
     }
 }
Example #23
0
 /**
  * POST /pricelist
  *
  */
 public function s003()
 {
     $req = App::request();
     if ($req->isPost()) {
         $post = $req->post();
         if (!empty($post["price_list_nama"])) {
             $attributes = array("price_list_nama" => $post["price_list_nama"], "kode_invoice" => $post["kode_invoice"], "currency" => "IDR", "aktif" => isset($post["aktif"]) ? 1 : 0, "pembelian" => isset($post["pembelian"]) ? 1 : 0, "penjualan" => isset($post["penjualan"]) ? 1 : 0);
             $table = PriceList::table();
             if (is_null($post["gen_id"]) || $post["gen_id"] == "") {
                 $table->insert($attributes);
             } else {
                 $where = "price_list_nama = '" . $post["gen_id"] . "'";
                 $table->update($attributes, $where);
             }
             App::flash('info', 'Data Tersimpan.');
             App::redirect('pricelist.index');
         }
     }
     App::flash('error', 'Terjadi kesalahan pada inputan anda.');
     App::redirect('pricelist.a001');
 }
Example #24
0
 public function deletefile()
 {
     $req = App::request();
     $jsonData = array();
     $jsonData["result"] = null;
     if ($req->isPost()) {
         try {
             $post = $req->post();
             $jsonData["fileid"] = $post['fileid'];
             if (ZHelper::contentDir($post['fileid'])) {
                 $jsonData["msg"] = "The file " . $post['fileid'] . " has been delete";
                 $jsonData["result"] = "ok";
             } else {
                 $jsonData["msg"] = "failed remove directory";
             }
         } catch (Exception $e) {
             $jsonData["msg"] = $e->getMessage();
         }
         echo json_encode($jsonData);
     }
 }
Example #25
0
<?php

/*
 * mobiCMS Content Management System (http://mobicms.net)
 *
 * For copyright and license information, please see the LICENSE.md
 * Installing the system or redistributions of files must retain the above copyright notice.
 *
 * @link        http://mobicms.net mobiCMS Project
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 */
defined('MOBICMS') or die('Error: restricted access');
use Config\System as Config;
$uri = App::request()->getUri();
$form = new Mobicms\Form\Form(['action' => $uri]);
$form->title(_dg('Clear Cache'))->html('<span class="description">' . _dg('The Cache clearing is required after installing a new language or upgrade existing ones.') . '</span>')->element('submit', 'update', ['value' => _dg('Clear Cache'), 'class' => 'btn btn-primary btn-xs'])->title(_dg('Default Language'))->element('radio', 'lng', ['checked' => Config::$lng, 'description' => _dg('If the choice is prohibited, the language will be forced to set for all visitors. If the choice is allowed, it will be applied only in the case, if requested by the client language is not in the system.'), 'items' => App::lng()->getLocalesList()])->element('checkbox', 'lngSwitch', ['checked' => Config::$lngSwitch, 'label_inline' => _dg('Allow to choose'), 'description' => _dg('Allow visitors specify the desired language from the list of available in the system. Including activated auto select languages by signatures of the browser.')])->divider()->element('submit', 'submit', ['value' => _g('Save'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _g('Back') . '</a>');
if ($form->process() === true) {
    if (isset($form->input['update'])) {
        // Обновляем кэш
        App::lng()->clearCache();
        App::redirect($uri . '?cache');
    } else {
        // Записываем настройки
        App::session()->remove('lng');
        (new Mobicms\Config\WriteHandler())->write('System', $form->output);
        App::redirect($uri . '?saved');
    }
}
App::view()->form = $form->display();
App::view()->setTemplate('edit_form.php');
Example #26
0
<?php

/*
 * mobiCMS Content Management System (http://mobicms.net)
 *
 * For copyright and license information, please see the LICENSE.md
 * Installing the system or redistributions of files must retain the above copyright notice.
 *
 * @link        http://mobicms.net mobiCMS Project
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 */
defined('MOBICMS') or die('Error: restricted access');
define('ROOT_DIR', '.');
$form = new Mobicms\Form\Form(['action' => App::request()->getUri()]);
$form->infoMessages = false;
$form->title(_m('Anti-Spyware'))->element('radio', 'mode', ['checked' => 1, 'items' => ['1' => _m('Scan to the appropriate distribution'), '2' => _m('Snapshot scan'), '3' => _m('Make snapshot')]])->divider()->element('submit', 'submit', ['value' => _s('Run'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _s('Back') . '</a>');
if ($form->process() === true) {
    require_once dirname(__DIR__) . '/classes/Scanner.php';
    $scanner = new Scanner();
    switch ($form->output['mode']) {
        case 1:
            // Сканируем на соответствие дистрибутиву
            $scanner->scan();
            if (count($scanner->modifiedFiles) || count($scanner->missingFiles) || count($scanner->newFiles)) {
                App::view()->modifiedFiles = $scanner->modifiedFiles;
                App::view()->missingFiles = $scanner->missingFiles;
                App::view()->extraFiles = $scanner->newFiles;
                App::view()->errormsg = _m('Distributive inconsistency!');
            } else {
                App::view()->ok = _m('List of files corresponds to the distributive');
     if ($_FILES['animation']['size'] > 20480) {
         $error[] = _m('Weight of the file exceeds 20kb');
     }
     $param = getimagesize($_FILES['animation']['tmp_name']);
     // Проверка на допустимый тип файла
     if ($param == false || $param['mime'] != 'image/gif') {
         $error[] = _m('Invalid file type, are only allowed to upload images in GIF format');
     }
     // Проверка на допустимый размер изображения
     if ($param != false && ($param[0] != 48 || $param[1] != 48)) {
         $error[] = _m('The size of the images must be 48x48');
     }
     if (empty($error)) {
         $profile = App::profile();
         if (move_uploaded_file($_FILES['animation']['tmp_name'], FILES_PATH . 'users' . DS . 'avatar' . DS . $profile->id . '.gif') == true) {
             $profile->avatar = App::request()->getBaseUrl() . '/uploads/users/avatar/' . $profile->id . '.gif';
             $profile->save();
             if (is_file(FILES_PATH . 'users' . DS . 'avatar' . DS . $profile->id . '.jpg')) {
                 unlink(FILES_PATH . 'users' . DS . 'avatar' . DS . $profile->id . '.jpg');
             }
             $form->continueLink = '../';
             $form->successMessage = _m(_m('Avatar is uploaded'));
             $form->confirmation = true;
             App::view()->hideuser = true;
         } else {
             $error[] = _m('Error uploading avatar');
         }
     } else {
         echo $error . ' <a href="../">' . _s('Back') . '</a>';
     }
 } else {
Example #28
0
 /**
  * Defines if the form has been submitted, and if so, return the action to perform (submitted or delete)
  *
  * @return mixed If the form is not submitted, this function will return FALSE.
  *               Else, the function will return 'register' or 'delete', depending on the user action
  */
 public function submitted()
 {
     if (App::request()->getMethod() == "delete") {
         return self::ACTION_DELETE;
     }
     $action = $this->method == 'get' ? App::request()->getParams('_submittedForm') : App::request()->getBody('_submittedForm');
     return $action ? $action : false;
 }
Example #29
0
<?php

use Config\System as Config;
$homeUrl = App::request()->getBaseUrl();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Config::$lng;
?>
">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes">
    <meta name="keywords" content="<?php 
echo htmlspecialchars(Config::$metaKey);
?>
"/>
    <meta name="description" content="<?php 
echo htmlspecialchars(Config::$metaDesc);
?>
"/>
    <meta name="HandheldFriendly" content="true"/>
    <meta name="MobileOptimized" content="width"/>
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <title><?php 
echo isset($this->pagetitle) ? $this->pagetitle : Config::$homeTitle;
?>
</title>
    <link rel="shortcut icon" href="<?php 
echo App::image('favicon.ico', [], false, false);
Example #30
-1
 /**
  * Display the list of the users
  */
 public function listUsers()
 {
     $example = array('id' => array('$ne' => User::GUEST_USER_ID));
     $filters = UserFilterWidget::getInstance()->getFilters();
     if (isset($filters['status']) && $filters['status'] != -1) {
         $example['active'] = $filters['status'];
     }
     $param = array('id' => 'admin-users-list', 'model' => 'User', 'action' => App::router()->getUri('list-users'), 'reference' => 'id', 'filter' => new DBExample($example), 'controls' => array(array('icon' => 'plus', 'label' => Lang::get($this->_plugin . '.new-user-btn'), 'class' => 'btn-success', 'href' => App::router()->getUri("edit-user", array('username' => '_new')), 'target' => 'dialog')), 'fields' => array('actions' => array('independant' => true, 'display' => function ($value, $field, $user) {
         $return = Icon::make(array('icon' => 'pencil', 'class' => 'text-primary', 'href' => App::router()->getUri('edit-user', array('username' => $user->username)), 'target' => 'dialog'));
         if ($user->isRemovable()) {
             $return .= Icon::make(array('icon' => 'close', 'class' => 'text-danger delete-user', 'data-user' => $user->username));
             $return .= $user->active ? Icon::make(array('icon' => 'lock', 'class' => 'text-warning lock-user', 'data-user' => $user->username)) : Icon::make(array('icon' => 'unlock', 'class' => 'text-success unlock-user', 'data-user' => $user->username));
         }
         return $return;
     }, 'search' => false, 'sort' => false), 'username' => array('label' => Lang::get($this->_plugin . '.users-list-username-label')), 'email' => array('label' => Lang::get($this->_plugin . '.users-list-email-label')), 'roleId' => array('label' => Lang::get($this->_plugin . '.users-list-roleId-label'), 'sort' => false, 'search' => array('type' => 'select', 'options' => call_user_func(function () {
         $options = array();
         foreach (Role::getAll('id', array('id')) as $id => $role) {
             $options[$id] = Lang::get('roles.role-' . $id . '-label');
         }
         return $options;
     }), 'invitation' => Lang::get($this->_plugin . '.user-filter-status-all')), 'display' => function ($value) {
         return Lang::get('roles.role-' . $value . '-label');
     }), 'active' => array('label' => Lang::get($this->_plugin . '.users-list-active-label'), 'search' => false, 'sort' => false, 'class' => function ($value) {
         return 'bold ' . ($value ? 'text-success' : 'text-danger');
     }, 'display' => function ($value) {
         return $value ? Lang::get($this->_plugin . '.users-list-active') : Lang::get($this->_plugin . '.users-list-inactive');
     }), 'createTime' => array('label' => Lang::get($this->_plugin . '.users-list-createTime-label'), 'search' => false, 'display' => function ($value) {
         return date(Lang::get('main.date-format'), $value);
     })));
     $list = new ItemList($param);
     if (App::request()->getParams('refresh')) {
         return $list->display();
     } else {
         $this->addKeysToJavaScript("admin.user-delete-confirmation");
         return View::make(Plugin::current()->getView("users-list.tpl"), array('list' => $list));
     }
 }