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


PHP XoopsMediaUploader::setTargetFileName方法代码示例

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


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

示例1: publisher_pagewrap_upload

/**
 * @param $errors
 *
 * @return bool
 */
function publisher_pagewrap_upload(&$errors)
{
    //    include_once PUBLISHER_ROOT_PATH . '/class/uploader.php';
    xoops_load('XoopsMediaUploader');
    $publisher =& PublisherPublisher::getInstance();
    $postField = 'fileupload';
    $maxFileSize = $publisher->getConfig('maximum_filesize');
    $maxImageWidth = $publisher->getConfig('maximum_image_width');
    $maxImageHeight = $publisher->getConfig('maximum_image_height');
    if (!is_dir(publisherGetUploadDir(true, 'content'))) {
        mkdir(publisherGetUploadDir(true, 'content'), 0757);
    }
    $allowedMimeTypes = array('text/html', 'text/plain', 'application/xhtml+xml');
    $uploader = new XoopsMediaUploader(publisherGetUploadDir(true, 'content') . '/', $allowedMimeTypes, $maxFileSize, $maxImageWidth, $maxImageHeight);
    if ($uploader->fetchMedia($postField)) {
        $uploader->setTargetFileName($uploader->getMediaName());
        if ($uploader->upload()) {
            return true;
        } else {
            $errors = array_merge($errors, $uploader->getErrors(false));
            return false;
        }
    } else {
        $errors = array_merge($errors, $uploader->getErrors(false));
        return false;
    }
}
开发者ID:trabisdementia,项目名称:publisher,代码行数:32,代码来源:pw_upload_file.php

示例2: publisher_pagewrap_upload

function publisher_pagewrap_upload(&$errors)
{
    $publisher = Publisher::getInstance();
    $post_field = 'fileupload';
    $max_size = $publisher->getConfig('maximum_filesize');
    $max_imgwidth = $publisher->getConfig('maximum_image_width');
    $max_imgheight = $publisher->getConfig('maximum_image_height');
    if (!is_dir(PublisherUtils::getUploadDir(true, 'content'))) {
        mkdir(PublisherUtils::getUploadDir(true, 'content'), 0757);
    }
    $allowed_mimetypes = array('text/html', 'text/plain', 'application/xhtml+xml');
    $uploader = new XoopsMediaUploader(PublisherUtils::getUploadDir(true, 'content') . '/', $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
    if ($uploader->fetchMedia($post_field)) {
        $uploader->setTargetFileName($uploader->getMediaName());
        if ($uploader->upload()) {
            return true;
        } else {
            $errors = array_merge($errors, $uploader->getErrors(false));
            return false;
        }
    } else {
        $errors = array_merge($errors, $uploader->getErrors(false));
        return false;
    }
}
开发者ID:mambax7,项目名称:publisher-26,代码行数:25,代码来源:pw_upload_file.php

示例3: storeUpload

 function storeUpload($post_field, $response = null, $allowed_mimetypes = null)
 {
     //global $xoopsModuleConfig, $xoopsUser, $xoopsDB, $xoopsModule;
     include_once XHELP_CLASS_PATH . '/uploader.php';
     $config =& xhelpGetModuleConfig();
     $ticketid = $this->getVar('id');
     if (!isset($allowed_mimetypes)) {
         $hMime =& xhelpGetHandler('mimetype');
         $allowed_mimetypes = $hMime->checkMimeTypes();
         if (!$allowed_mimetypes) {
             return false;
         }
     }
     $maxfilesize = $config['xhelp_uploadSize'];
     $maxfilewidth = $config['xhelp_uploadWidth'];
     $maxfileheight = $config['xhelp_uploadHeight'];
     if (!is_dir(XHELP_UPLOAD_PATH)) {
         mkdir(XHELP_UPLOAD_PATH, 0757);
     }
     $uploader = new XoopsMediaUploader(XHELP_UPLOAD_PATH . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
     if ($uploader->fetchMedia($post_field)) {
         if (!isset($response)) {
             $uploader->setTargetFileName($ticketid . "_" . $uploader->getMediaName());
         } else {
             $uploader->setTargetFileName($ticketid . "_" . $response . "_" . $uploader->getMediaName());
         }
         if ($uploader->upload()) {
             $hFile =& xhelpGetHandler('file');
             $file =& $hFile->create();
             $file->setVar('filename', $uploader->getSavedFileName());
             $file->setVar('ticketid', $ticketid);
             $file->setVar('mimetype', $allowed_mimetypes);
             $file->setVar('responseid', isset($response) ? intval($response) : 0);
             if ($hFile->insert($file)) {
                 return $file;
             } else {
                 return $uploader->getErrors();
             }
         } else {
             return $uploader->getErrors();
         }
     }
 }
开发者ID:trabisdementia,项目名称:xuups,代码行数:43,代码来源:responses.php

示例4: smartsection_pagewrap_upload

function smartsection_pagewrap_upload(&$errors)
{
    include_once SMARTSECTION_ROOT_PATH . "class/uploader.php";
    global $xoopsUser, $xoopsDB, $xoopsModule, $xoopsModule, $xoopsModuleConfig;
    include_once SMARTSECTION_ROOT_PATH . 'class/uploader.php';
    $config =& smartsection_getModuleConfig();
    $post_field = 'fileupload';
    //$allowed_mimetypes = '';
    // TODO : this needs to be managed by the MimeType section but we need a new parameter for allowed mimetype for pagewrap
    /*	if(!isset($allowed_mimetypes)){
           $hMime =& xoops_getmodulehandler('mimetype');
           $allowed_mimetypes = $hMime->checkMimeTypes($post_field);
           if(!$allowed_mimetypes){
           	$errors[] = _SMARTSECTION_MESSAGE_WRONG_MIMETYPE;
               return false;
           }
       }*/
    /*$maxfilesize = $config['xhelp_uploadSize'];
      $maxfilewidth = $config['xhelp_uploadWidth'];
      $maxfileheight = $config['xhelp_uploadHeight'];*/
    $max_size = $xoopsModuleConfig['maximum_filesize'];
    $max_imgwidth = $xoopsModuleConfig['maximum_image_width'];
    $max_imgheight = $xoopsModuleConfig['maximum_image_height'];
    if (!is_dir(smartsection_getUploadDir(true, 'content'))) {
        mkdir(smartsection_getUploadDir(true, 'content'), 0757);
    }
    $allowed_mimetypes = array('text/html', 'text/plain', 'application/xhtml+xml');
    $uploader = new XoopsMediaUploader(smartsection_getUploadDir(true, 'content') . '/', $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
    if ($uploader->fetchMedia($post_field)) {
        $uploader->setTargetFileName($uploader->getMediaName());
        if ($uploader->upload()) {
            return true;
        } else {
            $errors = array_merge($errors, $uploader->getErrors(false));
            return false;
        }
    } else {
        $errors = array_merge($errors, $uploader->getErrors(false));
        return false;
    }
}
开发者ID:severnaya99,项目名称:Sg-2010,代码行数:41,代码来源:pw_upload_file.php

示例5: storeUpload

 /**
  * @param string      $post_field
  * @param array       $allowed_mimetypes
  * @param array       $errors
  *
  * @return bool
  */
 public function storeUpload($post_field, $allowed_mimetypes = array(), &$errors)
 {
     $itemid = $this->getVar('itemid');
     if (empty($allowed_mimetypes)) {
         $allowed_mimetypes = $this->publisher->getMimetypeHandler()->getArrayByType();
     }
     $maxfilesize = $this->publisher->getConfig('maximum_filesize');
     $maxfilewidth = $this->publisher->getConfig('maximum_image_width');
     $maxfileheight = $this->publisher->getConfig('maximum_image_height');
     if (!is_dir(PublisherUtils::getUploadDir())) {
         mkdir(PublisherUtils::getUploadDir(), 0757);
     }
     $uploader = new XoopsMediaUploader(PublisherUtils::getUploadDir() . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
     if ($uploader->fetchMedia($post_field)) {
         $uploader->setTargetFileName($itemid . "_" . $uploader->getMediaName());
         if ($uploader->upload()) {
             $this->setVar('filename', $uploader->getSavedFileName());
             if ($this->getVar('name') == '') {
                 $this->setVar('name', $this->getNameFromFilename());
             }
             $this->setVar('mimetype', $uploader->getMediaType());
             return true;
         } else {
             $errors = array_merge($errors, $uploader->getErrors(false));
             return false;
         }
     } else {
         $errors = array_merge($errors, $uploader->getErrors(false));
         return false;
     }
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:38,代码来源:file.php

示例6: addTopic

function addTopic()
{
    global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
    $topicpid = isset($_POST['topic_pid']) ? intval($_POST['topic_pid']) : 0;
    $xt = new AmsTopic($xoopsDB->prefix("ams_topics"));
    if (!$xt->topicExists($topicpid, $_POST['topic_title'])) {
        $xt->setTopicPid($topicpid);
        if (empty($_POST['topic_title']) || trim($_POST['topic_title']) == '') {
            redirect_header("index.php?op=topicsmanager", 2, _AMS_AM_ERRORTOPICNAME);
        }
        $xt->setTopicTitle($_POST['topic_title']);
        if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] != "") {
            $xt->setTopicImgurl($_POST['topic_imgurl']);
        }
        if (isset($_POST['xoops_upload_file'])) {
            $fldname = $_FILES[$_POST['xoops_upload_file'][0]];
            $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name'];
            if (trim($fldname != '')) {
                $sfiles = new sFiles();
                $dstpath = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . '/images/topics';
                $destname = $sfiles->createUploadName($dstpath, $fldname, true);
                $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png');
                $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
                $uploader->setTargetFileName($destname);
                if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
                    if ($uploader->upload()) {
                        $xt->setTopicImgurl(basename($destname));
                    } else {
                        echo _AMS_AM_UPLOAD_ERROR;
                    }
                } else {
                    echo $uploader->getErrors();
                }
            }
        }
        $xt->banner_inherit = isset($_POST['banner_inherit']) ? 1 : 0;
        $xt->banner = $_POST['banner'];
        $xt->forum_id = isset($_POST['forum_id']) ? intval($_POST['forum_id']) : 0;
        if ($xt->store()) {
            //This will set default audience
            global $xoopsModule;
            $allTopics = $xt->getAllTopics();
            $totaltopics = count($allTopics);
            if ($totaltopics = 1) {
                //Make sure xoopsModule is AMS.
                if (!isset($xoopsModule) || $xoopsModule->getVar('dirname') != "AMS") {
                    $mod_handler =& xoops_gethandler('module');
                    $amsModule =& $mod_handler->getByDirname('AMS');
                } else {
                    $amsModule =& $xoopsModule;
                }
                // Check audience, and set default value if not yet exist
                if (!ams_isaudiencesetup($amsModule->getVar('mid'))) {
                    $gperm_handler =& xoops_gethandler('groupperm');
                    $member_handler =& xoops_gethandler('member');
                    $group_id_ref =& $member_handler->getGroups(null, true);
                    //insert all groups into default audience
                    foreach (array_keys($group_id_ref) as $i) {
                        $gperm_handler->addRight("ams_audience", 1, intval($group_id_ref[$i]->getVar('groupid')), intval($amsModule->getVar('mid')));
                    }
                }
            }
            //Added in AMS 2.50 Final. Use News 1.62 permission style
            // Permissions
            $gperm_handler =& xoops_gethandler('groupperm');
            if (isset($_POST['groups_AMS_can_approve'])) {
                foreach ($_POST['groups_AMS_can_approve'] as $onegroup_id) {
                    $gperm_handler->addRight('ams_approve', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid'));
                }
            }
            if (isset($_POST['groups_AMS_can_submit'])) {
                foreach ($_POST['groups_AMS_can_submit'] as $onegroup_id) {
                    $gperm_handler->addRight('ams_submit', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid'));
                }
            }
            if (isset($_POST['groups_AMS_can_view'])) {
                foreach ($_POST['groups_AMS_can_view'] as $onegroup_id) {
                    $gperm_handler->addRight('ams_view', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid'));
                }
            }
            AMS_updateCache();
            $notification_handler =& xoops_gethandler('notification');
            $tags = array();
            $tags['TOPIC_NAME'] = $_POST['topic_title'];
            $notification_handler->triggerEvent('global', 0, 'new_category', $tags);
            redirect_header('index.php?op=topicsmanager', 1, _AMS_AM_DBUPDATED);
            exit;
        }
    } else {
        redirect_header('index.php?op=topicsmanager', 2, _AMS_AM_ADD_TOPIC_ERROR);
        exit;
    }
}
开发者ID:severnaya99,项目名称:Sg-2010,代码行数:93,代码来源:index.php

示例7: isset

 $HotelObj->setVar('hotel_star', isset($_POST['hotel_star']) ? intval($_POST['hotel_star']) : 0);
 $HotelObj->setVar('hotel_address', isset($_POST['hotel_address']) ? addslashes($_POST['hotel_address']) : '');
 $HotelObj->setVar('hotel_telephone', isset($_POST['hotel_telephone']) ? addslashes($_POST['hotel_telephone']) : '');
 $HotelObj->setVar('hotel_fax', isset($_POST['hotel_fax']) ? addslashes($_POST['hotel_fax']) : '');
 $HotelObj->setVar('hotel_room_count', isset($_POST['hotel_room_count']) ? intval($_POST['hotel_room_count']) : 0);
 //file upload
 $hotel_icon = isset($_POST['hotel_icon_old']) ? $_POST['hotel_icon_old'] : null;
 include XOOPS_ROOT_PATH . '/class/uploader.php';
 if (!empty($_FILES['hotel_icon']['tmp_name'])) {
     $path = MARTIN_ROOT_PATH . '/images/hotelicon/';
     $FileTypeUpload = array("image/jpg", "image/png", "image/gif", "image/jpeg");
     $uploader = new XoopsMediaUploader($path, $FileTypeUpload, 2048 * 1024);
     if ($uploader->fetchMedia($_POST["xoops_upload_file"][0])) {
         $uploader->ext = strtolower(ltrim(strrchr($uploader->getMediaName(), '.'), '.'));
         $SaveFileName = time() . rand(1000, 10000) . "." . $uploader->ext;
         $uploader->setTargetFileName($SaveFileName);
         if (!$uploader->upload()) {
             xoops_error($uploader->getErrors());
             exit;
         } elseif (file_exists($uploader->getSavedDestination())) {
             //delete images
             if (!empty($hotel_icon)) {
                 unlink(MARTIN_ROOT_PATH . '/images/hotelicon/' . $hotel_icon);
             }
             $hotel_icon = $uploader->getSavedFileName();
         }
     } else {
         xoops_error($uploader->getErrors());
     }
 }
 //echo $hotel_icon;exit;
开发者ID:ponvino,项目名称:xoops-martin,代码行数:31,代码来源:martin.hotel.php

示例8: stripslashes

         $sfiles->delete();
     }
 }
 if (isset($_POST['xoops_upload_file'])) {
     $fldname = $_FILES[$_POST['xoops_upload_file'][0]];
     $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name'];
     if (xoops_trim($fldname != '')) {
         $sfiles = new sFiles();
         $destname = $sfiles->createUploadName(XOOPS_UPLOAD_PATH, $fldname);
         /**
          * You can attach files to your news
          */
         $permittedtypes = explode("\n", str_replace("\r", '', news_getmoduleoption('mimetypes')));
         array_walk($permittedtypes, 'trim');
         $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
         $uploader->setTargetFileName($destname);
         if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
             if ($uploader->upload()) {
                 $sfiles->setFileRealName($uploader->getMediaName());
                 $sfiles->setStoryid($story->storyid());
                 $sfiles->setMimetype($sfiles->giveMimetype(XOOPS_UPLOAD_PATH . '/' . $uploader->getMediaName()));
                 $sfiles->setDownloadname($destname);
                 if (!$sfiles->store()) {
                     echo _AM_UPLOAD_DBERROR_SAVE;
                 }
             } else {
                 echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors();
             }
         } else {
             echo $uploader->getErrors();
         }
开发者ID:BackupTheBerlios,项目名称:haxoo-svn,代码行数:31,代码来源:submit.php

示例9: addTopic

function addTopic()
{
    global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
    $topicpid = isset($_POST['topic_pid']) ? intval($_POST['topic_pid']) : 0;
    $xt = new NewsTopic();
    if (!$xt->topicExists($topicpid, $_POST['topic_title'])) {
        $xt->setTopicPid($topicpid);
        if (empty($_POST['topic_title']) || xoops_trim($_POST['topic_title']) == '') {
            redirect_header("index.php?op=topicsmanager", 2, _AM_ERRORTOPICNAME);
        }
        $xt->setTopicTitle($_POST['topic_title']);
        //$xt->Settopic_rssurl($_POST['topic_rssfeed']);
        $xt->setTopic_color($_POST['topic_color']);
        if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] != "") {
            $xt->setTopicImgurl($_POST['topic_imgurl']);
        }
        $xt->setMenu(intval($_POST['submenu']));
        $xt->setTopicFrontpage(intval($_POST['topic_frontpage']));
        if (isset($_POST['xoops_upload_file'])) {
            $fldname = $_FILES[$_POST['xoops_upload_file'][0]];
            $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name'];
            if (xoops_trim($fldname != '')) {
                $sfiles = new sFiles();
                $dstpath = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . '/images/topics';
                $destname = $sfiles->createUploadName($dstpath, $fldname, true);
                $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png');
                $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
                $uploader->setTargetFileName($destname);
                if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
                    if ($uploader->upload()) {
                        $xt->setTopicImgurl(basename($destname));
                    } else {
                        echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors();
                    }
                } else {
                    echo $uploader->getErrors();
                }
            }
        }
        $xt->setTopicDescription($_POST['topic_description']);
        $xt->store();
        updateCache();
        $notification_handler =& xoops_gethandler('notification');
        $tags = array();
        $tags['TOPIC_NAME'] = $_POST['topic_title'];
        $notification_handler->triggerEvent('global', 0, 'new_category', $tags);
        redirect_header('index.php?op=topicsmanager', 1, _AM_DBUPDATED);
    } else {
        redirect_header('index.php?op=topicsmanager', 2, _AM_ADD_TOPIC_ERROR);
    }
    exit;
}
开发者ID:BackupTheBerlios,项目名称:soopa,代码行数:52,代码来源:index.php

示例10: XoopsMediaUploader

 $max_imgheight = 0;
 // ou =$xoopsModuleConfig['max_imgheight']
 //$allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png');
 $allowed_mimetypes = '';
 include_once XOOPS_ROOT_PATH . "/class/uploader.php";
 // Retreive the filename to be uploaded
 $filename = $_POST["xoops_upload_file"][0];
 if (!empty($filename) || $filename != "") {
     if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) {
         redirect_header('javascript:history.go(-1)', 2, _AM_SS_FILEUPLOAD_ERROR);
         exit;
     }
     $uploader = new XoopsMediaUploader(ss_getUploadDir(), $allowed_mimetypes, $max_size, null, null);
     $ext = preg_replace("/^.+\\.([^.]+)\$/sU", "\\1", $_FILES["my_file"]['name']);
     $new_name = time() . "." . $ext;
     $uploader->setTargetFileName($new_name);
     if ($uploader->fetchMedia($filename) && $uploader->upload()) {
         if (!$xoopsUser) {
             if ($xoopsModuleConfig['anonpost'] == 1) {
                 $uid = 0;
             } else {
                 redirect_header("index.php", 3, _NOPERM);
                 exit;
             }
         } else {
             $uid = $xoopsUser->uid();
         }
         $fileObj = $smartsection_file_handler->create();
         $fileObj->setVar('name', $_POST['name']);
         $fileObj->setVar('description', $_POST['description']);
         $fileObj->setVar('filename', $uploader->getSavedFileName());
开发者ID:BackupTheBerlios,项目名称:soopa,代码行数:31,代码来源:file.php

示例11: array

             $obj->setVar('photo', $uploader->getSavedFileName());
         }
     } else {
         $obj->setVar('photo', Request::getString('photo'));
     }
 }
 if (!empty($_FILES['photo2']['name'])) {
     include_once XOOPS_ROOT_PATH . '/class/uploader.php';
     $uploaddir2 = XOOPS_ROOT_PATH . '/modules/alumni/photos/now_photo';
     $photomax = $xoops->getModuleConfig('alumni_photomax');
     $maxwide = $xoops->getModuleConfig('alumni_maxwide');
     $maxhigh = $xoops->getModuleConfig('alumni_maxhigh');
     $allowed_mimetypes = array('image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
     $uploader2 = new XoopsMediaUploader($uploaddir2, $allowed_mimetypes, $photomax, $maxwide, $maxhigh);
     if ($uploader2->fetchMedia($_POST['xoops_upload_file'][1])) {
         $uploader2->setTargetFileName($date . '_' . $_FILES['photo2']['name']);
         $uploader2->fetchMedia($_POST['xoops_upload_file'][1]);
         if (!$uploader2->upload()) {
             $errors = $uploader2->getErrors();
             $xoops->redirect('javascript:history.go(-1)', 3, $errors);
         } else {
             $obj->setVar('photo2', $uploader2->getSavedFileName());
         }
     } else {
         $obj->setVar('photo2', Request::getString('photo2'));
     }
 }
 if ($new_id = $listingHandler->insert($obj)) {
     if ($xoops->getModuleConfig('alumni_moderated') == '1') {
         $xoops->redirect('index.php', 3, AlumniLocale::MODERATE);
     } else {
开发者ID:jlm69,项目名称:alumni-26x,代码行数:31,代码来源:listing.php

示例12: storeUpload

 function storeUpload($post_field, $allowed_mimetypes = null, &$errors)
 {
     global $xoopsUser, $xoopsDB, $xoopsModule;
     include_once SMARTPARTNER_ROOT_PATH . 'class/uploader.php';
     $config =& smartpartner_getModuleConfig();
     $id = $this->getVar('id');
     if (!isset($allowed_mimetypes)) {
         $hMime =& xoops_getmodulehandler('mimetype');
         $allowed_mimetypes = $hMime->checkMimeTypes($post_field);
         if (!$allowed_mimetypes) {
             return false;
         }
     }
     /*$maxfilesize = $config['xhelp_uploadSize'];
       $maxfilewidth = $config['xhelp_uploadWidth'];
       $maxfileheight = $config['xhelp_uploadHeight'];*/
     $maxfilesize = $config['maximum_filesize'];
     $maxfilewidth = 100000;
     //$config['maximum_image_width'];
     $maxfileheight = 100000;
     //$config['maximum_image_height'];
     if (!is_dir(smartpartner_getUploadDir())) {
         mkdir(smartpartner_getUploadDir(), 0757);
     }
     $uploader = new XoopsMediaUploader(smartpartner_getUploadDir() . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
     if ($uploader->fetchMedia($post_field)) {
         $file_title = $this->purifyText($uploader->getMediaName());
         $uploader->setTargetFileName($id . "_" . $file_title);
         if ($uploader->upload()) {
             $this->setVar('filename', $uploader->getSavedFileName());
             if ($this->getVar('name') == '') {
                 $this->setVar('name', $this->getNameFromFilename());
             }
             $this->setVar('mimetype', $uploader->getMediaType());
             return true;
         } else {
             $errors = array_merge($errors, $uploader->getErrors(false));
             return false;
         }
     } else {
         $errors = array_merge($errors, $uploader->getErrors(false));
         return false;
     }
 }
开发者ID:trabisdementia,项目名称:xuups,代码行数:44,代码来源:file.php

示例13: saveNewVideoCategory

function saveNewVideoCategory()
{
    $videoCatHandler =& xoops_getmodulehandler('video_category', 'vidshop');
    $video = $videoCatHandler->create();
    $video->setVar('name', $_REQUEST["name"]);
    $video->setVar('description', $_REQUEST["description"]);
    if (isset($_POST['xoops_upload_file'])) {
        $fldname = $_FILES[$_POST['xoops_upload_file'][0]];
        $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name'];
        if (xoops_trim($fldname != '')) {
            $destname = md5(time()) . '_' . $fldname;
            /**
             * You can attach files to your news, actually : Web pictures (png, gif, jpeg), zip, pdf, gtar, tar, pdf
             */
            $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png');
            $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $permittedtypes, 1024 * 1024 * 3);
            $uploader->setTargetFileName($destname);
            if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
                if ($uploader->upload()) {
                    $video->setVar('image', str_replace(XOOPS_ROOT_PATH, '', $destname));
                } else {
                    echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors();
                }
            } else {
                echo $uploader->getErrors();
            }
        }
    }
    if ($cid = $videoCatHandler->insert($video)) {
        if (!strpos($_SERVER['REQUEST_URI'], '/vidshop/admin/')) {
            redirect_header('admin.php?op=cats&fct=edit&id=' . $cid, 8, sprintf(_VSP_RH_CATEGORY_EDITED, $video->getVar('name')));
        } else {
            redirect_header('admin.php?op=cats', 8, sprintf(_VSP_RH_CATEGORY_EDITED, $video->getVar('name')));
        }
        exit(0);
    } else {
        redirect_header('index.php', 4, sprintf(_VSP_RH_CATEGORY_NOCREATION, $video->getVar('name'), implode('<br/>', $video->getErrors())));
        exit(0);
    }
}
开发者ID:severnaya99,项目名称:Sg-2010,代码行数:40,代码来源:functions.php

示例14: isset

 } else {
     $obj =& $tablesHandler->create();
 }
 $tables_blocs = isset($_REQUEST['tables_blocs']) ? $_REQUEST['tables_blocs'] : '0';
 $tables_display_admin = isset($_REQUEST['tables_display_admin']) ? $_REQUEST['tables_display_admin'] : '0';
 $tables_search = isset($_REQUEST['tables_search']) ? $_REQUEST['tables_search'] : '0';
 $tables_coms = isset($_REQUEST['tables_coms']) ? $_REQUEST['tables_coms'] : '0';
 $select = isset($_REQUEST['select']) ? $_REQUEST['select'] : '0';
 //Image
 include_once XOOPS_ROOT_PATH . '/class/uploader.php';
 $uploaddir = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/images/uploads/tables/";
 $uploader = new XoopsMediaUploader($uploaddir, "gif|jpeg|pjpeg|png", 104857600, null, null);
 if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
     $extension = preg_replace("/^.+\\.([^.]+)\$/sU", "\\1", $_FILES["attachedfile"]['name']);
     $name_img = $_REQUEST['tables_name'] . '.' . $extension;
     $uploader->setTargetFileName($name_img);
     $uploader->fetchMedia($_POST['xoops_upload_file'][0]);
     if (!$uploader->upload()) {
         $errors = $uploader->getErrors();
         redirect_header("javascript:history.go(-1)", 3, $errors);
     } else {
         $obj->setVar('tables_img', $uploader->getSavedFileName());
     }
 } else {
     $obj->setVar('tables_img', $_REQUEST['tables_img']);
 }
 if ($tablesHandler->insert($obj)) {
     $tables_id = $xoopsDB->getInsertId();
     $obj = $tablesHandler->get($tables_id);
     $form = $obj->getFormChamps(false, $tables_id, intval($_REQUEST['tables_modules']), strtolower($_REQUEST['tables_name']), $tables_blocs, $tables_display_admin, $tables_search, $tables_coms, intval($_REQUEST['tables_nb_champs']), $select);
 }
开发者ID:severnaya99,项目名称:Sg-2010,代码行数:31,代码来源:tables.php

示例15: addTopic

function addTopic()
{
	global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
    $topicpid = isset($_POST['topic_pid']) ? intval($_POST['topic_pid']) : 0;
    $xt = new nw_NewsTopic();
    if (!$xt->topicExists($topicpid, $_POST['topic_title'])) {
        $xt->setTopicPid($topicpid);
        if (empty($_POST['topic_title']) || xoops_trim($_POST['topic_title'])=='') {
            redirect_header( 'index.php?op=topicsmanager', 2, _AM_NW_ERRORTOPICNAME );
        }
        $xt->setTopicTitle($_POST['topic_title']);
        //$xt->Settopic_rssurl($_POST['topic_rssfeed']);
        $xt->setTopic_color($_POST['topic_color']);
        if (isset($_POST['topic_imgurl'] ) && $_POST['topic_imgurl'] != '') {
            $xt->setTopicImgurl($_POST['topic_imgurl'] );
        }
		$xt->setMenu(intval($_POST['submenu']));
		$xt->setTopicFrontpage(intval($_POST['topic_frontpage']));
	    if(isset($_SESSION['items_count'])) {
    		$_SESSION['items_count'] = -1;
    	}
		if(isset($_POST['xoops_upload_file'])) {
			$fldname = $_FILES[$_POST['xoops_upload_file'][0]];
			$fldname = (get_magic_quotes_gpc()) ? stripslashes($fldname['name']) : $fldname['name'];
			if(xoops_trim($fldname!='')) {
				$sfiles = new nw_sFiles();
				$dstpath = NW_TOPICS_FILES_PATH;
				$destname=$sfiles->createUploadName($dstpath ,$fldname, true);
				$permittedtypes=array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png');
				$uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
				$uploader->setTargetFileName($destname);
				if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
					if ($uploader->upload()) {
						$xt->setTopicImgurl(basename($destname));
					} else {
						echo _AM_NW_UPLOAD_ERROR . ' ' . $uploader->getErrors();
					}
				} else {
					echo $uploader->getErrors();
				}
			}
		}
		if(isset($_POST['topic_description'])) {
		$xt->setTopicDescription($_POST['topic_description']);
		} else {
			$xt->setTopicDescription('');
		}
		$xt->store();
		// Permissions
		$gperm_handler = &xoops_gethandler('groupperm');
		if(isset($_POST['groups_news_can_approve'])) {
			foreach($_POST['groups_news_can_approve'] as $onegroup_id) {
				$gperm_handler->addRight('nw_approve', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid'));
			}
		}

		if(isset($_POST['groups_news_can_submit'])) {
			foreach($_POST['groups_news_can_submit'] as $onegroup_id) {
				$gperm_handler->addRight('nw_submit', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid'));
			}
		}

		if(isset($_POST['groups_news_can_view'])) {
			foreach($_POST['groups_news_can_view'] as $onegroup_id) {
				$gperm_handler->addRight('nw_view', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid'));
			}
		}
		nw_updateCache();

        $notification_handler = & xoops_gethandler('notification');
        $tags = array();
        $tags['TOPIC_NAME'] = $_POST['topic_title'];
        $notification_handler->triggerEvent( 'global', 0, 'new_category', $tags);
        redirect_header('index.php?op=topicsmanager', 1, _AM_NW_DBUPDATED);
    } else {
        redirect_header('index.php?op=topicsmanager', 2, _AM_NW_ADD_TOPIC_ERROR);
    }
    exit();
}
开发者ID:severnaya99,项目名称:Sg-2010,代码行数:79,代码来源:index.php


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