当前位置: 首页>>代码示例>>PHP>>正文


PHP today函数代码示例

本文整理汇总了PHP中today函数的典型用法代码示例。如果您正苦于以下问题:PHP today函数的具体用法?PHP today怎么用?PHP today使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了today函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show_form

 function show_form()
 {
     global $form_do_demande, $dbh, $charset;
     $date = formatdate(today());
     $date_fin = date("Ymd", time());
     //Selecteur des thèmes
     $req = "select * from demandes_theme order by libelle_theme";
     $res = mysql_query($req, $dbh);
     $theme_selector = "<select name='idtheme' >";
     while ($dmde = mysql_fetch_object($res)) {
         $theme_selector .= "<option value='" . $dmde->id_theme . "'>" . htmlentities($dmde->libelle_theme, ENT_QUOTES, $charset) . "</option>";
     }
     $theme_selector .= "</select>";
     //Selecteur des types
     $req = "select * from demandes_type order by libelle_type";
     $res = mysql_query($req, $dbh);
     $type_selector = "<select name='idtype' >";
     while ($dmde = mysql_fetch_object($res)) {
         $type_selector .= "<option value='" . $dmde->id_type . "'>" . htmlentities($dmde->libelle_type, ENT_QUOTES, $charset) . "</option>";
     }
     $type_selector .= "</select>";
     $form_do_demande = str_replace('!!date_fin!!', $date_fin, $form_do_demande);
     $form_do_demande = str_replace('!!date_fin_btn!!', $date, $form_do_demande);
     $form_do_demande = str_replace('!!select_theme!!', $theme_selector, $form_do_demande);
     $form_do_demande = str_replace('!!select_type!!', $type_selector, $form_do_demande);
     print $form_do_demande;
 }
开发者ID:bouchra012,项目名称:PMB,代码行数:27,代码来源:demandes.class.php

示例2: show_form

 function show_form($param = '')
 {
     global $base_path, $dbh, $charset, $msg;
     //paramètres pré-enregistré
     $liste_views = array();
     if ($param['list_view']) {
         foreach ($param['list_view'] as $id_view) {
             $liste_views[$id_view] = $id_view;
         }
     }
     $conso = $param["conso"] ? $param["conso"] : "1";
     $date_deb = $param["date_deb"];
     $date_fin = $param["date_fin"];
     $date_ech = $param["date_ech"];
     $requete = "SELECT id_vue, date_consolidation, nom_vue, comment FROM statopac_vues";
     $res = mysql_query($requete, $dbh);
     $nb_rows = mysql_num_rows($res);
     //taille du selecteur
     if ($nb_rows < 3) {
         $nb = 3;
     } else {
         if ($nb_rows > 10) {
             $nb = 10;
         } else {
             $nb = $nb_rows;
         }
     }
     $select_view = "<select id='list_view' class='saisie-50em' name='list_view[]' size='" . $nb . "' multiple>";
     while ($row = mysql_fetch_object($res)) {
         $select_view .= "<option id='" . $row->id_vue . "' value='" . $row->id_vue . "' " . ($liste_views[$row->id_vue] == $row->id_vue ? "selected" : "") . ">" . htmlentities($row->nom_vue, ENT_QUOTES, $charset) . "</option>";
     }
     $select_view .= "</select>";
     //liste des vues à consolider
     $form_task .= "\n\t\t<div class='row'>\n\t\t\t<div class='colonne3'>\n\t\t\t\t<label for='stats'>" . $this->msg["planificateur_stats_listView"] . "</label>\n\t\t\t</div>\n\t\t\t<div class='colonne_suite'>" . $select_view . "</div>\n\t\t</div>\n\t\t<div class='row'>&nbsp;</div>";
     /*appui sur la fin de la méthode do_form de la classe stat_view*/
     $form_task .= "<div class='row'>\n\t\t\t<div class='colonne3'>\n\t\t\t\t<label for='stats'>" . $this->msg["planificateur_stats_options"] . "</label>\n\t\t\t</div>\n\t\t\t<div class='colonne_suite'>\n\t\t\t\t<input type='radio' class='radio' id='id_lot' name='conso' value='1' " . ($conso == "1" ? "checked" : "") . "/> \n\t\t\t\t\t<label for='id_lot'>{$msg['stat_last_consolidation']}</label> <br><br>\n\t\t\t\t<input type='radio' class='radio' id='id_interval' name='conso' value='2' " . ($conso == "2" ? "checked" : "") . "/> \n\t\t\t\t\t<label for='id_interval'>{$msg['stat_interval_consolidation']} </label><br><br>\n\t\t\t\t<input type='radio' class='radio' id='id_debut' name='conso' value='3' " . ($conso == "3" ? "checked" : "") . "/> \n\t\t\t\t\t<label for='id_debut'>{$msg['stat_echeance_consolidation']}</label><br>\n\t\t\t</div>\n\t\t</div>";
     $btn_date_deb = "<input type='hidden' name='date_deb' value='!!date_deb!!'/><input type='button' name='date_deb_lib' class='bouton_small' value='!!date_deb_lib!!'   \n\t\t\tonClick=\"openPopUp('./select.php?what=calendrier&caller=planificateur_form&date_caller=!!date_deb!!&param1=date_deb&param2=date_deb_lib&auto_submit=NO&date_anterieure=YES', 'date_deb', 250, 300, -2, -2, 'toolbar=no, dependent=yes, resizable=yes')\" />";
     $btn_date_fin = "<input type='hidden' name='date_fin' value='!!date_fin!!'/><input type='button' name='date_fin_lib' class='bouton_small'   value='!!date_fin_lib!!'\n\t\t\tonClick=\"openPopUp('./select.php?what=calendrier&caller=planificateur_form&date_caller=!!date_fin!!&param1=date_fin&param2=date_fin_lib&auto_submit=NO&date_anterieure=YES', 'date_fin', 250, 300, -2, -2, 'toolbar=no, dependent=yes, resizable=yes')\" />";
     $btn_date_echeance = "<input type='hidden' name='date_ech' value='!!date_ech!!'/><input type='button' name='date_ech_lib' class='bouton_small' value='!!date_ech_lib!!'  \n\t\t\tonClick=\"openPopUp('./select.php?what=calendrier&caller=planificateur_form&date_caller=!!date_ech!!&param1=date_ech&param2=date_ech_lib&auto_submit=NO&date_anterieure=YES', 'date_ech', 250, 300, -2, -2, 'toolbar=no, dependent=yes, resizable=yes')\" />";
     if (!$date_deb) {
         // -- si nouvelle tâche = pas de params pré-enregistrés
         $date_deb = strftime("%Y-%m-%d", mktime(0, 0, 0, date('m'), date('d') - 1, date('y')));
     }
     $btn_date_deb = str_replace("!!date_deb!!", $date_deb, $btn_date_deb);
     $btn_date_deb = str_replace("!!date_deb_lib!!", formatdate($date_deb), $btn_date_deb);
     if (!$date_fin) {
         $date_fin = today();
     }
     $btn_date_fin = str_replace("!!date_fin!!", $date_fin, $btn_date_fin);
     $btn_date_fin = str_replace("!!date_fin_lib!!", formatdate($date_fin), $btn_date_fin);
     if (!$date_ech) {
         $date_ech = today();
     }
     $btn_date_echeance = str_replace("!!date_ech!!", $date_ech, $btn_date_echeance);
     $btn_date_echeance = str_replace("!!date_ech_lib!!", formatdate($date_ech), $btn_date_echeance);
     $form_task = str_replace("!!date_deb_btn!!", $btn_date_deb, $form_task);
     $form_task = str_replace("!!date_fin_btn!!", $btn_date_fin, $form_task);
     $form_task = str_replace("!!echeance_btn!!", $btn_date_echeance, $form_task);
     return $form_task;
 }
开发者ID:bouchra012,项目名称:PMB,代码行数:60,代码来源:stats.class.php

示例3: bodyBottom

function bodyBottom()
{
    global $TimerStart, $prog_name_full, $prog_ver;
    $today = today();
    $genTime = processTime();
    echo "\n</td>\n        </tr>\n      </table></td>\n  </tr>\n  <tr>\n    <td height=\"32\"><table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n        <tr>\n          <td height=\"1\" bgcolor=\"#7D7D7D\"></td>\n        </tr>\n        <tr>\n          <td><table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" bgcolor=\"#EAEAEA\" class=\"bottomBar\">\n              <tr>\n                <td width=\"30%\" class=\"bottomInfo\">" . _GENERATION_TIME . " {$genTime} " . _SECONDS . "</td>\n                <td class=\"bottomInfo\">\n                <div align=\"center\">Powered by <a href  >{$prog_name_full}</a> {$prog_ver} &copy; 2007</div></td>\n                <td width=\"30%\" class=\"bottomInfo\">\n                <div align=\"right\">" . _NOW . ": {$today}</div></td>\n              </tr>\n            </table></td>\n        </tr>\n        <tr>\n          <td height=\"1\" bgcolor=\"#7D7D7D\"></td>\n        </tr>\n      </table></td>\n  </tr>\n</table>\n\n\n</body>\n</html>";
}
开发者ID:Raxman,项目名称:stis,代码行数:7,代码来源:theme.php

示例4: index

 public function index()
 {
     $myID = getUserID();
     $title = trim(jsonInput('title'));
     $description = jsonInput('description');
     $location = jsonInput('location');
     $start = strtotime(jsonInput('start'));
     $end = strtotime(jsonInput('end'));
     if (empty($title)) {
         generate_json(array('status' => 0, 'message' => 'Please type event title.'));
     } else {
         if (!$start) {
             generate_json(array('status' => 0, 'message' => 'Start Date is required.'));
         } else {
             if ($end && $start > $end) {
                 generate_json(array('status' => 0, 'message' => 'Dates mismatch.'));
             } else {
                 $start = date("Y-m-d", $start);
                 $end = $end ? date("Y-m-d", $end) : $start;
                 $this->mdb->add_event(array('title' => $title, 'description' => $description, 'location' => $location, 'type' => 'default', 'start' => $start, 'end' => $end, 'date_added' => today(), 'source' => 'local', 'user_id' => $myID));
                 generate_json(array('status' => 1));
             }
         }
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:25,代码来源:Add_event.php

示例5: do_login

 public function do_login()
 {
     $username = $this->input->post('username');
     $password = ts_hash($this->input->post('password'));
     $status = 1;
     $message = '';
     $query = $this->model->login($username, $password);
     if ($query->num_rows()) {
         $row = $query->row();
         switch ($row->status) {
             case 0:
                 $status = 0;
                 $message = sprintf('Account not yet verified. <br /><a href="%s">Resend Verification?</a>', base_url('signup/resend_verification?token=' . $row->token . '&t=' . strtotime('now')));
                 break;
             case 2:
                 $status = 0;
                 $message = 'This account has been banned.';
                 break;
             default:
                 $uniqueToken = random_string('unique');
                 $this->model->user_update(array('last_active' => today(), 'token' => $uniqueToken), array('id' => $row->id));
                 $sessData = array('user_id' => $row->id, 'username' => $row->username, 'userlevel' => $row->userlevel, 'display_name' => $row->display_name, 'email_address' => $row->email_address, 'token' => $uniqueToken);
                 $this->session->set_userdata($sessData);
                 $message = $uniqueToken;
         }
     } else {
         $status = 0;
         $message = 'Incorrect Username / Password.';
     }
     generate_json(array('status' => $status, 'message' => $message));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:31,代码来源:Login.php

示例6: gl_inquiry_controls

function gl_inquiry_controls()
{
    $dim = get_company_pref('use_dimension');
    start_form();
    start_table(TABLESTYLE_NOBORDER);
    $date = today();
    if (!isset($_POST['TransFromDate'])) {
        $_POST['TransFromDate'] = begin_month($date);
    }
    if (!isset($_POST['TransToDate'])) {
        $_POST['TransToDate'] = end_month($date);
    }
    date_cells(_("From:"), 'TransFromDate');
    date_cells(_("To:"), 'TransToDate');
    if ($dim >= 1) {
        dimensions_list_cells(_("Dimension") . " 1:", 'Dimension', null, true, " ", false, 1);
    }
    if ($dim > 1) {
        dimensions_list_cells(_("Dimension") . " 2:", 'Dimension2', null, true, " ", false, 2);
    }
    check_cells(_("No zero values"), 'NoZero', null);
    check_cells(_("Only balances"), 'Balance', null);
    submit_cells('Show', _("Show"), '', '', 'default');
    end_table();
    end_form();
}
开发者ID:raqib,项目名称:ac_dev,代码行数:26,代码来源:gl_trial_balance.php

示例7: __construct

 public function __construct()
 {
     parent::__construct();
     if (empty($this->date)) {
         $this->date = today();
     }
 }
开发者ID:vivek201,项目名称:canteen-mgmt,代码行数:7,代码来源:order.class.php

示例8: error401

function error401()
{
    require_once 'russian.php';
    global $mail, $prog_name_full, $prog_ver;
    $today = today();
    $server = $_SERVER['HTTP_HOST'];
    echo "\n<html>\n<head>\n<title>{$prog_name}: " . Authentication_required . "!</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=KOI8-R\" />\n<style type=\"text/css\">\n<!--\nbody { \n    color: #000000; background-color: #FFFFFF; \n    font-family: Arial, Helvetica, sans-serif;\n    font-size: 14px;\n}\na:link { color: #0000CC; }\n-->\n</style>\n</head>\n\n<body>\n<h1><font font size=\"7\">" . Authentication_required . "!</font></h1>\n<HR noshade size=1px>\n<dl>\n<dd>\n\n\n    This server could not verify that you are authorized to access\n    the URL.\n    You either supplied the wrong credentials (e.g., bad password), or your\n    browser doesn't understand how to supply the credentials required.\n\n  </dd></dl><dl><dd>\n\n\n    In case you are allowed to request the document, please\n    check your user-id and password and try again.\n\n</dd></dl><dl><dd>\nIf you think this is a server error, please contact\nthe <a href=\"mailto:{$mail}\">{$mail}</a>\n\n</dd></dl>\n\n<h2><font font size=\"6\">" . _ERROR . " 401</font></h2>\n<HR noshade size=1px>\n<dl>\n<dd>\n<address>\n  <a href=\"/\">{$server}</a>\n  <br />\n\n  <small>{$today}</small>\n  <br />\n  <small>{$prog_name_full} {$prog_ver}</small>\n</address>\n</dd>\n</dl>\n</body>\n</html>\n";
}
开发者ID:Raxman,项目名称:stis,代码行数:8,代码来源:functions.php

示例9: do_signup

 private function do_signup()
 {
     if ($_POST) {
         $username = $this->input->post('username');
         $fullname = $this->input->post('fullname');
         $email = $this->input->post('email');
         $gender = $this->input->post('gender');
         $password = $this->input->post('password');
         $password2 = $this->input->post('password2');
         $alertMsg = '';
         $this->form_validation->set_rules('username', 'Username', 'required|trim|alpha_numeric|min_length[4]|max_length[20]|is_unique[users.username]');
         $this->form_validation->set_rules('fullname', 'Display name', 'required|alpha_numeric_spaces|max_length[30]');
         $this->form_validation->set_rules('email', 'Email address', 'required|valid_email|is_unique[users.email_address]');
         $this->form_validation->set_rules('password', 'Password', 'required|min_length[4]|max_length[20]');
         $this->form_validation->set_rules('password2', 'Confirm Password', 'matches[password]');
         $this->form_validation->set_message('required', '%s is required.');
         $this->form_validation->set_message('alpha_numeric', '%s must be alpha numeric only.');
         $this->form_validation->set_message('alpha_numeric_spaces', '%s must be letters, numbers and spaces only.');
         $this->form_validation->set_message('valid_email', 'Invalid %s.');
         $this->form_validation->set_message('is_unique', '%s already exists.');
         $this->form_validation->set_message('min_length', '%s must contain atleast %d characters.');
         $this->form_validation->set_message('max_length', '%s too long, allowed up to %d characters only.');
         $this->form_validation->set_message('matches', 'Passwords do not match.');
         $this->form_validation->set_error_delimiters('', '|');
         if ($this->form_validation->run()) {
             $emailVerification = $this->siteinfo->config('signup_verification');
             /* SUCCESS MESSAGE */
             $successMsg = array(sprintf('<div class="alert alert-success">Thank you for joining %s we are happy to have you here. You can now <a href="%s">Login</a>.</div>', ucfirst($this->siteinfo->config('site_name')), base_url()), '<div class="alert alert-danger">Thanks for joining, We have send you an email confirmation to validate your account.</div>');
             $alertMsg .= $emailVerification ? $successMsg[1] : $successMsg[0];
             /* SUCCESS MESSAGE END */
             //Inserts to database
             $mData = array('userlevel' => 0, 'username' => $username, 'email_address' => $email, 'password' => ts_hash($password), 'display_name' => $fullname, 'date_registered' => today(), 'last_active' => NULL, 'status' => $emailVerification ? 0 : 1, 'token' => random_string('unique'));
             $newID = $this->mdb->users_add($mData);
             $genders = $this->config->item('genders');
             if ($newID) {
                 $this->mdb->users_info_add(array('user_id' => $newID, 'firstname' => '', 'middlename' => '', 'lastname' => '', 'gender' => in_array($gender, $genders) ? $gender : $genders[0], 'timezone' => $this->siteinfo->config('timezone'), 'location' => '', 'contact_number' => '', 'company' => '', 'profile_pic' => '', 'email_privacy' => 1));
             }
             //Process Email Notification
             if ($emailVerification) {
             }
             //Clear fields after Success
             $username = '';
             $fullname = '';
             $email = '';
             $password = '';
             $password2 = '';
         } else {
             $errors = validation_errors();
             $errorsArr = explode("|", $errors);
             $alertMsg = '<div class="alert alert-warning">';
             $alertMsg .= isset($errorsArr[0]) ? $errorsArr[0] : 'Unknown error!';
             $alertMsg .= '</div>';
         }
         return array('alert_msg' => $alertMsg, 'username' => htmlentities($username), 'fullname' => htmlentities($fullname), 'email' => htmlentities($email), 'password' => htmlentities($password), 'password2' => htmlentities($password2));
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:56,代码来源:Signup.php

示例10: date_ago

function date_ago($date)
{
    switch ($date->diff(today())->days) {
        case 0:
            return \Lang::get('pages.updates.today');
            break;
        case 1:
            return \Lang::get('pages.updates.yesterday');
            break;
    }
    return $date->ago();
}
开发者ID:ankhzet,项目名称:Ankh,代码行数:12,代码来源:view.php

示例11: index

 public function index()
 {
     $myID = getUserID();
     $date = today();
     $title = trim(jsonInput('title'));
     $content = jsonInput('content');
     $category = trim(jsonInput('category'));
     if (empty($title)) {
         generate_json(array('status' => 0, 'message' => 'Title is required.'));
     } else {
         $insert_id = $this->mdb->insert_note(array('user_id' => $myID, 'title' => $title, 'content' => $content, 'category' => $category, 'date_created' => $date));
         generate_json(array('status' => 1, 'message' => 'Note successfully created.'));
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:14,代码来源:Create.php

示例12: index

 public function index()
 {
     $myID = getUserID();
     $query = $this->mdb->get_notif($myID, today());
     $items = array();
     foreach ($query->result() as $row) {
         $tagData = explode("|", $row->tag_data);
         $description = display_notif($row->type, $tagData, $row->counter);
         $description = convert_tag($description, 'span', array('class' => 'tag'));
         $dateNotify = convert_datetime($row->date_notify);
         $items[] = array('id' => $row->id, 'description' => $description, 'actor_id' => $row->actor_id, 'redirect_uri' => $row->redirect, 'timestamp' => relativedate(strtotime($dateNotify), true), 'is_read' => $row->is_read, 'is_new' => $row->is_new);
     }
     $this->mdb->update_notif(array('notify_to' => $myID, 'is_new' => 1), array('is_new' => 0));
     generate_json(array('status' => 1, 'items' => $items));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:15,代码来源:Notification.php

示例13: getLast12Months

function getLast12Months($format = "%b %Y")
{
    $currentDate = today();
    $currentMonth = formatDate($currentDate, "%m");
    $currentYear = formatDate($currentDate, "%Y");
    $startingYear = $currentYear - 1;
    $last_12_months = array();
    for ($i = (int) $currentMonth + 1; $i <= 12; $i++) {
        $last_12_months[] = formatDate($startingYear . "-" . $i . "-01", $format);
    }
    for ($i = 1; $i <= $currentMonth; $i++) {
        $last_12_months[] = formatDate($currentYear . "-" . $i . "-01", $format);
    }
    return $last_12_months;
}
开发者ID:nveeed,项目名称:ems,代码行数:15,代码来源:DateTimeHelper.php

示例14: index

 public function index()
 {
     $myID = getUserID();
     $name = trim(jsonInput('name'));
     $description = jsonInput('description');
     $membersPost = jsonInput('members');
     $this->np_validations();
     $newProjID = $this->mdb->project_add($myID, $name, $description);
     if ($newProjID) {
         //add yourself in project members
         $this->mdb->project_member_add(array('project_id' => $newProjID, 'user_id' => $myID, 'email_address' => getUserEmail(), 'joined_by' => 0, 'date_joined' => today(), 'last_visit' => today(), 'is_accepted' => 1, 'project_role' => 3));
         $this->mdb->add_project_settings(array('project_id' => $newProjID, 'task_approval' => 0, 'project_approval' => 1));
         //add specified members to project
         if (is_array($membersPost)) {
             foreach ($membersPost as $member) {
                 if (filter_var($member, FILTER_VALIDATE_EMAIL)) {
                     $qChkifAlreadyMember = $this->mdb->checkIfAlreadyMember($newProjID, $member);
                     if (!$qChkifAlreadyMember) {
                         $qChkUser = $this->model->getUserInfo(array('email_address' => $member));
                         if ($qChkUser->num_rows()) {
                             $pmRow = $qChkUser->row();
                             $this->mdb->project_member_add(array('project_id' => $newProjID, 'user_id' => $pmRow->id, 'email_address' => $pmRow->email_address, 'joined_by' => $myID, 'date_joined' => today(), 'last_visit' => NULL, 'is_accepted' => 0, 'project_role' => $this->siteinfo->config('project_roles_default')));
                             //notification
                             notify('project_invite', $pmRow->id, array('project_id' => $newProjID));
                             $qProj = $this->db->get_where('projects', array('id' => $newProjID));
                             if ($qProj->num_rows()) {
                                 $qProjRow = $qProj->row();
                                 $myName = $this->session->userdata('display_name');
                                 $redirectLink = base_url('#/app/projects/' . $newProjID);
                                 do_sendmail($pmRow->id, $qProjRow->project_name, "{$myName} invited you to join <a href='{$redirectLink}'>" . $qProjRow->project_name . "</a>");
                             }
                         } else {
                             $this->mdb->project_member_add(array('project_id' => $newProjID, 'user_id' => 0, 'email_address' => $member, 'joined_by' => $myID, 'date_joined' => today(), 'last_visit' => NULL, 'is_accepted' => 0, 'project_role' => $this->siteinfo->config('project_roles_default')));
                         }
                     }
                 }
             }
         }
         //add project roles
         foreach ($this->siteinfo->config('project_roles') as $roleID => $role) {
             $default = $this->siteinfo->config('project_roles_default') == $roleID ? 1 : 0;
             $this->mdb->project_roles_add($newProjID, $roleID, $default, $role);
         }
     }
     generate_json(array('status' => 1, 'message' => 'New project has been created.'));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:46,代码来源:New_project.php

示例15: index

 public function index()
 {
     updateLastActive();
     $myID = getUserID();
     $filepath = 'uploads/files/' . $myID . '/';
     $pid = (int) $this->input->get('pid');
     $tid = (int) $this->input->get('tid');
     if (!file_exists($filepath)) {
         mkdir($filepath, 0777, true);
     }
     if (!validate_access('valid_member', array('project_id' => $pid, 'user_id' => $myID))) {
         $this->output->set_status_header('400');
         echo 'You dont have enough permission to do this.';
     } else {
         $config['upload_path'] = $filepath;
         $config['allowed_types'] = 'jpg|gif|jpeg|bmp|ico|png|zip|rar|gz|mp3|mp4|mkv|avi|txt|apk|ipa|tar|exe|doc|docx|xls|xlsx|ppt|pptx|pdf';
         $config['max_size'] = 30000;
         $config['encrypt_name'] = true;
         $config['max_filename'] = 200;
         $config['remove_spaces'] = false;
         $this->load->library('upload', $config);
         if ($this->upload->do_upload('file')) {
             $data = $this->upload->data();
             $newID = $this->mdb->add_attachment(array('attachment_type' => 'file', 'uploader' => $myID, 'project_id' => $pid, 'task_id' => $tid, 'post_id' => 0, 'filename' => $data['orig_name'], 'filepath' => $data['file_name'], 'filesize' => $data['file_size'] * 1024, 'extension' => $data['file_ext'], 'date_added' => today(), 'date_deleted' => null, 'deleted_by' => 0, 'parent_folder' => 0));
             $imgTypes = array('.gif', '.jpg', '.jpeg', '.png');
             if (in_array(strtolower($data['file_ext']), $imgTypes)) {
                 $this->load->library('image_lib');
                 $thumbpath = $filepath . 'thumbs/';
                 if (!file_exists($thumbpath)) {
                     mkdir($thumbpath, 0777, true);
                 }
                 $config = array('image_library' => 'gd2', 'source_image' => $filepath . $data['file_name'], 'new_image' => $thumbpath . $data['file_name'], 'maintain_ratio' => true, 'height' => 300, 'width' => 300);
                 $this->image_lib->initialize($config);
                 $this->image_lib->resize();
                 $this->image_lib->clear();
             }
             echo $newID;
         } else {
             $errors = $this->upload->display_errors('', '|');
             $errorsArr = explode("|", $errors);
             $this->output->set_status_header('401');
             echo isset($errorsArr[0]) ? $errorsArr[0] : '';
         }
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:45,代码来源:Upload.php


注:本文中的today函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。