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


PHP file_get_mimetype函数代码示例

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


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


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