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


PHP nggGallery::fileinfo方法代码示例

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


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

示例1: swfupload_image

 /**
  * Upload function will be called via the Flash uploader
  *
  * @class nggAdmin
  * @param integer $galleryID
  * @return string $result
  */
 static function swfupload_image($galleryID = 0)
 {
     global $nggdb;
     if ($galleryID == 0) {
         return __('No gallery selected !', 'nggallery');
     }
     // WPMU action
     if (nggWPMU::check_quota()) {
         return '0';
     }
     // Check the upload
     if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0) {
         return __('Invalid upload. Error Code : ', 'nggallery') . $_FILES['Filedata']['error'];
     }
     // get the filename and extension
     $temp_file = $_FILES['Filedata']['tmp_name'];
     $filepart = nggGallery::fileinfo($_FILES['Filedata']['name']);
     $filename = $filepart['basename'];
     // check for allowed extension
     $ext = apply_filters('ngg_allowed_file_types', array('jpeg', 'jpg', 'png', 'gif'));
     if (!in_array(strtolower($filepart['extension']), $ext)) {
         return esc_html($_FILES[$key]['name']) . __('is no valid image file!', 'nggallery');
     }
     // get the path to the gallery
     $gallery = $nggdb->find_gallery((int) $galleryID);
     if (empty($gallery->path)) {
         @unlink($temp_file);
         return __('Failure in database, no gallery path set !', 'nggallery');
     }
     // read list of images
     $imageslist = nggAdmin::scandir(WINABSPATH . $gallery->path);
     // check if this filename already exist
     $i = 0;
     while (in_array($filename, $imageslist)) {
         $filename = $filepart['filename'] . '_' . $i++ . '.' . $filepart['extension'];
     }
     $dest_file = WINABSPATH . $gallery->path . '/' . $filename;
     // save temp file to gallery
     if (!@move_uploaded_file($_FILES["Filedata"]['tmp_name'], $dest_file)) {
         nggAdmin::check_safemode(WINABSPATH . $gallery->path);
         return __('Error, the file could not be moved to : ', 'nggallery') . esc_html($dest_file);
     }
     if (!nggAdmin::chmod($dest_file)) {
         return __('Error, the file permissions could not be set', 'nggallery');
     }
     return '0';
 }
开发者ID:jeanpage,项目名称:ca_learn,代码行数:54,代码来源:functions.php

示例2: swfupload_image

 /**
  * Upload function will be called via the Flash uploader
  * 
  * @class nggAdmin
  * @param integer $galleryID
  * @return string $result
  */
 function swfupload_image($galleryID = 0)
 {
     global $wpdb;
     if ($galleryID == 0) {
         return __('No gallery selected !', 'nggallery');
     }
     // WPMU action
     if (nggWPMU::check_quota()) {
         return '0';
     }
     // Check the upload
     if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0) {
         return __('Invalid upload. Error Code : ', 'nggallery') . $_FILES['Filedata']['error'];
     }
     // get the filename and extension
     $temp_file = $_FILES['Filedata']['tmp_name'];
     $filepart = nggGallery::fileinfo($_FILES['Filedata']['name']);
     $filename = $filepart['basename'];
     // check for allowed extension
     $ext = array('jpg', 'png', 'gif');
     if (!in_array($filepart['extension'], $ext)) {
         return $_FILES[$key]['name'] . __('is no valid image file!', 'nggallery');
     }
     // get the path to the gallery
     $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' ");
     if (!$gallerypath) {
         @unlink($temp_file);
         return __('Failure in database, no gallery path set !', 'nggallery');
     }
     // read list of images
     $imageslist = nggAdmin::scandir(WINABSPATH . $gallerypath);
     // check if this filename already exist
     $i = 0;
     while (in_array($filename, $imageslist)) {
         $filename = $filepart['filename'] . '_' . $i++ . '.' . $filepart['extension'];
     }
     $dest_file = WINABSPATH . $gallerypath . '/' . $filename;
     // save temp file to gallery
     if (!@move_uploaded_file($_FILES["Filedata"]['tmp_name'], $dest_file)) {
         nggAdmin::check_safemode(WINABSPATH . $gallerypath);
         return __('Error, the file could not be moved to : ', 'nggallery') . $dest_file;
     }
     if (!nggAdmin::chmod($dest_file)) {
         return __('Error, the file permissions could not be set', 'nggallery');
     }
     return '0';
 }
开发者ID:ahsaeldin,项目名称:projects,代码行数:54,代码来源:functions.php

示例3: uploadImage

 /**
  * Method "ngg.uploadImage"
  * Uploads a image to a gallery
  *
  * @since 1.4
  * 
  * @copyright addapted from WP Core
  * @param array $args Method parameters.
  * 			- int blog_id
  *	    	- string username
  *	    	- string password
  *	    	- struct data
  *	          o string name
  *            o string type (optional)
  *	          o base64 bits 
  *	          o bool overwrite (optional)
  *			  o int gallery 
  *			  o int image_id  (optional) 	 
  * @return array with image meta data
  */
 function uploadImage($args)
 {
     global $wpdb;
     require_once dirname(dirname(__FILE__)) . '/admin/functions.php';
     // admin functions
     require_once 'meta.php';
     // meta data import
     $blog_ID = (int) $args[0];
     $username = $wpdb->escape($args[1]);
     $password = $wpdb->escape($args[2]);
     $data = $args[3];
     $name = $data['name'];
     $type = $data['type'];
     $bits = $data['bits'];
     // gallery & image id
     $gid = (int) $data['gallery'];
     // required field
     $pid = (int) $data['image_id'];
     // optional but more foolproof of overwrite
     $image = false;
     // container for the image object
     logIO('O', '(NGG) Received ' . strlen($bits) . ' bytes');
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     // Check if you have the correct capability for upload
     if (!current_user_can('NextGEN Upload images')) {
         logIO('O', '(NGG) User does not have upload_files capability');
         $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.'));
         return $this->error;
     }
     // Look for the gallery , could we find it ?
     if (!($gallery = nggdb::find_gallery($gid))) {
         return new IXR_Error(404, __('Could not find gallery ' . $gid));
     }
     // Now check if you have the correct capability for this gallery
     if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
         logIO('O', '(NGG) User does not have upload_files capability');
         $this->error = new IXR_Error(401, __('You are not allowed to upload files to this gallery.'));
         return $this->error;
     }
     //clean filename and extract extension
     $filepart = nggGallery::fileinfo($name);
     $name = $filepart['basename'];
     // check for allowed extension and if it's an image file
     $ext = array('jpg', 'png', 'gif');
     if (!in_array($filepart['extension'], $ext)) {
         logIO('O', '(NGG) Not allowed file type');
         $this->error = new IXR_Error(401, __('This is no valid image file.', 'nggallery'));
         return $this->error;
     }
     // in the case you would overwrite the image, let's delete the old one first
     if (!empty($data["overwrite"]) && $data["overwrite"] == true) {
         // search for the image based on the filename, if it's not already provided
         if ($pid == 0) {
             $pid = $wpdb->get_col(" SELECT pid FROM {$wpdb->nggpictures} WHERE filename = '{$name}' AND galleryid = '{$gid}' ");
         }
         if (!($image = nggdb::find_image($pid))) {
             return new IXR_Error(404, __('Could not find image id ' . $pid));
         }
         // sync the gallery<->image parameter, otherwise we may copy it to the wrong gallery
         $gallery = $image;
         // delete now the image
         if (!@unlink($image->imagePath)) {
             $errorString = sprintf(__('Failed to delete image %1$s ', 'nggallery'), $image->imagePath);
             logIO('O', '(NGG) ' . $errorString);
             return new IXR_Error(500, $errorString);
         }
     }
     // upload routine from wp core, load first the image to the upload folder, $upload['file'] contain the path
     $upload = wp_upload_bits($name, $type, $bits);
     if (!empty($upload['error'])) {
         $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']);
         logIO('O', '(NGG) ' . $errorString);
         return new IXR_Error(500, $errorString);
     }
     // this is the dir to the gallery
     $path = WINABSPATH . $gallery->path;
     // check if the filename already exist, if not add a counter index
     $filename = wp_unique_filename($path, $name);
//.........这里部分代码省略.........
开发者ID:rtgibbons,项目名称:bya.org,代码行数:101,代码来源:xmlrpc.php


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