当前位置: 首页>>代码示例>>PHP>>正文


PHP uploader::remoteCopy方法代码示例

本文整理汇总了PHP中uploader::remoteCopy方法的典型用法代码示例。如果您正苦于以下问题:PHP uploader::remoteCopy方法的具体用法?PHP uploader::remoteCopy怎么用?PHP uploader::remoteCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在uploader的用法示例。


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

示例1: updatePreview

function updatePreview($file_id, $resource)
{
    $objResponse =& new xajaxResponse();
    $CFile = new CFile($file_id);
    $path_file = $CFile->path . 'sm_' . $CFile->name;
    if ($CFile->image_size['height'] > portfolio::PREVIEW_MAX_HEIGHT || $CFile->image_size['width'] > portfolio::PREVIEW_MAX_WIDTH) {
        $CFile = $CFile->resizeImage($path_file, portfolio::PREVIEW_MAX_WIDTH, portfolio::PREVIEW_MAX_HEIGHT, 'auto', true);
    } else {
        $CFile = uploader::remoteCopy($CFile->id, $CFile->table, $CFile->path, false, 'sm_f_');
    }
    uploader::sclear($resource);
    // Чистим заменяем
    uploader::screateFile($CFile, $resource);
    $callback = uploader::getCallback(uploader::sgetTypeUpload($resource));
    $template = uploader::getTemplate('uploader.file', 'portfolio/');
    $template = str_replace(array('{idFile}', '{fileName}'), array($CFile->id, $CFile->original_name), $template);
    $objResponse->script("\n        \$\$('#work_preview_file .qq-upload-list').set('html', '{$template}');\n        \$\$('#work_preview_file .qq-upload-list .qq-upload-file').set('href', '" . WDCPREFIX . "/{$path_file}');\n        \$\$('#work_preview_file .qq-upload-list .qq-uploader-fileID').show();\n    ");
    $objResponse->script("\n        \$\$('#work_preview_file .qq-upload-delete').addEvent('click', function() {\n            new Request.JSON({\n                url: '/uploader.php',\n                onSuccess: function(resp) {\n                    if(resp.success) {\n                        \$\$('#work_preview_file .qq-upload-list').set('html', '');\n                        if(resp.onComplete !== undefined) {\n                            eval(resp.onComplete);\n                        }\n                    }  \n                }\n            }).post({\n                'action': 'remove',\n                'files' : [{$CFile->id}],\n                'resource': '{$resource}',\n                'u_token_key': '{$_SESSION['rand']}'\n            });\n        });\n    ");
    $objResponse->script($callback);
    return $objResponse;
}
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:21,代码来源:portfolio.server.php

示例2: SendComplain

/**
* Добавляет жалобу на проект.
*
* @param    integer     $project_id     ID проекта
* @param    integer     $user_id        ID пользователя
* @param    integer     $type           тип жалобы
* @param    string      $msg            текст жалобы
* @param    string      $files          имена загруженных скриншотов
*
* @return                               xajax responce
*/
function SendComplain($project_id, $type, $msg, $files)
{
    global $session;
    session_start();
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/uploader/uploader.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects_complains.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/userecho.php';
    $objResponse = new xajaxResponse();
    $project_id = (int) $project_id;
    $user_id = get_uid(false);
    $type = (int) $type;
    $msg = __paramValue('htmltext', $msg);
    $error = false;
    $project = new projects();
    $prj = $project->GetPrj(0, $project_id, 1);
    $file_list = array();
    if ($files != '') {
        $files = uploader::sgetFiles($files);
        if (!empty($files)) {
            $emp = new users();
            $emp->GetUser($emp->GetField($prj['user_id'], $ee, 'login'));
            $dir = 'users/' . substr($emp->login, 0, 2) . '/' . $emp->login . '/upload/';
            foreach ($files as $file) {
                $copy = uploader::remoteCopy($file['id'], 'file_projects', $dir);
                $rfiles[] = $copy->name;
                $file_list[] = array('name' => $copy->original_name, 'link' => WDCPREFIX . '/' . $copy->path . $copy->name);
            }
            $files = implode(',', $rfiles);
        } else {
            $files = '';
        }
    }
    if (!$files) {
        $files = '';
    }
    if (projects::IsHaveComplainType($project_id, $user_id, $type)) {
        // Уже жаловался
        return $objResponse;
    }
    $projects_complains = new projects_complains();
    $type_name = $projects_complains->GetComplainType($type);
    $project_url = getAbsUrl(getFriendlyURL('project', $project_id));
    $is_moder = $projects_complains->isComplainTypeModer($type);
    if ($is_moder) {
        $userEcho = new UserEcho();
        $topic_message = $userEcho->constructMessage($project_url, $prj['name'], $msg, $file_list);
        $topicUrl = $userEcho->newTopicComplain($type_name, $topic_message, $file_list);
        if ($topicUrl) {
            messages::sendProjectComplain($user_id, $project_url, $prj['name'], $msg, $topicUrl);
        } else {
            $error = true;
        }
    }
    if (!$error) {
        $error = projects::AddComplain($project_id, $user_id, $type, $msg, $files, $is_moder && $topicUrl);
    }
    if ($error) {
        $objResponse->script("\$('abuse_project_popup').toggleClass('b-shadow_hide');");
        if ($is_moder) {
            $objResponse->script("\$('abuse-cause-error').removeClass('b-layout__txt_hide'); abuseResetSelection();");
        } else {
            $objResponse->script("\$\$('.abuse-btn-send').removeClass('b-button_rectangle_color_disable')");
        }
    } else {
        $upl = array('umask' => uploader::umask('prj_abuse'), 'validation' => array('allowedExtensions' => array('jpg', 'gif', 'png', 'jpeg'), 'restrictedExtensions' => array()), 'text' => array('uploadButton' => iconv('cp1251', 'utf8', 'Прикрепить файлы')));
        $objResponse->script("\n            \$('abuse{$type}').addClass('abuse-checked');\n            \$('abuse{$type}').getChildren().each(function(el) { \$(el).addClass('abuse-checked'); });\n        ");
        $objResponse->script("uploader.create('abuse_uploader', " . json_encode($upl) . ');');
        $objResponse->script("\$('prj_abuse_msg').set('value', '')");
        $objResponse->script("\$\$('.abuse-btn-send').removeClass('b-button_disabled')");
        $objResponse->script("\$('abuse_project_popup').toggleClass('b-shadow_hide');");
        $objResponse->script("\$('project_abuse_success').removeClass('b-layout__txt_hide');");
        $objResponse->script("\$('form_abuse').hide();");
        $objResponse->script("setTimeout(\"\$('project_abuse_success').addClass('b-layout__txt_hide')\", 5000);");
        if ($is_moder) {
            $objResponse->script("\$('abuse-cause-error').addClass('b-layout__txt_hide');");
        }
    }
    return $objResponse;
}
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:90,代码来源:projects_ci.server.php

示例3: editWork

 public function editWork($uid, $params)
 {
     global $DB;
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/uploader/uploader.php';
     $params = self::prepareWork($params);
     $error = self::validateWork($params);
     $work_id = $params['id'];
     if (!empty($error)) {
         return $error;
     }
     $update = array('link' => $params['link'], 'name' => antispam($params['work_name']), 'descr' => antispam($params['work_descr']), 'cost' => $params['work_cost'], 'cost_type' => $params['work_cost_type_db_id'], 'time_value' => $params['time_cost'], 'time_type' => $params['work_time_type_db_id'], 'prev_type' => $params['work_preview_type'], 'prof_id' => $params['work_category_db_id']);
     if ($params['video'] != '') {
         $video_link = video_validate($params['video']);
         $video_link = preg_replace("/^http:\\/\\//", '', $video_link);
         $update['video_link'] = $video_link;
         $update['is_video'] = true;
     } else {
         $update['video_link'] = '';
         $update['is_video'] = false;
     }
     if ($uid == $_SESSION['uid'] && !hasPermissions('users')) {
         // автор, не админ, не про меняет заголовок либо текст - отправить на модерирование
         $update['moderator_status'] = !is_pro() ? '0' : '-2';
     }
     if ($params['position_num'] !== NULL) {
         $update['norder'] = intval($params['position_num']);
     }
     $dir = 'users/' . substr($_SESSION['login'], 0, 2) . "/{$_SESSION['login']}/upload/";
     if (isset($params['IDResource']) && is_array($params['IDResource'])) {
         foreach ($params['IDResource'] as $resource) {
             $resources[uploader::sgetTypeUpload($resource)] = $resource;
         }
         if (isset($resources['portfolio'])) {
             $mainFile = current(uploader::sgetFiles($resources['portfolio']));
             if (!empty($mainFile)) {
                 // Если что-то загрузили и не удаляли
                 $MFile = uploader::remoteCopy($mainFile['id'], 'file', $dir, false);
                 uploader::sclear($resources['portfolio']);
                 // Делаем отдельное привью из оригинальной большой картинки  -- @todo ХЗ зачем но раньше так делали
                 if (in_array($MFile->getext(), $GLOBALS['graf_array']) && $MFile->getext() != 'swf') {
                     $MFile->resizeImage($dir . 'tn_' . $MFile->name, self::PREVIEW_MAX_WIDTH, self::PREVIEW_MAX_HEIGHT, 'auto', true);
                 }
                 $update['pict'] = $MFile->name;
                 $is_remove_main_file = true;
             }
         }
         if (isset($resources['pf_preview'])) {
             $preview = current(uploader::sgetFiles($resources['pf_preview']));
             if (!empty($preview)) {
                 // Если что-то загрузили и не удаляли
                 $PFile = uploader::remoteCopy($preview['id'], 'file', $dir, false, 'sm_f_');
                 uploader::sclear($resources['pf_preview']);
                 $update['prev_pict'] = $PFile->name;
                 $is_remove_preview_file = true;
             }
         }
     }
     if ($params['main_file'] == '' && !isset($MFile)) {
         // Удаляем файл
         $update['pict'] = '';
         $is_remove_main_file = true;
     }
     if ($params['preview_file'] == '' && !isset($PFile)) {
         // Удаляем файл
         $update['prev_pict'] = '';
         $is_remove_preview_file = true;
     }
     if ($is_remove_main_file) {
         $cf = new CFile();
         $cf->Delete(0, $dir, $params['old_main_file']);
         // удаляем ранее загруженный файл
     }
     if ($is_remove_preview_file) {
         $cf = new CFile();
         $cf->Delete(0, $dir, $params['old_preview_file']);
         // удаляем ранее загруженный файл
     }
     if (empty($error)) {
         $wmodeAllowValues = array('direct', 'gpu', 'window');
         if (!in_array($params['wmode'], $wmodeAllowValues)) {
             $params['wmode'] = 'window';
         }
         if ($work_id) {
             $update['edit_date'] = 'NOW()';
             $result = $DB->update('portfolio', $update, 'id = ?i AND user_id = ?i', $work_id, $uid);
         } else {
             $update['user_id'] = $uid;
             $result = $DB->insert('portfolio', $update, 'id');
             $work_id = $result;
         }
         if ($MFile && $MFile->getext() == 'swf' && $MFile->id) {
             $res = $DB->query('UPDATE swf_file_params SET wmode = ?, table_name = ? WHERE fid = ?i', $params['wmode'], $MFile->table, $MFile->id);
             if (pg_affected_rows($res) == 0) {
                 $res = $DB->query('INSERT INTO swf_file_params (fid, wmode, table_name) VALUES(?i, ?, ?)', $MFile->id, $params['wmode'], $MFile->table);
             }
         } else {
             if (!$MFile) {
                 $ext = preg_replace("#.*(\\.[a-zA-Z0-9]*)\$#", '$1', $params['main_file']);
                 if (strtolower($ext) == '.swf') {
                     $res = $DB->query('UPDATE swf_file_params SET wmode = ? WHERE fid = (SELECT id FROM file WHERE fname = ?)', $params['wmode'], $params['main_file']);
//.........这里部分代码省略.........
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:101,代码来源:portfolio.php


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