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


PHP sha1_file函数代码示例

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


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

示例1: upload

 /**
  * Handles uploaded files.
  */
 public function upload()
 {
     // save files
     $files = $this->parameters['__files']->getFiles();
     $file = $files[0];
     try {
         if (!$file->getValidationErrorType()) {
             $data = array('userID' => WCF::getUser()->userID ?: null, 'filename' => $file->getFilename(), 'fileType' => $file->getMimeType(), 'fileHash' => sha1_file($file->getLocation()), 'filesize' => $file->getFilesize(), 'uploadTime' => TIME_NOW);
             // save file
             $upload = FileUploadEditor::create($data);
             // move uploaded file
             if (@copy($file->getLocation(), $upload->getLocation())) {
                 @unlink($file->getLocation());
                 // return result
                 return array('uploadID' => $upload->uploadID, 'filename' => $upload->filename, 'filesize' => $upload->filesize, 'formattedFilesize' => FileUtil::formatFilesize($upload->filesize));
             } else {
                 // moving failed; delete file
                 $editor = new FileUploadEditor($upload);
                 $editor->delete();
                 throw new UserInputException('fileUpload', 'uploadFailed');
             }
         }
     } catch (UserInputException $e) {
         $file->setValidationErrorType($e->getType());
     }
     return array('errorType' => $file->getValidationErrorType());
 }
开发者ID:Griborim,项目名称:de.incendium.cms.filebase,代码行数:30,代码来源:FileUploadAction.class.php

示例2: get_plugins_supporting_mobile

 /**
  * Returns a list of Moodle plugins supporting the mobile app.
  *
  * @return array an array of objects containing the plugin information
  */
 public static function get_plugins_supporting_mobile()
 {
     global $CFG;
     require_once $CFG->libdir . '/adminlib.php';
     $pluginsinfo = [];
     $plugintypes = core_component::get_plugin_types();
     foreach ($plugintypes as $plugintype => $unused) {
         // We need to include files here.
         $pluginswithfile = core_component::get_plugin_list_with_file($plugintype, 'db' . DIRECTORY_SEPARATOR . 'mobile.php');
         foreach ($pluginswithfile as $plugin => $notused) {
             $path = core_component::get_plugin_directory($plugintype, $plugin);
             $component = $plugintype . '_' . $plugin;
             $version = get_component_version($component);
             require_once "{$path}/db/mobile.php";
             foreach ($addons as $addonname => $addoninfo) {
                 $plugininfo = array('component' => $component, 'version' => $version, 'addon' => $addonname, 'dependencies' => !empty($addoninfo['dependencies']) ? $addoninfo['dependencies'] : array(), 'fileurl' => '', 'filehash' => '', 'filesize' => 0);
                 // All the mobile packages must be under the plugin mobile directory.
                 $package = $path . DIRECTORY_SEPARATOR . 'mobile' . DIRECTORY_SEPARATOR . $addonname . '.zip';
                 if (file_exists($package)) {
                     $plugininfo['fileurl'] = $CFG->wwwroot . '' . str_replace($CFG->dirroot, '', $package);
                     $plugininfo['filehash'] = sha1_file($package);
                     $plugininfo['filesize'] = filesize($package);
                 }
                 $pluginsinfo[] = $plugininfo;
             }
         }
     }
     return $pluginsinfo;
 }
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:34,代码来源:api.php

示例3: checksum

 /**
  * Returns the SHA1 checksum of the given file
  *
  * @param string $file Path to file
  *
  * @return string Checksum or empty string if file doesn't exist
  */
 public function checksum($file)
 {
     if (file_exists($file)) {
         return sha1_file($file);
     }
     return '';
 }
开发者ID:aedart,项目名称:license-file-manager,代码行数:14,代码来源:Handler.php

示例4: getDirsChecksums

 public static function getDirsChecksums($_dir, $_opts = array())
 {
     $dirs = is_array($_dir) ? $_dir : array($_dir);
     sort($dirs);
     $files = array();
     $ignore = isset($_opts["ignore"]) ? $_opts["ignore"] : null;
     $substDir = isset($_opts["substDir"]) ? $_opts["substDir"] : false;
     foreach ($dirs as $dir) {
         $dirLength = strlen($dir);
         foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)) as $path => $fileinfo) {
             if (!$fileinfo->isFile()) {
                 continue;
             }
             $key = $substDir ? substr($path, $dirLength) : $path;
             if (DIRECTORY_SEPARATOR !== "/") {
                 $key = str_replace(DIRECTORY_SEPARATOR, "/", $key);
             }
             if ($ignore && preg_match($ignore, $key)) {
                 continue;
             }
             $files[$key] = sha1_file($path);
         }
     }
     ksort($files);
     return $files;
 }
开发者ID:keradus,项目名称:ker,代码行数:26,代码来源:File.php

示例5: processDeposit

 /**
  * {@inheritdoc}
  */
 protected function processDeposit(Deposit $deposit)
 {
     $depositPath = $this->filePaths->getHarvestFile($deposit);
     if (!$this->fs->exists($depositPath)) {
         throw new Exception("Cannot find deposit bag {$depositPath}");
     }
     $checksumValue = null;
     switch (strtoupper($deposit->getChecksumType())) {
         case 'SHA-1':
         case 'SHA1':
             $checksumValue = sha1_file($depositPath);
             break;
         case 'MD5':
             $checksumValue = md5_file($depositPath);
             break;
         default:
             throw new Exception("Deposit checksum type {$deposit->getChecksumType()} unknown.");
     }
     if (strtoupper($checksumValue) !== $deposit->getChecksumValue()) {
         $deposit->addErrorLog("Deposit checksum does not match. Expected {$deposit->getChecksumValue()} != Actual " . strtoupper($checksumValue));
         $this->logger->warning("Deposit checksum does not match for deposit {$deposit->getDepositUuid()}");
         return false;
     }
     $this->logger->info("Deposit {$depositPath} validated.");
     return true;
 }
开发者ID:ubermichael,项目名称:pkppln-php,代码行数:29,代码来源:ValidatePayloadCommand.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $videos = glob(public_path() . '/b/*');
     usort($videos, function ($a, $b) {
         $a = (int) basename($a, '.webm');
         $b = (int) basename($b, '.webm');
         if ($a == $b) {
             return 0;
         }
         return $a < $b ? -1 : 1;
     });
     $category = \App\Models\Category::where('shortname', '=', 'misc')->first();
     $user = \App\Models\User::find(1);
     foreach ($videos as $video) {
         if (\App\Models\Video::whereFile(basename($video))->count() > 0) {
             continue;
         }
         $v = new \App\Models\Video();
         $v->user()->associate($user);
         $v->category()->associate($category);
         $v->hash = sha1_file($video);
         $v->file = basename($video);
         $v->save();
     }
 }
开发者ID:sirx,项目名称:w0bm.com,代码行数:30,代码来源:VideoTableSeeder.php

示例7: compare

 function compare($dir, $racine)
 {
     $retour = 'terminée avec succès.<br>';
     $files = array_diff(scandir($dir), array('.', '..'));
     foreach ($files as $file) {
         if (is_dir($dir . $file)) {
             if (file_exists($racine . $file)) {
                 compare($dir . $file . '/', $racine . $file . '/');
             } else {
                 mkdir($racine . $file);
             }
         } else {
             if (file_exists($racine . $file)) {
                 $shaNow = sha1_file($racine . $file);
                 $shaNext = sha1_file($dir . $file);
                 if ($shaNow != $shaNext) {
                     if (filemtime($dir . $file) >= filemtime($racine . $file)) {
                         $retour .= $racine . $file . ' Le fichier actuel a une date de modification plus récente<br>';
                     } else {
                         transfertFile($dir . '/' . $file, $racine . $file);
                     }
                 }
             } else {
                 transfertFile($dir . '/' . $file, $racine . $file);
             }
         }
     }
     return $retour;
 }
开发者ID:akwawa,项目名称:RipMeal-v2,代码行数:29,代码来源:miseAJour.php

示例8: readXmlDocument

 public function readXmlDocument($file, $cli = false)
 {
     try {
         if ($cli) {
             if (!$file) {
                 throw new XmlValidatorException("The file argument is missing!");
             } else {
                 if (!file_exists($file)) {
                     throw new XmlValidatorException("The input file: " . $file . " does't exist!");
                 } else {
                     if (!is_readable($file)) {
                         throw new XmlValidatorException("Unbale to read input file: " . $file . "!");
                     }
                 }
             }
             $this->hash = sha1_file($file);
             $this->file = $file;
             if ($this->cache_only) {
                 return true;
             }
         }
         $this->document = new DOMDocument();
         $this->document->load($file);
         $this->file = $file;
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:28,代码来源:XmlValidator.class.php

示例9: tasks

 /**
  * @inheritdoc
  */
 public function tasks()
 {
     return ['default' => ['.description' => 'Show map of subtasks', '.task' => ['class' => 'cookyii\\build\\tasks\\MapTask', 'task' => $this]], 'update' => ['.description' => 'Self update `cookyii/build` package', '.task' => ['class' => '\\cookyii\\build\\tasks\\CallableTask', 'handler' => function () {
         $source_url = 'http://cookyii.com/b/build.phar';
         $checksum_url = 'http://cookyii.com/b/checksum';
         $build_phar = $this->cwd . '/build.phar';
         try {
             $checksum = file_get_contents($checksum_url);
             if ($checksum !== sha1_file($build_phar)) {
                 $result = copy($source_url, $build_phar);
                 if ($result) {
                     $this->log('<task-result> COPY </task-result> `build.phar` updated to actual version.');
                 } else {
                     $this->log('<task-error> ERR </task-error> Error updating `build.phar`');
                 }
             } else {
                 $result = true;
                 if ($this->output->isVerbose()) {
                     $this->log('<task-result>  OK  </task-result> `build.phar` already updated.');
                 }
             }
         } catch (\Exception $e) {
             if ($this->output->isVerbose()) {
                 $this->log('<task-error> ERR </task-error> Error updating `build.phar`');
             }
             throw $e;
         }
         return $result;
     }]]];
 }
开发者ID:cookyii,项目名称:build,代码行数:33,代码来源:SelfTask.php

示例10: setUp

 public function setUp()
 {
     $this->image = realpath(APPLICATION_PATH . '/../' . self::PICTURE_LANDSCAPE);
     $this->hash = sha1_file($this->image);
     $this->adapter = $this->getMock('Zend_Cloud_StorageService_Adapter');
     $this->service = new StorageService($this->adapter);
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:7,代码来源:StorageServiceTest.php

示例11: download

 /**
  * Download the remote Phar file.
  *
  * @param Updater $updater
  *
  * @throws \Exception on failure
  */
 public function download(Updater $updater)
 {
     $version = $this->getCurrentRemoteVersion($updater);
     if ($version === false) {
         throw new \Exception('No remote versions found');
     }
     $versionInfo = $this->getAvailableVersions();
     if (!isset($versionInfo[$version]['url'])) {
         throw new \Exception(sprintf('Failed to find download URL for version %s', $version));
     }
     if (!isset($versionInfo[$version]['sha1'])) {
         throw new \Exception(sprintf('Failed to find download checksum for version %s', $version));
     }
     $downloadResult = file_get_contents($versionInfo[$version]['url']);
     if ($downloadResult === false) {
         throw new HttpRequestException(sprintf('Request to URL failed: %s', $versionInfo[$version]['url']));
     }
     $saveResult = file_put_contents($updater->getTempPharFile(), $downloadResult);
     if ($saveResult === false) {
         throw new \Exception(sprintf('Failed to write file: %s', $updater->getTempPharFile()));
     }
     $tmpSha = sha1_file($updater->getTempPharFile());
     if ($tmpSha !== $versionInfo[$version]['sha1']) {
         unlink($updater->getTempPharFile());
         throw new \Exception(sprintf('The downloaded file does not have the expected SHA-1 hash: %s', $versionInfo[$version]['sha1']));
     }
 }
开发者ID:drewmelck,项目名称:platformsh-cli,代码行数:34,代码来源:ManifestStrategy.php

示例12: resetsha1

 function resetsha1()
 {
     $list = F('resetshalist');
     if (empty($list)) {
         $list = M('Picture')->field('id,path')->select();
         F('resetshalist', $list);
         F('resetshalistnum', count($list));
     }
     $total = F('resetshalistnum');
     $i = 1;
     foreach ($list as $key => $val) {
         $i++;
         $sha1 = sha1_file('.' . $val['path']);
         M('Picture')->where("id={$val['id']}")->save(array('sha1' => $sha1));
         unset($list[$key]);
         if ($i > 1000 || empty($list)) {
             $num = count($list);
             if ($num > 0) {
                 F('resetshalist', $list);
                 $this->error('已经处理' . ($total - $num) . ',还有' . $num . '张');
             } else {
                 F('resetshalist', null);
                 F('resetshalistnum', null);
                 $this->success('SHA1重置成功,总共有' . $total . '张图片');
             }
             break;
         }
     }
 }
开发者ID:735579768,项目名称:Ainiku,代码行数:29,代码来源:FileController.class.php

示例13: execute

 /**
  * {@inheritdoc}
  */
 public function execute(ConsumerEvent $event, $directory)
 {
     $sha1LockFile = sha1_file($this->workingTempPath . '/' . $directory . '/composer.lock');
     $this->triggerSuccess($event, array('link' => '/assets/' . $sha1LockFile . '/vendor.zip'));
     $this->filesystem->remove($this->workingTempPath . '/' . $directory);
     return 0;
 }
开发者ID:pborreli,项目名称:composer-service,代码行数:10,代码来源:FinalizeStep.php

示例14: calculate_hash

function calculate_hash($string, $hash = 'MD5', $isFile = false)
{
    $str = '';
    if ($isFile) {
        switch ($hash) {
            case 'SHA1':
                $str = sha1_file($string);
                break;
            case 'MD5':
            default:
                $str = md5_file($string);
                break;
        }
    } else {
        switch ($hash) {
            case 'SHA1':
                $str = sha1($string);
                break;
            case 'MD5':
            default:
                $str = md5($string);
                break;
        }
    }
    return $str;
}
开发者ID:nayanshah,项目名称:phpBox,代码行数:26,代码来源:HashGen.php

示例15: dl_apk

function dl_apk($id)
{
    $config = array("a" => "credentials_us.conf", "b" => "credentials_us_f1.conf", "3" => "credentials_us_f2.conf", "4" => "credentials_us_f3.conf", "5" => "credentials_us_f4.conf", "6" => "credentials_us_f5.conf");
    $cfg = array_rand($config, 1);
    //$dl_cmd="python /home/wwwroot/www.voteapps.com/terry/gplay-cli/gplay-cli.py  -d $id -f apkfiles -y -p -c credentials_us.conf";
    $dl_cmd = "python /home/wwwroot/www.voteapps.com/terry/gplay-cli/gplay-cli.py  -d {$id} -f /home/wwwroot/www.voteapps.com/apkfiles -y -p -c {$config[$cfg]}";
    //echo 	$dl_cmd;
    //$dl_480="youtube-dl -f $f -o $path_480 https://www.youtube.com/watch?v=$dl_url";
    //执行下载
    exec($dl_cmd, $output, $return_var);
    //print_r($output);
    //print_r($return_var);
    //返回状态码 0 成功 1失败
    $array[code] = $return_var;
    if ($return_var == '0') {
        $time = time();
        $name = $id . $time . "[www.apkdigg.co]";
        if (!file_exists("/home/wwwroot/www.voteapps.com/apkfiles/{$id}.apk")) {
            $array[code] = '1';
        } else {
            rename("/home/wwwroot/www.voteapps.com/apkfiles/{$id}.apk", "/home/wwwroot/www.voteapps.com/apkfiles/{$name}.apk");
            $array[file] = "apkfiles/{$name}.apk";
            $array[sha] = sha1_file("/home/wwwroot/www.voteapps.com/apkfiles/{$name}.apk");
            $pack_url = "/home/wwwroot/www.voteapps.com/apkfiles/{$name}.apk";
            //$array[pack_info]= drupal_http_request($pack_url)->data;
            //$array[pack_info]= curldom($pack_url);
            $array['filemd5'] = md5_file($pack_url);
            $array[pack_info] = apkinfo($pack_url);
            //  $array[pack_info]=get_permissions($pack_url);
        }
    } else {
    }
    return $array;
}
开发者ID:napoler,项目名称:t-drupal-module,代码行数:34,代码来源:dl.php


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