• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP UTIL_File类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addTemplate

 public function addTemplate($fileName, $roleIds = null, $default = false)
 {
     $canvasWidth = self::CANVAS_WIDTH;
     $canvasHeight = $this->config['cover_height'];
     $coverImage = new UTIL_Image($fileName);
     $imageHeight = $coverImage->getHeight();
     $imageWidth = $coverImage->getWidth();
     $css = array('width' => 'auto', 'height' => 'auto');
     $tmp = $canvasWidth * $imageHeight / $imageWidth;
     if ($tmp >= $canvasHeight) {
         $css['width'] = '100%';
     } else {
         $css['height'] = '100%';
     }
     $template = new UHEADER_BOL_Template();
     $extension = UTIL_File::getExtension($fileName);
     $template->file = uniqid('template-') . '.' . $extension;
     $template->default = $default;
     $template->timeStamp = time();
     $dimensions = array('height' => $imageHeight, 'width' => $imageWidth);
     $template->setSettings(array('dimensions' => $dimensions, 'css' => $css, 'canvas' => array('width' => $canvasWidth, 'height' => $canvasHeight), 'position' => array('top' => 0, 'left' => 0)));
     $this->service->saveTemplate($template);
     if ($roleIds !== null) {
         $this->service->saveRoleIdsForTemplateId($template->id, $roleIds);
     }
     $templatePath = $this->service->getTemplatePath($template);
     OW::getStorage()->copyFile($fileName, $templatePath);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:28,代码来源:templates_bridge.php


示例2: uploadTmpAvatar

 public function uploadTmpAvatar($file)
 {
     if (isset($file)) {
         $lang = OW::getLanguage();
         if (!UTIL_File::validateImage($file['name'])) {
             return array('result' => false, 'error' => $lang->text('base', 'not_valid_image'));
         }
         if (!empty($file['error'])) {
             $message = BOL_FileService::getInstance()->getUploadErrorMessage($file['error']);
         }
         if (!empty($message)) {
             return array('result' => false, 'error' => $message);
         }
         $filesize = OW::getConfig()->getValue('base', 'avatar_max_upload_size');
         if (empty($file['size']) || $filesize * 1024 * 1024 < $file['size']) {
             $message = OW::getLanguage()->text('base', 'upload_file_max_upload_filesize_error');
             return array('result' => false, 'error' => $message);
         }
         $avatarService = BOL_AvatarService::getInstance();
         $key = $avatarService->getAvatarChangeSessionKey();
         $uploaded = $avatarService->uploadUserTempAvatar($key, $file['tmp_name']);
         if (!$uploaded) {
             return array('result' => false, 'error' => $lang->text('base', 'upload_avatar_faild'));
         }
         $url = $avatarService->getTempAvatarUrl($key, 3);
         return array('result' => true, 'url' => $url);
     }
     return array('result' => false);
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:29,代码来源:upload_tmp_avatar_trait.php


示例3: import

 public function import($params)
 {
     $importDir = $params['importDir'];
     $txtFile = $importDir . 'configs.txt';
     // import configs
     if (file_exists($txtFile)) {
         $string = file_get_contents($txtFile);
         $configs = json_decode($string, true);
     }
     if (!$configs) {
         return;
     }
     $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
     $attDir = OW::getPluginManager()->getPlugin('forum')->getUserFilesDir();
     $attachments = $attachmentService->findAllAttachments();
     if (!$attachments) {
         return;
     }
     foreach ($attachments as $file) {
         OW::getDbo()->query("SELECT 1 ");
         $ext = UTIL_File::getExtension($file->fileName);
         $path = $attachmentService->getAttachmentFilePath($file->id, $file->hash, $ext);
         $fileName = str_replace($attDir, '', $path);
         $content = file_get_contents($configs['url'] . '/' . $fileName);
         if (mb_strlen($content)) {
             OW::getStorage()->fileSetContent($path, $content);
         }
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:29,代码来源:import.php


示例4: processCleanUp

 public function processCleanUp()
 {
     $configs = OW::getConfig()->getValues('cacheextreme');
     //clean template cache
     if ($configs['template_cache']) {
         OW_ViewRenderer::getInstance()->clearCompiledTpl();
     }
     //clean db backend cache
     if ($configs['backend_cache']) {
         OW::getCacheManager()->clean(array(), OW_CacheManager::CLEAN_ALL);
     }
     //clean themes static contents cache
     if ($configs['theme_static']) {
         OW::getThemeManager()->getThemeService()->processAllThemes();
     }
     //clean plugins static contents cache
     if ($configs['plugin_static']) {
         $pluginService = BOL_PluginService::getInstance();
         $activePlugins = $pluginService->findActivePlugins();
         /* @var $pluginDto BOL_Plugin */
         foreach ($activePlugins as $pluginDto) {
             $pluginStaticDir = OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'static' . DS;
             if (file_exists($pluginStaticDir)) {
                 $staticDir = OW_DIR_STATIC_PLUGIN . $pluginDto->getModule() . DS;
                 if (file_exists($staticDir)) {
                     UTIL_File::removeDir($staticDir);
                 }
                 mkdir($staticDir);
                 chmod($staticDir, 0777);
                 UTIL_File::copyDir($pluginStaticDir, $staticDir);
             }
         }
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:34,代码来源:service.php


示例5: includeStaticFile

 public function includeStaticFile($file)
 {
     $document = OW::getDocument();
     $staticUrl = $this->plugin->getStaticUrl();
     $ext = UTIL_File::getExtension($file);
     $file .= "?" . $this->plugin->getDto()->build;
     switch ($ext) {
         case "css":
             $document->addStyleSheet($staticUrl . $file);
             break;
         case "js":
             $document->addScript($staticUrl . $file);
             break;
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:15,代码来源:plugin.php


示例6: addFile

 public function addFile(MAILBOX_BOL_FileUpload $dto, $filePath)
 {
     $ext = UTIL_File::getExtension($dto->fileName);
     if (!$this->fileExtensionIsAllowed($ext) && !file_exists($filePath)) {
         return false;
     }
     $uploadPath = $this->getUploadFilePath($dto->hash, $ext);
     $dto->filePath = $uploadPath;
     $this->saveOrUpdate($dto);
     $attId = $dto->id;
     if (move_uploaded_file($filePath, $uploadPath)) {
         @chmod($uploadPath, 0666);
         return true;
     } else {
         $this->uploadFileDao->deleteById($attId);
         return false;
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:18,代码来源:file_upload_service.php


示例7: renderInput

 /**
  * @see FormElement::renderInput()
  *
  * @param array $params
  * @return string
  */
 public function renderInput($params = null)
 {
     parent::renderInput($params);
     $fileElementId = $this->getId() . '_file';
     $entityId = $this->getValue();
     if (empty($entityId)) {
         $entityId = uniqid('upload');
     }
     $iframeUrl = OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'fileUpload', array('entityId' => $entityId, 'formElementId' => $fileElementId));
     $attachFileHtml = '<div id="file_attachment" class="ow_mailbox_attachment">
                            <span class="ow_mailbox_attachment_icon ow_ic_attach ">&nbsp;</span>
                            <a class="file" href="javascript://"></a> (<span class="filesize"></span>)
                            <a rel="40" class="ow_delete_attachment ow_lbutton ow_hidden" href="javascript://" style="display: none;">' . OW::getLanguage()->text('mailbox', 'attache_file_delete_button') . '</a>
                        </div>';
     $fileList = array();
     if (!empty($entityId)) {
         $fileService = MAILBOX_BOL_FileUploadService::getInstance();
         $uploadFileDtoList = $fileService->findUploadFileList($entityId);
         foreach ($uploadFileDtoList as $uploadFileDto) {
             $file = array();
             $file['hash'] = $uploadFileDto->hash;
             $file['filesize'] = round($uploadFileDto->fileSize / 1024, 2) . 'Kb';
             $file['filename'] = $uploadFileDto->fileName;
             $file['fileUrl'] = $fileService->getUploadFileUrl($uploadFileDto->hash, UTIL_File::getExtension($uploadFileDto->fileName));
             $fileList[] = $file;
         }
     }
     $params = array('elementId' => $fileElementId, 'ajaxResponderUrl' => OW::getRouter()->urlFor("MAILBOX_CTRL_Mailbox", "responder"), 'fileResponderUrl' => $iframeUrl, 'attachFileHtml' => $attachFileHtml, 'fileList' => $fileList);
     $script = "  window.fileUpload_" . $this->getId() . " = new fileUpload(" . json_encode($params) . ");\n                        window.fileUpload_" . $this->getId() . ".init();";
     OW::getDocument()->addOnloadScript($script);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("mailbox")->getStaticJsUrl() . 'ajax_file_upload.js');
     $hiddenAttr = array('id' => $this->getId(), 'type' => 'hidden', 'name' => $this->getName(), 'value' => $entityId);
     $fileAttr = $this->attributes;
     unset($fileAttr['name']);
     $fileAttr['id'] = $fileElementId;
     return UTIL_HtmlTag::generateTag('input', $hiddenAttr) . '<span class="' . $fileElementId . '_class">' . UTIL_HtmlTag::generateTag('input', $fileAttr) . '</span>
             <div id="' . $fileElementId . '_list" class="ow_small ow_smallmargin">
                 <div class="ow_attachments_label mailbox_attachments_label ow_hidden">' . OW::getLanguage()->text('mailbox', 'attachments') . ' :</div>
             </div>';
 }
开发者ID:vazahat,项目名称:dudex,代码行数:46,代码来源:ajax_file_upload.php


示例8: createAvatar

 protected function createAvatar($userId)
 {
     $avatarService = BOL_AvatarService::getInstance();
     $path = $_FILES['userPhoto']['tmp_name'];
     if (!file_exists($path)) {
         return false;
     }
     if (!UTIL_File::validateImage($_FILES['userPhoto']['name'])) {
         return false;
     }
     $event = new OW_Event('base.before_avatar_change', array('userId' => $userId, 'avatarId' => null, 'upload' => true, 'crop' => false, 'isModerable' => false));
     OW::getEventManager()->trigger($event);
     $avatarSet = $avatarService->setUserAvatar($userId, $path, array('isModerable' => false, 'trackAction' => false));
     if ($avatarSet) {
         $avatar = $avatarService->findByUserId($userId);
         if ($avatar) {
             $event = new OW_Event('base.after_avatar_change', array('userId' => $userId, 'avatarId' => $avatar->id, 'upload' => true, 'crop' => false));
             OW::getEventManager()->trigger($event);
         }
     }
     return $avatarSet;
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:22,代码来源:join.php


示例9: getFileNameList

 public function getFileNameList($dirPath, $prefix = null, array $fileTypes = null)
 {
     $dirPath = UTIL_File::removeLastDS($dirPath);
     $resultList = array();
     $handle = opendir($dirPath);
     while (($item = readdir($handle)) !== false) {
         if ($item === '.' || $item === '..') {
             continue;
         }
         if ($prefix != null) {
             $prefixLength = strlen($prefix);
             if (!($prefixLength <= strlen($item) && substr($item, 0, $prefixLength) === $prefix)) {
                 continue;
             }
         }
         $path = $dirPath . DS . $item;
         if ($fileTypes === null || is_file($path) && in_array(UTIL_File::getExtension($item), $fileTypes)) {
             $resultList[] = $path;
         }
     }
     closedir($handle);
     return $resultList;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:23,代码来源:file_storage.php


示例10: exportThemes

 private function exportThemes(ZipArchive $za, $archiveDir)
 {
     $currentTheme = OW::getThemeManager()->getSelectedTheme()->getDto();
     $currentThemeDir = OW::getThemeManager()->getSelectedTheme()->getRootDir();
     $currentThemeUserfilesDir = OW_DIR_THEME_USERFILES;
     $this->configs['currentTheme'] = array('name' => $currentTheme->name, 'customCss' => $currentTheme->customCss, 'customCssFileName' => $currentTheme->customCssFileName, 'description' => $currentTheme->description, 'isActive' => $currentTheme->isActive, 'sidebarPosition' => $currentTheme->sidebarPosition, 'title' => $currentTheme->title);
     $controlValueList = OW::getDbo()->queryForList(" SELECT * FROM " . BOL_ThemeControlValueDao::getInstance()->getTableName() . " WHERE themeId = :themeId ", array('themeId' => $currentTheme->id));
     foreach ($controlValueList as $controlValue) {
         $this->configs['controlValue'][$controlValue['themeControlKey']] = $controlValue['value'];
     }
     $za->addEmptyDir($archiveDir . '/' . $currentTheme->getName());
     $this->zipFolder($za, $currentThemeDir, $archiveDir . '/' . $currentTheme->getName() . '/');
     $themesDir = Ow::getPluginManager()->getPlugin('dataexporter')->getPluginFilesDir() . 'themes' . DS;
     UTIL_File::copyDir(OW_DIR_THEME_USERFILES, $themesDir);
     $fileList = Ow::getStorage()->getFileNameList(OW_DIR_THEME_USERFILES);
     mkdir($themesDir, 0777);
     foreach ($fileList as $file) {
         if (Ow::getStorage()->isFile($file)) {
             Ow::getStorage()->copyFileToLocalFS($file, $themesDir . mb_substr($file, mb_strlen(OW_DIR_THEME_USERFILES)));
         }
     }
     $za->addEmptyDir($archiveDir . '/themes');
     $this->zipFolder($za, $themesDir, $archiveDir . '/themes/');
 }
开发者ID:vazahat,项目名称:dudex,代码行数:24,代码来源:export.php


示例11: updateThemeInfo

 /**
  * Update theme info in the [OW_DB_PREFIX]_base_theme table according to the theme.xml file and force theme rebuilding if necessary
  * @param $name
  * @param bool $processTheme
  */
 public function updateThemeInfo($name, $processTheme = false)
 {
     $path = OW_DIR_THEME . $name;
     $xmlFiles = UTIL_File::findFiles($path, array('xml'), 1);
     $themeXml = $xmlFiles[0];
     if (basename($themeXml) === self::MANIFEST_FILE) {
         $xml = simplexml_load_file($themeXml);
         $title = (string) $xml->name;
         $build = (int) $xml->build;
         $developerKey = (string) $xml->developerKey;
         $sidebarPosition = (string) $xml->sidebarPosition;
         if (!in_array(trim($sidebarPosition), array('left', 'right', 'none'))) {
             $sidebarPosition = 'none';
         }
         $xmlArray = (array) $xml;
         unset($xmlArray['masterPages']);
         $description = json_encode($xmlArray);
         if (!trim($title)) {
             $title = $name;
         }
         $theme = $this->findThemeByName($name);
         if (empty($theme)) {
             return;
         }
         $theme->setName($name);
         $theme->setTitle($title);
         $theme->setDescription($description);
         $theme->setSidebarPosition($sidebarPosition);
         $theme->setDeveloperKey($developerKey);
         $this->themeDao->save($theme);
         if ($processTheme) {
             $this->processTheme($theme->getId());
         }
     }
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:40,代码来源:theme_service.php


示例12: deleteAttachmentsByConversationList

 /**
  *
  * @param array $conversationIdList
  * @return array<MAILBOX_BOL_Attachment>
  */
 public function deleteAttachmentsByConversationList(array $conversationIdList)
 {
     $attachmentList = $this->attachmentDao->findAttachmentstByConversationList($conversationIdList);
     foreach ($attachmentList as $attachment) {
         $ext = UTIL_File::getExtension($attachment['fileName']);
         $path = $this->getAttachmentFilePath($attachment['id'], $attachment['hash'], $ext);
         if (OW::getStorage()->removeFile($path)) {
             $this->attachmentDao->deleteById($attachment['id']);
         }
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:16,代码来源:conversation_service.php


示例13: process

 /**
  * Uploads avatar
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $avatarService = BOL_AvatarService::getInstance();
     $userId = OW::getUser()->getId();
     if (strlen($_FILES['avatar']['tmp_name'])) {
         if (!UTIL_File::validateImage($_FILES['avatar']['name'])) {
             return array('result' => false, 'error' => -1);
         }
         $event = new OW_Event('base.before_avatar_change', array('userId' => $userId, 'upload' => true, 'crop' => false));
         OW::getEventManager()->trigger($event);
         $avatarSet = $avatarService->setUserAvatar($userId, $_FILES['avatar']['tmp_name']);
         $event = new OW_Event('base.after_avatar_change', array('userId' => $userId, 'upload' => true, 'crop' => false));
         OW::getEventManager()->trigger($event);
         $avatar = $avatarService->findByUserId($userId);
         if ($avatar) {
             $avatarService->trackAvatarChangeActivity($userId, $avatar->id);
         }
         return array('result' => $avatarSet);
     } else {
         return array('result' => false);
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:28,代码来源:avatar.php


示例14: deleteAttachmentFiles

 public function deleteAttachmentFiles()
 {
     $attachDtoList = $this->attachmentDao->getAttachmentForDelete();
     foreach ($attachDtoList as $attachDto) {
         /* @var $attachDto MAILBOX_BOL_Attachment */
         $ext = UTIL_File::getExtension($attachDto->fileName);
         $attachmentPath = $this->getAttachmentFilePath($attachDto->id, $attachDto->hash, $ext, $attachDto->fileName);
         try {
             OW::getStorage()->removeFile($attachmentPath);
             $this->attachmentDao->deleteById($attachDto->id);
         } catch (Exception $ex) {
         }
     }
 }
开发者ID:tammyrocks,项目名称:mailbox,代码行数:14,代码来源:conversation_service.php


示例15: uninstall

 /**
  * Uninstalls plugin.
  *
  * @param string $key
  */
 public function uninstall($key)
 {
     if (empty($key)) {
         throw new LogicException('');
     }
     $pluginDto = $this->findPluginByKey(trim($key));
     if ($pluginDto === null) {
         throw new LogicException('');
     }
     // trigger event
     $event = new OW_Event(OW_EventManager::ON_BEFORE_PLUGIN_UNINSTALL, array('pluginKey' => $pluginDto->getKey()));
     OW::getEventManager()->trigger($event);
     include OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'deactivate.php';
     // include plugin custom uninstall script
     include OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'uninstall.php';
     // delete plugin work dirs
     $dirsToRemove = array(OW_DIR_PLUGINFILES . $pluginDto->getModule(), OW_DIR_PLUGIN_USERFILES . $pluginDto->getModule());
     if (!defined('OW_PLUGIN_XP')) {
         $dirsToRemove[] = OW_DIR_STATIC_PLUGIN . $pluginDto->getModule();
     }
     foreach ($dirsToRemove as $dir) {
         if (file_exists($dir)) {
             UTIL_File::removeDir($dir);
         }
     }
     // remove plugin configs
     OW::getConfig()->deletePluginConfigs($pluginDto->getKey());
     // delete language prefix
     $prefixId = BOL_LanguageService::getInstance()->findPrefixId($pluginDto->getKey());
     if (!empty($prefixId)) {
         BOL_LanguageService::getInstance()->deletePrefix($prefixId, true);
     }
     //delete authorization stuff
     BOL_AuthorizationService::getInstance()->deleteGroup($pluginDto->getKey());
     // drop plugin tables
     $tables = OW::getDbo()->queryForColumnList("SHOW TABLES LIKE '" . str_replace('_', '\\_', OW_DB_PREFIX) . $pluginDto->getKey() . "\\_%'");
     if (!empty($tables)) {
         $query = "DROP TABLE ";
         foreach ($tables as $table) {
             $query .= "`" . $table . "`,";
         }
         $query = substr($query, 0, -1);
         OW::getDbo()->query($query);
     }
     //remove entry in DB
     $this->deletePluginById($pluginDto->getId());
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:52,代码来源:plugin_service.php


示例16: uploadPhoto

function uploadPhoto()
{
    global $language;
    global $PHOTO_BOL_PhotoService_inst;
    global $PHOTO_BOL_PhotoAlbumService;
    global $PHOTO_BOL_PhotoTemporaryService;
    global $BOL_AuthorizationService;
    global $getConfig;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    $user_id = $app->request()->params('user_id');
    //$data = $_POST;
    //$requdired_data = array("userId");
    //    foreach ($required_data as $rdata) {
    //        if (!array_key_exists($rdata, $data) || empty($data[$rdata])) {
    //            $return = array("message" => "Please enter " . $rdata, "status" => "false");
    //            echo json_encode($return);
    //            exit();
    //        }
    //    }
    $language = $language;
    $userId = $user_id;
    $albumName = "randoms";
    // Delete old temporary photos
    $tmpPhotoService = $PHOTO_BOL_PhotoTemporaryService;
    $photoService = $PHOTO_BOL_PhotoService_inst;
    $photoAlbumService = $PHOTO_BOL_PhotoAlbumService;
    $file = $_FILES['photo'];
    print_r($file);
    die;
    $tmpPhotoService->deleteUserTemporaryPhotos($userId);
    $accepted = floatval($getConfig->getValue('photo', 'accepted_filesize') * 1024 * 1024);
    if (strlen($file['tmp_name'])) {
        if (!UTIL_File::validateImage($file['name']) || $file['size'] > $accepted) {
            $json = array("response_message" => $language->text('photo', 'no_photo_uploaded'), "response_status" => "0");
            $app->response->setBody(json_encode($json));
            //$this->redirect();
        }
        $tmpPhotoService->addTemporaryPhoto($file['tmp_name'], $userId, 1);
        $tmpList = $tmpPhotoService->findUserTemporaryPhotos($userId, 'order');
        $tmpList = array_reverse($tmpList);
        // check album exists
        if (!($album = $photoAlbumService->findAlbumByName($albumName, $userId))) {
            $album = new PHOTO_BOL_PhotoAlbum();
            $album->name = $albumName;
            $album->userId = $userId;
            $album->createDatetime = time();
            $photoAlbumService->addAlbum($album);
        }
        foreach ($tmpList as $tmpPhoto) {
            $photo = $tmpPhotoService->moveTemporaryPhoto($tmpPhoto['dto']->id, $album->id, null);
            if ($photo) {
                $BOL_AuthorizationService->trackAction('photo', 'upload');
                $photoService->createAlbumCover($album->id, array($photo));
                $photoService->triggerNewsfeedEventOnSinglePhotoAdd($album, $photo);
                $photoParams = array('addTimestamp' => $photo->addDatetime, 'photoId' => $photo->id, 'hash' => $photo->hash, 'description' => $photo->description);
                $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_ADD, array($photoParams));
                OW::getEventManager()->trigger($event);
                $photo = $photoService->findPhotoById($photo->id);
                if ($photo) {
                    $return_data = array("response_status" => "1", "response_message" => "photo has been uploaded with success!");
                    $app->response->setBody(json_encode($return_data));
                } else {
                    //                    $json = array("message" => "photo not uploaded, something went wrong!", "status" => "false");
                    //                    echo json_encode($json);
                    //                    exit();
                    $return_data = array("response_status" => "0", "response_message" => "photo not uploaded, something went wrong!");
                    $app->response->setBody(json_encode($return_data));
                }
            }
        }
    } else {
        //        $json = array("message" => $language->text('photo', 'no_photo_uploaded'), "status" => "false");
        //        echo json_encode($json);
        //        exit();
        $return_data = array("response_message" => $language->text('photo', 'no_photo_uploaded'), "response_status" => "0");
        $app->response->setBody(json_encode($return_data));
    }
    //  }
}
开发者ID:bhushansonar,项目名称:hammu,代码行数:81,代码来源:index____.php


示例17: uploadPhoto

function uploadPhoto()
{
    global $language;
    global $PHOTO_BOL_PhotoTemporaryService;
    global $PHOTO_BOL_PhotoService_inst;
    global $PHOTO_BOL_PhotoAlbumService;
    global $getConfig;
    global $BOL_AuthorizationService;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    //Lang Call Start
    $hammu_lang_id = $app->request()->params("lang_id");
    if (!empty($hammu_lang_id)) {
        getCurrentLanguages($hammu_lang_id);
    }
    //Lang Call end
    $user_id = $app->request()->params('user_id');
    $language = $language;
    $userId = $user_id;
    $albumName = "randoms";
    // Delete old temporary photos
    $tmpPhotoService = $PHOTO_BOL_PhotoTemporaryService;
    $photoService = $PHOTO_BOL_PhotoService_inst;
    $photoAlbumService = $PHOTO_BOL_PhotoAlbumService;
    $file = $_FILES['photo'];
    $tmpPhotoService->deleteUserTemporaryPhotos($userId);
    $accepted = floatval($getConfig->getValue('photo', 'accepted_filesize') * 1024 * 1024);
    if (strlen($file['tmp_name'])) {
        if (!UTIL_File::validateImage($file['name']) || $file['size'] > $accepted) {
            $json = array("response_message" => $language->text('photo', 'no_photo_uploaded'), "response_status" => "0");
            $app->response->setBody(json_encode($json));
            //$this->redirect();
        }
        $tmpPhotoService->addTemporaryPhoto($file['tmp_name'], $userId, 1);
        $tmpList = $tmpPhotoService->findUserTemporaryPhotos($userId, 'order');
        $tmpList = array_reverse($tmpList);
        // check album exists
        if (!($album = $photoAlbumService->findAlbumByName($albumName, $userId))) {
            $album = new PHOTO_BOL_PhotoAlbum();
            $album->name = $albumName;
            $album->userId = $userId;
            $album->createDatetime = time();
            $photoAlbumService->addAlbum($album);
        }
        foreach ($tmpList as $tmpPhoto) {
            $photo = $tmpPhotoService->moveTemporaryPhoto($tmpPhoto['dto']->id, $album->id, null);
            if ($photo) {
                $BOL_AuthorizationService->trackAction('photo', 'upload');
                $photoService->createAlbumCover($album->id, array($photo));
                $photoService->triggerNewsfeedEventOnSinglePhotoAdd($album, $photo);
                $photoParams = array('addTimestamp' => $photo->addDatetime, 'photoId' => $photo->id, 'hash' => $photo->hash, 'description' => $photo->description);
                $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_ADD, array($photoParams));
                OW::getEventManager()->trigger($event);
                $photo = $photoService->findPhotoById($photo->id);
                $photoDataArr = array('albumId' => $photo->albumId, 'status' => $photo->status, 'hash' => $photo->hash, 'id' => $photo->id, 'uploadKey' => $photo->uploadKey);
                if ($photo) {
                    $message = $language->text("hammu", "photo_upload_success");
                    //"photo has been uploaded successfully!"
                    $return_data = array("response_status" => "1", "response_message" => $message, "data" => $photoDataArr);
                    $app->response->setBody(json_encode($return_data));
                } else {
                    $message = $language->text("hammu", "photo_upload_fail");
                    //"photo not uploaded, something went wrong!"
                    $return_data = array("response_status" => "0", "response_message" => $message);
                    $app->response->setBody(json_encode($return_data));
                }
            }
        }
    } else {
        $return_data = array("response_message" => $language->text('photo', 'no_photo_uploaded'), "response_status" => "0");
        $app->response->setBody(json_encode($return_data));
    }
    //  }
}
开发者ID:bhushansonar,项目名称:hammu,代码行数:75,代码来源:index_4_7_2015.php


示例18: process

 /**
  * Creates new conversation
  *
  * @param int $initiatorId
  * @param int $interlocutorId
  */
 public function process($initiatorId, $interlocutorId)
 {
     if (OW::getRequest()->isAjax()) {
         if (empty($initiatorId) || empty($interlocutorId)) {
             echo json_encode(array('result' => false));
             exit;
         }
         $isAuthorized = OW::getUser()->isAuthorized('mailbox', 'send_message');
         if (!$isAuthorized) {
             echo json_encode(array('result' => 'permission_denied'));
             exit;
         }
         // credits check
         $eventParams = array('pluginKey' => 'mailbox', 'action' => 'send_message', 'extra' => array('senderId' => $initiatorId, 'recipientId' => $interlocutorId));
         $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
         if ($credits === false) {
             $error = OW::getEventManager()->call('usercredits.error_message', $eventParams);
             echo json_encode(array('result' => 'permission_denied', 'message' => $error));
             exit;
         }
         $captcha = $this->getElement('captcha');
         $captcha->setRequired();
         if ($this->displayCapcha && (!$captcha->isValid() || !UTIL_Validator::isCaptchaValid($captcha->getValue()))) {
             echo json_encode(array('result' => 'display_captcha'));
             exit;
         }
         $values = $this->getValues();
         $conversationService = MAILBOX_BOL_ConversationService::getInstance();
         $uploadFiles = MAILBOX_BOL_FileUploadService::getInstance();
         $conversation = $conversationService->createConversation($initiatorId, $interlocutorId, htmlspecialchars($values['subject']), $values['message']);
         $message = $conversationService->getLastMessages($conversation->id);
         $fileDtoList = $uploadFiles->findUploadFileList($values['attachments']);
         foreach ($fileDtoList as $fileDto) {
             $attachmentDto = new MAILBOX_BOL_Attachment();
             $attachmentDto->messageId = $message->initiatorMessageId;
             $attachmentDto->fileName = htmlspecialchars($fileDto->fileName);
             $attachmentDto->fileSize = $fileDto->fileSize;
             $attachmentDto->hash = $fileDto->hash;
             if ($conversationService->fileExtensionIsAllowed(UTIL_File::getExtension($fileDto->fileName))) {
                 $conversationService->addAttachment($attachmentDto, $fileDto->filePath);
             }
             $uploadFiles->deleteUploadFile($fileDto->hash, $fileDto->userId);
         }
         // credits track
         if ($credits === true) {
             OW::getEventManager()->call('usercredits.track_action', $eventParams);
         }
         BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_display_capcha', false, OW::getUser()->getId());
         $timestamp = 0;
         if ($this->displayCapcha == false) {
             $timestamp = time();
         }
         BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_stamp', $timestamp, OW::getUser()->getId());
         echo json_encode(array('result' => true));
         exit;
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:63,代码来源:create_conversation_form.php


示例19: setCustomDefaultAvatar

 public function setCustomDefaultAvatar($size, $file)
 {
     $conf = json_decode(OW::getConfig()->getValue('base', 'default_avatar'), true);
     $dir = OW::getPluginManager()->getPlugin('base')->getUserFilesDir() . 'avatars' . DS;
     $ext = UTIL_File::getExtension($file['name']);
     $prefix = 'default_' . ($size == 1 ? self::AVATAR_PREFIX : self::AVATAR_BIG_PREFIX);
     $fileName = $prefix . uniqid() . '.' . $ext;
     if (is_uploaded_file($file['tmp_name'])) {
         $storage = OW::getStorage();
         if ($storage->copyFile($file['tmp_name'], $dir . $fileName)) {
             if (isset($conf[$size])) {
                 $storage->removeFile($dir . $conf[$size]);
             }
             $conf[$size] = $fileName;
             OW::getConfig()->saveConfig('base', 'default_avatar', json_encode($conf));
             return true;
         }
     }
     return false;
 }
开发者ID:hardikamutech,项目名称:hammu,代码行数:20,代码来源:avatar_service.php


示例20: addFromPhotos

 public function addFromPhotos($query)
 {
     $photoId = $query['photoId'];
     $groupId = $query['groupId'];
     if (!GHEADER_CLASS_CreditsBridge::getInstance()->credits->isAvaliable(GHEADER_CLASS_Credits::ACTION_ADD)) {
         $error = GHEADER_CLASS_CreditsBridge::getInstance()->credits->getErrorMessage(GHEADER_CLASS_Credits::ACTION_ADD);
         throw new InvalidArgumentException($error);
     }
     $sourcePath = GHEADER_CLASS_PhotoBridge::getInstance()->pullPhoto($photoId);
     if ($sourcePath === null) {
         throw new InvalidArgumentException("The requested photo wasn't find");
     }
     $canvasWidth = $query['width'];
     $canvasHeight = OW::getConfig()->getValue('gheader', 'cover_height');
     $coverImage = new UTIL_Image($sourcePath);
     $imageHeight = $coverImage->getHeight();
     $imageWidth = $coverImage->getWidth();
     $css = array('width' => 'auto', 'height' => 'auto');
     $tmp = $canvasWidth * $imageHeight / $imageWidth;
     if ($tmp >= $canvasHeight) {
         $css['width'] = '100%';
     } else {
         $css['height'] = '100%';
     }
     $this->validateImage($coverImage, $canvasWidth, $canvasHeight);
     $cover = $this->service->findCoverByGroupId($groupId, GHEADER_BOL_Cover::STATUS_TMP);
     if ($cover === null) {
         $cover = new GHEADER_BOL_Cover();
     }
     $extension = UTIL_File::getExtension($sourcePath);
     $cover->file = uniqid('cover-' . $groupId . '-') . '.' . $extension;
     $cover->groupId = $groupId;
     $cover->status = GHEADER_BOL_Cover::STATUS_TMP;
     $cover->timeStamp = time();
     $dimensions = array('height' => $imageHeight, 'width' => $imageWidth);
     $cover->setSettings(array('photoId' => $photoId, 'dimensions' => $dimensions, 'css' => $css, 'canvas' => array('width' => $canvasWidth, 'height' => $canvasHeight), 'position' => array('top' => 0, 'left' => 0)));
     $this->service->saveCover($cover);
     $coverPath = $this->service->getCoverPath($cover);
     OW::getStorage()->copyFile($sourcePath, $coverPath);
     @unlink($sourcePath);
     $coverUrl = $this->service->getCoverUrl($cover);
     return array('src' => $coverUrl, 'data' => $cover->getSettings());
 }
开发者ID:vazahat,项目名称:dudex,代码行数:43,代码来源:header.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP UTIL_HtmlTag类代码示例发布时间:2022-05-23
下一篇:
PHP UTIL_DateTime类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap