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


PHP md5_file函数代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $remoteFilename = 'http://get.insight.sensiolabs.com/insight.phar';
     $localFilename = $_SERVER['argv'][0];
     $tempFilename = basename($localFilename, '.phar') . '-temp.phar';
     try {
         copy($remoteFilename, $tempFilename);
         if (md5_file($localFilename) == md5_file($tempFilename)) {
             $output->writeln('<info>insight is already up to date.</info>');
             unlink($tempFilename);
             return;
         }
         chmod($tempFilename, 0777 & ~umask());
         // test the phar validity
         $phar = new \Phar($tempFilename);
         // free the variable to unlock the file
         unset($phar);
         rename($tempFilename, $localFilename);
         $output->writeln('<info>insight updated.</info>');
     } catch (\Exception $e) {
         if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
             throw $e;
         }
         unlink($tempFilename);
         $output->writeln('<error>The download is corrupt (' . $e->getMessage() . ').</error>');
         $output->writeln('<error>Please re-run the self-update command to try again.</error>');
     }
 }
开发者ID:ftdysa,项目名称:insight,代码行数:31,代码来源:SelfUpdateCommand.php

示例2: buildjs

function buildjs()
{
    $t = $_GET["t"];
    $time = time();
    $MEPOST = 0;
    header("content-type: application/x-javascript");
    $tpl = new templates();
    $page = CurrentPageName();
    $array = unserialize(@file_get_contents($GLOBALS["CACHEFILE"]));
    $prc = intval($array["POURC"]);
    $title = $tpl->javascript_parse_text($array["TEXT"]);
    $md5file = trim(md5_file($GLOBALS["LOGSFILES"]));
    echo "// CACHE FILE: {$GLOBALS["CACHEFILE"]} {$prc}%\n";
    echo "// LOGS FILE: {$GLOBALS["LOGSFILES"]} - {$md5file} " . strlen($md5file) . "\n";
    if ($prc == 0) {
        if (strlen($md5file) < 32) {
            echo "\n\t// PRC = {$prc} ; md5file={$md5file}\n\tfunction Start{$time}(){\n\t\t\tif(!RTMMailOpen()){return;}\n\t\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
            return;
        }
    }
    if ($md5file != $_GET["md5file"]) {
        echo "\n\tvar xStart{$time}= function (obj) {\n\t\tif(!document.getElementById('text-{$t}')){return;}\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){\n\t\t\tdocument.getElementById('text-{$t}').value=res;\n\t\t}\t\t\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$md5file}');\n\t}\t\t\n\t\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('Filllogs', 'yes');\n\t\tXHR.appendData('t', '{$t}');\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('{$page}', 'POST',xStart{$time},false); \n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
        return;
    }
    if ($prc > 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\tdocument.getElementById('title-{$t}').style.border='1px solid #C60000';\n\t\tdocument.getElementById('title-{$t}').style.color='#C60000';\n\t\t\$('#progress-{$t}').progressbar({ value: 100 });\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    if ($prc == 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\t\$('#SQUID_ARTICA_QUOTA_RULES').flexReload();\n\t\tRTMMailHide();\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    echo "\t\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1500);\n";
}
开发者ID:articatech,项目名称:artica,代码行数:34,代码来源:squid.global.wl.center.progress.php

示例3: beforeSave

 public function beforeSave()
 {
     $path = $this->getRealPath();
     if (!$this->md5 && $this->path && file_exists($path)) {
         $this->md5 = md5_file($path);
     }
 }
开发者ID:krvd,项目名称:cms-Inji,代码行数:7,代码来源:File.php

示例4: testIfWillDeleteEmbeddedImage

 public function testIfWillDeleteEmbeddedImage()
 {
     $fileName = __DIR__ . '/logo-1024.png';
     $md5 = md5_file($fileName);
     // NOTE: Must work fine even if _id is not set
     $model = new ModelWithEmbeddedImage();
     $model->file = new Image();
     $model->file->set($fileName);
     $em = new EntityManager($model);
     $em->save();
     $finder = new Finder($model);
     $found = $finder->findByPk($model->_id);
     /* @var $found ModelWithEmbeddedImage */
     $file = $found->file->get()->getBytes();
     $this->assertSame($md5, md5($file));
     // Resize image
     $params = new ImageParams();
     $params->width = 100;
     $params->height = 100;
     $resized = $found->file->get($params)->getBytes();
     // Check if was resized
     $this->assertTrue($file > $resized);
     $mangan = new Mangan();
     $gfs = $mangan->getDbInstance()->getGridFS();
     $tmp = $mangan->getDbInstance()->getGridFS(File::TmpPrefix);
     $criteria = ['parentId' => $found->file->_id];
     $this->assertSame(1, $gfs->count($criteria));
     $this->assertSame(1, $tmp->count($criteria));
     $deleted = $found->delete();
     $this->assertTrue($deleted);
     $this->assertSame(0, $gfs->count($criteria));
     $this->assertSame(0, $tmp->count($criteria));
 }
开发者ID:maslosoft,项目名称:mangantest,代码行数:33,代码来源:EmbeddedFileTest.php

示例5: mise_a_jour_ecran_securite

/**
 * Mise a jour automatisee de l'ecran de securite
 * On se base sur le filemtime de l'ecran source avec un en-tete if_modified_since
 * Mais on fournit aussi le md5 de notre ecran actuel et la version branche de SPIP
 * Cela peut permettre de diffuser un ecran different selon la version de SPIP si besoin
 * ou de ne repondre une 304 que si le md5 est bon
 */
function mise_a_jour_ecran_securite()
{
    // TODO : url https avec verification du certificat
    return;
    // si l'ecran n'est pas deja present ou pas updatable, sortir
    if (!_URL_ECRAN_SECURITE or !file_exists($filename = _DIR_ETC . "ecran_securite.php") or !is_writable($filename) or !($last_modified = filemtime($filename)) or !($md5 = md5_file($filename))) {
        return false;
    }
    include_spip('inc/distant');
    $tmp_file = _DIR_TMP . "ecran_securite.php";
    $url = parametre_url(_URL_ECRAN_SECURITE, "md5", $md5);
    $url = parametre_url($url, "vspip", $GLOBALS['spip_version_branche']);
    $res = recuperer_url($url, array('if_modified_since' => $last_modified, 'file' => $tmp_file));
    // si il y a une version plus recente que l'on a recu correctement
    if ($res['status'] == 200 and $res['length'] and $tmp_file = $res['file']) {
        if ($md5 !== md5_file($tmp_file)) {
            // on essaye de l'inclure pour verifier que ca ne fait pas erreur fatale
            include_once $tmp_file;
            // ok, on le copie a la place de l'ecran existant
            // en backupant l'ecran avant, au cas ou
            @copy($filename, $filename . "-bck-" . date('Y-m-d-His', $last_modified));
            @rename($tmp_file, $filename);
        } else {
            @unlink($tmp_file);
        }
    }
}
开发者ID:xablen,项目名称:Semaine14_SPIP_test,代码行数:34,代码来源:mise_a_jour.php

示例6: afterValidate

 public function afterValidate($event)
 {
     $this->prepareDataDirectory();
     $file = CUploadedFile::getInstanceByName($this->uploadInstance);
     if ($file instanceof CUploadedFile && $file->getError() == UPLOAD_ERR_OK && !$this->Owner->hasErrors()) {
         $uniqueFilename = P3StringHelper::generateUniqueFilename($file->getName());
         $fullFilePath = $this->_fullDataPath . DIRECTORY_SEPARATOR . $uniqueFilename;
         $relativeFilePath = $this->_relativeDataPath . DIRECTORY_SEPARATOR . $uniqueFilename;
         if ($file->saveAs($fullFilePath)) {
             #echo $fullFilePath;exit;
             if (!$this->Owner->isNewRecord) {
                 $this->deleteFile($this->Owner->path);
             }
             if (!$this->Owner->title) {
                 $this->Owner->title = P3StringHelper::cleanName($file->name, 32);
             }
             $this->Owner->path = $relativeFilePath;
             $this->Owner->mimeType = $file->type;
             $this->Owner->size = $file->size;
             $this->Owner->originalName = $file->name;
             $this->Owner->md5 = md5_file($fullFilePath);
         } else {
             $this->Owner->addError('filePath', 'File uploaded failed!');
         }
     } else {
         if ($this->Owner->isNewRecord) {
             #$this->Owner->addError('filePath', 'No file uploaded!');
             Yii::trace('No file uploaded!');
         }
     }
 }
开发者ID:ranvirp,项目名称:rdp,代码行数:31,代码来源:P3FileUploadBehavior.php

示例7: scan_file_lists

/**
 * 文件扫描
 * @param $filepath     目录
 * @param $subdir       是否搜索子目录
 * @param $ex           搜索扩展
 * @param $isdir        是否只搜索目录
 * @param $md5			是否生成MD5验证码
 * @param $enforcement  强制更新缓存
 */
function scan_file_lists($filepath, $subdir = 1, $ex = '', $isdir = 0, $md5 = 0, $enforcement = 0)
{
    static $file_list = array();
    if ($enforcement) {
        $file_list = array();
    }
    $flags = $isdir ? GLOB_ONLYDIR : 0;
    $list = glob($filepath . '*' . (!empty($ex) && empty($subdir) ? '.' . $ex : ''), $flags);
    if (!empty($ex)) {
        $ex_num = strlen($ex);
    }
    foreach ($list as $k => $v) {
        $v1 = str_replace(PHPCMS_PATH, '', $v);
        if ($subdir && is_dir($v)) {
            scan_file_lists($v . DIRECTORY_SEPARATOR, $subdir, $ex, $isdir, $md5);
            continue;
        }
        if (!empty($ex) && strtolower(substr($v, -$ex_num, $ex_num)) == $ex) {
            if ($md5) {
                $file_list[$v1] = md5_file($v);
            } else {
                $file_list[] = $v1;
            }
            continue;
        } elseif (!empty($ex) && strtolower(substr($v, -$ex_num, $ex_num)) != $ex) {
            unset($list[$k]);
            continue;
        }
    }
    return $file_list;
}
开发者ID:klj123wan,项目名称:czsz,代码行数:40,代码来源:global.func.php

示例8: getMD5Hash

/** 
 * Function which will return the hash after passing through all folders and subfolders within it. 
 * @param $dir - Starting folder to scan
 * @param $excludeFileList - List of filenames to exclude from scan
 * @param $excludeExtensionList - List of extensions to exclude from scan  
 * @return Final MD5 of all files scanned.
 */
function getMD5Hash($dir, $excludeFileList, $excludeExtensionList)
{
    if (!is_dir($dir)) {
        return false;
    }
    $fileMD5list = array();
    $d = dir($dir);
    while (false !== ($entry = $d->read())) {
        if ($entry != '.' && $entry != '..') {
            if (is_dir($dir . '/' . $entry)) {
                $fileMD5list[] = getMD5Hash($dir . '/' . $entry, $excludeFileList, $excludeExtensionList);
            } else {
                if (stripos($excludeFileList, $entry) === false) {
                    $extension = end(explode('.', $entry));
                    //get the file extension
                    if (stripos($excludeExtensionList, $extension) === false) {
                        $fileMD5list[] = md5_file($dir . '/' . $entry);
                        //Prepare list to MD5 only allowed
                    }
                }
            }
        }
    }
    $d->close();
    return md5(implode('', $fileMD5list));
    //Return final MD5 of all files
}
开发者ID:angelesramil79,项目名称:projects,代码行数:34,代码来源:websitecds.php

示例9: check_new_file

 private static function check_new_file($old_image, $new_image)
 {
     if (md5_file($old_image) == md5_file($new_image) || filesize($old_image) == filesize($new_image)) {
         return 0;
     }
     return 1;
 }
开发者ID:kidambimanoj,项目名称:FollowU,代码行数:7,代码来源:PhotoDownloader.php

示例10: hashName

 /**
  * Get a filename for the file that is the MD5 hash of the contents.
  *
  * @param  string  $path
  * @return string
  */
 public function hashName($path = null)
 {
     if ($path) {
         $path = rtrim($path, '/') . '/';
     }
     return $path . md5_file($this->path()) . '.' . $this->extension();
 }
开发者ID:yipersevere,项目名称:2016UndergraduationCoursework,代码行数:13,代码来源:UploadedFile.php

示例11: moveUploadedFile

 public function moveUploadedFile(UploadedFile $file, $uploadBasePath, $relativePath, $fileName)
 {
     $originalName = $file->getFilename();
     // use filemtime() to have a more determenistic way to determine the subpath, otherwise its hard to test.
     // $relativePath = date('Y-m', filemtime($file->getPath()));
     $targetFileName = $relativePath . DIRECTORY_SEPARATOR . $originalName;
     $targetFilePath = $uploadBasePath . DIRECTORY_SEPARATOR . $targetFileName;
     $ext = $file->getExtension();
     $i = 1;
     while (file_exists($targetFilePath) && md5_file($file->getPath()) != md5_file($targetFilePath)) {
         if ($ext) {
             $prev = $i == 1 ? "" : $i;
             $targetFilePath = $targetFilePath . str_replace($prev . $ext, $i++ . $ext, $targetFilePath);
         } else {
             $targetFilePath = $targetFilePath . $i++;
         }
     }
     $targetDir = $uploadBasePath . DIRECTORY_SEPARATOR . $relativePath;
     if (!is_dir($targetDir)) {
         $ret = mkdir($targetDir, umask(), true);
         if (!$ret) {
             throw new \RuntimeException("Could not create target directory to move temporary file into.");
         }
     }
     //$file->move($targetDir, basename($targetFilePath));
     //$file->move($targetDir, basename($fileName.'.'.$ext));
     $file->move($targetDir, basename($fileName));
     return str_replace($uploadBasePath . DIRECTORY_SEPARATOR, "", $targetFilePath);
 }
开发者ID:alangalipaud,项目名称:ProjetQCM,代码行数:29,代码来源:UploadFileMover.php

示例12: downloadPlugin

 public function downloadPlugin($name, $url, $signature)
 {
     if (is_dir(ipFile("Plugin/{$name}/"))) {
         Service::deactivatePlugin($name);
         Helper::removeDir(ipFile("Plugin/{$name}/"));
     }
     //download plugin
     $net = new \Ip\Internal\NetHelper();
     $pluginTempFilename = $net->downloadFile($url, ipFile('file/secure/tmp/'), $name . '.zip');
     if (!$pluginTempFilename) {
         throw new \Ip\Exception('Plugin file download failed.');
     }
     $archivePath = ipFile('file/secure/tmp/' . $pluginTempFilename);
     //check signature
     $fileMd5 = md5_file($archivePath);
     $rsa = new \Crypt_RSA();
     $rsa->loadKey($this->publicKey);
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $verified = $rsa->verify($fileMd5, base64_decode($signature));
     if (!$verified) {
         throw new \Ip\Exception('Plugin signature verification failed.');
     }
     //extract
     $secureTmpDir = ipFile('file/secure/tmp/');
     $tmpExtractedDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $secureTmpDir);
     \Ip\Internal\Helper\Zip::extract($secureTmpDir . $pluginTempFilename, $secureTmpDir . $tmpExtractedDir);
     unlink($archivePath);
     //install
     $extractedDir = $this->getFirstDir($secureTmpDir . $tmpExtractedDir);
     $installDir = Model::pluginInstallDir();
     $newPluginDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $installDir);
     rename($secureTmpDir . $tmpExtractedDir . '/' . $extractedDir, $installDir . $newPluginDir);
     Service::activatePlugin($name);
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:34,代码来源:PluginDownloader.php

示例13: stat

 function stat($file, $md5 = true, $sha1 = true)
 {
     $rval = array();
     foreach (stat($file) as $i => $v) {
         if (is_numeric($i)) {
             continue;
         }
         $rval[$i] = $v;
     }
     $rval['type'] = filetype($file);
     if ($rval['type'] == 'file') {
         if ($md5) {
             $rval['md5'] = md5_file($file);
         }
         if ($sha1) {
             $rval['sha1'] = sha1_file($file);
         }
     }
     $dir = $this->dir;
     if (0 !== strpos($file, $dir) && 'wp-config.php' == basename($file)) {
         $dir = explode(DIRECTORY_SEPARATOR, $dir);
         array_pop($dir);
         $dir = implode(DIRECTORY_SEPARATOR, $dir);
     }
     $rval['path'] = str_replace($dir, '', $file);
     return $rval;
 }
开发者ID:roblarsen,项目名称:jquery-wp-content,代码行数:27,代码来源:class.vaultpress-filesystem.php

示例14: resourceCache

 public function resourceCache($file)
 {
     // Second to cache
     $STC = 86400;
     // Greenwich Mean Time
     $GMT = gmdate("D, d M Y H:i:s", time() + $STC) . " GMT";
     // Last Modified
     $lastModified = filemtime($file);
     // Get a unique hash of this file (etag)
     $etagFile = md5_file($file);
     // Get the HTTP_IF_MODIFIED_SINCE header if set
     $ifModifiedSince = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
     // Get the HTTP_IF_NONE_MATCH header if set (etag: unique file hash)
     $etagHeader = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false;
     // Set etag-header
     header("Etag: {$etagFile}");
     // Set last-modified header
     header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastModified) . " GMT");
     header("Expires: {$GMT}");
     header("Pragma: cache");
     // Make sure caching is turned on
     header("Cache-Control: public, max-age={$STC}");
     // Check if page has changed. If not, send 304 and exit
     if (@strtotime($ifModifiedSince) == $lastModified || $etagHeader == $etagFile) {
         header("HTTP/1.1 304 Not Modified");
         exit;
     }
 }
开发者ID:letid,项目名称:framework,代码行数:28,代码来源:response.php

示例15: testCorrectWorkflow

 /**
  * Testing correct create models
  *
  * @dataProvider dataProviderForCorrectWorkflow
  */
 public function testCorrectWorkflow($columns, $primaryKey, $rowTemplatePath, $tableTemplatePath)
 {
     $container = new \Mockery\Container();
     $templateRow = $container->mock('\\Bluzman\\Generator\\Template\\RowTemplate')->shouldDeferMissing()->shouldAllowMockingProtectedMethods();
     $templateRow->shouldReceive('getDefaultTemplateData')->atLeast(1)->andReturn($this->dataForTemplate)->getMock();
     $templateTable = $container->mock('\\Bluzman\\Generator\\Template\\TableTemplate')->shouldDeferMissing()->shouldAllowMockingProtectedMethods();
     $templateTable->shouldReceive('getDefaultTemplateData')->atLeast(1)->andReturn($this->dataForTemplate)->getMock();
     $command = $container->mock('\\Bluzman\\Command\\Init\\ModelCommand[getPrimaryKey, getColumns, getObjTemplate]')->shouldDeferMissing()->shouldAllowMockingProtectedMethods();
     $command->shouldReceive('getPrimaryKey')->atLeast(1)->andReturn($primaryKey)->getMock();
     $command->shouldReceive('getColumns')->atLeast(1)->andReturn($columns)->getMock();
     $command->shouldReceive('getObjTemplate')->withArgs(['RowTemplate'])->andReturn($templateRow)->getMock();
     $command->shouldReceive('getObjTemplate')->withArgs(['TableTemplate'])->andReturn($templateTable)->getMock();
     $this->getApplication()->addCommands([$command]);
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName(), '--name' => $this->name, '--table' => $this->table]);
     // check that all went well
     $this->assertTrue($command->verify());
     $display = $commandTester->getDisplay();
     // check all messages were displayed
     $this->assertRegExp('/Running "init:model" command/', $display);
     $this->assertRegExp('/has been successfully created/', $display);
     $table = $this->modelPath . DS . 'Table.php';
     $row = $this->modelPath . DS . 'Row.php';
     $this->assertFileExists($table);
     $this->assertEquals(md5_file($table), md5_file($tableTemplatePath));
     $this->assertFileExists($row);
     $this->assertEquals(md5_file($row), md5_file($rowTemplatePath));
 }
开发者ID:bluzphp,项目名称:bluzman,代码行数:33,代码来源:ModelCommandTest.php


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