/**
  * 上传图片的方法
  * @return [type] [description]
  */
 public function upload()
 {
     $up = new fileupload();
     //设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
     $up->set("path", $this->imagedir);
     $up->set("maxsize", 2000000);
     $up->set("allowtype", array("gif", "png", "jpg", "jpeg"));
     $up->set("israndname", true);
     //使用对象中的upload方法, 就可以上传文件, 方法需要传一个上传表单的名子 pic, 如果成功返回true, 失败返回false
     if ($up->upload("pic")) {
         $data['imagename'] = $up->getoriginname();
         $data['imageid'] = $up->getFileName();
         $data['imageurl'] = $this->imagebaseurl . $data['imageid'];
         $this->res->setdata($data);
         $this->res->echores();
     } else {
         //获取上传失败以后的错误提示
         $this->res->seterr("4001", $up->getErrorMsg());
         $this->res->echores();
         ///Users/baidu/data/devtools/imagetmp
     }
 }
Exemple #2
0
} elseif ($_POST["mulu"] == 'busios') {
    $topass = BUSIOS;
} elseif ($_POST["mulu"] == 'trainandroid') {
    $topass = TRAINANDROID;
} elseif ($_POST["mulu"] == 'trainios') {
    $topass = TRAINIOS;
} elseif ($_POST["mulu"] == 'documentsbus') {
    $topass = DOCUMENTSBUS;
} elseif ($_POST["mulu"] == 'documentstrain') {
    $topass = DOCUMENTSTRAIN;
} elseif ($_POST["mulu"] == 'documentsother') {
    $topass = DOCUMENTSOTHER;
} else {
    $topass = LAJI;
}
$up = new fileupload();
//设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
$up->set("path", $topass);
$up->set("maxsize", 100000000);
$up->set("allowtype", array("apk", "APK", "ipa", "IPA", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "pdf", "jpg", "bmp", "png", "gif", "rb", "zip"));
$up->set("israndname", false);
//使用对象中的upload方法, 就可以上传文件, 方法需要传一个上传表单的名子 pic, 如果成功返回true, 失败返回false
if ($up->upload("file")) {
    //获取上传后文件名子
    echo "恭喜!" . $up->getFileName() . "上传成功<br/>";
    echo '<br/><input type="button" value="继续上传" name="name" onclick="javascript: window.history.back(-1);"/>';
} else {
    //获取上传失败以后的错误提示
    echo $up->getErrorMsg();
    echo '<br/><input type="button" value="继续上传" name="name" onclick="javascript: window.history.back(-1);"/>';
}
 /**
  * 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);
     }
     $tpl->assign('role', $_SESSION['userdata']['role']);
     $tpl->assign('availableUsers', $this->getAvailableUsersForTicket());
     $tpl->assign('type', $this->getType());
     //		var_dump($tpl->get)'getAll')
     $tpl->assign('info', $msgKey);
     $tpl->assign('projects', $projects);
     $tpl->assign('objTickets', $this);
     $tpl->assign('employees', $user->getEmployees());
     $tpl->display('tickets.newTicket');
 }
 /**
  * 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');
     }
 }
Exemple #5
0
         $cf->cleanStoragePath($current_company->getId());
         $dir = $cf->getStoragePath($current_company->getId());
         break;
     case 'license':
         $upload->set_max_filesize(20000);
         //1mb or less
         $upload->set_acceptable_types(array('text/plain', 'plain/text', 'application/octet-stream'));
         // comma separated string, or array
         $upload->set_overwrite_mode(1);
         $dir = Environment::getStorageBasePath() . DIRECTORY_SEPARATOR . 'license' . DIRECTORY_SEPARATOR . $current_company->getId();
         break;
 }
 Debug::Text('bUpload... Object Type: ' . $object_type, __FILE__, __LINE__, __METHOD__, 10);
 if (isset($dir)) {
     @mkdir($dir, 0700, TRUE);
     $upload_result = $upload->upload("userfile", $dir);
     //var_dump($upload ); //file data
     if ($upload_result) {
         $success = $upload_result . ' ' . TTi18n::gettext('Successfully Uploaded');
     } else {
         $error = $upload->get_error();
     }
 }
 Debug::Text('cUpload... Object Type: ' . $object_type, __FILE__, __LINE__, __METHOD__, 10);
 switch ($object_type) {
     case 'invoice_config':
         Debug::Text('Post Upload Operation...', __FILE__, __LINE__, __METHOD__, 10);
         if (isset($success) and $success != '') {
             Debug::Text('Rename', __FILE__, __LINE__, __METHOD__, 10);
             //Submit filename to db.
             //Rename file to just "logo" so its always consistent.
Exemple #6
0
Debug::Text('Object Type: ' . $object_type . ' ID: ' . $object_id . ' Parent ID: ' . $parent_id . ' POST SessionID: ' . $SessionID, __FILE__, __LINE__, __METHOD__, 10);
$upload = new fileupload();
switch ($object_type) {
    case 'invoice_config':
        if ($permission->Check('invoice_config', 'add') or $permission->Check('invoice_config', 'edit') or $permission->Check('invoice_config', 'edit_child') or $permission->Check('invoice_config', 'edit_own')) {
            $upload->set_max_filesize(1000000);
            //1mb or less
            //$upload->set_acceptable_types( array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png') ); // comma separated string, or array
            //$upload->set_max_image_size(600, 600);
            $upload->set_overwrite_mode(1);
            $icf = TTnew('InvoiceConfigFactory');
            $icf->cleanStoragePath($current_company->getId());
            $dir = $icf->getStoragePath($current_company->getId());
            if (isset($dir)) {
                @mkdir($dir, 0700, TRUE);
                $upload_result = $upload->upload("filedata", $dir);
                //var_dump($upload ); //file data
                if ($upload_result) {
                    $success = $upload_result . ' ' . TTi18n::gettext('Successfully Uploaded');
                } else {
                    $error = $upload->get_error();
                }
            }
            Debug::Text('Post Upload Operation...', __FILE__, __LINE__, __METHOD__, 10);
            if (isset($success) and $success != '') {
                Debug::Text('Rename', __FILE__, __LINE__, __METHOD__, 10);
                //Submit filename to db.
                //Rename file to just "logo" so its always consistent.
                $file_data_arr = $upload->get_file();
                rename($dir . '/' . $upload_result, $dir . '/logo' . $file_data_arr['extension']);
                //$post_js = 'window.opener.document.getElementById(\'logo\').src = \''. Environment::getBaseURL().'/send_file.php?object_type=invoice_config&rand='.time().'\'; window.opener.showLogo();';
Exemple #7
0
<meta charset="utf-8">
<?php 
mysql_connect('localhost', 'root', '');
mysql_select_db('myworks');
//包含一个文件上传类中的上传类
include "fileupload.class.php";
$up = new fileupload();
//设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
$up->set("path", "./upload/");
$up->set("maxsize", 2000000);
$up->set("allowtype", array("gif", "png", "jpg", "jpeg"));
$up->set("israndname", false);
//使用对象中的upload方法, 就可以上传文件, 方法需要传一个上传表单的名子 pic, 如果成功返回true, 失败返回false
if ($up->upload("pic")) {
    echo '<pre>';
    //获取上传后文件名子
    var_dump($up->getFileName());
    $img = $up->getFileName();
    echo '</pre> 文件上传成功!接下来写入数据库!';
    $sql = "INSERT into myworks(`name`, `desc`, `img`, `time`, `sort`, `level`) values('" . htmlspecialchars($_POST['name']) . "', '" . htmlspecialchars($_POST['desc']) . "', '" . $img . "', '" . time() . "', '" . $_POST['sort'] . "', '" . $_POST['level'] . "')";
    // echo $sql;
    $result = mysql_query($sql);
    if ($result) {
        echo "<p>插入数据库成功!<a href='../'>【返回首页】</a></p>";
    } else {
        echo "<p>插入数据库失败! <a href='../'>【返回首页】</a></p>";
    }
} else {
    echo '<pre>';
    //获取上传失败以后的错误提示
    var_dump($up->getErrorMsg());
 /**
  * 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();
         if (!$values['projectId']) {
             $projectId = $row['projectId'];
         } else {
             $projectId = $values['projectId'];
         }
         $tpl->assign('role', $_SESSION['userdata']['role']);
         $tpl->assign('type', $this->getType());
         $tpl->assign('info', $msgKey);
         $tpl->assign('projects', $projects);
         $available = $this->getAvailableUsersForTicket($projectId);
         $tpl->assign('availableUsers', $available);
         $tpl->assign('values', $values);
         $tpl->assign('objTickets', $this);
         $tpl->assign('helper', $helper);
         $tpl->display('tickets.editTicket');
     } else {
         $tpl->display('general.error');
     }
 }
 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;
 }