Пример #1
0
 public function __construct()
 {
     $fields = [form::create('field_string', 'username')->set_attr('label', 'Username'), form::create('field_password', 'password')->set_attr('label', 'Password')];
     parent::__construct($fields);
     $this->pre_fields_text = node::create('h2.form-signin-heading.text-center', [], node::create('small', [], 'Admin Login<br/>') . ini::get('site', 'title_tag'))->get();
     $this->submit = 'Login';
     $this->id = 'cms_login';
 }
Пример #2
0
 public function send()
 {
     $content = $this->do_replace($this->content);
     if (static::$sending_method == static::METHOD_SENDMAIL) {
         return mail(implode(',', $this->recipients['']), $this->do_replace($this->subject), $content);
     } else {
         if (static::$sending_method == static::METHOD_SES) {
             require_once root . '/library/aws.phar';
             $controller = new \Aws\Ses\SesClient(['version' => 'latest', 'profile' => _ini::get('aws', 'profile'), 'region' => _ini::get('aws', 'region', 'eu-west-1')]);
             return $controller->sendEmail(['Source' => _ini::get('email', 'from_address'), 'Destination' => ['ToAddresses' => $this->recipients[''], 'CcAddresses' => $this->recipients['cc'], 'BccAddresses' => $this->recipients['bcc']], 'Message' => ['Subject' => ['Data' => $this->subject, 'Charset' => 'UTF8'], 'Body' => ['Text' => ['Data' => '', 'Charset' => 'UTF8'], 'Html' => ['Data' => $content, 'Charset' => 'UTF8']]]]);
         }
     }
 }
Пример #3
0
 public function get_view()
 {
     try {
         ini::get('mysql', 'server');
     } catch (\Exception $e) {
         $form = new cms_builder_form();
         return $form->get_html();
     }
     $form = new cms_login_form();
     $form->wrapper_class[] = 'container';
     $form->wrapper_class[] = 'form-signin';
     return $form->get_html();
 }
Пример #4
0
 public function do_submit()
 {
     db::connect_root();
     db::query('CREATE DATABASE IF NOT EXISTS `' . get::fn($this->username) . '`');
     db::query('USE mysql');
     if (db::select('user')->retrieve(['user'])->filter(['`user`=:user AND `host`=:host'], ['user' => $this->username, 'host' => '127.0.0.1'])->execute()->rowCount()) {
         db::query('CREATE USER \'' . get::fn($this->username) . '\'@\'127.0.0.1\' IDENTIFIED BY \'' . $this->password . '\'', [], true);
     }
     if (db::select('user')->retrieve(['user'])->filter(['`user`=:user AND `host`=:host'], ['user' => $this->username, 'host' => 'localhost'])->execute()->rowCount()) {
         db::query('CREATE USER \'' . get::fn($this->username) . '\'@\'localhost\' IDENTIFIED BY \'' . $this->password . '\'', [], true);
     }
     db::query('GRANT ALL PRIVILEGES ON `' . get::fn($this->username) . '`.* TO \'' . get::fn($this->username) . '\'@\'127.0.0.1\'', [], true);
     db::query('GRANT ALL PRIVILEGES ON `' . get::fn($this->username) . '`.* TO \'' . get::fn($this->username) . '\'@\'localhost\'', [], true);
     if (!is_dir(root . '/.conf')) {
         mkdir(root . '/.conf');
     }
     ini::save(root . '/.conf/config.ini', ['mysql' => ['server' => '127.0.0.1', 'username' => get::fn($this->username), 'password' => $this->password, 'database' => get::fn($this->username)], 'site' => ['title_tag' => $this->site_name]]);
     ini::reload();
     db::default_connection();
     $cms_builder = new \module\cms\object\cms_builder();
     $cms_builder->manage();
     $i = 0;
     do {
         if ($this->{'user_' . $i} && $this->{'password_' . $i}) {
             $user = new _cms_user();
             $user->title = $this->{'user_' . $i};
             $user->password = $this->{'password_' . $i};
             $user->ulid = $this->{'user_level_' . $i} ?: 1;
         }
         $i++;
     } while (isset($this->{'user_' . $i}));
     ajax::current()->redirect = '/cms/login';
 }
Пример #5
0
 public function get_title_tag()
 {
     return ini::get('site', 'title_tag', 'NO Title tag!!!');
 }
Пример #6
0
define('root', $_SERVER['DOCUMENT_ROOT']);
define('core_dir', root . '/.core');
define('ajax', isset($_REQUEST['module']));
define('host', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'Unknown_Host');
define('uri', isset($_SERVER['REQUEST_URI']) ? trim($_SERVER['REQUEST_URI'], '/') : 'Unknown_URI');
define('ip', isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'Unknown_IP');
if (!class_exists('\\classes\\autoloader', false)) {
    require_once root . '/.core/classes/auto_loader.php';
    require_once root . '/.core/dependent/classes/auto_loader.php';
}
$auto_loader = new \classes\auto_loader();
set_error_handler(['\\classes\\error_handler', 'handle_error']);
register_shutdown_function(['\\classes\\error_handler', 'fatal_handler']);
define('dev', in_array(host, \classes\ini::get('domain', 'development', [])));
define('local', in_array(host, \classes\ini::get('domain', 'local', ['localhost'])));
define('debug', in_array(ip, \classes\ini::get('developers', 'ip', [])));
date_default_timezone_set(\classes\get::ini('zone', 'time', 'Europe/London'));
if (debug || dev) {
    error_reporting(-1);
    ini_set('display_errors', '1');
}
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
    define('ie', true);
    define('ie_ver', 0);
} else {
    define('ie', false);
    define('ie_ver', 0);
}
if (!defined('load_core') || load_core) {
    $core = new core();
}
Пример #7
0
 /**
  *
  */
 public function load_page()
 {
     $compiler = new compiler();
     $options = ['ajax' => ajax, 'admin' => core::is_admin(), "dev" => dev, "debug" => debug];
     try {
         $compiler_page = $compiler->load(uri, $options);
     } catch (\Exception $e) {
         if ($this->path) {
             if (!is_numeric($this->path[0])) {
                 $this->module_name = $this->path[0];
             } else {
                 $this->module_name = 'pages';
             }
         } else {
             $this->module_name = ini::get('site', 'default_module', 'pages');
         }
         $compiler_page = new compiler_page();
         if (class_exists('module\\' . $this->module_name . '\\controller')) {
             $class_name = 'module\\' . $this->module_name . '\\controller';
             $this->module = new $class_name();
             $this->module->__controller($this->path);
             $this->module->page = $this->pagination_page;
             if (!ajax) {
                 $compiler_page->content = $this->module->view_object->get_page();
             } else {
                 $compiler_page->content = $this->module->view_object->get();
                 $compiler_page->ajax = ajax::current();
             }
             $push_state = $this->module->get_push_state();
             if ($push_state) {
                 $push_state->data->actions = array_merge($push_state->data->actions, self::$push_state_ajax_calls);
             }
             $compiler_page->push_state = $push_state;
         }
         $compiler->save(uri, $compiler_page, $options);
     }
     if (!ajax) {
         if ($compiler_page->push_state) {
             $compiler_page->push_state->type = push_state::REPLACE;
             $compiler_page->push_state->get();
         }
         echo $compiler_page->content;
     } else {
         ajax::set_current($compiler_page->ajax);
         if ($compiler_page->push_state) {
             ajax::push_state($compiler_page->push_state);
         }
         $class = new \ReflectionClass('\\classes\\ajax');
         $function = $class->getMethod('inject');
         $function->invokeArgs(null, $compiler_page->content);
     }
 }
Пример #8
0
 /**
  * @param array $data associative array of key => value to be added the the cache table.
  * @param array $dependencies table dependencies.
  * @param int $cache_time Cache time in seconds, 0 for not breaking
  * @return bool returns true on successful add or false on failure.
  */
 public static function set(array $data, array $dependencies = ['global'], $cache_time = null)
 {
     if (self::$current == null) {
         try {
             self::connect(_ini::get('memcached', 'instance'), _ini::get('memcached', 'server'), _ini::get('memcached', 'port'));
         } catch (\Exception $e) {
             return;
             //trigger_error('Could not connect to memcached instance;' . $e->getMessage());
         }
     }
     if (is_null($cache_time)) {
         $cache_time = self::DEFAULT_CACHE_TIME;
     }
     foreach ($data as $key => $value) {
         $new_key = self::get_key($key, $dependencies);
         self::$current->set($new_key, $value, $cache_time);
     }
     return true;
 }