Пример #1
0
 public function indexAction()
 {
     WAuthUtil::whetherLogout($this);
     $routeID = $this->params()->fromRoute('id');
     $auth = WAuthUtil::get_auth();
     $userID = $auth == null ? 0 : $auth->userID;
     $mode = $routeID == $userID ? self::User_EDIT : self::USER_CHECK;
     //处理上传头像请求
     $request = $this->getRequest();
     $user = $this->getservice()->getUser($routeID);
     if ($request->isPost() && $_FILES["faceimgpath"]["error"] == 0) {
         $upfilepath = $_FILES["faceimgpath"]["tmp_name"];
         //             Debug::dump($_FILES["faceimgpath"]["tmp_name"]);
         //http://framework.zend.com/manual/current/en/modules/zend.filter.file.html
         $basepath = WBasePath::getBasePath();
         //public
         $filter = new Rename(array("target" => $basepath . '/' . "data/face/face.jpg", "randomize" => true));
         $filepath = $filter->filter($upfilepath);
         // public/,,,
         $filepath = substr($filepath, strlen($basepath));
         // File has been renamed to "./data/uploads/newfile_4b3403665fea6.txt"
         $user->setFaceimgpath($filepath);
         //             Debug::dump($filepath);
         $this->getservice()->updateUser($user);
     }
     WAuthUtil::addUserpanelToLayout($this, '/account/' . $routeID);
     return new ViewModel(array('mode' => $mode, 'user' => $user, 'friends' => $this->getservice()->getSimi()));
 }
Пример #2
0
 public function getNewRecruitIDandMakedir()
 {
     $ID = $this->getNewRecruitID();
     $base = WBasePath::getBasePath();
     //public
     $dirpath = $base . '/data/recruit/' . $ID;
     if (!file_exists($dirpath)) {
         mkdir($dirpath);
     }
     return $ID;
 }
Пример #3
0
 public function addUpPicSerAction()
 {
     $path_for_route = "/data/postinlineimg/";
     //由于在apache配置文件里设置到了public,注意前面的/一定要加,表示绝对路径
     $path_for_frame = WBasePath::getBasePath() . "/" . $path_for_route;
     //实际存的时候存放的地址。
     //         if (file_exists($path. $_FILES["upload"]["name"]))
     //         {
     //              echo $_FILES["upload"]["name"] . " already exists please choose another image.";
     //         }
     //             $ran_path_for_route=$this->getservice()->getRandomizedname();
     //         $suffixfilter=new BaseName();
     //         $suffixname=$suffixfilter->filter($_FILES['upload']['name']);//upload name
     $filter = new Rename(array("target" => $path_for_frame . $_FILES["upload"]["name"], "randomize" => true));
     $filepath = $filter->filter($_FILES['upload']['tmp_name']);
     $suffixfilter = new BaseName();
     $suffixname = $suffixfilter->filter($filepath);
     //              move_uploaded_file($_FILES["upload"]["tmp_name"],
     //              $path_for_frame . $_FILES["upload"]["name"]);
     //              echo "Stored in: " . $path_for_frame . $_FILES["upload"]["name"];
     // Required: anonymous function reference number as explained above.
     $funcNum = $_GET['CKEditorFuncNum'];
     // Optional: instance name (might be used to load a specific configuration file or anything else).
     $CKEditor = $_GET['CKEditor'];
     // Optional: might be used to provide localized messages.
     $langCode = $_GET['langCode'];
     // Check the $_FILES array and save the file. Assign the correct path to a variable ($url).
     $url = $path_for_route . $suffixname;
     // Usually you will only assign something here if the file could not be uploaded.
     $message = '';
     echo "<script type='text/javascript'> window.parent.CKEDITOR.tools.callFunction({$funcNum}, '{$url}', '{$message}');</script>";
     $viewfordisable = new ViewModel();
     $viewfordisable->setTerminal(true);
     //disable layout
     return $viewfordisable;
 }