本文整理汇总了PHP中sha1_file函数的典型用法代码示例。如果您正苦于以下问题:PHP sha1_file函数的具体用法?PHP sha1_file怎么用?PHP sha1_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sha1_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: main
/**
* @param Configuration $config
* @throws \Exception
*/
public function main(Configuration &$config)
{
$siteRoot = $config->get(array('task', 'siteRoot'), '');
$fileDir = $config->get(array('task', 'fileDir'), '');
if (empty($siteRoot)) {
throw new \Exception('Task/Typo3/File: No site root defined.');
}
if (empty($fileDir)) {
throw new \Exception('Task/Typo3/File: No file directory defined.');
}
// Empty data
$this->data = [];
// Trim slashes from paths
$siteRoot = rtrim($siteRoot, '/');
$fileDir = '/' . trim($fileDir, '/');
// List files in the directory
$files = new Directory($siteRoot . $fileDir);
// Download files from remote server
foreach ($files as $file) {
// Connect to the file
$identifier = $fileDir . '/' . $file->getFilename();
// File is invalid
if ($file->getSize() === 0) {
continue;
}
// Update record info with typo3 sys_file compatible data
$this->data[] = ['identifier' => $identifier, 'storage' => 1, 'identifier_hash' => sha1($identifier), 'folder_hash' => sha1($fileDir), 'extension' => $file->getExtension(), 'mime_type' => MimeType::get($file->getFilename()), 'name' => $file->getFilename(), 'sha1' => sha1_file($file->getRealPath()), 'size' => $file->getSize(), 'tstamp' => time(), 'last_indexed' => time(), 'creation_date' => $file->getCTime(), 'modification_date' => $file->getMTime()];
}
}
开发者ID:AgenceStratis,项目名称:migrator,代码行数:33,代码来源:FileTask.php
示例17: newAction
/**
* @Route("/new", name="new")
*/
public function newAction(Request $request)
{
$file_root = $request->server->get('DOCUMENT_ROOT') . '/integrity/web/files/';
$comparison = new Comparison();
$form = $this->createFormBuilder($comparison)->add('first_file', FileType::class)->add('second_file', FileType::class)->add('save', SubmitType::class, array('label' => 'Submit'))->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($comparison);
$em->flush();
if (is_file($file_root . $comparison->getFirstFileName()) && is_file($file_root . $comparison->getSecondFileName())) {
if (sha1_file($file_root . $comparison->getFirstFileName()) === sha1_file($file_root . $comparison->getSecondFileName())) {
$comparison->setPercentage('100');
$em->persist($comparison);
$em->flush();
} else {
similar_text(file_get_contents($file_root . $comparison->getFirstFileName()), file_get_contents($file_root . $comparison->getSecondFileName()), $percentage);
$comparison->setPercentage($percentage);
$em->persist($comparison);
$em->flush();
}
}
return $this->redirectToRoute('view_item', array('id' => $comparison->getId()));
}
return $this->render('default/new.html.twig', ['base_dir' => realpath($this->container->getParameter('kernel.root_dir') . '/..'), 'form' => $form->createView()]);
}
开发者ID:insmod,项目名称:filediffsf,代码行数:29,代码来源:DefaultController.php
示例18: encrypt
/**
* Encrypts the data
* @param string $data file name
* @return string
* @throws \InvalidArgumentException
* @see sha1_file()
*/
public function encrypt($data)
{
if (!is_string($data)) {
throw new \InvalidArgumentException('data');
}
return sha1_file($data, $this->getRawOutput());
}
开发者ID:nyclagniappe,项目名称:phpjazz,代码行数:14,代码来源:File.php
示例19: hashedUrl
/**
* Returns a URL with a prefix of a hash of the file's contents appended
* to the filename. This is used for busting the cache and making sure browsers
* can cache the asset until it changes.
*
* @param string $key
* @return string
*/
public function hashedUrl($key)
{
$file = $this->path($key);
$hash = substr(sha1_file($file), 0, 8);
$parts = preg_split('/\\.(?=[^\\.]+$)/', $this->url($key));
return sprintf('%s.%s.%s', $parts[0], $hash, $parts[1]);
}
开发者ID:EMRL,项目名称:fire,代码行数:15,代码来源:Asset.php
示例20: selfupdate
function selfupdate($argv, $inPhar)
{
$opts = ['http' => ['method' => 'GET', 'header' => "User-agent: phpfmt fmt.phar selfupdate\r\n"]];
$context = stream_context_create($opts);
// current release
$releases = json_decode(file_get_contents('https://api.github.com/repos/phpfmt/fmt/tags', false, $context), true);
$commit = json_decode(file_get_contents($releases[0]['commit']['url'], false, $context), true);
$files = json_decode(file_get_contents($commit['commit']['tree']['url'], false, $context), true);
foreach ($files['tree'] as $file) {
if ('fmt.phar' == $file['path']) {
$phar_file = base64_decode(json_decode(file_get_contents($file['url'], false, $context), true)['content']);
}
if ('fmt.phar.sha1' == $file['path']) {
$phar_sha1 = base64_decode(json_decode(file_get_contents($file['url'], false, $context), true)['content']);
}
}
if (!isset($phar_sha1) || !isset($phar_file)) {
fwrite(STDERR, 'Could not autoupdate - not release found' . PHP_EOL);
exit(255);
}
if ($inPhar && !file_exists($argv[0])) {
$argv[0] = dirname(Phar::running(false)) . DIRECTORY_SEPARATOR . $argv[0];
}
if (sha1_file($argv[0]) != $phar_sha1) {
copy($argv[0], $argv[0] . '~');
file_put_contents($argv[0], $phar_file);
chmod($argv[0], 0777 & ~umask());
fwrite(STDERR, 'Updated successfully' . PHP_EOL);
exit(0);
}
fwrite(STDERR, 'Up-to-date!' . PHP_EOL);
exit(0);
}
开发者ID:straiway,项目名称:fmt,代码行数:33,代码来源:selfupdate.php
注:本文中的sha1_file函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论