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


PHP files::getUniqueName方法代码示例

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


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

示例1: event_CreateRevision

 function event_CreateRevision(&$data)
 {
     $res = sql::query("\r\n\t\t\t\tSELECT \r\n\t\t\t\t\t*\r\n\t\t\t\tFROM \r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_movie\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tID = '" . $data['id'] . "' AND\r\n\t\t\t\t\trevision = '" . $data['from'] . "'\r\n\t\t\t");
     while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
         $directory = _BASE_MEDIA_ . 'movies/';
         $filename = files::getUniqueName($row['type'], $directory);
         copy($directory . $row['filename'], $directory . $filename);
         sql::query("\r\n\t\t\t\t\tINSERT INTO \r\n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_movie \r\n\t\t\t\t\tSET \r\n\t\t\t\t\t\tID='" . $data['id'] . "', \r\n\t\t\t\t\t\trevision='" . $data['to'] . "',\r\n\t\t\t\t\t\tfilename='" . addslashes($filename) . "',\r\n\t\t\t\t\t\tname='" . addslashes($row['name']) . "',\r\n\t\t\t\t\t\ttype='" . addslashes($row['type']) . "',\r\n\t\t\t\t\t\tsize='" . $row['size'] . "', \r\n\t\t\t\t\t\twidth='" . $row['width'] . "', \r\n\t\t\t\t\t\theight='" . $row['height'] . "', \r\n\t\t\t\t\t\tautostart='" . $row['autostart'] . "'\r\n\t\t\t\t");
     }
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:10,代码来源:plugin.php

示例2: action_medialibrary

 function action_medialibrary($args)
 {
     global $lang, $user;
     $folder = isset($_REQUEST['folder']) ? $_REQUEST['folder'] : (isset($_SESSION['lastFolder']) ? $_SESSION['lastFolder'] : 1);
     $_SESSION['lastFolder'] = $folder;
     $res = sql::query("\r\n\t\t\t\tSELECT \r\n\t\t\t\t\t*\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tID = '" . $folder . "'\r\n\t\t\t");
     if (sql::num_rows($res) == 0) {
         $res = sql::query("\r\n\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t*\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t`order`\r\n\t\t\t\t\tLIMIT 1\r\n\t\t\t\t");
         if ($row = sql::fetch_array($res)) {
             $folder = $row['ID'];
         }
     }
     $flash = false;
     // Map Flash upload name to regular upload name
     if (isset($_FILES['Filedata'])) {
         $flash = true;
         $_FILES['file'] =& $_FILES['Filedata'];
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['file'])) {
         if ($_FILES['file']['error'] > UPLOAD_ERR_OK) {
             error_log('Could not upload file because error ' . $_FILES['file']['error'] . ' occurred');
         } else {
             if (is_uploaded_file($_FILES['file']['tmp_name'])) {
                 $directory = _BASE_MEDIA_ . 'images/';
                 $original = $_FILES['file']['name'];
                 $contenttype = files::getCleanContentType($_FILES['file']['type'], $_FILES['file']['name']);
                 $filename = files::getUniqueName($contenttype, $directory);
                 if (files::allowedContentType($contenttype, 'picture')) {
                     // Move file to the media directory
                     move_uploaded_file($_FILES['file']['tmp_name'], $directory . $filename);
                     // Get information from the file...
                     list($width, $height) = getimagesize($directory . $filename);
                     $size = round(filesize($directory . $filename) / 1024);
                     // Insert it into the database
                     $res = sql::query("\r\n\t\t\t\t\t\t\t\tINSERT INTO\r\n\t\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t\tfolder = '" . $folder . "',\r\n\t\t\t\t\t\t\t\t\tfilename = '" . addslashes($filename) . "',\r\n\t\t\t\t\t\t\t\t\toriginal = '" . addslashes(basename($original)) . "',\r\n\t\t\t\t\t\t\t\t\twidth = '" . $width . "',\r\n\t\t\t\t\t\t\t\t\theight = '" . $height . "',\r\n\t\t\t\t\t\t\t\t\tsize = '" . $size . "',\r\n\t\t\t\t\t\t\t\t\tmodified = NOW()\r\n\t\t\t\t\t\t\t");
                     if ($flash) {
                         // Workaround for a Flash bug on OS X.. We need to send back content... any content will do
                         echo " ";
                         flush();
                     }
                 } else {
                     error_log('Could not upload file because its mimetype was not recognized or rejected');
                 }
             } else {
                 error_log('Could not upload file because it got lost on the server');
             }
         }
         if ($flash == false) {
             header('Location: ' . url::action('medialibrary') . '?folder=' . $folder);
         }
         exit;
     } else {
         if (isset($_REQUEST['json'])) {
             if ($_REQUEST['json'] == 'editImage' && isset($_REQUEST['image'])) {
                 $id = intval($_REQUEST['image']);
                 $res = sql::query("\r\n\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\toriginal = '" . addslashes($_REQUEST['value']) . "'\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tfolder = '" . $folder . "' AND\r\n\t\t\t\t\t\t\t\tid = '" . addslashes($id) . "'\r\n\t\t\t\t\t\t");
                 echo $_REQUEST['value'];
                 exit;
             }
             if ($_REQUEST['json'] == 'moveImage' && isset($_REQUEST['image'])) {
                 $ids = explode(',', $_REQUEST['image']);
                 while (list(, $id) = each($ids)) {
                     $res = sql::query("\r\n\t\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t\tfolder = '" . $folder . "'\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tid = '" . addslashes($id) . "'\r\n\t\t\t\t\t\t\t");
                 }
                 exit;
             }
             if ($_REQUEST['json'] == 'deleteImage' && isset($_REQUEST['image'])) {
                 $ids = explode(',', $_REQUEST['image']);
                 while (list(, $id) = each($ids)) {
                     $res = sql::query("\r\n\t\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t\tdeleted = 1\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tfolder = '" . $folder . "' AND\r\n\t\t\t\t\t\t\t\t\tid = '" . addslashes($id) . "'\r\n\t\t\t\t\t\t\t");
                 }
                 exit;
             }
             if ($_REQUEST['json'] == 'orderFolder' && isset($_REQUEST['folders'])) {
                 $order = 0;
                 while (list(, $id) = each($_REQUEST['folders'])) {
                     $res = sql::query("\r\n\t\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t\t`order` = " . $order . "\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tID = '" . addslashes($id) . "'\r\n\t\t\t\t\t\t\t");
                     $order++;
                 }
                 exit;
             }
             if ($_REQUEST['json'] == 'editFolder' && isset($_REQUEST['value'])) {
                 $res = sql::query("\r\n\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\tname = '" . addslashes($_REQUEST['value']) . "'\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tID = '" . addslashes($folder) . "'\r\n\t\t\t\t\t\t");
                 echo $_REQUEST['value'];
                 exit;
             }
             if ($_REQUEST['json'] == 'deleteFolder') {
                 $res = sql::query("\r\n\t\t\t\t\t\t\tDELETE FROM\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tID = '" . addslashes($folder) . "'\r\n\t\t\t\t\t\t");
                 exit;
             }
             if ($_REQUEST['json'] == 'newFolder') {
                 $res = sql::query("\r\n\t\t\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t\t\tMAX(`order`) AS max\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t");
                 if ($row = sql::fetch_array($res)) {
                     $order = $row['max'] + 1;
                 } else {
                     $order = 0;
                 }
                 $res = sql::query("\r\n\t\t\t\t\t\t\tINSERT INTO\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t`name` = '" . addslashes($user->lang->s('untitled')) . "',\r\n\t\t\t\t\t\t\t\t`order` = " . $order . "\r\n\t\t\t\t\t\t");
                 echo '[{id: "' . sql::insert_id() . '", name: "' . addslashes($user->lang->s('untitled')) . '"}]';
                 exit;
//.........这里部分代码省略.........
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:101,代码来源:plugin.php


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