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


PHP CUtils::getNextFileName方法代码示例

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


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

示例1: getSQLValue

 public function getSQLValue($name = '')
 {
     global $PRJ_DIR;
     $name = $name ? $name : $this->getName();
     $ret = CUtils::_postVar($name . '_oldValue');
     if ($ret && CUtils::_postVar($name . '_delete')) {
         if ($ret != '/img/lib/empty_photo.gif' && $ret != '') {
             @unlink($PRJ_DIR . $ret);
             if (isset($this->props['sizes'])) {
                 $path_parts = pathinfo($PRJ_DIR . $ret);
                 $asizes = explode(',', $this->props['sizes']);
                 foreach ($asizes as $sz) {
                     $asz = explode('|', $sz);
                     if (sizeof($asz) == 2) {
                         @unlink($path_parts['dirname'] . '/' . $asz[0] . '_' . $path_parts['basename']);
                     }
                 }
             }
         }
         $ret = '';
     }
     if (is_array($_FILES) && sizeof($_FILES) > 0 && isset($_FILES[$name]) && $_FILES[$name]['name'] != '') {
         if ($ret && $ret != '/img/lib/empty_photo.gif') {
             @unlink($PRJ_DIR . $ret);
             if (isset($this->props['sizes'])) {
                 $path_parts = pathinfo($PRJ_DIR . $ret);
                 $asizes = explode(',', $this->props['sizes']);
                 foreach ($asizes as $sz) {
                     $asz = explode('|', $sz);
                     if (sizeof($asz) == 2) {
                         @unlink($path_parts['dirname'] . '/' . $asz[0] . '_' . $path_parts['basename']);
                     }
                 }
             }
         }
         $dest = CUtils::getNextFileName('/upload/' . strtolower(CUtils::translitStr($_FILES[$name]['name'])));
         @move_uploaded_file($_FILES[$name]['tmp_name'], $PRJ_DIR . $dest);
         $ret = $dest;
         $this->afterUpload($ret);
     }
     return $ret;
 }
开发者ID:rawork,项目名称:colors-life,代码行数:42,代码来源:image.php

示例2: getSQLValue

 public function getSQLValue($name = '')
 {
     global $PRJ_DIR;
     $name = $name ? $name : $this->getName();
     $ret = $_REQUEST[$name . '_oldValue'];
     if ($ret && CUtils::_postVar($name . '_delete')) {
         @unlink($PRJ_DIR . $ret);
         $ret = '';
     }
     if (is_array($_FILES) && sizeof($_FILES) > 0 && isset($_FILES[$name]) && $_FILES[$name]['name'] != '') {
         if ($ret) {
             @unlink($PRJ_DIR . $ret);
         }
         $dest = CUtils::getNextFileName('/upload/' . strtolower(CUtils::translitStr($_FILES[$name]['name'])));
         move_uploaded_file($_FILES[$name]['tmp_name'], $PRJ_DIR . $dest);
         $ret = $dest;
         $this->afterUpload($ret);
     }
     return $ret;
 }
开发者ID:rawork,项目名称:colors-life,代码行数:20,代码来源:file.php

示例3: getSQLValue

 public function getSQLValue($name = '')
 {
     global $VERSION_QUANTITY, $PRJ_DIR;
     $name = $name ? $name : $this->getName();
     $ret = CUtils::_postVar($name . '_oldValue');
     $date_stamp = date('Y_m_d_H_i_s');
     $values = '';
     if ($ret && CUtils::_postVar($name . '_delete')) {
         $backup_ret = str_replace('/templates/', '/templates/backup/', $ret);
         @copy($PRJ_DIR . $ret, $PRJ_DIR . $backup_ret . $date_stamp . '.bak');
         @unlink($PRJ_DIR . $ret);
         $values = "'" . $this->props['cls'] . "','" . $this->getName() . "'," . $this->dbId . ",NOW(),'" . $backup_ret . $date_stamp . '.bak' . "'";
         $ret = '';
     } elseif ($ret && CUtils::_postVar($name . '_version', true, 0)) {
         $backup_ret = str_replace('/templates/', '/templates/backup/', $ret);
         @copy($PRJ_DIR . $ret, $PRJ_DIR . $backup_ret . $date_stamp . '.bak');
         @unlink($PRJ_DIR . $ret);
         $values = "'" . $this->props['cls'] . "','" . $this->getName() . "'," . $this->dbId . ",NOW(),'" . $backup_ret . $date_stamp . '.bak' . "'";
         $ver = $GLOBALS['db']->getItem('templates_version', "SELECT * FROM templates_version WHERE id=" . CUtils::_postVar($name . '_version', true, 0));
         @copy($PRJ_DIR . $ver['file'], $PRJ_DIR . $ret);
     } elseif ($ret) {
         $f = fopen($PRJ_DIR . $ret . '_new', 'w');
         fwrite($f, $_POST[$name . '_temp']);
         fclose($f);
         if (md5_file($PRJ_DIR . $ret . '_new') != md5_file($PRJ_DIR . $ret)) {
             $backup_ret = str_replace('/templates/', '/templates/backup/', $ret);
             @copy($PRJ_DIR . $ret, $PRJ_DIR . $backup_ret . $date_stamp . '.bak');
             $values = "'" . $this->props['cls'] . "','" . $this->getName() . "'," . $this->dbId . ",NOW(),'" . $backup_ret . $date_stamp . '.bak' . "'";
             @copy($PRJ_DIR . $ret . '_new', $PRJ_DIR . $ret);
         }
         @unlink($PRJ_DIR . $ret . '_new');
     }
     if (CUtils::_postVar($name . '_cre')) {
         $ret = CUtils::_postVar($name);
         if (trim($ret) != '') {
             $dest = CUtils::getNextFileName('/templates' . (isset($this->props['basepath']) ? $this->props['basepath'] : '') . '/' . CUtils::translitStr($ret));
             $ret = $dest;
             $f = fopen($PRJ_DIR . $ret, 'w');
             fwrite($f, $_POST[$name . "_temp"]);
             fclose($f);
             chmod($PRJ_DIR . $ret, 0666);
         }
     } elseif (is_array($_FILES) && sizeof($_FILES) > 0 && isset($_FILES[$name]) && $_FILES[$name]['name'] != '') {
         if ($ret) {
             $backup_ret = str_replace('/templates/', '/templates/backup/', $ret);
             @copy($PRJ_DIR . $ret, $PRJ_DIR . $backup_ret . $date_stamp . '.bak');
             @unlink($PRJ_DIR . $ret);
             $values = "'" . $this->props['cls'] . "','" . $this->getName() . "'," . $this->dbId . ",NOW(),'" . $backup_ret . $date_stamp . '.bak' . "'";
         }
         $dest = CUtils::getNextFileName('/templates' . (isset($this->props['basepath']) ? $this->props['basepath'] : '') . '/' . $_FILES[$name]['name']);
         move_uploaded_file($_FILES[$name]['tmp_name'], $PRJ_DIR . $dest);
         chmod($PRJ_DIR . $dest, 0666);
         $ret = $dest;
     }
     if ($values) {
         $vers = $GLOBALS['db']->getItems('select_version', "SELECT * FROM templates_version WHERE cls='" . $this->props['cls'] . "' AND fld='" . $this->getName() . "' AND rc=" . $this->dbId . ' ORDRER BY id');
         if (sizeof($vers) >= __VERSION_QUANTITY) {
             $GLOBALS['db']->execQuery('templates_version', 'DELETE FROM templates_version WHERE id=' . $vers[0]['id']);
         }
         $db_ret = $GLOBALS['db']->execQuery('add_version', 'INSERT INTO templates_version(cls,fld,rc,credate,file) VALUES(' . $values . ')');
         //var_dump($db_ret, 'INSERT INTO templates_version(cls,fld,rc,credate,file) VALUES('.$values.')');
         //die();
     }
     return $ret;
 }
开发者ID:rawork,项目名称:colors-life,代码行数:65,代码来源:template.php

示例4: insertArray

 function insertArray(&$a)
 {
     global $db;
     $names = $values = '';
     foreach ($a as $k => $v) {
         foreach ($this->fields as $f) {
             if ($k && $f['name'] == $k) {
                 $names = ($names ? $names . ', ' : '') . $f['name'];
                 if ($a[$f['name']] && ($f['type'] == 'image' || $f['type'] == 'file' || $f['type'] == 'template')) {
                     $ft = $this->createFieldType($f);
                     $dest = CUtils::getNextFileName($v);
                     @copy($GLOBALS['PRJ_DIR'] . $v, $GLOBALS['PRJ_DIR'] . $dest);
                     $values = ($values ? $values . ', ' : '') . "'" . $dest . "'";
                     if ($f['type'] == 'image' && isset($ft->props['sizes'])) {
                         $path_parts = pathinfo($a[$ft->getName()]);
                         $asizes = explode(',', $ft->props['sizes']);
                         foreach ($asizes as $sz) {
                             $asz = explode('|', $sz);
                             if (sizeof($asz) == 2) {
                                 $v = $path_parts['dirname'] . '/' . $asz[0] . '_' . $path_parts['basename'];
                                 $dest = CUtils::getNextFileName($v);
                                 @copy($GLOBALS['PRJ_DIR'] . $v, $GLOBALS['PRJ_DIR'] . $dest);
                             }
                         }
                     }
                 } else {
                     $values = ($values ? $values . ', ' : '') . "'" . $v . "'";
                 }
                 break;
             }
         }
     }
     $ret = $this->insert($names, $values);
     $iLastInsertID = $db->getInsertID();
     if ($this->props['multifile']) {
         $sql = "SELECT * FROM system_files WHERE record_id={$a['id']} AND table_name='" . $this->getDBTableName() . "'";
         $photos = $db->getItems('get_system_files', $sql);
         foreach ($photos as $photo) {
             $filepath = $photo['file'];
             $dest = CUtils::getNextFileName($filepath);
             @copy($GLOBALS['PRJ_DIR'] . $filepath, $GLOBALS['PRJ_DIR'] . $dest);
             unset($photo['id']);
             $photo['file'] = $dest;
             $photo['credate'] = date("Y-m-d H:i:s");
             $photo['record_id'] = $iLastInsertID;
             $names = implode(',', array_keys($photo));
             array_walk($photo, "fillValue");
             $values = implode(',', $photo);
             $sql = "INSERT INTO system_files ({$names}) VALUES ({$values})";
             $db->execQuery($this->getDBTableName(), $sql);
         }
     }
     //exit;
     return $ret;
 }
开发者ID:rawork,项目名称:colors-life,代码行数:55,代码来源:DBTable.php

示例5: getNextFileName

 public static function getNextFileName($name, $counter = 0)
 {
     preg_match('/([^\\.]+).(.+)/', $name, $regs);
     $newName = $counter ? $regs[1] . '_' . $counter . '.' . $regs[2] : $name;
     return @file_exists($GLOBALS['PRJ_DIR'] . $newName) ? CUtils::getNextFileName($name, $counter + 1) : $newName;
 }
开发者ID:rawork,项目名称:colors-life,代码行数:6,代码来源:CUtils.php

示例6: elseif

             break;
         case '8':
             $error = 'Загрузка файла прервана';
             break;
         case '999':
         default:
             $error = 'Не известный код ошибки';
     }
 } elseif (empty($_FILES[$fileElementName]['tmp_name'][$i]) || $_FILES[$fileElementName]['tmp_name'][$i] == 'none') {
     $error = 'Файлы не загружены..';
 } else {
     /*if (file_exists($upload_path . $_FILES[$fileElementName]['name'][$i])){
     			$error = $_FILES[$fileElementName]['name'][$i] . " уже существует. ";
     		} else {*/
     $msg = " File Name: " . $_FILES[$fileElementName]['name'][$i] . "<br/>";
     $fileref = CUtils::getNextFileName($upload_ref . $_FILES[$fileElementName]['name'][$i]);
     move_uploaded_file($_FILES[$fileElementName]['tmp_name'][$i], $GLOBALS['PRJ_DIR'] . $fileref);
     $filename = $_FILES[$fileElementName]['name'][$i];
     $filesize = @filesize($upload_path . $_FILES[$fileElementName]['name'][$i]);
     $filetype = $_FILES[$fileElementName]['type'][$i];
     $table_name = CUtils::_postVar('table_name');
     $record_id = CUtils::_postVar('record_id', true, 0);
     $filewidth = 0;
     $fileheight = 0;
     if (is_array($file_info = @GetImageSize($GLOBALS['PRJ_DIR'] . $fileref))) {
         $filewidth = $file_info[0];
         $fileheight = $file_info[1];
     }
     $sql = "INSERT INTO system_files(name,mimetype,file,width,height,filesize,table_name,record_id,credate) " . " VALUES('{$filename}','{$filetype}','{$fileref}',{$filewidth},{$fileheight},'{$filesize}','{$table_name}','{$record_id}',NOW())";
     $GLOBALS['db']->execQuery('addfile', $sql);
     //$msg .= $sql;
开发者ID:rawork,项目名称:colors-life,代码行数:31,代码来源:doajaxfileupload.php


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