function on_before_validate($values) { if ($values['username'] == "" || $values['username'] == NULL) { $this->password_in_clear = $password = $this->random_password(); $ci = CI_Controller::get_instance(); $ci->load->helper('url'); $ci->load->library('session'); $ci->load->library('extemplate'); $ci->load->library("email"); $ci->load->config('tank_auth', TRUE); $hasher = new PasswordHash($ci->config->item('phpass_hash_strength', 'tank_auth'), $ci->config->item('phpass_hash_portable', 'tank_auth')); $hashed_password = $hasher->HashPassword($password); $values["password"] = $hashed_password; $values["created"] = datetime_now(); $values['username'] = trim($values['email']); $values["last_ip"] = $_SERVER['REMOTE_ADDR']; $data = $values; $data['site_name'] = 'http://www.ressphere.com'; $data['password'] = $this->password_in_clear; if ($ci->config->item('email_account_details')) { base::_begin_send_email('Welcome to', $data['email'], $data, $ci); } } return parent::on_before_validate($values); }
public function form_fields($values = array(), $related = array()) { $fields = parent::form_fields($values, $related); $fields['publish_date']['comment'] = 'If blank, will default to current date/time'; $fields['publish_date']['value'] = datetime_now(); return $fields; }
function on_before_clean($values = array()) { if (!(int) $values['date_added']) { $values['date_added'] = datetime_now(); } return $values; }
function form_fields($values = array(), $related = array()) { $fields = parent::form_fields($values, $related); $fields['post_date']['comment'] = 'If blank, will default to current date/time'; $fields['post_date']['value'] = datetime_now(); $fields['skillset_requirements']['class'] = 'no_editor'; return $fields; }
function logit($msg, $user = null) { $CI =& get_instance(); if (empty($user)) { $user = $CI->fuel_auth->user_data(); } $save['user_id'] = $user['id']; $save['message'] = $msg; $save['entry_date'] = datetime_now(); $this->save($save); }
function import_view_cancel() { if ($this->input->post('id')) { // don't need to pass anything because it will automatically update last_modified' $save['id'] = $this->input->post('id'); $save['name'] = $this->input->post('name'); $save['last_modified'] = datetime_now(); if ($this->model->save($save)) { $this->output->set_output('success'); return; } } $this->output->set_output('error'); }
/** * Saves to the logging table * * @access public * @param string The message to associate with the log * @param string The type of log (optional) * @param int The user ID associated with the log (optional) * @return boolean TRUE if saved correctly. FALSE otherwise */ public function logit($msg, $type = NULL, $user_id = NULL) { $CI =& get_instance(); if (!isset($user_id)) { $user = $CI->fuel->auth->user_data(); if (isset($user['id'])) { $user_id = $user['id']; } } $save['message'] = $msg; $save['type'] = $type; $save['user_id'] = $user_id; $save['entry_date'] = datetime_now(); return $this->save($save); }
<p>Extends the CodeIgniter date helper functions. This helper is <strong>autoloaded</strong>.</p> <p>This helper is loaded using the following code:</p> <pre class="brush: php"> $this->load->helper('date'); </pre> <p>The following functions are available:</p> <h2>datetime_now()</h2> <p>Returns a the current time in a yyyy-mm-dd hh:mm:ss format which can be used with MySQL databases.</p> <pre class="brush: php"> echo datetime_now(); // <?php echo datetime_now(); ?> </pre> <h2>is_date_format('<var>date</var>')</h2> <p>Returns a boolean value as to whether the date is in an english (mm/dd/yyyy) or database (yyyy-mm-dd) format.</p> <pre class="brush: php"> is_date_format('2010/01/01'); // returns FALSE is_date_format('2010-01-01'); // returns TRUE </pre>
public function find_upcoming($limit = NULL) { return $this->find_all(array('start_date >=' => datetime_now()), NULL, $limit); }
?> " ; var UPLOADDO_URL = "<?php echo ADMINER_URL . '/upload/'; ?> "; <?php } ?> var UPLOAD_URL = "<?php echo UPLOAD_URL; ?> " ; var mime = ["video/*","image/*"]; var today = '<?php echo datetime_now(false); ?> '; // cookie theme </script> <!--[if lt IE 9]> <?php //echo static_file('IE9.js'); ?> <![endif]--> <?php echo static_file('jquery-1.10.2.js'); echo static_file('normalize.css');
} } // ..end for break; case "DB": $result = $site->fetch_live_data(); if ($result === FALSE) { $data['notice']['error'] = "DB Error: fetching records failed"; } break; } } //debug_show($result); // check for errors if (!empty($data['notice']['error'])) { $message = datetime_now() . " - " . $data['notice']['error'] . "\n"; log_message($settings['log_file'], $message); } else { if ($site->request_value == "all") { //debug_show($result); return $result; } else { $show_sport = $site->json_sports_config(); $requested_sport = str_replace(' ', '', $site->request_value); //if (isset($show_sport[$site->request_value]['code'])) if (isset($show_sport[$requested_sport]['code'])) { //debug_show($result[$show_sport[$site->request_value]['code']]); } else { echo " No result has found: " . $site->request_value; } }
public function on_before_save($values) { parent::on_before_save($values); if (empty($values[$this->order_by_field])) { $values[$this->order_by_field] = datetime_now(); } return $values; }
/** * Used for displaying content that is published * * @access protected * @return void */ protected function _publish_status() { $fields = $this->fields(); if (in_array('published', $fields)) { if (in_array('published', $this->boolean_fields)) { $this->db->where(array($this->table_name . '.published' => 1)); } else { $this->db->where(array($this->table_name . '.published' => 'yes')); } } if (in_array('active', $fields)) { if (in_array('active', $this->boolean_fields)) { $this->db->where(array($this->table_name . '.active' => 1)); } else { $this->db->where(array($this->table_name . '.active' => 'yes')); } } if (in_array('publish_date', $fields)) { $this->db->where(array('publish_date <=' => datetime_now())); } }
<p>Extends the CodeIgniter date helper functions. This helper is <strong>autoloaded</strong>.</p> <p>This helper is loaded using the following code:</p> <pre class="brush: php"> $this->load->helper('date'); </pre> <p>The following functions are available:</p> <h2>datetime_now([<var>hms</var>])</h2> <p>Returns a the current time in a yyyy-mm-dd hh:mm:ss format which can be used with MySQL databases. The optional parameter will return the current date without the time if set to FALSE (default is TRUE).</p> <pre class="brush: php"> echo datetime_now(); // <?=datetime_now()?> echo datetime_now(FALSE); // <?=datetime_now(FALSE)?> </pre> <h2>is_date_format('<var>date</var>')</h2> <p>Returns a boolean value as to whether the date is in an english (mm/dd/yyyy) or database (yyyy-mm-dd) format.</p> <pre class="brush: php"> is_date_format('2010/01/01'); // returns FALSE is_date_format('2010-01-01'); // returns TRUE </pre> <h2>is_date_db_format('<var>date</var>')</h2>
function on_before_clean($values) { $values['slug'] = empty($values['slug']) && !empty($values['title']) ? url_title($values['title'], 'dash', TRUE) : url_title($values['slug'], 'dash'); if (empty($values['post_date'])) { $values['post_date'] = datetime_now(); } // create author if it doesn't exists' $CI =& get_instance(); $id = !empty($values['author_id']) ? $values['author_id'] : $CI->fuel->auth->user_data('id'); $CI->load->module_model(BLOG_FOLDER, 'blog_users_model'); $author = $CI->blog_users_model->find_one(array('fuel_user_id' => $id)); if (!isset($author->id)) { $author = $CI->blog_users_model->create(); $author->fuel_user_id = $CI->fuel->auth->user_data('id'); // determine a display name if one isn't provided' if (trim($author->display_name) == '') { $display_name = $CI->fuel->auth->user_data('first_name') . ' ' . $this->fuel->auth->user_data('last_name'); if (trim($display_name) == '') { $display_name = $CI->fuel->auth->user_data('email'); } if (empty($display_name)) { $display_name = $CI->fuel->auth->user_data('user_name'); } $author->display_name = $display_name; } // save author $author->save(); $values['author_id'] = $author->fuel_user_id; } return $values; }
/** * Used for displaying content that is published * * @access protected * @return void */ protected function _publish_status() { //$fields = $this->fields(); $fields = $fields = array_keys($this->table_info()); // used to prevent an additional query that the fields() method would create if (in_array('published', $fields)) { if (in_array('published', $this->boolean_fields)) { $this->db->where(array($this->table_name . '.published' => 1)); } else { $this->db->where(array($this->table_name . '.published' => 'yes')); } } if (in_array('active', $fields)) { if (in_array('active', $this->boolean_fields)) { $this->db->where(array($this->table_name . '.active' => 1)); } else { $this->db->where(array($this->table_name . '.active' => 'yes')); } } if (in_array('publish_date', $fields)) { $this->db->where(array($this->table_name . '.publish_date <=' => datetime_now())); } }
/** * Returns where condition based on the users logged in state * * @access protected * @param string * @param mixed * @return array */ protected function _publish_status($t = 'blog_posts', $where = array()) { $this->CI->load->module_helper(FUEL_FOLDER, 'fuel'); $tables = Base_module_model::$tables; if (!is_fuelified()) { if (empty($where) or is_array($where)) { // taken care of in the model //$where[$tables[$t].'.published'] = 'yes'; // don't show posts in the future' if ($t == 'blog_posts') { $where[$tables[$t] . '.post_date <= '] = datetime_now(); } } else { // $where .= ' AND '.$tables[$t].'.published = "yes"'; // don't show posts in the future' if ($t == 'blog_posts') { // $where .= ' AND '.$tables[$t].'.post_date <= "'.datetime_now().'"'; } } } return $where; }
public function upload($inline = FALSE) { $this->load->helper('file'); $this->load->helper('security'); $this->load->library('form_builder'); $this->load->library('upload'); $this->js_controller_params['method'] = 'upload'; if (!empty($_POST) and !empty($_FILES)) { $params['upload_path'] = sys_get_temp_dir(); $params['allowed_types'] = 'php|html|txt'; // to ensure we check the proper mime types $this->upload->initialize($params); // Hackery to ensure that a proper php mimetype is set. // Would set in mimes.php config but that may be updated with the next version of CI which does not include the text/plain $this->upload->mimes['php'] = array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source', 'text/plain'); if ($this->upload->do_upload('file')) { $upload_data = $this->upload->data(); $error = FALSE; // read in the file so we can filter it $file = read_file($upload_data['full_path']); // sanitize the file before saving $file = $this->_sanitize($file); $id = $this->input->post('id', TRUE); $name = $this->input->post('name', TRUE); $language = $this->input->post('language', TRUE); if (empty($name)) { $name = current(explode('.', $file_info['name'])); } if ($id) { $save['id'] = $id; } $save['name'] = $name; $save['view'] = $file; $save['language'] = $language; $save['date_added'] = datetime_now(); $save['last_modified'] = date('Y-m-d H:i:s', time() + 1); // to prevent window from popping up after upload $id = $this->model->save($save); if (!$id) { add_error(lang('error_upload')); } else { // change list view page state to show the selected group id $this->fuel->admin->set_notification(lang('blocks_success_upload'), Fuel_admin::NOTIFICATION_SUCCESS); redirect(fuel_url('blocks/edit/' . $id)); } } else { $error_msg = $this->upload->display_errors('', ''); add_error($error_msg); } } $fields = array(); $blocks = $this->model->options_list('id', 'name', array('published' => 'yes'), 'name'); $fields['name'] = array('label' => lang('form_label_name'), 'type' => 'inline_edit', 'options' => $blocks, 'module' => 'blocks'); $fields['file'] = array('type' => 'file', 'accept' => '', 'required' => TRUE); $fields['id'] = array('type' => 'hidden'); $fields['language'] = array('type' => 'hidden'); $field_values = $_POST; $common_fields = $this->_common_fields($field_values); $fields = array_merge($fields, $common_fields); $this->form_builder->hidden = array(); $this->form_builder->set_fields($fields); $this->form_builder->set_field_values($_POST); $this->form_builder->submit_value = ''; $this->form_builder->use_form_tag = FALSE; $vars['instructions'] = lang('blocks_upload_instructions'); $vars['form'] = $this->form_builder->render(); $vars['back_action'] = ($this->fuel->admin->last_page() and $this->fuel->admin->is_inline()) ? $this->fuel->admin->last_page() : fuel_uri($this->module_uri); //$vars['back_action'] = fuel_uri($this->module_uri); $crumbs = array($this->module_uri => $this->module_name, lang('action_upload')); $this->fuel->admin->set_titlebar($crumbs); $this->fuel->admin->render('upload', $vars, Fuel_admin::DISPLAY_NO_ACTION); }
function do_action() { if (is_ajax()) { // $result['status'] = -98; // echo json_encode($result); // die; $post_arr = $this->input->post(); $now = datetime_now(false); $start = date(uri_safe_decode($post_arr['start'])); $deadline = date(uri_safe_decode($post_arr['deadline'])); // $result['now'] = $now; // $result['start'] = $start; // $result['deadline'] = $deadline; // $result['test1'] = $now>=$start; // $result['test2'] = $now<$deadline; // $result['test3'] = $now<$start; // $result['test4'] = $now>$deadline; // echo json_encode($result); // die; if ($now < $start) { $result['status'] = -97; echo json_encode($result); die; } if ($now > $deadline) { $result['status'] = -98; echo json_encode($result); die; } $item_id = $post_arr['item_id']; $action_code = $post_arr['action_code']; $this->load->helper('cookie'); $target_url = $this->input->cookie("voting_target_url"); if (!isset($target_url) || $target_url == "") { $target_url = site_url(); } $user_id = $this->code_model->get_logged_in_account(); if ($user_id == null || $user_id == "") { $result['status'] = -99; $result['login_url'] = site_url() . 'login'; echo json_encode($result); die; } $is_fb = !filter_var($user_id, FILTER_VALIDATE_EMAIL); //fb 登入才能分享&讚 if (!$is_fb && ($action_code == 'S' || $action_code == 'L')) { $result['forbidden'] = 'Y'; } else { $result['forbidden'] = 'N'; // $result['user_id'] = $user_id; // echo json_encode($result); // die; // $user_id = 」;//TODO:先寫死 $can_vote = $this->events_model->user_can_action($user_id, $item_id, $action_code); if ($can_vote) { $sucesss = $this->events_model->insert($user_id, $action_code, $item_id); $result['exists'] = $sucesss ? 'N' : 'Y'; $result['limit_of_vote'] = 'N'; } else { $result['limit_of_vote'] = 'Y'; $result['exists'] = 'Y'; } } $result['status'] = 1; echo json_encode($result); } else { // redirect(site_url(), 'refresh'); $result['status'] = -1; $result['msg'] = "發生錯誤,請再試一次"; echo json_encode($result); } die; }