コード例 #1
0
ファイル: CustomerAction.class.php プロジェクト: 2ger/trunk
 public function import()
 {
     $save_path = get_save_path();
     $opmode = $_POST["opmode"];
     if ($opmode == "import") {
         import("@.ORG.Util.UploadFile");
         $upload = new UploadFile();
         $upload->savePath = $save_path;
         $upload->allowExts = array('xlsx');
         $upload->saveRule = uniqid;
         $upload->autoSub = false;
         if (!$upload->upload()) {
             $this->error($upload->getErrorMsg());
         } else {
             //取得成功上传的文件信息
             $uploadList = $upload->getUploadFileInfo();
             Vendor('Excel.PHPExcel');
             //导入thinkphp第三方类库
             $inputFileName = $save_path . $uploadList[0]["savename"];
             $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
             $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
             $model = M("Customer");
             for ($i = 2; $i <= count($sheetData); $i++) {
                 $data = array();
                 $data['name'] = $sheetData[$i]["A"];
                 $data['short'] = $sheetData[$i]["B"];
                 $data['letter'] = get_letter($sheetData[$i]["A"]);
                 $data['biz_license'] = $sheetData[$i]["C"];
                 $data['payment'] = $sheetData[$i]["D"];
                 $data['address'] = $sheetData[$i]["E"];
                 $data['salesman'] = $sheetData[$i]["F"];
                 $data['contact'] = $sheetData[$i]["G"];
                 $data['email'] = $sheetData[$i]["H"];
                 $data['office_tel'] = $sheetData[$i]["I"];
                 $data['mobile_tel'] = $sheetData[$i]["J"];
                 $data['fax'] = $sheetData[$i]["K"];
                 $data['im'] = $sheetData[$i]["L"];
                 $data['remark'] = $sheetData[$i]["M"];
                 $data['is_del'] = 0;
                 $model->add($data);
             }
             //dump($sheetData);
             if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . $inputFileName)) {
                 unlink($_SERVER["DOCUMENT_ROOT"] . "/" . $inputFileName);
             }
             $this->assign('jumpUrl', get_return_url());
             $this->success('导入成功!');
         }
     } else {
         $this->display();
     }
 }
コード例 #2
0
ファイル: FileAction.class.php プロジェクト: hongweipeng/oa
 function player()
 {
     $user_id = get_user_id();
     $this->assign("user_id", $user_id);
     $file_id = $_GET['attach_id'];
     $file_id = f_decode($file_id);
     $add_file = explode(";", $add_file);
     $add_file = $add_file[0];
     $where['id'] = $file_id;
     $video_path = M("File")->where($where)->getField("savename");
     $video_ext = M("File")->where($where)->getField("extension");
     $this->assign('video_file', get_save_path() . $video_path);
     $this->assign('video_ext', $video_ext);
     $this->display();
 }
コード例 #3
0
 /** 上传限制 */
 protected function _upload()
 {
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     if (!empty($_FILES)) {
         import("@.ORG.Util.UploadFile");
         $upload = new UploadFile();
         $upload->subFolder = strtolower(MODULE_NAME);
         $upload->savePath = get_save_path();
         $upload->saveRule = "uniqid";
         $upload->autoSub = true;
         $upload->subType = "date";
         /** @var  allowExts上传格式设置 */
         $allowExts_arr = array('jpg', 'jpeg', 'png');
         $upload->allowExts = array_filter($allowExts_arr, 'upload_filter');
         if (!$upload->upload()) {
             $data['error'] = 1;
             $data['message'] = $upload->getErrorMsg();
             $data['status'] = 0;
             exit(json_encode($data));
             //exit($upload -> getErrorMsg());
         } else {
             //取得成功上传的文件信息
             $upload_list = $upload->getUploadFileInfo();
             $sid = get_sid();
             $file_info = $upload_list[0];
             //                var_dump($file_info);
             $model = M("File");
             $model->create($upload_list[0]);
             $model->create_time = time();
             $model->user_id = get_user_id();
             $model->sid = $sid;
             $model->module = MODULE_NAME;
             $file_id = $model->add();
             $file_info['sid'] = $sid;
             $file_info['error'] = 0;
             $file_info['url'] = __ROOT__ . "/" . $file_info['savepath'] . $file_info['savename'];
             $file_info['status'] = 1;
             //header("Content-Type:text/html; charset=utf-8");
             exit(json_encode($file_info));
             //$this->ajaxReturn(json_encode($file_info),'上传成功',1,$file_info['url']);
             //$this->success ('上传成功!');
         }
     }
 }
コード例 #4
0
 public function import()
 {
     $save_path = get_save_path();
     $opmode = $_POST["opmode"];
     if ($opmode == "import") {
         import("@.ORG.Util.UploadFile");
         $upload = new UploadFile();
         $upload->savePath = $save_path;
         $upload->allowExts = array('xlsx', 'xls');
         $upload->saveRule = uniqid;
         $upload->autoSub = false;
         if (!$upload->upload()) {
             $this->error($upload->getErrorMsg());
         } else {
             //取得成功上传的文件信息
             $uploadList = $upload->getUploadFileInfo();
             Vendor('Excel.PHPExcel');
             //导入thinkphp第三方类库
             $inputFileName = $save_path . $uploadList[0]["savename"];
             $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
             $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
             // dump(count($sheetData));
             // exit;
             $model = M(MODULE_NAME);
             //dump($sheetData);
             for ($i = $this->first_row; $i <= count($sheetData); $i++) {
                 $data = array();
                 $data['emp_no'] = $sheetData[$i]["A"];
                 //                    $data['B']=PHPExcel_Shared_Date::ExcelToPHP($sheetData[$i]["B"]);
                 $data['B'] = $sheetData[$i]["B"];
                 for ($k = 67; $k <= 67 + $this->field_count; $k++) {
                     $data[chr($k)] = $sheetData[$i][chr($k)];
                 }
                 $model->add($data);
             }
             //dump($sheetData);
             if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . $inputFileName)) {
                 unlink($_SERVER["DOCUMENT_ROOT"] . "/" . $inputFileName);
             }
             $this->assign('jumpUrl', get_return_url());
             $this->success('导入成功!');
         }
     } else {
         $this->display();
     }
 }
コード例 #5
0
 protected function _destory_file($file_list)
 {
     if (isset($file_list)) {
         if (is_array($file_list)) {
             $where["sid"] = array("in", $file_list);
         } else {
             $where["sid"] = array('in', array_filter(explode(',', $file_list)));
         }
     }
     $model = M("File");
     $where['module'] = MODULE_NAME;
     $admin = $this->config['auth']['admin'];
     if ($admin) {
         $where['user_id'] = array('eq', get_user_id());
     }
     $list = $model->where($where)->select();
     $save_path = get_save_path();
     foreach ($list as $file) {
         if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . $save_path . $file['savename'])) {
             unlink($_SERVER["DOCUMENT_ROOT"] . "/" . $save_path . $file['savename']);
         }
     }
     $result = $model->where($where)->delete();
     if ($result !== false) {
         return true;
     } else {
         return false;
     }
 }
コード例 #6
0
 private function _receive_file($str, &$model)
 {
     if (!empty($str)) {
         $ar = array_filter(explode(",", $str));
         foreach ($ar as $key => $value) {
             $ar2 = explode("_", $value);
             $cid = $ar2[0];
             if (true) {
                 //if(strlen($cid)>10){
                 $inline = $ar2[1];
                 $file_name = $ar2[2];
                 $File = M("File");
                 $File->name = $file_name;
                 $File->user_id = $model->user_id;
                 $File->size = filesize($this->tmpPath . urlencode($value));
                 $File->extension = getExt($value);
                 $File->create_time = time();
                 $sid = get_sid();
                 $File->sid = $sid;
                 $File->module = MODULE_NAME;
                 $dir = 'mail/' . get_emp_no() . "/" . date("Ym");
                 $File->savename = $dir . '/' . uniqid() . '.' . $File->extension;
                 $save_name = $File->savename;
                 if (!is_dir(get_save_path() . $dir)) {
                     mkdir(get_save_path() . $dir, 0777, true);
                     chmod(get_save_path() . $dir, 0777);
                 }
                 if (!is_dir($this->tmpPath . $dir)) {
                     mkdir($this->tmpPath . $dir, 0777, true);
                     chmod($this->tmpPath . $dir, 0777);
                 }
                 if (rename($this->tmpPath . urlencode($value), get_save_path() . $save_name)) {
                     $file_id = $File->add();
                     if ($inline == "INLINE") {
                         $model->content = str_replace("cid:" . $cid, "/" . get_save_path() . $save_name, $model->content);
                     } else {
                         $add_file = $add_file . $sid . ';';
                     }
                 }
             }
         }
         return $add_file;
     }
 }
コード例 #7
0
ファイル: PopupAction.class.php プロジェクト: hongweipeng/oa
 function resize_img()
 {
     if (!($image = $_POST["img"])) {
         $result['result_code'] = 101;
         $result['result_des'] = "图片不存在";
     } else {
         $real_img = $_SERVER['DOCUMENT_ROOT'] . $image;
         $info = get_img_info($real_img);
         if (!$info) {
             $result['result_code'] = 102;
             $result['result_des'] = $image;
         } else {
             $max_width = 440;
             if ($info['type'] == 'jpg' || $info['type'] == 'jpeg') {
                 $im = imagecreatefromjpeg($real_img);
             }
             if ($info['type'] == 'gif') {
                 $im = imagecreatefromgif($real_img);
             }
             if ($info['type'] == 'png') {
                 $im = imagecreatefrompng($real_img);
             }
             if ($info['width'] <= $max_width) {
                 $rate = 1;
             } else {
                 $rate = $info['width'] / $max_width;
                 if ($info['width'] > $info['height']) {
                     $max_height = intval($info['height'] / ($info['width'] / $max_width));
                 } else {
                     $max_width = intval($info['width'] / ($info['height'] / $max_height));
                 }
             }
             $x = $_POST["x"];
             $y = $_POST["y"];
             $w = $_POST["w"];
             $h = $_POST["h"];
             $width = $srcWidth = $info['width'];
             $height = $srcHeight = $info['height'];
             $type = empty($type) ? $info['type'] : $type;
             $type = strtolower($type);
             unset($info);
             //创建缩略图
             if ($type != 'gif' && function_exists('imagecreatetruecolor')) {
                 $thumbImg = imagecreatetruecolor($width, $height);
             } else {
                 $thumbImg = imagecreate($width, $height);
             }
             // 复制图片
             if (function_exists("imagecopyresampled")) {
                 imagecopyresampled($thumbImg, $im, 0, 0, 0, 0, $width, $height, $srcWidth, $srcHeight);
             } else {
                 imagecopyresized($thumbImg, $im, 0, 0, 0, 0, $width, $height, $srcWidth, $srcHeight);
             }
             if ('gif' == $type || 'png' == $type) {
                 $background_color = imagecolorallocate($thumbImg, 0, 255, 0);
                 imagecolortransparent($thumbImg, $background_color);
             }
             // 对jpeg图形设置隔行扫描
             if ('jpg' == $type || 'jpeg' == $type) {
                 imageinterlace($thumbImg, 1);
             }
             if (!is_dir(get_save_path() . "emp_pic/")) {
                 mkdir(get_save_path() . "emp_pic/", 0777, true);
                 chmod(get_save_path() . "emp_pic/", 0777);
             }
             // 生成图片
             $imageFun = 'image' . ($type == 'jpg' ? 'jpeg' : $type);
             $id = $_REQUEST['id'];
             $thumbname = get_save_path() . "emp_pic/" . $id . "." . $type;
             $imageFun($thumbImg, $thumbname, 100);
             $thumbImg_120 = imagecreatetruecolor(120, 120);
             imagecopyresampled($thumbImg_120, $thumbImg, 0, 0, intval($x * $rate), intval($y * $rate), intval(120 * 1), intval(120 * 1), intval($w * $rate), intval($h * $rate));
             $imageFun($thumbImg_120, $thumbname, 100);
             imagedestroy($thumbImg);
             imagedestroy($im);
             $result['result_code'] = 1;
             $result['result_des'] = str_replace(get_save_path(), "", $thumbname);
         }
     }
     echo json_encode($result);
 }
コード例 #8
0
 protected function _down()
 {
     $attach_id = $_REQUEST["attach_id"];
     $file_id = f_decode($attach_id);
     $File = M("File")->find($file_id);
     $filepath = get_save_path() . $File['savename'];
     $filePath = realpath($filepath);
     $fp = fopen($filePath, 'rb');
     $ua = $_SERVER["HTTP_USER_AGENT"];
     if (!preg_match("/MSIE/", $ua)) {
         header("Content-Length: " . filesize($filePath));
         Header("Content-type: application/octet-stream");
         header("Content-Length: " . filesize($filePath));
         header("Accept-Ranges: bytes");
         header("Accept-Length: " . filesize($filePath));
     }
     header("Content-Disposition:attachment;filename =" . str_ireplace('+', '%20', URLEncode($File['name'])));
     header('Cache-Control:must-revalidate, post-check=0,pre-check=0');
     header('Expires:     0');
     header('Pragma:     public');
     //echo $query;
     fpassthru($fp);
     exit;
 }
コード例 #9
0
ファイル: common.php プロジェクト: hongweipeng/oa
function get_emp_pic($id)
{
    $data = M("User")->where("id={$id}")->getField("pic");
    if (empty($data)) {
        $data = get_save_path() . "emp_pic/no_avatar.jpg";
    }
    return $data;
}
コード例 #10
0
 public function sync_send_to()
 {
     $this->_get_mail_account();
     $title = $_REQUEST['name'];
     $body = $_REQUEST['content'];
     $to = $_REQUEST['wai1'];
     $cc = $_REQUEST['cc'];
     $bcc = $_REQUEST['bcc'];
     $this->_set_recent($to . $cc . $bcc);
     //header('Content-type:text/html;charset=utf-8');
     //vendor("Mail.class#send");
     import("@.ORG.Util.send");
     //从PHPMailer目录导入class.send.php类文件
     $mail = new PHPMailer(true);
     // the true param means it will throw exceptions on errors, which we need to catch
     $mail->IsSMTP();
     // telling the class to use SMTP
     try {
         $mail->Host = $this->_account['smtpsvr'];
         //"smtp.qq.com"; // SMTP server 部分邮箱不支持SMTP,QQ邮箱里要设置开启的
         $mail->SMTPDebug = false;
         // 改为2可以开启调试
         $mail->SMTPAuth = true;
         // enable SMTP authentication
         $mail->Port = 25;
         // set the SMTP port for the GMAIL server
         $mail->CharSet = "UTF-8";
         // 这里指定字符集!解决中文乱码问题
         $mail->Encoding = "base64";
         $mail->Username = $this->_account['mail_id'];
         // SMTP account username
         $mail->Password = $this->_account['mail_pwd'];
         // SMTP account password
         $mail->SetFrom($this->_account['email'], $this->_account['mail_name']);
         //发送者邮箱
         $mail->AddReplyTo($this->_account['email'], $this->_account['mail_name']);
         //回复到这个邮箱
         $arr_to = array_filter(explode(';', $to));
         foreach ($arr_to as $item) {
             //                dump($item);
             //                exit;
             if (strpos($item, "dept@group") !== false) {
                 $arr_tmp = array_filter(explode('|', $item));
                 $dept_id = str_replace("dept_", '', $arr_tmp[2]);
                 $mail_list = $this->get_mail_list_by_dept_id($dept_id);
                 foreach ($mail_list as $val) {
                     //                        dump($val);
                     //                        exit;
                     if (PHPMailer::validateAddress($item)) {
                         $mail->AddAddress($item, $val["emp_name"]);
                     }
                     // 收件人
                 }
             } else {
                 $arr_tmp = explode('|', $item);
                 if (PHPMailer::validateAddress($item)) {
                     $mail->AddAddress($item, $arr_tmp[0]);
                 }
                 // 收件人
             }
         }
         $arr_cc = array_filter(explode(';', $cc));
         foreach ($arr_to as $item) {
             if (strpos($item, "dept@group") !== false) {
                 $arr_tmp = array_filter(explode('|', $item));
                 $dept_id = str_replace("dept_", '', $arr_tmp[2]);
                 $mail_list = $this->get_mail_list_by_dept_id($dept_id);
                 foreach ($mail_list as $val) {
                     if (PHPMailer::validateAddress($val["email"])) {
                         $mail->AddAddress($val["email"], $val["emp_name"]);
                     }
                     // 收件人
                 }
             } else {
                 $arr_tmp = explode('|', $item);
                 if (PHPMailer::validateAddress($arr_tmp[1])) {
                     $mail->AddAddress($arr_tmp[1], $arr_tmp[0]);
                 }
                 // 收件人
             }
         }
         $arr_bcc = array_filter(explode(';', $bcc));
         foreach ($arr_bcc as $item) {
             if (strpos($item, "dept@group") !== false) {
                 $arr_tmp = array_filter(explode('|', $item));
                 $dept_id = str_replace("dept_", '', $arr_tmp[2]);
                 $mail_list = $this->get_mail_list_by_dept_id($dept_id);
                 foreach ($mail_list as $val) {
                     if (PHPMailer::validateAddress($val["email"])) {
                         $mail->AddAddress($val["email"], $val["emp_name"]);
                     }
                     // 收件人
                 }
             } else {
                 $tmp = explode('|', $item);
                 var_dump(PHPMailer::validateAddress($arr_tmp[1]));
                 if (PHPMailer::validateAddress($tmp[1])) {
                     $mail->AddAddress($tmp[1], $tmp[0]);
                 }
                 // 收件人
             }
         }
         $mail->Subject = "=?UTF-8?B?" . base64_encode($title) . "?=";
         //嵌入式图片处理
         if (preg_match('/\\/Data\\/files\\/\\d{6}\\/.{14}(jpg|gif|png)/', $body, $images)) {
             $i = 1;
             foreach ($images as $image) {
                 if (strlen($image) > 20) {
                     $cid = 'img' . $i++;
                     $name = $mail->AddEmbeddedImage(substr($image, 1), $cid);
                     $body = str_replace($image, "cid:{$cid}", $body);
                 }
             }
         }
         $mail->MsgHTML($body);
         $add_file = $_REQUEST['add_file'];
         if (!empty($add_file)) {
             $files = $this->_real_file($add_file);
             foreach ($files as $file) {
                 $mail->AddAttachment(get_save_path() . $file['savename'], $file['name']);
             }
         }
         //同步内部邮箱
         $flag = $this->_send();
         if (!$flag) {
             $this->error("内部错误");
         }
         if ($mail->Send()) {
             cookie('current_node', 105);
             return true;
             // $this->success("发送成功", U('mail/receiving'));
         } else {
             $this->error($mail->ErrorInfo);
         }
     } catch (phpmailerException $e) {
         echo $e->errorMessage();
         // $exception = $e -> errorMessage();
         // $this->error("发送失败!$exception");
         //Pretty error messages from PHPMailer
     } catch (Exception $e) {
         // echo "aaaaaa";
         echo $e->getMessage();
         //Boring error messages from anything else!
     }
 }