コード例 #1
0
 function assignVariables()
 {
     if (isset($_POST['recheck'])) {
         $error = '';
         $test = testFileUploads('cksumdat');
         if (isset($test->error)) {
             $error = $test->error;
         } elseif (count($test->files) > 1) {
             $error = ilang('upload_file_multiple');
         } else {
             if (isset($test->files[0]['error_string'])) {
                 $error = $test->files[0]['error_string'];
             } else {
                 $checksum_file = $test->files[0]['tmp_name'];
                 if ($this->debug) {
                     $handle = fopen($checksum_file, 'rb');
                 } else {
                     $handle = @fopen($checksum_file, 'rb');
                 }
                 if (!$handle) {
                     $error = ilang('upload_file_no_readable');
                 }
             }
         }
         if (empty($error)) {
             $results = array();
             while (!feof($handle)) {
                 $line = @fgets($handle, 4096);
                 $line = trim($line);
                 // clean
                 if (empty($line)) {
                     continue;
                 }
                 // skip empty line
                 $pos = strpos($line, '#');
                 if ($pos) {
                     $line = substr($line, 0, $pos);
                 }
                 // strip out comments
                 list($md5sum, $file) = explode(' *./', $line, 2);
                 // split it into fields
                 $md5sum = trim($md5sum);
                 $file = trim($file);
                 $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
                 // avoid windows suck
                 $test_file = CMS_BASE . DIRECTORY_SEPARATOR . $file;
                 $test = testFileChecksum(0, '', $test_file, $md5sum, '', ilang('format_datetime'), $this->debug);
                 if ($test->res == 'green') {
                     continue;
                 }
                 // ok, skip
                 $results[] = $test;
             }
             @fclose($handle);
             if (count($results) > 0) {
                 $this->smarty->assign('results', $results);
                 $this->smarty->assign('error_fragment', 'Checksum_report_errors');
             }
             $this->smarty->assign('try_test', true);
         } else {
             $this->errors[] = $error;
         }
     }
     $this->smarty->assign('errors', $this->errors);
 }
コード例 #2
0
ファイル: cmschecksum.php プロジェクト: Alexkuva/Beaupotager
                continue;
            }
            // skip empty line
            $pos = strpos($line, '#');
            if ($pos) {
                $line = substr($line, 0, $pos);
            }
            // strip out comments
            list($md5sum, $file) = explode(' *./', $line, 2);
            // split it into fields
            $md5sum = trim($md5sum);
            $file = trim($file);
            $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
            // avoid windows suck
            $test_file = $root_path . DIRECTORY_SEPARATOR . $file;
            $test = testFileChecksum(0, 'Checksum', $test_file, $md5sum, '', lang('format_datetime'), $debug);
            if ($test->res == 'green') {
                continue;
            }
            // ok, skip
            $results[] = $test;
        }
        @fclose($handle);
    }
}
// PRESENTATION
echo '<h2>' . lang('checksum') . '</h2>';
if (!empty($error)) {
    die($error);
}
if (isset($results)) {