Ejemplo n.º 1
0
 /**
  * Create a form open tag
  *
  * @param   string|array  action string or array with more tag attribute settings
  * @return  string
  */
 public static function open($attributes = array(), array $hidden = array())
 {
     $attributes = !is_array($attributes) ? array('action' => $attributes) : $attributes;
     // If there is still no action set, Form-post
     if (!array_key_exists('action', $attributes) or $attributes['action'] === null) {
         $attributes['action'] = \Uri::main();
     } elseif (!strpos($attributes['action'], '://')) {
         $attributes['action'] = \Uri::create($attributes['action']);
     }
     if (empty($attributes['accept-charset'])) {
         $attributes['accept-charset'] = strtolower(\Fuel::$encoding);
     }
     // If method is empty, use POST
     !empty($attributes['method']) || ($attributes['method'] = \Config::get('form.form_method', 'post'));
     $form = '<form';
     foreach ($attributes as $prop => $value) {
         $form .= ' ' . $prop . '="' . $value . '"';
     }
     $form .= '>';
     // Add hidden fields when given
     foreach ($hidden as $field => $value) {
         $form .= PHP_EOL . static::hidden($field, $value);
     }
     return $form;
 }
Ejemplo n.º 2
0
 /**
  * @author NamNT
  * action index
  */
 public function action_index()
 {
     $model = new \Model_Person();
     $filter = array();
     $data = array();
     if (Input::get()) {
         $filter = Input::get();
         $query_string = http_build_query($filter);
         \Session::set('url_filter_persons', $query_string);
         $person_url = $query_string ? '?' . $query_string : '';
     } else {
         $person_url = '';
     }
     if (Input::get('export', false)) {
         $filter['per_page'] = 100000;
         $download_his = new \Model_Downloadhis();
         $download = array('param' => json_encode($filter), 'content' => json_encode(Input::server()));
         $download_his->set_data($download);
         if ($download_his->save_data()) {
             $this->export($model->get_filter_person($filter));
         }
     }
     $config = ['pagination_url' => \Uri::base() . 'job/persons/index' . $person_url, 'total_items' => $model->count_data($filter), 'per_page' => \Constants::$default_limit_pagination, 'uri_segment' => 'page', 'num_links' => \Constants::$default_num_links, 'show_last' => true];
     \Fuel\Core\Cookie::set('person_url', \Uri::main() . $person_url, 30 * 60);
     $pagination = \Uospagination::forge('mypagination', $config);
     $filter['offset'] = $pagination->offset;
     $filter['limit'] = $pagination->per_page;
     $data['listPerson'] = $model->get_filter_person($filter);
     $data['groups'] = (new \Model_Mgroups())->get_type(1);
     $this->template->title = 'UOS求人システム';
     $this->template->content = \View::forge('persons/persons', $data);
 }
Ejemplo n.º 3
0
 public function action_index()
 {
     if (!\DBUtil::table_exists('blog') && !\DBUtil::table_exists('blog_comment')) {
         \Response::redirect('blog/installrequired');
     }
     // list posts -----------------------------------------------------------------------------------------------------
     $option['limit'] = \Model_Config::getval('content_items_perpage');
     $option['offset'] = trim(\Input::get('page')) != null ? ((int) \Input::get('page') - 1) * $option['limit'] : 0;
     $list_items = \Blog\Model_Blog::listItems($option);
     // pagination config
     $config['pagination_url'] = \Uri::main() . \Uri::getCurrentQuerystrings(true, true, false);
     $config['total_items'] = $list_items['total'];
     $config['per_page'] = $option['limit'];
     $config['uri_segment'] = 'page';
     $config['num_links'] = 3;
     $config['show_first'] = true;
     $config['show_last'] = true;
     $config['first-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['first-inactive-link'] = '<a href="#">{page}</a>';
     $config['first-marker'] = '&laquo;';
     $config['last-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['last-inactive-link'] = '<a href="#">{page}</a>';
     $config['last-marker'] = '&raquo;';
     $config['previous-marker'] = '&lsaquo;';
     $config['next-marker'] = '&rsaquo;';
     $pagination = \Pagination::forge('viewlogins_pagination', $config);
     $output['list_items'] = $list_items;
     $output['pagination'] = $pagination;
     unset($config, $list_accounts, $option, $pagination);
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('blog'));
     // <head> output ----------------------------------------------------------------------------------------------
     return $this->generatePage('blog_v', $output, false);
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     parent::__construct();
     // validate admin logged in
     if (\Model_Accounts::isAdminLogin() == false) {
         \Response::redirect(\Uri::create('admin/login') . '?rdr=' . urlencode(\Uri::main()));
     }
     // load global admin language
     \Lang::load('admin');
 }
Ejemplo n.º 5
0
 public function action_index()
 {
     // log out.
     \Model_Accounts::logout();
     // go back
     if (\Input::referrer() != null && \Input::referrer() != \Uri::main()) {
         \Response::redirect(\Input::referrer());
     } else {
         \Response::redirect(\Uri::base());
     }
 }
 public function response()
 {
     $error_code = $this->getMessage();
     $error_list = Lang::load('error/user', $error_code);
     if (!isset($error_list[$error_code])) {
         $error_code = \Model_Error::ER00001;
     }
     $error_message = $error_list[$error_code];
     $params = array('error_code' => $error_code, 'error_message' => $error_message, 'line' => $this->getLine(), 'file' => $this->getFile(), 'url' => Uri::main(), 'input' => print_r(Input::all(), true), 'real_ip' => Input::real_ip(), 'user_agent' => Input::user_agent(), 'user_id' => Auth::get_user_id(), 'occurred_at' => date('Y/m/d H:i:s'));
     $email = new Model_Email();
     $email->sendMailByParams('error', $params);
     $response = \Request::forge('errors/index', false)->execute($params)->response();
     return $response;
 }
Ejemplo n.º 7
0
 /**
  * generate Fuel Start sortable link. it can generate any querystring url.
  *
  * @param array $sortable_data
  * @param array $except_querystring
  * @param string $link
  * @param string $link_text
  * @param array $attributes
  * @param boolean $secure
  * @return string
  */
 public static function fuelStartSortableLink(array $sortable_data = array(), array $except_querystring = array(), $link = null, $link_text = '', array $attributes = array(), $secure = null)
 {
     if ($link == null) {
         $link = \Uri::main();
     }
     if (!is_array($except_querystring)) {
         $except_querystring = array();
     }
     $querystring = array();
     // build querystring of sortable_data
     if (!empty($sortable_data) && is_array($sortable_data)) {
         foreach ($sortable_data as $name => $value) {
             if (!empty($name) || !empty($value)) {
                 $querystring_array[] = $name . '=' . $value;
                 $except_querystring = array_merge($except_querystring, array($name));
             }
         }
         unset($name, $value);
     }
     // build querystring of exists querystring except except_querystring
     $all_querystring = \Uri::getAllQuerystring(true);
     foreach ($all_querystring as $q_name => $q_value) {
         if (!empty($q_name) || !empty($q_value)) {
             if (!in_array(urldecode($q_name), $except_querystring)) {
                 $querystring_array[] = $q_name . '=' . $q_value;
             }
         }
     }
     // endforeach
     unset($all_querystring, $q_name, $q_value);
     if (isset($querystring_array)) {
         $querystring[1] = implode('&amp;', $querystring_array);
     }
     $querystring_str = implode('&amp;', $querystring);
     // if there is querystring. build it as string (name=val&amp;name2=val2...)
     if (!empty($querystring)) {
         $link .= '?' . $querystring_str;
         unset($i, $key, $querystring, $querystring_str, $value);
     }
     // add sorted icons.
     if (isset($sortable_data['orders']) && $sortable_data['orders'] == \Input::get('orders')) {
         if (strtoupper(\Input::get('sort')) == 'ASC') {
             $link_text .= ' <span class="glyphicon glyphicon-sort-by-attributes"></span>';
         } elseif (strtoupper(\Input::get('sort')) == 'DESC') {
             $link_text .= ' <span class="glyphicon glyphicon-sort-by-attributes-alt"></span>';
         }
     }
     return \Html::anchor($link, $link_text, $attributes, $secure);
 }
Ejemplo n.º 8
0
 /**
  * get and set submit redirection url
  * 
  * @return string
  */
 private function getAndSetSubmitRedirection()
 {
     $session = \Session::forge();
     if ($session->get('submitted_redirect') == null) {
         if (\Input::referrer() != null && \Input::referrer() != \Uri::main()) {
             $session->set('submitted_redirect', \Input::referrer());
             return \Input::referrer();
         } else {
             $redirect_uri = 'dbhelper/admin';
             $session->set('submitted_redirect', $redirect_uri);
             return $redirect_uri;
         }
     } else {
         return $session->get('submitted_redirect');
     }
 }
Ejemplo n.º 9
0
" class="btn btn-default btn-sm"><?php 
echo __('account_forgot_username_or_password');
?>
</a>
            </div>
        </div>
    <?php 
echo \Form::close();
?>
 
    
    <hr />
    <h2>Ajax form</h2>
    
    <?php 
echo \Form::open(array('action' => \Uri::main() . (isset($go_to) ? '?rdr=' . $go_to : ''), 'class' => 'form-horizontal ajax-member-login', 'role' => 'form'));
?>
 
        <div class="form-status-placeholder">
            <?php 
if (isset($form_status) && isset($form_status_message)) {
    ?>
 
            <div class="alert alert-<?php 
    echo str_replace('error', 'danger', $form_status);
    ?>
"><button type="button" class="close" data-dismiss="alert">&times;</button><?php 
    echo $form_status_message;
    ?>
</div>
            <?php 
Ejemplo n.º 10
0
 public function action_accountMultisite()
 {
     $act = trim(\Input::post('act'));
     $output = [];
     if (strtolower(\Fuel\Core\Input::method()) == 'post') {
         if ($act == 'createmaintable') {
             $create_table = \Fuel\Core\DBUtil::create_table('testmultisiteaccount', ['id' => ['constraint' => 11, 'type' => 'int', 'auto_increment' => true], 'account_id' => ['constraint' => 11, 'type' => 'int', 'null' => true, 'comment' => 'refer to accounts.account_id'], 'actdate' => ['type' => 'bigint', 'null' => true, 'comment' => 'date/time of record date.']], ['id'], true);
             $output['create_table_result'] = $create_table;
             $output['result'] = true;
         } elseif ($act == 'insertdemodata') {
             // get accounts that is not guest
             $account_result = \DB::select('account_id')->as_object()->from('accounts')->where('account_id', '!=', '0')->execute();
             // get all sites from site table
             $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute();
             $output['tables_data'] = [];
             if ($sites_result != null) {
                 foreach ($sites_result as $site) {
                     if ($site->site_id == '1') {
                         $test_table = 'testmultisiteaccount';
                     } else {
                         $test_table = $site->site_id . '_testmultisiteaccount';
                     }
                     if (\DBUtil::table_exists($test_table)) {
                         \DBUtil::truncate_table($test_table);
                         if ($account_result != null) {
                             foreach ($account_result as $account) {
                                 \DB::insert($test_table)->set(['account_id' => $account->account_id, 'actdate' => time()])->execute();
                             }
                             // endforeach; $account_result
                         }
                         // endif; $account_result
                         // finished insert get data from this table.
                         $this_table_result = \DB::select()->as_object('stdClass')->from($test_table)->limit(10)->order_by('id', 'DESC')->execute()->as_array();
                         $output['tables_data'][$test_table] = $this_table_result;
                         unset($this_table_result);
                     }
                     unset($test_table);
                 }
                 // endforeach; $sites_result
                 $output['result'] = true;
             }
             // endif; $sites_result
             unset($account, $account_result, $site, $sites_result);
         } elseif ($act == 'loaddemodata') {
             // get all sites from site table
             $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute();
             $output['tables_data'] = [];
             if ($sites_result != null) {
                 foreach ($sites_result as $site) {
                     if ($site->site_id == '1') {
                         $test_table = 'testmultisiteaccount';
                     } else {
                         $test_table = $site->site_id . '_testmultisiteaccount';
                     }
                     if (\DBUtil::table_exists($test_table)) {
                         $this_table_result = \DB::select()->as_object('stdClass')->from($test_table)->limit(10)->order_by('id', 'DESC')->execute()->as_array();
                         $output['tables_data'][$test_table] = $this_table_result;
                         unset($this_table_result);
                     }
                 }
                 // endforeach; $sites_result
                 $output['result'] = true;
             }
             // endif; $sites_result
             unset($site, $sites_result);
         } elseif ($act == 'droptable') {
             // get all sites from site table
             $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute();
             if ($sites_result != null) {
                 foreach ($sites_result as $site) {
                     if ($site->site_id == '1') {
                         $test_table = 'testmultisiteaccount';
                     } else {
                         $test_table = $site->site_id . '_testmultisiteaccount';
                     }
                     if (\DBUtil::table_exists($test_table)) {
                         \DBUtil::drop_table($test_table);
                     }
                 }
                 // endforeach; $sites_result
                 $output['result'] = true;
             }
             // endif; $sites_result
             unset($site, $sites_result);
         }
         // endif; $act
         if (\Input::is_ajax()) {
             $response = new \Response();
             // no cache
             $response->set_header('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
             $response->set_header('Cache-Control', 'post-check=0, pre-check=0', false);
             $response->set_header('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT');
             $response->set_header('Pragma', 'no-cache');
             // content type
             $response->set_header('Content-Type', 'application/json');
             // set body
             if ($output == null) {
                 $output = [];
             }
             $response->body(json_encode($output));
             return $response;
         }
     }
     // <head> output -------------------------------------------
     $output['page_title'] = $this->generateTitle('Test module plugin');
     // <head> output -------------------------------------------
     // breadcrumb -------------------------------------------------------------------------------------------------
     $page_breadcrumb = [];
     $page_breadcrumb[0] = ['name' => \Lang::get('admin_admin_home'), 'url' => \Uri::create('admin')];
     $page_breadcrumb[1] = ['name' => 'Test module plugin', 'url' => \Uri::create('testmod/admin/index')];
     $page_breadcrumb[2] = ['name' => 'Test delete account on multisite table', 'url' => \Uri::main()];
     $output['page_breadcrumb'] = $page_breadcrumb;
     unset($page_breadcrumb);
     // breadcrumb -------------------------------------------------------------------------------------------------
     return $this->generatePage('admin/templates/index/accountMultisite_v', $output, false);
 }
Ejemplo n.º 11
0
<article class="general-page-container">
    <h1><?php 
echo __('account_confirm_change_email');
?>
</h1>
    
    <?php 
echo \Form::open(array('action' => \Uri::main(), 'class' => 'form-horizontal', 'role' => 'form'));
?>
 
        <div class="form-status-placeholder">
            <?php 
if (isset($form_status) && isset($form_status_message)) {
    ?>
 
            <div class="alert alert-<?php 
    echo str_replace('error', 'danger', $form_status);
    ?>
"><button type="button" class="close" data-dismiss="alert">&times;</button><?php 
    echo $form_status_message;
    ?>
</div>
            <?php 
}
?>
 
        </div>
        <?php 
echo \Extension\NoCsrf::generate();
?>
 
Ejemplo n.º 12
0
 /**
  * Generate a pagination link
  */
 protected function _make_link($page)
 {
     // make sure we have a valid page number
     empty($page) and $page = 1;
     // construct a pagination url if we don't have one
     if (is_null($this->config['pagination_url'])) {
         // start with the main uri
         $this->config['pagination_url'] = \Uri::main();
         \Input::get() and $this->config['pagination_url'] .= '?' . http_build_query(\Input::get());
     }
     // was a placeholder defined in the url?
     if (strpos($this->config['pagination_url'], '{page}') === false) {
         // break the url in bits so we can insert it
         $url = parse_url($this->config['pagination_url']);
         // parse the query string
         if (isset($url['query'])) {
             parse_str($url['query'], $url['query']);
         } else {
             $url['query'] = array();
         }
         // do we have a segment offset due to the base_url containing segments?
         $seg_offset = parse_url(rtrim(\Uri::base(), '/'));
         $seg_offset = empty($seg_offset['path']) ? 0 : count(explode('/', trim($seg_offset['path'], '/')));
         // is the page number a URI segment?
         if (is_numeric($this->config['uri_segment'])) {
             // get the URL segments
             $segs = isset($url['path']) ? explode('/', trim($url['path'], '/')) : array();
             // do we have enough segments to insert? we can't fill in any blanks...
             if (count($segs) < $this->config['uri_segment'] - 1) {
                 throw new \RuntimeException("Not enough segments in the URI, impossible to insert the page number");
             }
             // replace the selected segment with the page placeholder
             $segs[$this->config['uri_segment'] - 1 + $seg_offset] = '{page}';
             $url['path'] = '/' . implode('/', $segs);
         } else {
             // add our placeholder
             $url['query'][$this->config['uri_segment']] = '{page}';
         }
         // re-assemble the url
         $query = empty($url['query']) ? '' : '?' . preg_replace('/%7Bpage%7D/', '{page}', http_build_query($url['query']));
         unset($url['query']);
         empty($url['scheme']) or $url['scheme'] .= '://';
         empty($url['port']) or $url['host'] .= ':';
         $this->config['pagination_url'] = implode($url) . $query;
     }
     // return the page link
     return str_replace('{page}', $page, $this->config['pagination_url']);
 }
Ejemplo n.º 13
0
 public function action_index()
 {
     // load language
     \Lang::load('account');
     // is user logged in?
     if (\Model_Accounts::isMemberLogin() == false) {
         \Response::redirect(\Uri::create('account/login') . '?rdr=' . urlencode(\Uri::main()));
     }
     // load config from db.
     $cfg_values = array('allow_avatar', 'avatar_size', 'avatar_allowed_types');
     $config = \Model_Config::getvalues($cfg_values);
     $output['config'] = $config;
     // set config data to display in view file.
     $output['allow_avatar'] = $config['allow_avatar']['value'];
     $output['avatar_size'] = $config['avatar_size']['value'];
     $output['avatar_allowed_types'] = $config['avatar_allowed_types']['value'];
     unset($cfg_values);
     // read flash message for display errors. this is REQUIRED if you coding the check login with simultaneous login detection on.
     $form_status = \Session::get_flash('form_status');
     if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
         $output['form_status'] = $form_status['form_status'];
         $output['form_status_message'] = $form_status['form_status_message'];
     }
     unset($form_status);
     // get account id
     $cookie_account = \Model_Accounts::forge()->getAccountCookie();
     // get account data
     $query = \Model_Accounts::query()->where('account_id', $cookie_account['account_id'])->where('account_username', $cookie_account['account_username'])->where('account_email', $cookie_account['account_email']);
     if ($query->count() > 0) {
         // found
         $row = $query->get_one();
         $output['row'] = $row;
         // loop set data for display in form.
         foreach ($row as $key => $field) {
             $output[$key] = $field;
         }
         // get account_fields data of current user and send to views form
         // to access data from view, use $account_field['field_name']. for example: the field_name is phone, just use $account_field['phone'];
         $account_fields = \Model_AccountFields::getData($cookie_account['account_id']);
         if ($account_fields->count() > 0) {
             foreach ($account_fields as $af) {
                 $output['account_field'][$af->field_name] = \Extension\Str::isJsonFormat($af->field_value) ? json_decode($af->field_value, true) : $af->field_value;
             }
         }
         unset($account_fields, $af);
         // get timezone list to display.
         \Config::load('timezone', 'timezone');
         $output['timezone_list'] = \Config::get('timezone.timezone', array());
         unset($query);
     } else {
         // not found account.
         unset($cookie_account, $query);
         \Model_Accounts::logout();
         \Response::redirect(\Uri::create('account/login') . '?rdr=' . urlencode(\Uri::main()));
     }
     // if form submitted
     if (\Input::method() == 'POST') {
         // store data for save to db.
         $data['account_id'] = $cookie_account['account_id'];
         $data['account_username'] = $cookie_account['account_username'];
         //trim(\Input::post('account_username'));//no, do not edit username.
         $data['account_old_email'] = $cookie_account['account_email'];
         $data['account_email'] = \Security::strip_tags(trim(\Input::post('account_email')));
         $data['account_password'] = trim(\Input::post('account_password'));
         $data['account_new_password'] = trim(\Input::post('account_new_password'));
         $data['account_display_name'] = \Security::htmlentities(\Input::post('account_display_name'));
         $data['account_firstname'] = \Security::htmlentities(trim(\Input::post('account_firstname', null)));
         if ($data['account_firstname'] == null) {
             $data['account_firstname'] = null;
         }
         $data['account_middlename'] = \Security::htmlentities(trim(\Input::post('account_middlename', null)));
         if ($data['account_middlename'] == null) {
             $data['account_middlename'] = null;
         }
         $data['account_lastname'] = \Security::htmlentities(trim(\Input::post('account_lastname', null)));
         if ($data['account_lastname'] == null) {
             $data['account_lastname'] = null;
         }
         $data['account_birthdate'] = \Security::strip_tags(trim(\Input::post('account_birthdate', null)));
         if ($data['account_birthdate'] == null) {
             $data['account_birthdate'] = null;
         }
         $data['account_signature'] = \Security::htmlentities(trim(\Input::post('account_signature', null)));
         if ($data['account_signature'] == null) {
             $data['account_signature'] = null;
         }
         $data['account_timezone'] = \Security::strip_tags(trim(\Input::post('account_timezone')));
         $data['account_language'] = \Security::strip_tags(trim(\Input::post('account_language', null)));
         if ($data['account_language'] == null) {
             $data['account_language'] = null;
         }
         // store data for account_fields
         $data_field = array();
         if (is_array(\Input::post('account_field'))) {
             foreach (\Input::post('account_field') as $field_name => $field_value) {
                 if (is_string($field_name)) {
                     if (is_array($field_value)) {
                         $field_value = json_encode($field_value);
                     }
                     $data_field[$field_name] = $field_value;
                 }
             }
         }
         unset($field_name, $field_value);
         // validate form.
         $validate = \Validation::forge();
         $validate->add_callable(new \Extension\FsValidate());
         //$validate->add('account_username', \Lang::get('account_username'), array(), array('required', 'noSpaceBetweenText'));//no, do not edit username.
         $validate->add('account_email', \Lang::get('account_email'), array(), array('required', 'valid_email'));
         $validate->add('account_display_name', \Lang::get('account_display_name'), array(), array('required'));
         $validate->add('account_birthdate', \Lang::get('account_birthdate'))->add_rule('valid_date', 'Y-m-d');
         $validate->add('account_timezone', \Lang::get('account_timezone'), array(), array('required'));
         if (!\Extension\NoCsrf::check()) {
             // validate token failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('fslang_invalid_csrf_token');
         } elseif (!$validate->run()) {
             // validate failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = $validate->show_errors();
         } else {
             // save
             $result = \Model_accounts::memberEditProfile($data, $data_field);
             if ($result === true) {
                 if (\Session::get_flash('form_status', null, false) == null) {
                     \Session::set_flash('form_status', array('form_status' => 'success', 'form_status_message' => \Lang::get('account_saved')));
                 }
                 \Response::redirect(\Uri::main());
             } else {
                 $output['form_status'] = 'error';
                 $output['form_status_message'] = $result;
             }
         }
         // re-populate form
         //$output['account_username'] = trim(\Input::post('account_username'));//no, do not edit username.
         $output['account_email'] = trim(\Input::post('account_email'));
         $output['account_display_name'] = trim(\Input::post('account_display_name'));
         $output['account_firstname'] = trim(\Input::post('account_firstname'));
         $output['account_middlename'] = trim(\Input::post('account_middlename'));
         $output['account_lastname'] = trim(\Input::post('account_lastname'));
         $output['account_birthdate'] = trim(\Input::post('account_birthdate'));
         $output['account_signature'] = trim(\Input::post('account_signature'));
         $output['account_timezone'] = trim(\Input::post('account_timezone'));
         $output['account_language'] = trim(\Input::post('account_language'));
         // re-populate form for account fields
         if (is_array(\Input::post('account_field'))) {
             foreach (\Input::post('account_field') as $field_name => $field_value) {
                 if (is_string($field_name)) {
                     $output['account_field'][$field_name] = $field_value;
                 }
             }
         }
         unset($field_name, $field_value);
     }
     // clear variables
     unset($cookie_account, $data, $result);
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('account_edit'));
     // <head> output ----------------------------------------------------------------------------------------------
     return $this->generatePage('front/templates/account/edit_v', $output, false);
 }
Ejemplo n.º 14
0
 public function action_index()
 {
     // load language
     \Lang::load('admin');
     \Lang::load('account');
     // load config from db.
     $cfg_values = array('member_max_login_fail', 'member_login_fail_wait_time');
     $config = Model_Config::getvalues($cfg_values);
     $output['config'] = $config;
     unset($cfg_values);
     // set active theme for admin. this controller is not based on admin controller, then it is require to set to admin theme.
     $theme = \Theme::instance();
     $theme->active($this->theme_system_name);
     // set login redirect
     if (\Input::get('rdr') != null) {
         $output['go_to'] = urlencode(\Input::get('rdr'));
     } else {
         $output['go_to'] = urlencode(\Uri::create('admin'));
     }
     // read flash message for display errors. this is REQUIRED if you coding the check login with simultaneous login detection on.
     // this is REQUIRED in login page. because failed 'is login' check will redirect to here.
     $form_status = \Session::get_flash('form_status');
     if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
         $output['form_status'] = $form_status['form_status'];
         $output['form_status_message'] = $form_status['form_status_message'];
     }
     unset($form_status);
     // count login fail and show captcha.
     if (\Session::get('login_all_fail_count', '0') >= $this->login_fail_time_show_captcha || \Session::get('show_captcha', false) === true) {
         $output['show_captcha'] = true;
         // if last time login failed is over wait time, reset it
         if ((time() - \Session::get('login_all_fail_time', time())) / 60 > $config['member_login_fail_wait_time']['value']) {
             // reset captcha requirement and wait time.
             \Session::set('login_all_fail_count', \Session::get('login_all_fail_count') - ($this->login_fail_time_show_captcha + 1));
             // do not reset this, just reduce to fail time show captcha+1. doing this to prevent brute force attack.
             \Session::delete('login_all_fail_time');
             \Session::delete('show_captcha');
         }
     }
     // browser check
     $output['browser_check'] = $this->browserCheck();
     // if form submitted --------------------------------------------------------------------------------------------
     if (\Input::method() == 'POST') {
         // store data for login
         $data['account_identity'] = trim(\Input::post('account_identity'));
         if (strpos($data['account_identity'], '@') === false) {
             $data['account_username'] = $data['account_identity'];
         } else {
             $data['account_email'] = $data['account_identity'];
         }
         $data['account_password'] = trim(\Input::post('account_password'));
         // validate form.
         $validate = \Validation::forge();
         // check username or email required
         $validate->add('account_identity', \Lang::get('account_username_or_email'), array(), array('required'));
         $validate->add('account_password', \Lang::get('account_password'), array(), array('required'));
         if (!\Extension\NoCsrf::check()) {
             // validate token failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('fslang_invalid_csrf_token');
             $output['input_csrf_token'] = \Extension\NoCsrf::generate();
         } elseif (!$validate->run()) {
             // validate failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = $validate->show_errors();
             if (\Input::is_ajax()) {
                 $response = new \Response();
                 $response->set_header('Content-Type', 'application/json');
                 $response->body(json_encode($output));
                 return $response;
             }
         } else {
             // count login failed and wait if it was exceed max failed allowed.
             if (\Session::get('login_all_fail_count', '0') > $config['member_max_login_fail']['value'] && (time() - \Session::get('login_all_fail_time', time())) / 60 <= $config['member_login_fail_wait_time']['value']) {
                 // continuous login failed over max fail limit.
                 $result = Lang::get('account_login_failed_too_many', array('wait_minute' => $config['member_login_fail_wait_time']['value'], 'wait_til_time' => date('d F Y H:i:s', time() + $config['member_login_fail_wait_time']['value'] * 60)));
             } else {
                 // not reach maximum limit
                 // check if show captcha
                 if (isset($output['show_captcha']) && $output['show_captcha'] === true) {
                     include APPPATH . 'vendor' . DS . 'securimage' . DS . 'securimage.php';
                     $securimage = new \Securimage();
                     if ($securimage->check(\Input::post('captcha')) == false) {
                         $result = \Lang::get('account_wrong_captcha_code');
                     }
                 }
                 // try to login. ---------------------------------------------
                 if (!isset($result) || isset($result) && $result == null) {
                     $result = \Model_Accounts::adminLogin($data);
                 }
             }
             // check login result ----------------------------------------------
             if ($result === true) {
                 // success
                 $all_fail_count = 0;
                 \Session::delete('login_all_fail_count');
                 \Session::delete('login_all_fail_time');
                 \Session::delete('show_captcha');
                 if (\Input::is_ajax()) {
                     $output['login_status'] = true;
                     $output['form_status'] = 'success';
                     $output['form_status_message'] = \Lang::get('account_login_success');
                     if (!isset($output['go_to'])) {
                         $output['go_to'] = \Uri::main();
                     } else {
                         $output['go_to'] = urldecode($output['go_to']);
                     }
                     $response = new \Response();
                     $response->set_header('Content-Type', 'application/json');
                     $response->body(json_encode($output));
                     return $response;
                 } else {
                     if (isset($output['go_to'])) {
                         \Response::redirect(urldecode($output['go_to']));
                     } else {
                         \Response::redirect(\Uri::base());
                     }
                 }
             } else {
                 // failed
                 $all_fail_count = \Session::get('login_all_fail_count', '0') + 1;
                 \Session::set('login_all_fail_count', $all_fail_count);
                 \Session::set('login_all_fail_time', time());
                 // if login fail count more than or equal to fail time show captcha
                 if ($all_fail_count >= $this->login_fail_time_show_captcha) {
                     $output['show_captcha'] = true;
                     \Session::set('show_captcha', true);
                 }
                 $output['form_status'] = 'error';
                 $output['form_status_message'] = $result;
                 if (\Input::is_ajax()) {
                     $response = new \Response();
                     $response->set_header('Content-Type', 'application/json');
                     $response->body(json_encode($output));
                     return $response;
                 }
             }
         }
         // re-populate form
         $output['account_identity'] = $data['account_identity'];
     }
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('account_login'));
     $output['page_meta'][] = '<meta name="robots" content="noindex, nofollow" />';
     // <head> output ----------------------------------------------------------------------------------------------
     // breadcrumb -------------------------------------------------------------------------------------------------
     $page_breadcrumb = [];
     $page_breadcrumb[0] = ['name' => \Lang::get('admin_admin_home'), 'url' => \Uri::create('admin')];
     $page_breadcrumb[1] = ['name' => \Lang::get('account_login'), 'url' => \Uri::create('admin/login')];
     $output['page_breadcrumb'] = $page_breadcrumb;
     unset($page_breadcrumb);
     // breadcrumb -------------------------------------------------------------------------------------------------
     if (\Input::is_ajax()) {
         $response = new \Response();
         $response->set_header('Content-Type', 'application/json');
         $response->body(json_encode($output));
         return $response;
     } else {
         return $theme->view('admin/templates/login/index_v', $output, false);
     }
 }
Ejemplo n.º 15
0
 /**
  * リンク生成
  * 
  * Paginationクラスからの改変はコメント部分の一行のみ
  * 
  *  @param int     $page Paginationのページ番号
  *  @return string       URL
  */
 protected function _make_link($page)
 {
     empty($page) and $page = 1;
     if (is_null($this->config['pagination_url'])) {
         $this->config['pagination_url'] = \Uri::main();
         // <<< GET変数の引き継ぎに関するここの一行を削除 >>>
     }
     if (strpos($this->config['pagination_url'], '{page}') === false) {
         $url = parse_url($this->config['pagination_url']);
         if (isset($url['query'])) {
             parse_str($url['query'], $url['query']);
         } else {
             $url['query'] = array();
         }
         $seg_offset = parse_url(rtrim(\Uri::base(), '/'));
         $seg_offset = empty($seg_offset['path']) ? 0 : count(explode('/', trim($seg_offset['path'], '/')));
         if (is_numeric($this->config['uri_segment'])) {
             $segs = isset($url['path']) ? explode('/', trim($url['path'], '/')) : array();
             if (count($segs) < $this->config['uri_segment'] - 1) {
                 throw new \RuntimeException("Not enough segments in the URI, impossible to insert the page number");
             }
             $segs[$this->config['uri_segment'] - 1 + $seg_offset] = '{page}';
             $url['path'] = '/' . implode('/', $segs);
         } else {
             $url['query'][$this->config['uri_segment']] = '{page}';
         }
         $query = empty($url['query']) ? '' : '?' . preg_replace('/%7Bpage%7D/', '{page}', http_build_query($url['query'], '', '&amp;'));
         unset($url['query']);
         empty($url['scheme']) or $url['scheme'] .= '://';
         empty($url['port']) or $url['host'] .= ':';
         $this->config['pagination_url'] = implode($url) . $query;
     }
     return str_replace('{page}', $page, $this->config['pagination_url']);
 }
Ejemplo n.º 16
0
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<?php 
echo Asset::js(array('http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js', 'bootstrap.js', 'responsive-tables.js'));
?>

<link rel="shortcut icon" href="/favicon.ico">
<link rel="canonical" href="<?php 
echo Uri::main();
?>
">
<link rel="alternate" media="handheld" href="<?php 
echo Uri::main();
?>
" />
<script type="text/javascript">
$(function(){
  $('.dropdown-toggle').dropdown();
  $('.datepicker').datepicker();
});
</script>

<meta property="og:title" content="僕のログブック<?php 
echo $title;
?>
">
<meta property="og:type" content="article">
<meta property="og:url" content="<?php 
Ejemplo n.º 17
0
 public function action_index()
 {
     // is user logged in?
     if (\Model_Accounts::isMemberLogin() == false) {
         \Response::redirect(\Uri::create('account/login') . '?rdr=' . urlencode(\Uri::main()));
     }
     // load language
     \Lang::load('account');
     \Lang::load('accountlogins');
     // get account id
     $cookie_account = \Model_Accounts::forge()->getAccountCookie();
     // get account data
     $row = \Model_Accounts::find($cookie_account['account_id']);
     if ($row == null) {
         // not found user data.
         unset($row);
         \Response::redirect(\Uri::main());
     }
     $output['account'] = $row;
     // set sort variable for sortable in views.
     $next_sort = \Security::strip_tags(trim(\Input::get('sort')));
     if ($next_sort == null || $next_sort == 'DESC') {
         $next_sort = 'ASC';
     } else {
         $next_sort = 'DESC';
     }
     $output['next_sort'] = $next_sort;
     unset($next_sort);
     // list logins -----------------------------------------------------------------------------------------------------
     $option['limit'] = \Model_Config::getval('content_items_perpage');
     $option['offset'] = trim(\Input::get('page')) != null ? ((int) \Input::get('page') - 1) * $option['limit'] : 0;
     if (\Security::strip_tags(trim(\Input::get('orders'))) != null) {
         $option['orders'] = \Security::strip_tags(trim(\Input::get('orders')));
     }
     if (\Security::strip_tags(trim(\Input::get('sort'))) != null) {
         $option['sort'] = \Security::strip_tags(trim(\Input::get('sort')));
     }
     $data['account_id'] = $cookie_account['account_id'];
     $data['site_id'] = \Model_Sites::getSiteId();
     $list_logins = \Model_AccountLogins::listLogins($data, $option);
     // pagination config
     $config['pagination_url'] = \Uri::main() . \Uri::getCurrentQuerystrings(true, true, false);
     $config['total_items'] = $list_logins['total'];
     $config['per_page'] = $option['limit'];
     $config['uri_segment'] = 'page';
     $config['num_links'] = 3;
     $config['show_first'] = true;
     $config['show_last'] = true;
     $config['first-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['first-inactive-link'] = '<a href="#">{page}</a>';
     $config['first-marker'] = '&laquo;';
     $config['last-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['last-inactive-link'] = '<a href="#">{page}</a>';
     $config['last-marker'] = '&raquo;';
     $config['previous-marker'] = '&lsaquo;';
     $config['next-marker'] = '&rsaquo;';
     $pagination = \Pagination::forge('viewlogins_pagination', $config);
     $output['list_logins'] = $list_logins;
     $output['pagination'] = $pagination;
     unset($config, $data, $list_logins, $option, $pagination);
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('account_login_history'));
     // <head> output ----------------------------------------------------------------------------------------------
     return $this->generatePage('front/templates/account/viewlogins_v', $output, false);
 }
Ejemplo n.º 18
0
 public function action_multiple()
 {
     $ids = \Input::post('id');
     $act = trim(\Input::post('act'));
     if (\Extension\NoCsrf::check()) {
         if ($act == 'del') {
             // check permission.
             if (\Model_AccountLevelPermission::checkAdminPermission('blog_perm', 'blog_manage_perm') == false) {
                 \Response::redirect(\Uri::create('admin'));
             }
             if (is_array($ids)) {
                 foreach ($ids as $id) {
                     \Blog\Model_Blog::find($id)->delete();
                 }
             }
         }
     }
     // go back
     if (\Input::referrer() != null && \Input::referrer() != \Uri::main()) {
         \Response::redirect(\Input::referrer());
     } else {
         \Response::redirect('blog/admin');
     }
 }
Ejemplo n.º 19
0
 /**
  * Generate values for the "properties" key for the page() method.
  * 
  * @return array The array of data for the "properties" key.
  */
 private function _get_page_properties()
 {
     $properties_data['properties'] = array('url' => \Uri::base() . 'SEGMENT_PACKAGE_NO_URL_SET', 'referrer' => \Input::referrer(), 'path' => '/' . \Uri::string());
     /*
      * Fix: When \Request::main() is false, \Uri::main() tryies to get a property of the non-object
      * \Request::main().
      */
     if (\Request::main() instanceof \Request) {
         $properties_data['properties']['url'] = \Uri::main();
     }
     return $properties_data;
 }
Ejemplo n.º 20
0
 public function action_index()
 {
     // check permission
     if (\Model_AccountLevelPermission::checkAdminPermission('config_global', 'config_global') == false) {
         \Session::set_flash('form_status', array('form_status' => 'error', 'form_status_message' => \Lang::get('admin_permission_denied', array('page' => \Uri::string()))));
         \Response::redirect(\Uri::create('admin'));
     }
     // get timezone list for select box
     \Config::load('timezone', 'timezone');
     $output['timezone_list'] = \Config::get('timezone.timezone', array());
     // read flash message for display errors.
     $form_status = \Session::get_flash('form_status');
     if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
         $output['form_status'] = $form_status['form_status'];
         $output['form_status_message'] = $form_status['form_status_message'];
     }
     unset($form_status);
     $allowed_field = array();
     // load config to form.
     $result = \DB::select('*')->from(\Model_Config::getTableName())->as_object('Model_Config')->where('config_core', '1')->execute();
     if ((is_array($result) || is_object($result)) && !empty($result)) {
         foreach ($result as $row) {
             $allowed_field[] = $row->config_name;
             $output[$row->config_name] = $row->config_value;
         }
     }
     unset($result, $row);
     // if form submitted
     if (\Input::method() == 'POST') {
         // store data to variable for update to db.
         $data = array();
         foreach (\Input::post() as $key => $value) {
             if (in_array($key, $allowed_field)) {
                 $data[$key] = $value;
             }
         }
         unset($allowed_field);
         // check again for some required default value config data.
         // tab website
         $data['site_name'] = \Security::htmlentities($data['site_name']);
         $data['page_title_separator'] = \Security::htmlentities($data['page_title_separator']);
         // tab account
         if (!isset($data['member_allow_register']) || $data['member_allow_register'] != '1') {
             $data['member_allow_register'] = '0';
         }
         if (!isset($data['member_register_notify_admin']) || $data['member_register_notify_admin'] != '1') {
             $data['member_register_notify_admin'] = '0';
         }
         if (!isset($data['simultaneous_login']) || $data['simultaneous_login'] != '1') {
             $data['simultaneous_login'] = '******';
         }
         if (!is_numeric($data['member_max_login_fail'])) {
             $data['member_max_login_fail'] = '10';
         }
         if (!is_numeric($data['member_login_fail_wait_time'])) {
             $data['member_login_fail_wait_time'] = '30';
         }
         if (!is_numeric($data['member_login_remember_length'])) {
             $data['member_login_remember_length'] = '30';
         }
         if (!is_numeric($data['member_confirm_wait_time'])) {
             $data['member_confirm_wait_time'] = '10';
         }
         if (!isset($data['member_email_change_need_confirm']) || $data['member_email_change_need_confirm'] != '1') {
             $data['member_email_change_need_confirm'] = '0';
         }
         if (!isset($data['allow_avatar']) || $data['allow_avatar'] != '1') {
             $data['allow_avatar'] = '0';
         }
         if (!is_numeric($data['avatar_size'])) {
             $data['avatar_size'] = '200';
         }
         if (empty($data['avatar_allowed_types'])) {
             $data['avatar_allowed_types'] = 'jpg|jpeg';
         }
         if ($data['avatar_path'] == null) {
             unset($data['avatar_path']);
         }
         // tab email
         if ($data['mail_protocol'] == null) {
             $data['mail_protocol'] = 'mail';
         }
         if (!is_numeric($data['mail_smtp_port'])) {
             $data['mail_smtp_port'] = '0';
         }
         // tab content
         if (!is_numeric($data['content_items_perpage'])) {
             $data['content_items_perpage'] = '10';
         }
         if (!is_numeric($data['content_admin_items_perpage'])) {
             $data['content_admin_items_perpage'] = '10';
         }
         // tab media
         if (empty($data['media_allowed_types'])) {
             $data['media_allowed_types'] = 'avi|doc|docx|flv|gif|jpeg|jpg|mid|midi|mov|mp3|mpeg|mpg|pdf|png|swf|xls|xlsx|zip';
         }
         // tab ftp
         if (!is_numeric($data['ftp_port'])) {
             $data['ftp_port'] = '21';
         }
         if (!isset($data['ftp_passive']) || $data['ftp_passive'] != 'false') {
             $data['ftp_passive'] = 'true';
         }
         // validate form.
         $validate = \Validation::forge();
         if (!\Extension\NoCsrf::check()) {
             // validate token failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('fslang_invalid_csrf_token');
         } elseif (!$validate->run()) {
             // validate failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = $validate->show_errors();
         } else {
             // try to save config.
             $result = \Model_Config::saveData($data);
             // save change site name to sites table
             $site_id = \Model_Sites::getSiteId(false);
             $entry = \Model_Sites::find($site_id);
             $entry->site_name = $data['site_name'];
             $entry->save();
             unset($entry, $site_id);
             if ($result === true) {
                 \Session::set_flash('form_status', array('form_status' => 'success', 'form_status_message' => \Lang::get('admin_saved')));
                 \Response::redirect(\Uri::main());
             } else {
                 $output['form_status'] = 'error';
                 $output['form_status_message'] = $result;
             }
         }
         // re-populate form.
         foreach ($data as $key => $value) {
             $output[$key] = html_entity_decode($value);
         }
     }
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('config_global_configuration'));
     // <head> output ----------------------------------------------------------------------------------------------
     // breadcrumb -------------------------------------------------------------------------------------------------
     $page_breadcrumb = [];
     $page_breadcrumb[0] = ['name' => \Lang::get('admin_admin_home'), 'url' => \Uri::create('admin')];
     $page_breadcrumb[1] = ['name' => \Lang::get('config_global_configuration'), 'url' => \Uri::create('admin/config')];
     $output['page_breadcrumb'] = $page_breadcrumb;
     unset($page_breadcrumb);
     // breadcrumb -------------------------------------------------------------------------------------------------
     return $this->generatePage('admin/templates/config/index_v', $output, false);
 }
Ejemplo n.º 21
0
include_once __DIR__ . DS . 'permission_table.php';
?>
 

<script type="text/javascript">
    function ajaxResetPermission() 
    {
        var confirm_del = window.confirm('<?php 
echo __('acperm_are_you_sure_to_reset');
?>
');
        
        if (confirm_del == true) {
            $.ajax({
                url: '<?php 
echo \Uri::main();
?>
/reset',
                type: 'POST',
                data: csrf_name+'='+nocsrf_val,
                dataType: 'json',
                success: function(data) {
                    if (data.result == true) {
                        alert('<?php 
echo __('acperm_reset_completed');
?>
');
                        location.reload();
                    } else {
                        alert('<?php 
echo __('acperm_failed_to_reset_permission');
Ejemplo n.º 22
0
// endif; $browser_check
?>
 


<div class="container">
    <div class="row">
        <div class="col-sm-4 col-sm-offset-4">
            <div class="admin-login-page-layout">
                <div class="login-block">
                    <h1><?php 
echo \Model_Config::getval('site_name');
?>
</h1>
                    <?php 
echo \Form::open(array('action' => \Uri::main() . '?rdr=' . $go_to, 'class' => 'form-horizontal', 'role' => 'form', 'onsubmit' => 'return ajaxAdminLogin($(this));'));
?>
 
                        <noscript><div class="alert alert-danger"><?php 
echo __('admin_please_enable_javascript');
?>
</div></noscript>
                        <div class="form-status-placeholder">
                            <?php 
if (isset($form_status) && isset($form_status_message)) {
    ?>
 
                            <div class="alert alert-<?php 
    echo str_replace('error', 'danger', $form_status);
    ?>
"><button type="button" class="close" data-dismiss="alert">&times;</button><?php