• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP file_get_mimetype函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中file_get_mimetype函数的典型用法代码示例。如果您正苦于以下问题:PHP file_get_mimetype函数的具体用法?PHP file_get_mimetype怎么用?PHP file_get_mimetype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: __construct

 /**
  * Constructs a FeedsEnclosure object.
  *
  * @param string $uri
  *   A path to a local file or a URL to a remote document.
  * @param string $mime_type
  *   (optional) The mime type of the resource. If not provided, the mime type
  *   will be guessed based on the file name.
  */
 public function __construct($uri, $mime_type = NULL)
 {
     $this->uri = $uri;
     if ($mime_type) {
         $this->mimeType = $mime_type;
     } else {
         $this->mimeType = file_get_mimetype($uri);
     }
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:18,代码来源:FeedsEnclosure.php


示例2: actionCreate

 public function actionCreate()
 {
     if (isset($_POST['phone']) & isset($_POST['title']) & isset($_POST['content']) & isset($_POST['place']) & isset($_POST['create_time']) & isset($_POST['uid'])) {
         //用户积分修改
         $u = user_load($_POST['uid']);
         $edit = array('field_jifen' => array('und' => array(0 => array('value' => $u->field_jifen['und'][0]['value'] + 3))));
         user_save($u, $edit);
         $node->title = $_POST['title'];
         $node->field_phone['und'][0]['value'] = $_POST['phone'];
         $node->type = "sr";
         $node->body['und'][0]['value'] = $_POST['content'];
         $node->uid = $_POST['uid'];
         $node->language = 'zh-hans';
         $node->status = 0;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 2;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         //$node->field_riq['und'][0]['value'] =date('Y:m:d H:i:s');
         $node->field_riq['und'][0]['value'] = $_POST['create_time'];
         $node->field_src['und'][0]['value'] = $_POST['place'];
         $node->field_status['und'][0]['value'] = '处理中';
         //默认为匿名
         if (isset($_POST['name'])) {
             $node->field_shimin['und'][0]['value'] = $_POST['name'];
         }
         $image = CUploadedFile::getInstanceByName('img');
         if (is_object($image) && get_class($image) === 'CUploadedFile') {
             $dir = Yii::getPathOfAlias('webroot') . '/assets/urban/';
             //$ext = $image->getExtensionName();
             $fileName = uniqid() . '.jpg';
             $name = $dir . $fileName;
             $image->saveAs($name, true);
             $file = (object) array('uid' => $_POST['uid'], 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1);
             $file = file_copy($file, 'public://pictures/urban');
             $node->field_tux['und'][0] = (array) $file;
         }
         $node = node_submit($node);
         // Prepare node for saving
         node_save($node);
         $basic = new basic();
         $basic->error_code = 0;
         //$basic->error_msg="no input parameters";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
     } else {
         $basic = new basic();
         $basic->error_code = 1;
         $basic->error_msg = "no input parameters";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
     }
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:54,代码来源:UrbanController.php


示例3: getFileFromUri

 /**
  * Convert a URI into a file object.
  *
  * @param string $uri
  *   A file URI.
  *
  * @return object
  *   A file object with the uri, filemime, and filesize properties defined.
  */
 public static function getFileFromUri($uri)
 {
     // Allow the URI to be altered.
     drupal_alter('favicon_file_uri', $uri);
     $file = new stdClass();
     $file->uri = $uri;
     $file->filemime = file_get_mimetype($uri);
     $file->filesize = @filesize($uri);
     static::validateFile($file);
     // Allow modules to alter the generated favicon file.
     drupal_alter('favicon_file', $file);
     return $file;
 }
开发者ID:kevintnguyens,项目名称:testsite,代码行数:22,代码来源:DrupalFavicon.php


示例4: carbon_html_head_alter

/**
 * Implements hook_html_head_alter().
 */
function carbon_html_head_alter(&$head_elements) {
  // If the theme's info file contains the custom theme setting
  // default_favicon_path, change the favicon <link> tag to reflect that path.
  if (($default_favicon_path = theme_get_setting('default_favicon_path')) && theme_get_setting('default_favicon')) {
    $favicon_url = file_create_url(path_to_theme() . '/' . $default_favicon_path);
  }
  else {
    if (module_exists('gardens_misc')) {
      $favicon_url = file_create_url(drupal_get_path('module', 'gardens_misc') . '/images/gardens.ico');
    }
  }
  if (!empty($favicon_url)) {
    $favicon_mimetype = file_get_mimetype($favicon_url);
    foreach ($head_elements as &$element) {
      if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'shortcut icon') {
	$element['#attributes']['href'] = $favicon_url;
	$element['#attributes']['type'] = $favicon_mimetype;
      }
    }
  }
}
开发者ID:rtdean93,项目名称:tbytam,代码行数:24,代码来源:template.php


示例5: actionCreate

 public function actionCreate()
 {
     if (isset($_POST['phone']) & isset($_POST['title']) & isset($_POST['content']) & isset($_POST['place']) & isset($_POST['create_time'])) {
         $node->title = $_POST['title'];
         $node->field_phone['und'][0]['value'] = $_POST['phone'];
         $node->type = "sr";
         $node->body['und'][0]['value'] = $_POST['content'];
         $node->uid = 1;
         $node->language = 'zh-hans';
         $node->status = 0;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 2;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         $node->field_riq['und'][0]['value'] = date('Y:m:d H:i:s');
         $node->field_src['und'][0]['value'] = $_POST['place'];
         $node->field_status['und'][0]['value'] = '处理中';
         if (isset($_POST['name'])) {
             $node->field_shimin['und'][0]['value'] = $_POST['name'];
         }
         $image = CUploadedFile::getInstanceByName('img');
         if (is_object($image) && get_class($image) === 'CUploadedFile') {
             $dir = Yii::getPathOfAlias('webroot') . '/assets/pic/';
             //$ext = $image->getExtensionName();
             $fileName = uniqid() . '.jpg';
             $name = $dir . $fileName;
             $image->saveAs($name, true);
             $file = (object) array('uid' => 1, 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1);
             $file = file_copy($file, 'public://pictures/');
             $node->field_tux['und'][0] = (array) $file;
         }
         $node = node_submit($node);
         // Prepare node for saving
         node_save($node);
         echo '1';
     } else {
         echo '0';
     }
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:40,代码来源:MsController.php


示例6: sp2015_file_link

function sp2015_file_link($variables)
{
    $file = $variables['file'];
    $icon_directory = $variables['icon_directory'];
    $url = file_create_url($file->uri);
    // Human-readable names, for use as text-alternatives to icons.
    $mime_name = array('application/msword' => t('Microsoft Office document icon'), 'application/vnd.ms-excel' => t('Office spreadsheet icon'), 'application/vnd.ms-powerpoint' => t('Office presentation icon'), 'application/pdf' => t('PDF icon'), 'video/quicktime' => t('Movie icon'), 'audio/mpeg' => t('Audio icon'), 'audio/wav' => t('Audio icon'), 'image/jpeg' => t('Image icon'), 'image/png' => t('Image icon'), 'image/gif' => t('Image icon'), 'application/zip' => t('Package icon'), 'text/html' => t('HTML icon'), 'text/plain' => t('Plain text icon'), 'application/octet-stream' => t('Binary Data'));
    $fileclass = substr($file->filename, -3);
    $mimetype = file_get_mimetype($file->uri);
    $icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory, 'alt' => !empty($mime_name[$mimetype]) ? $mime_name[$mimetype] : t('File')));
    // Set options as per anchor format described at
    // http://microformats.org/wiki/file-format-examples
    $options = array('attributes' => array('type' => $file->filemime . '; length=' . $file->filesize));
    // Use the description as the link text if available.
    if (empty($file->description)) {
        $link_text = $file->filename . ' (' . format_size($file->filesize) . ')';
    } else {
        $link_text = $file->description . format_size($file->filesize);
        $options['attributes']['title'] = check_plain($file->filename);
    }
    return '<span class="file ' . $fileclass . '">' . l($link_text, $url, $options) . '</span>';
}
开发者ID:pstampy,项目名称:margetest,代码行数:22,代码来源:template.php


示例7: createContentFromImage

/**
 * Funzione che consente di creare automaticamente un contenuto drupal con le immagini jpg caricate in temp_img
 * e i dati exif ricavati da esse.
 *
 * @param $lat
 * @param $lng
 * @param $fileName
 *
 */
function createContentFromImage($lat, $lng, $fileName)
{
    $node = new stdClass();
    // Create a new node object Or page, or whatever content type you like
    $node->type = "exif_data";
    // Set some default values
    node_object_prepare($node);
    $node->language = "en";
    $node->uid = 1;
    $coords = (object) array('lat' => $lat, 'lng' => $lng);
    $node->field_posizione['und'][0] = (array) $coords;
    //@ToDo here you have to substitute the path
    $file_path = "/var/www/.." . $fileName;
    $count_photo = count($file_path);
    for ($i = 0; $i < $count_photo; $i++) {
        if (getimagesize($file_path)) {
            $file_gallery = (object) array('uid' => 0, 'uri' => $file_path, 'filemime' => file_get_mimetype($file_path), 'status' => 1);
            //substitute "your_destination_folder" with a folder name
            try {
                file_copy($file_gallery, 'public://your_destination_folder');
                $node->field_image['und'][0] = (array) $file_gallery;
                echo "File correctly copied";
            } catch (Exception $e) {
                echo $e->getMessage();
            }
        }
    }
    //$node = node_submit($node); // Prepare node for saving
    if ($node = node_submit($node)) {
        // Prepare node for saving
        node_save($node);
        //Drupal node saving function call
        $status = "Content created correctly" . "";
    } else {
        $status = "Something went wrong during the node submitting";
    }
    echo $status;
}
开发者ID:marshall86,项目名称:Drupal-content-generator,代码行数:47,代码来源:contentGenerator.php


示例8: preCreate

 /**
  * {@inheritdoc}
  */
 public static function preCreate(EntityStorageInterface $storage, array &$values)
 {
     // Automatically detect filename if not set.
     if (!isset($values['filename']) && isset($values['uri'])) {
         $values['filename'] = drupal_basename($values['uri']);
     }
     // Automatically detect filemime if not set.
     if (!isset($values['filemime']) && isset($values['uri'])) {
         $values['filemime'] = file_get_mimetype($values['uri']);
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:14,代码来源:File.php


示例9: mail


//.........这里部分代码省略.........
                         }
                     }
                 } elseif (strpos($body_part, 'text/plain')) {
                     // Clean up the text.
                     $body_part = trim($this->_remove_headers(trim($body_part)));
                     if ($text_html) {
                         $mailer->AltBody = $body_part;
                         $mailer->IsHTML(TRUE);
                         $mailer->ContentType = 'multipart/mixed';
                     } else {
                         $mailer->Body = $body_part;
                         $mailer->IsHTML(FALSE);
                         $mailer->ContentType = 'multipart/mixed';
                     }
                 } elseif (strpos($body_part, 'text/html')) {
                     // Clean up the text.
                     $body_part = trim($this->_remove_headers(trim($body_part)));
                     // Include it as part of the mail object.
                     $mailer->Body = $body_part;
                     $mailer->IsHTML(TRUE);
                     $mailer->ContentType = 'multipart/mixed';
                 } elseif (strpos($body_part, 'Content-Disposition: attachment;') && !isset($message['params']['attachments'])) {
                     $file_path = $this->_get_substring($body_part, 'filename=', '"', '"');
                     $file_name = $this->_get_substring($body_part, ' name=', '"', '"');
                     $file_encoding = $this->_get_substring($body_part, 'Content-Transfer-Encoding', ' ', "\n");
                     $file_type = $this->_get_substring($body_part, 'Content-Type', ' ', ';');
                     if (file_exists($file_path)) {
                         if (!$mailer->AddAttachment($file_path, $file_name, $file_encoding, $file_type)) {
                             drupal_set_message(t('Attahment could not be found or accessed.'));
                         }
                     } else {
                         // Clean up the text.
                         $body_part = trim($this->_remove_headers(trim($body_part)));
                         if (Unicode::strtolower($file_encoding) == 'base64') {
                             $attachment = base64_decode($body_part);
                         } elseif (Unicode::strtolower($file_encoding) == 'quoted-printable') {
                             $attachment = quoted_printable_decode($body_part);
                         } else {
                             $attachment = $body_part;
                         }
                         $attachment_new_filename = \Drupal::service('file_system')->tempnam('temporary://', 'smtp');
                         $file_path = file_save_data($attachment, $attachment_new_filename, FILE_EXISTS_REPLACE);
                         $real_path = \Drupal::service('file_system')->realpath($file_path->uri);
                         if (!$mailer->AddAttachment($real_path, $file_name)) {
                             drupal_set_message(t('Attachment could not be found or accessed.'));
                         }
                     }
                 }
             }
             break;
         default:
             $mailer->Body = $body;
             break;
     }
     // Process mimemail attachments, which are prepared in mimemail_mail().
     if (isset($message['params']['attachments'])) {
         foreach ($message['params']['attachments'] as $attachment) {
             if (isset($attachment['filecontent'])) {
                 $mailer->AddStringAttachment($attachment['filecontent'], $attachment['filename'], 'base64', $attachment['filemime']);
             }
             if (isset($attachment['filepath'])) {
                 $filename = isset($attachment['filename']) ? $attachment['filename'] : basename($attachment['filepath']);
                 $filemime = isset($attachment['filemime']) ? $attachment['filemime'] : file_get_mimetype($attachment['filepath']);
                 $mailer->AddAttachment($attachment['filepath'], $filename, 'base64', $filemime);
             }
         }
     }
     // Set the authentication settings.
     $username = $this->smtpConfig->get('smtp_username');
     $password = $this->smtpConfig->get('smtp_password');
     // If username and password are given, use SMTP authentication.
     if ($username != '' && $password != '') {
         $mailer->SMTPAuth = TRUE;
         $mailer->Username = $username;
         $mailer->Password = $password;
     }
     // Set the protocol prefix for the smtp host.
     switch ($this->smtpConfig->get('smtp_protocol')) {
         case 'ssl':
             $mailer->SMTPSecure = 'ssl';
             break;
         case 'tls':
             $mailer->SMTPSecure = 'tls';
             break;
         default:
             $mailer->SMTPSecure = '';
     }
     // Set other connection settings.
     $mailer->Host = $this->smtpConfig->get('smtp_host') . ';' . $this->smtpConfig->get('smtp_hostbackup');
     $mailer->Port = $this->smtpConfig->get('smtp_port');
     $mailer->Mailer = 'smtp';
     $mailerArr = array('mailer' => $mailer, 'to' => $to, 'from' => $from);
     if ($this->smtpConfig->get('smtp_queue')) {
         watchdog('smtp', 'Queue sending mail to: @to', array('@to' => $to));
         smtp_send_queue($mailerArr);
     } else {
         return _smtp_mailer_send($mailerArr);
     }
     return TRUE;
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:101,代码来源:SMTPMailSystem.php


示例10: array

//dd($items);
?>
    <?php 
static $videojs_sources;
?>
    <?php 
$codecs = array('video/mp4' => 'avc1.42E01E, mp4a.40.2', 'video/webm' => 'vp8, vorbis', 'video/ogg' => 'theora, vorbis', 'video/ogv' => 'theora, vorbis', 'video/quicktime' => 'avc1.42E01E, mp4a.40.2');
?>
    <?php 
foreach ($video->files as $filetype => $file) {
    ?>
    <?php 
    $filepath = $file->url;
    ?>
    <?php 
    $mimetype = file_get_mimetype($file->filename);
    ?>
    <?php 
    if (array_key_exists($mimetype, $codecs)) {
        ?>
    <?php 
        $mimetype = $mimetype == 'video/quicktime' ? 'video/mp4' : $mimetype;
        ?>
    <?php 
        if ($mimetype == 'video/mp4' || $mimetype == 'video/flv') {
            $flash = $filepath;
        }
        ?>
    <?php 
        $videojs_sources .= "<source src=\"{$filepath}\" type='{$mimetype}; codecs=\"" . $codecs[$mimetype] . "\"' />";
        ?>
开发者ID:rczamor,项目名称:Activ8,代码行数:31,代码来源:video-play-html5.tpl.php


示例11: fileSaveUpload

  /**
   * An adaptation of file_save_upload() that includes more verbose errors.
   *
   * @param string $source
   *   A string specifying the filepath or URI of the uploaded file to save.
   *
   * @return stdClass
   *   The saved file object.
   *
   * @throws \RestfulBadRequestException
   * @throws \RestfulServiceUnavailable
   *
   * @see file_save_upload()
   */
  protected function fileSaveUpload($source) {
    static $upload_cache;

    $account = $this->getAccount();
    $options = $this->getPluginKey('options');

    $validators = $options['validators'];
    $destination = $options['scheme'] . "://";
    $replace = $options['replace'];

    // Return cached objects without processing since the file will have
    // already been processed and the paths in _FILES will be invalid.
    if (isset($upload_cache[$source])) {
      return $upload_cache[$source];
    }

    // Make sure there's an upload to process.
    if (empty($_FILES['files']['name'][$source])) {
      return NULL;
    }

    // Check for file upload errors and return FALSE if a lower level system
    // error occurred. For a complete list of errors:
    // See http://php.net/manual/features.file-upload.errors.php.
    switch ($_FILES['files']['error'][$source]) {
      case UPLOAD_ERR_INI_SIZE:
      case UPLOAD_ERR_FORM_SIZE:
        $message = format_string('The file %file could not be saved, because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $_FILES['files']['name'][$source], '%maxsize' => format_size(file_upload_max_size())));
        throw new \RestfulBadRequestException($message);

      case UPLOAD_ERR_PARTIAL:
      case UPLOAD_ERR_NO_FILE:
        $message = format_string('The file %file could not be saved, because the upload did not complete.', array('%file' => $_FILES['files']['name'][$source]));
        throw new \RestfulBadRequestException($message);

      case UPLOAD_ERR_OK:
        // Final check that this is a valid upload, if it isn't, use the
        // default error handler.
        if (is_uploaded_file($_FILES['files']['tmp_name'][$source])) {
          break;
        }

      // Unknown error
      default:
        $message = format_string('The file %file could not be saved. An unknown error has occurred.', array('%file' => $_FILES['files']['name'][$source]));
        throw new \RestfulServiceUnavailable($message);
    }

    // Begin building file object.
    $file = new stdClass();
    $file->uid      = $account->uid;
    $file->status   = 0;
    $file->filename = trim(drupal_basename($_FILES['files']['name'][$source]), '.');
    $file->uri      = $_FILES['files']['tmp_name'][$source];
    $file->filemime = file_get_mimetype($file->filename);
    $file->filesize = $_FILES['files']['size'][$source];

    $extensions = '';
    if (isset($validators['file_validate_extensions'])) {
      if (isset($validators['file_validate_extensions'][0])) {
        // Build the list of non-munged extensions if the caller provided them.
        $extensions = $validators['file_validate_extensions'][0];
      }
      else {
        // If 'file_validate_extensions' is set and the list is empty then the
        // caller wants to allow any extension. In this case we have to remove the
        // validator or else it will reject all extensions.
        unset($validators['file_validate_extensions']);
      }
    }
    else {
      // No validator was provided, so add one using the default list.
      // Build a default non-munged safe list for file_munge_filename().
      $extensions = 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp';
      $validators['file_validate_extensions'] = array();
      $validators['file_validate_extensions'][0] = $extensions;
    }

    if (!empty($extensions)) {
      // Munge the filename to protect against possible malicious extension hiding
      // within an unknown file type (ie: filename.html.foo).
      $file->filename = file_munge_filename($file->filename, $extensions);
    }

    // Rename potentially executable files, to help prevent exploits (i.e. will
    // rename filename.php.foo and filename.php to filename.php.foo.txt and
//.........这里部分代码省略.........
开发者ID:humanitarianresponse,项目名称:site,代码行数:101,代码来源:RestfulFilesUpload.php


示例12: array

 * Theme file to handle HTML5 output.
 *
 * Variables passed.
 * $video is the video object.
 * $node is the node object.
 *
 * @TODO : Fallback to flash should be done nicely
 *
 */
?>
<!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
<video width="<?php echo $video->player_width; ?>" autobuffer="<?php print $video->autobuffering; ?>" height="<?php echo $video->player_height; ?>" controls="controls" preload="auto" poster="<?php echo $video->thumbnail->url; ?>">
  <?php //dd($items); ?>
  <?php static $videojs_sources; ?>
  <?php $codecs = array('video/mp4' => 'avc1.42E01E, mp4a.40.2', 'video/webm' => 'vp8, vorbis', 'video/ogg' => 'theora, vorbis', 'application/ogg' => 'theora, vorbis', 'video/ogv' => 'theora, vorbis', 'video/quicktime' => 'avc1.42E01E, mp4a.40.2'); ?>
  <?php foreach ($video->files as $filetype => $file): ?>
  <?php $filepath = $file->url; ?>
  <?php $mimetype = file_get_mimetype($file->filepath); ?>
  <?php if (array_key_exists($mimetype, $codecs)): ?>
  <?php $mimetype = ($mimetype == 'video/quicktime') ? 'video/mp4' : $mimetype; ?>
  <?php if ($mimetype == 'video/mp4' || $mimetype == 'video/flv')
        $flash = $filepath; ?>
  <?php $videojs_sources .= "<source src=\"$filepath\" type='$mimetype; codecs=\"" . $codecs[$mimetype] . "\"' />"; ?>
  <?php endif; ?>
  <?php endforeach; ?>
  <?php print $videojs_sources; ?>
      <!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
  <?php $video->player = 'flv'; ?>
  <?php $video->files->flv->url = $flash; ?>
  <?php echo theme('video_flv', array('video' => $video)); ?>
</video>
开发者ID:rtdean93,项目名称:therock,代码行数:31,代码来源:video-play-html5.tpl.php


示例13: package_release_update_node

/**
 * Update the DB with the new file info for a given release node.
 *
 * @param $nid
 *   The node ID of the release node to update.
 * @param $files
 *   Array of files to add to the release node.
 * @param $package_contents
 *   Optional. Array of nids of releases contained in a release package.
 */
function package_release_update_node($nid, $files, $package_contents = array())
{
    global $drupal_root, $dest_root, $task;
    // PHP will cache the results of stat() and give us stale answers
    // here, unless we manually tell it otherwise!
    clearstatcache();
    // Make sure we're back at the webroot so node_load() and node_save()
    // can always find any files they (and the hooks they invoke) need.
    if (!drupal_chdir($drupal_root)) {
        return FALSE;
    }
    // If the site is using DB replication, force this node_load() to use the
    // primary database to avoid node_load() failures.
    if (function_exists('db_set_ignore_slave')) {
        db_set_ignore_slave();
    }
    // We don't want to waste too much RAM by leaving all these loaded nodes
    // in RAM, so we reset the node_load() cache each time we call it.
    $node = node_load($nid, NULL, TRUE);
    if (empty($node->nid)) {
        wd_err('node_load(@nid) failed', array('@nid' => $nid));
        return FALSE;
    }
    foreach ($files as $file_path) {
        // Compute the metadata for this file that we care about.
        $full_path = $dest_root . '/' . $file_path;
        $file_name = basename($file_path);
        $file_date = filemtime($full_path);
        $file_size = filesize($full_path);
        $file_hash = md5_file($full_path);
        $file_mime = file_get_mimetype($full_path);
        // First, see if we already have this file for this release node
        $file_data = db_fetch_object(db_query("SELECT prf.* FROM {project_release_file} prf INNER JOIN {files} f ON prf.fid = f.fid WHERE prf.nid = %d AND f.filename = '%s'", $node->nid, $file_name));
        // Insert or update the record in the DB as need.
        if (empty($file_data)) {
            // Don't have this file, insert a new record.
            db_query("INSERT INTO {files} (uid, filename, filepath, filemime, filesize, status, timestamp) VALUES (%d, '%s', '%s', '%s', %d, %d, %d)", $node->uid, $file_name, $file_path, $file_mime, $file_size, FILE_STATUS_PERMANENT, $file_date);
            $fid = db_last_insert_id('files', 'fid');
            db_query("INSERT INTO {project_release_file} (fid, nid, filehash) VALUES (%d, %d, '%s')", $fid, $node->nid, $file_hash);
        } else {
            // Already have this file for this release, update it.
            db_query("UPDATE {files} SET uid = %d, filename = '%s', filepath = '%s', filemime = '%s', filesize = %d, status = %d, timestamp = %d WHERE fid = %d", $node->uid, $file_name, $file_path, $file_mime, $file_size, FILE_STATUS_PERMANENT, $file_date, $file_data->fid);
            db_query("UPDATE {project_release_file} SET filehash = '%s' WHERE fid = %d", $file_hash, $file_data->fid);
        }
    }
    // Store package contents if necessary.
    if (!empty($package_contents) && module_exists('project_package')) {
        foreach ($package_contents as $item_nid) {
            db_query("INSERT INTO {project_package_local_release_item} (package_nid, item_nid) VALUES (%d, %d)", $nid, $item_nid);
        }
    }
    // Don't auto-publish security updates.
    $security_update_tid = variable_get('project_release_security_update_tid', 0);
    if ($task == 'tag' && !empty($node->taxonomy[$security_update_tid])) {
        watchdog('package_security', 'Not auto-publishing security update release.', array(), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
        return;
    }
    // Finally publish the node if it is currently unpublished. Instead of
    // directly updating {node}.status, we use node_save() so that other modules
    // which implement hook_nodeapi() will know that this node is now published.
    if (empty($node->status)) {
        $node->status = 1;
        node_save($node);
    }
}
开发者ID:Br3nda,项目名称:drupal-module-project,代码行数:75,代码来源:package-release-nodes.php


示例14: actionPic

 public function actionPic()
 {
     if (!isset($_POST['uid'])) {
         $basic = new basic();
         $basic->error_code = 1;
         $basic->error_msg = "请登录";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
         die(0);
     }
     $image = CUploadedFile::getInstanceByName('img');
     if (is_object($image) && get_class($image) === 'CUploadedFile') {
         $dir = Yii::getPathOfAlias('webroot') . '/assets/upic/';
         $fileName = uniqid() . '.jpg';
         $name = $dir . $fileName;
         $image->saveAs($name, true);
         $account = user_load($_POST['uid']);
         $file = (object) array('uid' => $_POST['uid'], 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1);
         $file = file_copy($file, 'public://pictures/upic');
         $edit['picture'] = $file;
         user_save($account, $edit);
         $pic->error_code = 0;
         $pic->userheadimg = str_replace("public://", BigImg, $account->picture->uri);
         $pic->error_code = 0;
     } else {
         $pic->error_code = 2;
         $pic->error_msg = "上传头像失败";
     }
     $jsonObj = CJSON::encode($pic);
     echo $jsonObj;
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:31,代码来源:SiteController.php


示例15: sprintf

$tplVars['feedlink'] = $GLOBALS['root'];
$tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
$bookmarks =& $bookmarkservice->getBookmarks(0, 15, $userid, $cat, NULL, getSortOrder(), $watchlist);
$bookmarks_tmp =& filter($bookmarks['bookmarks']);
$bookmarks_tpl = array();
foreach (array_keys($bookmarks_tmp) as $key) {
    $row =& $bookmarks_tmp[$key];
    $_link = $row['bAddress'];
    // Redirection option
    if ($GLOBALS['useredir']) {
        $_link = $GLOBALS['url_redir'] . $_link;
    }
    $_pubdate = date("r", strtotime($row['bDatetime']));
    $uriparts = explode('.', $_link);
    $extension = end($uriparts);
    unset($uriparts);
    $enclosure = array();
    if ($keys = multi_array_search($extension, $GLOBALS['filetypes'])) {
        $enclosure['mime'] = file_get_mimetype($_link);
        $enclosure['length'] = file_get_filesize($_link);
    }
    $bookmarks_tpl[] = array('title' => $row['bTitle'], 'link' => $_link, 'description' => $row['bDescription'], 'creator' => $row['username'], 'pubdate' => $_pubdate, 'tags' => $row['tags'], 'enclosure_mime' => $enclosure['mime'], 'enclosure_length' => $enclosure['length']);
}
unset($bookmarks_tmp);
unset($bookmarks);
$tplVars['bookmarks'] =& $bookmarks_tpl;
$templateservice->loadTemplate('rss.tpl', $tplVars);
if ($usecache) {
    // Cache output if existing copy has expired
    $cacheservice->End($hash);
}
开发者ID:kidwellj,项目名称:scuttle,代码行数:31,代码来源:rss.php


示例16: getAttachmentStruct

 static function getAttachmentStruct($path)
 {
     $struct = array();
     try {
         if (!@is_file($path)) {
             throw new Exception($path . ' is not a valid file.');
         }
         $filename = basename($path);
         if (!function_exists('get_magic_quotes')) {
             function get_magic_quotes()
             {
                 return FALSE;
             }
         }
         if (!function_exists('set_magic_quotes')) {
             function set_magic_quotes($value)
             {
                 return TRUE;
             }
         }
         if (strnatcmp(phpversion(), '6') >= 0) {
             $magic_quotes = get_magic_quotes_runtime();
             set_magic_quotes_runtime(0);
         }
         $file_buffer = file_get_contents($path);
         $file_buffer = chunk_split(base64_encode($file_buffer), 76, "\n");
         if (strnatcmp(phpversion(), '6') >= 0) {
             set_magic_quotes_runtime($magic_quotes);
         }
         $mime_type = file_get_mimetype($path);
         if (!Mandrill::isValidContentType($mime_type)) {
             throw new Exception($mime_type . ' is not a valid content type (it should be ' . implode('*,', self::getValidContentTypes()) . ').');
         }
         $struct['type'] = $mime_type;
         $struct['name'] = $filename;
         $struct['content'] = $file_buffer;
     } catch (Exception $e) {
         throw new Mandrill_Exception('Error creating the attachment structure: ' . $e->getMessage());
     }
     return $struct;
 }
开发者ID:nyccwebmaster,项目名称:nycc_email,代码行数:41,代码来源:mandrill.class.php


示例17: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     parent::submitForm($form, $form_state);
     $config = $this->config($form_state['values']['config_key']);
     // Exclude unnecessary elements before saving.
     form_state_values_clean($form_state);
     unset($form_state['values']['var']);
     unset($form_state['values']['config_key']);
     $values = $form_state['values'];
     // If the user uploaded a new logo or favicon, save it to a permanent location
     // and use it in place of the default theme-provided file.
     if ($this->moduleHandler->moduleExists('file')) {
         if ($file = $values['logo_upload']) {
             unset($values['logo_upload']);
             $filename = file_unmanaged_copy($file->getFileUri());
             $values['default_logo'] = 0;
             $values['logo_path'] = $filename;
             $values['toggle_logo'] = 1;
         }
         if ($file = $values['favicon_upload']) {
             unset($values['favicon_upload']);
             $filename = file_unmanaged_copy($file->getFileUri());
             $values['default_favicon'] = 0;
             $values['favicon_path'] = $filename;
             $values['toggle_favicon'] = 1;
         }
         // If the user entered a path relative to the system files directory for
         // a logo or favicon, store a public:// URI so the theme system can handle it.
         if (!empty($values['logo_path'])) {
             $values['logo_path'] = $this->validatePath($values['logo_path']);
         }
         if (!empty($values['favicon_path'])) {
             $values['favicon_path'] = $this->validatePath($values['favicon_path']);
         }
         if (empty($values['default_favicon']) && !empty($values['favicon_path'])) {
             $values['favicon_mimetype'] = file_get_mimetype($values['favicon_path']);
         }
     }
     theme_settings_convert_to_config($values, $config)->save();
     // Invalidate either the theme-specific cache tag or the global theme
     // settings cache tag, depending on whose settings were actually changed.
     if (isset($values['theme'])) {
         Cache::invalidateTags(array('theme' => $values['theme']));
     } else {
         Cache::invalidateTags(array('theme_global_settings' => TRUE));
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:50,代码来源:ThemeSettingsForm.php


示例18: transferDownload

 /**
  * Sends the file's binary data to a user via HTTP and updates the database.
  *
  * @param $file_user
  *   The file_user object from the uc_file_users.
  * @param $ip
  *   The string containing the IP address the download is going to.
  */
 protected function transferDownload($file_user, $ip)
 {
     // Create the response.
     $response = new BinaryFileResponse();
     // Check if any hook_uc_file_transfer_alter() calls alter the download.
     $module_handler = $this->moduleHandler();
     foreach ($module_handler->getImplementations('uc_file_transfer_alter') as $module) {
         $name = $module . '_uc_file_transfer_alter';
         $file_user->full_path = $name($file_user, $ip, $file_user->fid, $file_user->full_path);
     }
     // This could get clobbered, so make a copy.
     $filename = $file_user->filename;
     // Gather relevant info about the file.
     $size = filesize($file_user->full_path);
     $mimetype = file_get_mimetype($filename);
     // Workaround for IE filename bug with multiple periods / multiple dots
     // in filename that adds square brackets to filename -
     // eg. setup.abc.exe becomes setup[1].abc.exe
     if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
         $filename = preg_replace('/\\./', '%2e', $filename, substr_count($filename, '.') - 1);
     }
     // Check if HTTP_RANGE is sent by browser (or download manager).
     $range = NULL;
     if (isset($_SERVER['HTTP_RANGE'])) {
         if (substr($_SERVER['HTTP_RANGE'], 0, 6) == 'bytes=') {
             // Multiple ranges could be specified at the same time,
             // but for simplicity only serve the first range
             // See http://tools.ietf.org/id/draft-ietf-http-range-retrieval-00.txt
             list($range, $extra_ranges) = explode(',', substr($_SERVER['HTTP_RANGE'], 6), 2);
         } else {
             $response->headers->set('Status', '416 Requested Range Not Satisfiable');
             $response->headers->set('Content-Range', 'bytes */' . $size);
             return $response;
         }
     }
     // Figure out download piece from range (if set).
     if (isset($range)) {
         list($seek_start, $seek_end) = explode('-', $range, 2);
     }
     // Set start and end based on range (if set),
     // else set defaults and check for invalid ranges.
     $seek_end = intval(empty($seek_end) ? $size - 1 : min(abs(intval($seek_end)), $size - 1));
     $seek_start = intval(empty($seek_start) || $seek_end < abs(intval($seek_start)) ? 0 : max(abs(intval($seek_start)), 0));
     // Only send partial content header if downloading a piece of the file (IE
     // workaround).
     if ($seek_start > 0 || $seek_end < $size - 1) {
         $response->headers->set('Status', '206 Partial Content');
     }
     // Standard headers, including content-range and length
     $response->headers->set('Pragma', 'public');
     $response->headers->set('Cache-Control', 'cache, must-revalidate');
     $response->headers->set('Accept-Ranges', 'bytes');
     $response->headers->set('Content-Range', 'bytes ' . $seek_start . '-' . $seek_end . '/' . $size);
     $response->headers->set('Content-Type', $mimetype);
     $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
     $response->headers->set('Content-Length', $seek_end - $seek_start + 1);
     // Last-Modified is required for content served dynamically.
     $response->headers->set('Last-Modified', gmdate("D, d M Y H:i:s", filemtime($file_user->full_path)) . " GMT");
     // Etag header is required for Firefox3 and other managers.
     $response->headers->set('ETag', md5($file_user->full_path));
     // Open the file and seek to starting byte.
     $fp = fopen($file_user->full_path, 'rb');
     fseek($fp, $seek_start);
     // Start buffered download.
     while (!feof($fp)) {
         // Reset time limit for large files.
         drupal_set_time_limit(0);
         // Push the data to the client.
         print fread($fp, UC_FILE_BYTE_SIZE);
         flush();
         // Suppress PHP notice that occurs when output buffering isn't enabled.
         // The ob_flush() is needed because if output buffering *is* enabled,
         // clicking on the file download link won't download anything if the buffer
         // isn't flushed.
         @ob_flush();
     }
     // Finished serving the file, close the stream and log the download
     // to the user table.
     fclose($fp);
     $this->logDownload($file_user, $ip);
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:89,代码来源:DownloadController.php


示例19: package_release_update_node


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP file_get_submitted_draft_itemid函数代码示例发布时间:2022-05-15
下一篇:
PHP file_get_html函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap