Click here to Skip to main content
15,887,854 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
Questionسلام به همه ایرانی های عزیز Pin
rahmani12328-Sep-11 21:37
rahmani12328-Sep-11 21:37 
AnswerRe: سلام به همه ایرانی های عزیز Pin
Richard MacCutchan30-Sep-11 22:00
mveRichard MacCutchan30-Sep-11 22:00 
GeneralRe: سلام به همه ایرانی های عزیز Pin
Luc Pattyn19-Oct-11 2:01
sitebuilderLuc Pattyn19-Oct-11 2:01 
GeneralRe: سلام به همه ایرانی های عزیز Pin
Richard MacCutchan19-Oct-11 2:28
mveRichard MacCutchan19-Oct-11 2:28 
Questionencode & decode Pin
mryazdani22-Sep-11 10:02
mryazdani22-Sep-11 10:02 
AnswerRe: encode & decode Pin
Luc Pattyn22-Sep-11 10:30
sitebuilderLuc Pattyn22-Sep-11 10:30 
GeneralRe: encode & decode Pin
mryazdani22-Sep-11 10:57
mryazdani22-Sep-11 10:57 
AnswerRe: encode & decode Pin
Luc Pattyn23-Sep-11 2:03
sitebuilderLuc Pattyn23-Sep-11 2:03 
Hi,

I looked a bit closer, here is your code again, then my comments:

PHP
  1  define('BUFSIZ', 4095);
  2  $url = $_GET["addr"];
  3  $msk = $_GET["key"];
  4  $msklen = count($msk);
  5  $rfile = fopen($url, 'r');
  6  $lfile = fopen(basename($url), 'w');
  7  while(!feof($rfile))
  8  {
  9      $content = fread($rfile, BUFSIZ);
 10      while($i=0; $i < BUFSIZ; $i++)
 11           $content[$i] = $content[$i] ^ &msk[$i % count($msk)];
 12      fwrite($lfile, $content, BUFSIZ);
 13  }
 14  fclose($rfile);
 15  fclose($lfile);


1.
your code does not compile, there are several mistakes.

2.
line 10 is wrong; a while statement takes one argument, you intended to use a for loop?

3.
line 11: &msk needs a dollar sign, not an ampersand.

4.
line 11: you can't silently convert a character to an integer; when you want the ASCII index of a character, use the ord function[^]. The reverse operation is performed using the chr function[^].


Finally, here is some code that might help you:
PHP
// writes a single string
function par($string) {
    echo "<p>$string</p>\n";
}

// dumps the first 20 characters of a file using HEX
function hexdump($title, $filename1) {
    $BUFSIZ=20;
    $hex="0123456789ABCDEF";
    $dump="";
    $rfile = fopen($filename1, 'r');
    $content = fread($rfile, $BUFSIZ);
    $len=strlen($content);
    for($i=0; $i < $len; $i++) {
        $val=ord($content[$i]);
        $dump=$dump." ".$hex[$val/16].$hex[$val%16];
    }
    par("");
    par($title);
    par($dump);
}




Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: encode & decode Pin
mryazdani26-Sep-11 9:58
mryazdani26-Sep-11 9:58 
Questionprevent Click Jacking in PHP Pin
Shama Shahzadi20-Sep-11 19:07
Shama Shahzadi20-Sep-11 19:07 
AnswerRe: prevent Click Jacking in PHP Pin
Mohibur Rashid30-Sep-11 21:30
professionalMohibur Rashid30-Sep-11 21:30 
QuestionCurrency Converter using PHP Pin
lovelyMAT20-Sep-11 9:32
lovelyMAT20-Sep-11 9:32 
AnswerRe: Currency Converter using PHP Pin
CodingLover21-Sep-11 21:54
CodingLover21-Sep-11 21:54 
AnswerRe: Currency Converter using PHP Pin
Smithers-Jones22-Sep-11 1:01
Smithers-Jones22-Sep-11 1:01 
QuestionGenerate quotation using FPDF Pin
Shah Rizal13-Sep-11 20:59
Shah Rizal13-Sep-11 20:59 
AnswerRe: Generate quotation using FPDF Pin
Mohibur Rashid14-Sep-11 17:42
professionalMohibur Rashid14-Sep-11 17:42 
GeneralRe: Generate quotation using FPDF Pin
Shah Rizal14-Sep-11 21:54
Shah Rizal14-Sep-11 21:54 
GeneralReview of Python Tools for Visual Studio Pin
AditSheth13-Sep-11 20:35
AditSheth13-Sep-11 20:35 
GeneralRe: Review of Python Tools for Visual Studio Pin
Pete O'Hanlon13-Sep-11 22:01
mvePete O'Hanlon13-Sep-11 22:01 
Questionxml to html Pin
AndyInUK13-Sep-11 1:00
AndyInUK13-Sep-11 1:00 
AnswerRe: xml to html Pin
Matt Meyer13-Sep-11 11:19
Matt Meyer13-Sep-11 11:19 
AnswerRe: xml to html Pin
cjoki15-Sep-11 7:31
cjoki15-Sep-11 7:31 
AnswerRe: xml to html Pin
timoteui21-Sep-11 21:18
timoteui21-Sep-11 21:18 
QuestionOpenGL PinPopular
Iranian MM12-Sep-11 5:56
Iranian MM12-Sep-11 5:56 
AnswerRe: OpenGL Pin
TheGreatAndPowerfulOz12-Sep-11 12:32
TheGreatAndPowerfulOz12-Sep-11 12:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.