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


PHP fileupload::renameFile方法代码示例

本文整理汇总了PHP中fileupload::renameFile方法的典型用法代码示例。如果您正苦于以下问题:PHP fileupload::renameFile方法的具体用法?PHP fileupload::renameFile怎么用?PHP fileupload::renameFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fileupload的用法示例。


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

示例1: run

 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     $helper = new helper();
     $projectObj = new projects();
     $user = new users();
     $language = new language();
     $language->setModule('tickets');
     $lang = $language->readIni();
     $projects = $projectObj->getUserProjects("open");
     $msgKey = '';
     if (isset($_POST['save'])) {
         $values = array('headline' => $_POST['headline'], 'type' => $_POST['type'], 'description' => $_POST['description'], 'priority' => $_POST['priority'], 'projectId' => $_POST['project'], 'editorId' => implode(',', $_POST['editorId']), 'userId' => $_SESSION['userdata']['id'], 'date' => $helper->timestamp2date(date("Y-m-d H:i:s"), 2), 'dateToFinish' => $_POST['dateToFinish'], 'status' => 3, 'browser' => $_POST['browser'], 'os' => $_POST['os'], 'resolution' => $_POST['resolution'], 'version' => $_POST['version'], 'url' => $_POST['url'], 'editFrom' => $_POST['editFrom'], 'editTo' => $_POST['editTo']);
         if ($values['headline'] === '') {
             $tpl->setNotification('ERROR_NO_HEADLINE', 'error');
         } elseif ($values['description'] === '') {
             $tpl->setNotification('ERROR_NO_DESCRIPTION', 'error');
         } elseif ($values['projectId'] === '') {
             $tpl->setNotification('ERROR_NO_PROJECT', 'error');
         } else {
             $values['date'] = $helper->timestamp2date($values['date'], 4);
             $values['dateToFinish'] = $helper->timestamp2date($values['dateToFinish'], 4);
             $values['editFrom'] = $helper->timestamp2date($values['editFrom'], 4);
             $values['editTo'] = $helper->timestamp2date($values['editTo'], 4);
             // returns last inserted id
             $id = $this->addTicket($values);
             //Take the old value to avoid nl character
             $values['description'] = $_POST['description'];
             $values['date'] = $helper->timestamp2date($values['date'], 2);
             $values['dateToFinish'] = $helper->timestamp2date($values['dateToFinish'], 2);
             $values['editFrom'] = $helper->timestamp2date($values['editFrom'], 2);
             $values['editTo'] = $helper->timestamp2date($values['editTo'], 2);
             $msgKey = 'TICKET_ADDED';
             $tpl->setNotification('TICKET_ADDED', 'success');
             //Fileupload
             if (htmlspecialchars($_FILES['file']['name']) != '') {
                 $upload = new fileupload();
                 $upload->initFile($_FILES['file']);
                 if ($upload->error == '') {
                     // hash name on server for security reasons
                     $newname = md5($id . time());
                     //Encrypt filename on server
                     $upload->renameFile($newname);
                     if ($upload->upload() === true) {
                         $fileValues = array('encName' => $upload->file_name, 'realName' => $upload->real_name, 'date' => date("Y-m-d H:i:s"), 'ticketId' => $id, 'userId' => $_SESSION['userdata']['id']);
                         $this->addFile($fileValues);
                     } else {
                         $msgKey = 'ERROR_FILEUPLOAD_' . $upload->error . '';
                     }
                 } else {
                     $msgKey = 'ERROR_FILEUPLOAD_' . $upload->error . '';
                 }
             }
             /*
             //Send mail
             $mail = new mailer();
             
             $row = $projectObj->getProject($values['projectId']);
             
             $mail->setSubject(''.$lang['ZYPRO_NEW_TICKET'].' "'.$row['name'].'" ');
             
             $username = $user->getUser($_SESSION['userdata']['id']);
             
             $url = 'http://'.$_SERVER['HTTP_HOST'].'/index.php?act=tickets.showTicket&id='.$id.'';
             
             $mailMsg = "".$lang['NEW_TICKET_MAIL_1']." ".$id." ".$lang['NEW_TICKET_MAIL_2']." ".$username['lastname']." ".$username['firstname']." ".$lang['NEW_TICKET_MAIL_3']." ".$row['name']." ".$lang['NEW_TICKET_MAIL_4']." ".$url." ".$lang['NEW_TICKET_MAIL_5']."";
             
             $mail->setText($mailMsg);
             
             if(is_numeric($values['editorId']) === false ){
             
             	$mails = $user->getMailRecipients($values['projectId']);
             		
             }else{
             			
             	$mails = $user->getSpecificMailRecipients($id);
             		
             }
             		
             
             
             $to = array();
             
             foreach($mails as $row){
             		
             	array_push($to, $row['user']);
             
             }
             
             $mail->sendMail($to);
             */
         }
         $tpl->assign('values', $values);
     }
//.........这里部分代码省略.........
开发者ID:DevelopIdeas,项目名称:leantime,代码行数:101,代码来源:class.newTicket.php

示例2: run

 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     $projects = new projects();
     $user = new users();
     $helper = new helper();
     $language = new language();
     $language->setModule('tickets');
     $lang = $language->readIni();
     $projects = $projects->getUserProjects("open");
     $msgKey = '';
     if (isset($_GET['id']) === true) {
         $id = (int) $_GET['id'];
     }
     $row = $this->getTicket($id);
     $values = array('id' => $row['id'], 'headline' => $row['headline'], 'type' => $row['type'], 'description' => $row['description'], 'priority' => $row['priority'], 'production' => $row['production'], 'staging' => $row['staging'], 'projectId' => $row['projectId'], 'userId' => $row['userId'], 'date' => $helper->timestamp2date($row['date'], 2), 'dateToFinish' => $helper->timestamp2date($row['dateToFinish'], 2), 'status' => $row['status'], 'browser' => $row['browser'], 'os' => $row['os'], 'resolution' => $row['resolution'], 'version' => $row['version'], 'url' => $row['url'], 'planHours' => $row['planHours'], 'dependingTicketId' => $row['dependingTicketId'], 'editFrom' => $helper->timestamp2date($row['editFrom'], 2), 'editTo' => $helper->timestamp2date($row['editTo'], 2), 'editorId' => $row['editorId'], 'userFirstname' => $row['userFirstname'], 'userLastname' => $row['userLastname']);
     //Make copy of array for comparison later)
     $oldValues = $values;
     if (!empty($row) && $values['headline'] !== null) {
         if (isset($_POST['save'])) {
             $timesheet = new timesheets();
             //Set admin inputs to old values, no need to use hidden fields
             if ($_SESSION['userdata']['role'] === 'client') {
                 $_POST['userId'] = $oldValues['userId'];
                 $_POST['editFrom'] = $oldValues['editFrom'];
                 $_POST['editTo'] = $oldValues['editTo'];
                 $_POST['editorId'] = $oldValues['editorId'];
                 $_POST['planHours'] = $oldValues['planHours'];
                 $_POST['dependingTicketId'] = $oldValues['dependingTicketId'];
             }
             if (!isset($_POST['production'])) {
                 $_POST['production'] = 0;
             } else {
                 $_POST['production'] = 1;
             }
             if (!isset($_POST['staging'])) {
                 $_POST['staging'] = 0;
             } else {
                 $_POST['staging'] = 1;
             }
             if (isset($_POST['editorId']) && count($_POST['editorId'])) {
                 $editorId = implode(',', $_POST['editorId']);
             } else {
                 $editorId = '';
             }
             $values = array('id' => $id, 'headline' => $_POST['headline'], 'type' => $_POST['type'], 'description' => $_POST['description'], 'projectId' => $_POST['project'], 'priority' => $_POST['priority'], 'editorId' => $editorId, 'staging' => $_POST['staging'], 'production' => $_POST['production'], 'date' => $helper->timestamp2date(date("Y-m-d H:i:s"), 2), 'dateToFinish' => $_POST['dateToFinish'], 'status' => $_POST['status'], 'browser' => $_POST['browser'], 'os' => $_POST['os'], 'planHours' => $_POST['planHours'], 'resolution' => $_POST['resolution'], 'version' => $_POST['version'], 'url' => $_POST['url'], 'editFrom' => $_POST['editFrom'], 'editTo' => $_POST['editTo'], 'dependingTicketId' => $_POST['dependingTicketId'], 'userFirstname' => $row['userFirstname'], 'userLastname' => $row['userLastname'], 'userId' => $row['userId']);
             if ($values['headline'] === '') {
                 $tpl->setNotification('ERROR_NO_HEADLINE', 'error');
                 $msgKey = "ERROR_NO_HEADLINE";
             } elseif ($values['description'] === '') {
                 $tpl->setNotification('ERROR_NO_DESCRIPTION', 'error');
             } else {
                 //Prepare dates for db
                 $values['date'] = $helper->date2timestamp($values['date']);
                 $values['dateToFinish'] = $helper->date2timestamp($values['dateToFinish']);
                 $values['editFrom'] = $helper->date2timestamp($values['editFrom']);
                 $values['editTo'] = $helper->date2timestamp($values['editTo']);
                 //Update Ticket
                 $this->updateTicket($values, $id);
                 //Take the old value to avoid nl character
                 $values['description'] = $_POST['description'];
                 $values['date'] = $helper->timestamp2date($values['date'], 2);
                 $values['dateToFinish'] = $helper->timestamp2date($values['dateToFinish'], 2);
                 $values['editFrom'] = $helper->timestamp2date($values['editFrom'], 2);
                 $values['editTo'] = $helper->timestamp2date($values['editTo'], 2);
                 $tpl->setNotification('EDIT_SUCCESS', 'success');
                 //						$msgKey = "TICKET_EDITED";
             }
         }
         //File upload
         if (isset($_POST['upload'])) {
             if (htmlspecialchars($_FILES['file']['name']) !== '') {
                 $upload = new fileupload();
                 $upload->initFile($_FILES['file']);
                 $tpl->assign('info', $upload->error);
                 if ($upload->error == '') {
                     // hash name on server for securty reasons
                     $newname = md5($id . time());
                     $upload->renameFile($newname);
                     if ($upload->upload() === true) {
                         $fileValues = array('encName' => $upload->file_name, 'realName' => $upload->real_name, 'date' => date("Y-m-d H:i:s"), 'ticketId' => $id, 'userId' => $_SESSION['userdata']['id']);
                         $this->addFile($fileValues);
                         $tpl->setNotification('FILE_UPLOADED', 'success');
                     } else {
                         $tpl->setNotification('ERROR_FILEUPLOAD_' . $upload->error . '', 'error');
                     }
                 } else {
                     $tpl->setNotification('ERROR_FILEUPLOAD_' . $upload->error . '', 'error');
                 }
             } else {
                 $tpl->setNotification('NO_FILE', 'error');
             }
         }
         //				var_dump($values); die();
//.........这里部分代码省略.........
开发者ID:DevelopIdeas,项目名称:leantime,代码行数:101,代码来源:class.editTicket.php

示例3: run

 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     //Only admins
     if ($_SESSION['userdata']['role'] == 'admin') {
         if (isset($_GET['id']) === true) {
             $id = (int) $_GET['id'];
             $row = $this->getProject($id);
             $msgKey = '';
             $values = array('name' => $row['name'], 'details' => $row['details'], 'clientId' => $row['clientId'], 'state' => $row['state'], 'hourBudget' => $row['hourBudget'], 'assignedUsers' => $this->getProjectUserRelation($id), 'dollarBudget' => $row['dollarBudget']);
             //Edit project
             if (isset($_POST['save']) === true) {
                 if (isset($_POST['editorId']) && count($_POST['editorId'])) {
                     $assignedUsers = $_POST['editorId'];
                 } else {
                     $assignedUsers = array();
                 }
                 $values = array('name' => $_POST['name'], 'details' => $_POST['details'], 'clientId' => $_POST['clientId'], 'state' => $_POST['projectState'], 'hourBudget' => $_POST['hourBudget'], 'assignedUsers' => $assignedUsers, 'dollarBudget' => $_POST['dollarBudget']);
                 if ($values['name'] !== '') {
                     if ($this->hasTickets($id) && $values['state'] == 1) {
                         $tpl->setNotification('PROJECT_HAS_TICKETS', 'error');
                     } else {
                         $this->editProject($values, $id);
                         //Take the old value to avoid nl character
                         $values['details'] = $_POST['details'];
                         $tpl->setNotification('PROJECT_EDITED', 'success');
                     }
                 } else {
                     $tpl->setNotification('NO_PROJECTTNAME', 'error');
                 }
             }
             //Add Account
             if (isset($_POST['accountSubmit']) === true) {
                 $accountValues = array('name' => $_POST['accountName'], 'kind' => $_POST['kind'], 'username' => $_POST['username'], 'password' => $_POST['password'], 'host' => $_POST['host'], 'projectId' => $id);
                 if ($accountValues['name'] !== '') {
                     $this->addProjectAccount($accountValues);
                     $tpl->setNotification('ACCOUNT_ADDED', 'sucess');
                 } else {
                     $tpl->setNotification('NO_ACCOUNT_NAME', 'error');
                 }
                 $tpl->assign('accountValues', $accountValues);
             }
             //Upload file
             if (isset($_POST['upload']) === true) {
                 if ($_FILES['file']['name'] !== '') {
                     $upload = new fileupload();
                     $upload->initFile($_FILES['file']);
                     if ($upload->error == '') {
                         //Name on Server is encoded
                         $newname = md5($id . time());
                         $upload->renameFile($newname);
                         if ($upload->upload() === true) {
                             $fileValues = array('encName' => $upload->file_name, 'realName' => $upload->real_name, 'date' => date("Y-m-d H:i:s"), 'ticketId' => $id, 'userId' => $_SESSION['userdata']['id']);
                             $this->addFile($fileValues);
                             $tpl->setNotification('FILE_UPLOADED', 'success');
                         } else {
                             $tpl->setNotification('ERROR_FILEUPLOAD', 'error');
                         }
                     } else {
                         $tpl->setNotification('ERROR_FILEUPLOAD', 'error');
                     }
                 } else {
                     $tpl->setNotification('NO_FILE', 'error');
                 }
             }
             $helper = new helper();
             $clients = new clients();
             $user = new users();
             $tpl->assign('availableUsers', $user->getAll());
             //Assign vars
             $tpl->assign('info', $msgKey);
             $tpl->assign('clients', $clients->getAll());
             $tpl->assign('values', $values);
             $tpl->assign('files', $this->getFiles($id));
             $tpl->assign('helper', $helper);
             $tpl->assign('accounts', $this->getProjectAccounts($id));
             $tpl->display('projects.editProject');
         } else {
             $tpl->display('general.error');
         }
     } else {
         $tpl->display('general.error');
     }
 }
开发者ID:DevelopIdeas,项目名称:leantime,代码行数:90,代码来源:class.editProject.php

示例4: upload

 public function upload($file, $module, $moduleId)
 {
     $upload = new fileupload();
     $path = $file['file']['name'];
     $ext = pathinfo($path, PATHINFO_EXTENSION);
     $newPath = $upload->getPath() . $module . '/';
     $upload->setPath($newPath);
     $upload->initFile($file['file']);
     $return = false;
     if ($upload->error == '') {
         $newname = md5($_SESSION['userdata']['id'] . time());
         $upload->renameFile($newname);
         if ($upload->upload() === true) {
             $values = array('encName' => $newname, 'realName' => str_replace('.' . $ext, '', $file['file']['name']), 'extension' => $ext, 'moduleId' => $moduleId, 'userId' => $_SESSION['userdata']['id']);
             $return = $this->addFile($values, $module);
         }
     }
     return $return;
 }
开发者ID:DevelopIdeas,项目名称:leantime,代码行数:19,代码来源:class.files.php


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