protected function _doSave_upload($v0666f0acdeed38d4cd9084ade1739498, $v28e3d688a3c077b887921cea3fb1dbc7, $vb068931cc450442b63f5b3d276ea4297)
 {
     $v109633366fd0d46d371ede589998abaa = getcwd();
     chdir(CURRENT_WORKING_DIR);
     $v4bd19a884f07e6a2211760e682f98588 = 0;
     $vb1444fb0c07653567ad325aa25d4e37a = regedit::getInstance();
     $v594c103f2c6e04c3d8ab059f031e0c1a = cmsController::getInstance();
     $v435ed7e9f07f740abf511a62c00eef6e = "." . rtrim($v28e3d688a3c077b887921cea3fb1dbc7, "/\\") . DIRECTORY_SEPARATOR . $vb068931cc450442b63f5b3d276ea4297;
     if (isset($_FILES['upload'])) {
         foreach ($_FILES['upload']['name'] as $v865c0c0b4ab0e063e5caa3387c1a8741 => $v1cf7e4c33df66ca3d5459264ea9a5885) {
             if ($v1cf7e4c33df66ca3d5459264ea9a5885 == $vb068931cc450442b63f5b3d276ea4297) {
                 $v435ed7e9f07f740abf511a62c00eef6e = $_FILES['upload']['tmp_name'][$v865c0c0b4ab0e063e5caa3387c1a8741];
                 $v4bd19a884f07e6a2211760e682f98588 = $v865c0c0b4ab0e063e5caa3387c1a8741;
             }
         }
     }
     $v11b4278c7e5a79003db77272c1ed2cf5 = (int) filesize($v435ed7e9f07f740abf511a62c00eef6e);
     if (umiImageFile::getIsImage($vb068931cc450442b63f5b3d276ea4297)) {
         $ve6a7ab42343e8bc9131d89646abcb773 = $v594c103f2c6e04c3d8ab059f031e0c1a->getModule('data')->getAllowedMaxFileSize('img') * 1024 * 1024;
         if ($ve6a7ab42343e8bc9131d89646abcb773 > 0) {
             if ($ve6a7ab42343e8bc9131d89646abcb773 < $v11b4278c7e5a79003db77272c1ed2cf5) {
                 chdir($v109633366fd0d46d371ede589998abaa);
                 return $this->setError(getLabel('error-max_img_filesize') . ' ' . $ve6a7ab42343e8bc9131d89646abcb773 / 1024 / 1024 . "M");
             }
         }
         if (getRequest('water_mark')) {
             umiImageFile::setWatermarkOn();
         }
         $v8c7dd922ad47494fc02c388e12c00eac = umiImageFile::upload('upload', $v4bd19a884f07e6a2211760e682f98588, $v28e3d688a3c077b887921cea3fb1dbc7);
     } else {
         $v79001f389eb5f5185f6945430cb57be1 = $v594c103f2c6e04c3d8ab059f031e0c1a->getModule('data')->getAllowedMaxFileSize() * 1024 * 1024;
         if ($v79001f389eb5f5185f6945430cb57be1 > 0) {
             if ($v79001f389eb5f5185f6945430cb57be1 < $v11b4278c7e5a79003db77272c1ed2cf5) {
                 chdir($v109633366fd0d46d371ede589998abaa);
                 return $this->setError(getLabel('error-max_filesize') . ' ' . $v79001f389eb5f5185f6945430cb57be1 / 1024 / 1024 . "M");
             }
         }
         $v8c7dd922ad47494fc02c388e12c00eac = umiFile::upload('upload', $v4bd19a884f07e6a2211760e682f98588, $v28e3d688a3c077b887921cea3fb1dbc7);
     }
     chdir($v109633366fd0d46d371ede589998abaa);
     if (!$v8c7dd922ad47494fc02c388e12c00eac instanceof umiFile || $v8c7dd922ad47494fc02c388e12c00eac->getIsBroken()) {
         return $this->setError(elFinder::ERROR_UPLOAD);
     } else {
         return CURRENT_WORKING_DIR . $v8c7dd922ad47494fc02c388e12c00eac->getFilePath(true);
     }
 }
Esempio n. 2
0
 public function uploadImages()
 {
     $parentId = getRequest("param0");
     $parentElement = umiHierarchy::getInstance()->getElement($parentId);
     $hierarchy = umiHierarchy::getInstance();
     $hierarchyTypes = umiHierarchyTypesCollection::getInstance();
     $objectTypes = umiObjectTypesCollection::getInstance();
     $cmsController = cmsController::getInstance();
     if ($parentElement) {
         $folder = './images/cms/data/';
         $curEl = $parentElement;
         $altDirs = array();
         while (true) {
             $altDir = $curEl->getAltName();
             if ($altDir) {
                 array_unshift($altDirs, $altDir);
             }
             $curEl = $hierarchy->getElement($curEl->getRel());
             if (empty($curEl)) {
                 break;
             }
         }
         foreach ($altDirs as $alt) {
             $folder .= $alt . '/';
             if (!file_exists($folder)) {
                 mkdir($folder);
             }
         }
         $allowedTypes = array("jpg", "jpeg", "gif", "bmp", "png");
         $tplId = $parentElement->getTplId();
         $domainId = $parentElement->getDomainId();
         $langId = $parentElement->getLangId();
         $hierarchyTypeId = $hierarchyTypes->getTypeByName("photoalbum", "photo")->getId();
         $objectTypeId = $objectTypes->getBaseType("photoalbum", "photo");
         $objectType = $objectTypes->getType($objectTypeId);
         if ($objectType->getHierarchyTypeId() != $hierarchyTypeId) {
             $this->errorNewMessage("Object type and hierarchy type doesn't match");
             $this->errorPanic();
         }
         if (isset($_FILES['fs_upl_files']) && is_array($_FILES['fs_upl_files'])) {
             $uploadedFiles = $_FILES['fs_upl_files'];
             foreach ($uploadedFiles['name'] as $id => $pathName) {
                 if ($fileUploaded = umiImageFile::upload("fs_upl_files", $id, $folder)) {
                     $fileName = $fileUploaded->getFileName();
                     $filePath = $fileUploaded->getFilePath();
                     $fileExt = $fileUploaded->getExt();
                     if (in_array(strtolower($fileExt), $allowedTypes)) {
                         $pathInfo = getPathInfo($fileName);
                         $title = $pathInfo['filename'];
                         $elementId = $hierarchy->addElement($parentId, $hierarchyTypeId, $title, $title, $objectTypeId, $domainId, $langId, $tplId);
                         permissionsCollection::getInstance()->setDefaultPermissions($elementId);
                         $element = $hierarchy->getElement($elementId, true);
                         $element->setIsActive(true);
                         $element->setIsVisible(false);
                         $element->setName($title);
                         $element->setValue("photo", $fileUploaded);
                         $element->setValue("create_time", time());
                         $element->commit();
                         $parentElement->setUpdateTime(time());
                         $parentElement->commit();
                     } else {
                         $fileUploaded->delete();
                     }
                 }
             }
             $this->chooseRedirect();
         } else {
             throw new publicAdminException(getLabel("error-expect-files-array"));
         }
     } else {
         throw new publicAdminException(getLabel("error-expect-parent-id"));
     }
 }
Esempio n. 3
0
		public function onAutoCreateAvatar(iUmiEventPoint $oEventPoint) {
			$user_id = $oEventPoint->getParam("user_id");
			$avatar_type_id = $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("users", "avatar");
			if($oEventPoint->getMode() != "after") {
				return;
			}

			if($image = umiImageFile::upload("avatar", "user_avatar_file", "./images/cms/data/picture/")) {
				$avatar_id = umiObjectsCollection::getInstance()->addObject("Avatar for user {$user_id}", $avatar_type_id);

				$avatar = umiObjectsCollection::getInstance()->getObject($avatar_id);
				$avatar->setValue("picture", $image);
				$avatar->setValue("is_hidden", true);
				$avatar->commit();

				$user = umiObjectsCollection::getInstance()->getObject($user_id);
				$user->setValue("avatar", $avatar_id);
				$user->commit();

				return true;
			} else {
				return false;
			}
		}
 /**
  * TODO PHPDoc
  * Enter description here ...
  * @param unknown_type $object_id
  * @param unknown_type $is_new
  * @param unknown_type $b_force_owner
  * @param unknown_type $all
  */
 public function saveEditedObject($object_id, $is_new = false, $b_force_owner = false, $all = false)
 {
     global $_FILES;
     $cmsController = cmsController::getInstance();
     $permissions = permissionsCollection::getInstance();
     if (!($object = umiObjectsCollection::getInstance()->getObject($object_id))) {
         return false;
     }
     if (!$b_force_owner && !$permissions->isOwnerOfObject($object_id)) {
         return false;
     }
     $object_type_id = $object->getTypeId();
     $object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id);
     $key = $is_new ? "new" : $object_id;
     if (is_null(getRequest('data'))) {
         if (is_null($_FILES)) {
             return true;
         } else {
             $_REQUEST['data'][$key] = array();
         }
     }
     $data = isset($_REQUEST['data'][$key]) ? $_REQUEST['data'][$key] : array();
     foreach ($_REQUEST as $skey => $value) {
         $real_key = substr($skey, 7);
         if (substr($skey, 0, 7) == 'select_' && !isset($data[$real_key])) {
             $data[$real_key] = $value;
         }
     }
     if (isset($_FILES['data']['tmp_name'][$key])) {
         foreach ($_FILES['data']['tmp_name'][$key] as $i => $v) {
             $data[$i] = $v;
         }
     }
     $data = $this->checkRequiredData($object_type, $data, $object_id, $is_new);
     $data = $this->checkAllowedData($object_type, $data);
     foreach ($data as $field_name => $field_value) {
         if (!($field_id = $object_type->getFieldId($field_name))) {
             continue;
         }
         $field = umiFieldsCollection::getInstance()->getField($field_id);
         if (!$field->getIsVisible() && !$all) {
             //continue;
         }
         $field_type = $field->getFieldType();
         $data_type = $field_type->getDataType();
         $fldr_name = $field_name . '/';
         switch ($data_type) {
             case "password":
                 if (isset($field_value[1])) {
                     $field_value = $field_value[0] == $field_value[1] ? md5($field_value[0]) : NULL;
                 } else {
                     if (is_array($field_value)) {
                         $field_value = $field_value[0] ? md5($field_value[0]) : NULL;
                     } else {
                         $field_value = $field_value ? md5($field_value) : NULL;
                     }
                 }
                 break;
             case "date":
                 $oDate = new umiDate();
                 $oDate->setDateByString($field_value);
                 $field_value = $oDate;
                 break;
             case "img_file":
                 switch ($field_name) {
                     case "menu_pic_ua":
                         $destination_folder = "./images/cms/menu/";
                         break;
                     case "header_pic":
                         $destination_folder = "./images/cms/headers/";
                         break;
                     case "menu_pic_a":
                         $destination_folder = "./images/cms/menu/";
                         break;
                     default:
                         $destination_folder = "./images/cms/data/";
                         break;
                 }
                 // TODO: вставить проверку на необходимость наложения на картинку водного знака (by lauri)
                 $oldValue = $object->getValue($field_name);
                 if ($value = umiImageFile::upload("data", $field_name, substr($destination_folder, 2), $key)) {
                     $field_value = $value;
                 } else {
                     $file_name = substr($field_value, 0, 2) == "./" ? $field_value : $destination_folder . $field_value;
                     $field_value = new umiImageFile($file_name);
                 }
                 break;
             case "video_file":
             case "swf_file":
                 $destination_folder = "./files/" . (is_dir("./files/" . $fldr_name) ? $fldr_name : '');
                 if ($value = umiFile::upload("data", $field_name, $destination_folder, $key)) {
                     $field_value = $value;
                 } else {
                     $oldvalue = $object->getValue($field_name);
                     if ($oldvalue) {
                         $destination_folder = $oldvalue->getDirName() . "/";
                     }
                     $file_name = substr($field_value, 0, 2) == "./" ? $field_value : $destination_folder . $field_value;
                     $field_value = new umiFile($file_name);
                 }
                 break;
             case "file":
                 $destination_folder = "./files/" . (is_dir("./files/" . $fldr_name) ? $fldr_name : '');
                 if ($value = umiFile::upload("data", $field_name, $destination_folder, $key)) {
                     $field_value = $value;
                 } else {
                     $oldvalue = $object->getValue($field_name);
                     if ($oldvalue) {
                         $destination_folder = $oldvalue->getDirName() . "/";
                     }
                     $file_name = substr($field_value, 0, 2) == "./" ? $field_value : $destination_folder . $field_value;
                     $field_value = new umiFile($file_name);
                 }
                 break;
             case "string":
             case "text":
             case "wysiwyg":
                 if ($cmsController->getCurrentMode() != "admin") {
                     $field_value = strip_tags($field_value);
                 }
                 break;
         }
         $object->setValue($field_name, $field_value);
     }
     $object->commit();
     return true;
 }