Rev 2 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 4 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | if (!$signature) { |
35 | if (!$signature) { |
36 | echo "ERROR: $file\n"; |
36 | echo "ERROR: $file\n"; |
37 | continue; |
37 | continue; |
38 | } |
38 | } |
39 | 39 | ||
40 | $sign_line = '<?php /* <ViaThinkSoftSignature>'.base64_encode($signature).'</ViaThinkSoftSignature> */ ?>'; |
40 | $sign_line = '<?php /* <ViaThinkSoftSignature>'."\n".split_equal_length(base64_encode($signature),65).'</ViaThinkSoftSignature> */ ?>'; |
- | 41 | ||
- | 42 | // We have to put the signature at the beginning, because we don't know if the end of the file lacks a PHP closing tag |
|
41 | if (substr($cont,0,2) === '#!') { |
43 | if (substr($cont,0,2) === '#!') { |
42 | // Preserve shebang |
44 | // Preserve shebang |
43 | $shebang_pos = strpos($naked, "\n"); |
45 | $shebang_pos = strpos($naked, "\n"); |
44 | $shebang = substr($naked, 0, $shebang_pos); |
46 | $shebang = substr($naked, 0, $shebang_pos); |
45 | $rest = substr($naked, $shebang_pos+1); |
47 | $rest = substr($naked, $shebang_pos+1); |
Line 54... | Line 56... | ||
54 | } else { |
56 | } else { |
55 | echo "Already signed: $file\n"; |
57 | echo "Already signed: $file\n"; |
56 | } |
58 | } |
57 | } |
59 | } |
58 | 60 | ||
- | 61 | # --- |
|
- | 62 | ||
- | 63 | function split_equal_length($data, $width=65) { |
|
- | 64 | $out = ''; |
|
- | 65 | for ($i=0; $i<strlen($data); $i+=$width) { |
|
- | 66 | $out .= substr($data, $i, $width)."\n"; |
|
- | 67 | } |
|
- | 68 | return $out; |
|
- | 69 | } |
|
- | 70 |