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


PHP rex::getFilePerm方法代码示例

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


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

示例1: saveMedia

 function saveMedia($FILE, $filefolder, $extensions_array, $rex_file_category, $mediapool_user)
 {
     $FILENAME = $FILE['name'];
     $FILESIZE = $FILE['size'];
     $FILETYPE = $FILE['type'];
     $message = '';
     // ----- neuer filename und extension holen
     $NFILENAME = strtolower(preg_replace('/[^a-zA-Z0-9.\\-\\$\\+]/', '_', $FILENAME));
     if (strrpos($NFILENAME, '.') != '') {
         $NFILE_NAME = substr($NFILENAME, 0, strlen($NFILENAME) - (strlen($NFILENAME) - strrpos($NFILENAME, '.')));
         $NFILE_EXT = substr($NFILENAME, strrpos($NFILENAME, '.'), strlen($NFILENAME) - strrpos($NFILENAME, '.'));
     } else {
         $NFILE_NAME = $NFILENAME;
         $NFILE_EXT = '';
     }
     // ---- ext checken
     $ERROR_EXT = array('.php', '.php3', '.php4', '.php5', '.phtml', '.pl', '.asp', '.aspx', '.cfm');
     if (in_array($NFILE_EXT, $ERROR_EXT)) {
         $NFILE_NAME .= $NFILE_EXT;
         $NFILE_EXT = '.txt';
     }
     $standard_extensions_array = array('.rtf', '.pdf', '.doc', '.gif', '.jpg', '.jpeg');
     if (count($extensions_array) == 0) {
         $extensions_array = $standard_extensions_array;
     }
     if (!in_array($NFILE_EXT, $extensions_array)) {
         $RETURN = false;
         $RETURN['ok'] = false;
         return $RETURN;
     }
     $NFILENAME = $NFILE_NAME . $NFILE_EXT;
     // ----- filexists ? -> _1 ..
     if (file_exists($filefolder . '/' . $NFILENAME)) {
         for ($cf = 1; $cf < 1000; $cf++) {
             $NFILENAME = $NFILE_NAME . '_' . $cf . '.' . $NFILE_EXT;
             if (!file_exists($filefolder . '/' . $NFILENAME)) {
                 break;
             }
         }
     }
     // ----- dateiupload
     $upload = true;
     if (!move_uploaded_file($FILE['tmp_name'], $filefolder . "/{$NFILENAME}")) {
         if (!copy($FILE['tmp_name'], $filefolder . '/' . $NFILENAME)) {
             $message .= 'move file $NFILENAME failed | ';
             $RETURN = false;
             $RETURN['ok'] = false;
             return $RETURN;
         }
     }
     @chmod($filefolder . '/' . $NFILENAME, rex::getFilePerm());
     $RETURN['type'] = $FILETYPE;
     $RETURN['msg'] = $message;
     $RETURN['ok'] = true;
     $RETURN['filename'] = $NFILENAME;
     $FILESQL = rex_sql::factory();
     // $FILESQL->debugsql=1;
     $FILESQL->setTable(rex::getTablePrefix() . 'file');
     $FILESQL->setValue('filetype', $FILETYPE);
     $FILESQL->setValue('filename', $NFILENAME);
     $FILESQL->setValue('originalname', $FILENAME);
     $FILESQL->setValue('filesize', $FILESIZE);
     $FILESQL->setValue('category_id', $rex_file_category);
     $FILESQL->setValue('createdate', time());
     $FILESQL->setValue('createuser', $mediapool_user);
     $FILESQL->setValue('updatedate', time());
     $FILESQL->setValue('updateuser', $mediapool_user);
     $FILESQL->insert();
     return $RETURN;
 }
开发者ID:VIEWSION,项目名称:redaxo_yform,代码行数:70,代码来源:mediafile.php

示例2: rex_mediapool_updateMedia

/**
 * Holt ein upgeloadetes File und legt es in den Medienpool
 * Dabei wird kontrolliert ob das File schon vorhanden ist und es
 * wird eventuell angepasst, weiterhin werden die Fileinformationen übergeben.
 *
 * @param array  $FILE
 * @param array  $FILEINFOS
 * @param string $userlogin
 *
 * @return array
 */
function rex_mediapool_updateMedia($FILE, &$FILEINFOS, $userlogin = null)
{
    $RETURN = [];
    $FILESQL = rex_sql::factory();
    // $FILESQL->setDebug();
    $FILESQL->setTable(rex::getTablePrefix() . 'media');
    $FILESQL->setWhere(['id' => $FILEINFOS['file_id']]);
    $FILESQL->setValue('title', $FILEINFOS['title']);
    $FILESQL->setValue('category_id', $FILEINFOS['rex_file_category']);
    $updated = false;
    if ($_FILES['file_new']['name'] != '' && $_FILES['file_new']['name'] != 'none') {
        $ffilename = $_FILES['file_new']['tmp_name'];
        $ffiletype = $_FILES['file_new']['type'];
        $ffilesize = $_FILES['file_new']['size'];
        $p_new = pathinfo($_FILES['file_new']['name']);
        $p_old = pathinfo($FILEINFOS['filename']);
        // if ($ffiletype == $FILEINFOS["filetype"] || rex_media::compareImageTypes($ffiletype,$FILEINFOS["filetype"]))
        if ($p_new['extension'] == $p_old['extension']) {
            if (move_uploaded_file($ffilename, rex_path::media($FILEINFOS['filename'])) || copy($ffilename, rex_path::media($FILEINFOS['filename']))) {
                $RETURN['msg'] = rex_i18n::msg('pool_file_changed');
                $FILEINFOS['filetype'] = $ffiletype;
                $FILEINFOS['filesize'] = $ffilesize;
                $FILESQL->setValue('filetype', $FILEINFOS['filetype']);
                // $FILESQL->setValue('originalname',$ffilename);
                $FILESQL->setValue('filesize', $FILEINFOS['filesize']);
                if ($size = @getimagesize(rex_path::media($FILEINFOS['filename']))) {
                    $FILESQL->setValue('width', $size[0]);
                    $FILESQL->setValue('height', $size[1]);
                }
                @chmod(rex_path::media($FILEINFOS['filename']), rex::getFilePerm());
                $updated = true;
            } else {
                $RETURN['msg'] = rex_i18n::msg('pool_file_upload_error');
            }
        } else {
            $RETURN['msg'] = rex_i18n::msg('pool_file_upload_errortype');
        }
    } else {
        if ($size = @getimagesize(rex_path::media($FILEINFOS['filename']))) {
            $FILESQL->setValue('width', $size[0]);
            $FILESQL->setValue('height', $size[1]);
        }
        $FILESQL->setValue('filesize', @filesize(rex_path::media($FILEINFOS['filename'])));
    }
    // Aus BC gruenden hier mit int 1/0
    $RETURN['ok'] = $updated ? 1 : 0;
    if (!isset($RETURN['msg'])) {
        $RETURN['msg'] = rex_i18n::msg('pool_file_infos_updated');
        $RETURN['ok'] = 1;
    }
    if ($RETURN['ok'] == 1) {
        $RETURN['filename'] = $FILEINFOS['filename'];
        $RETURN['filetype'] = $FILEINFOS['filetype'];
        $RETURN['id'] = $FILEINFOS['file_id'];
    }
    $FILESQL->addGlobalUpdateFields();
    $FILESQL->update();
    rex_media_cache::delete($FILEINFOS['filename']);
    /*
    $RETURN['title'] = $FILEINFOS['title'];
    $RETURN['type'] = $FILETYPE;
    $RETURN['msg'] = $message;
    // Aus BC gruenden hier mit int 1/0
    $RETURN['ok'] = $success ? 1 : 0;
    $RETURN['filename'] = $NFILENAME;
    $RETURN['old_filename'] = $FILENAME;
    */
    return $RETURN;
}
开发者ID:skerbis,项目名称:redaxo,代码行数:80,代码来源:function_rex_mediapool.php

示例3: copy

 /**
  * Copies a file.
  *
  * @param string $srcfile Path of the source file
  * @param string $dstfile Path of the destination file or directory
  *
  * @return bool TRUE on success, FALSE on failure
  */
 public static function copy($srcfile, $dstfile)
 {
     if (is_file($srcfile)) {
         if (is_dir($dstfile)) {
             $dstdir = rtrim($dstfile, DIRECTORY_SEPARATOR);
             $dstfile = $dstdir . DIRECTORY_SEPARATOR . basename($srcfile);
         } else {
             $dstdir = dirname($dstfile);
             rex_dir::create($dstdir);
         }
         if (rex_dir::isWritable($dstdir) && (!file_exists($dstfile) || is_writable($dstfile)) && copy($srcfile, $dstfile)) {
             touch($dstfile, filemtime($srcfile));
             @chmod($dstfile, rex::getFilePerm());
             return true;
         }
     }
     return false;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:26,代码来源:file.php


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