Can anyone translate this for me...

Started by Microcyb, November 08, 2004, 05:54:02 PM

Previous topic - Next topic

Microcyb

I need this perl script in PHP.

      # Save the file
      my $sFileName = sprintf("W_%X", $iDream_ID);
      $sFileName =~ /(\w+)/ || die "Bad filename";
      $sFileName = $1;

      my $sScreenshot = $CONST_LocalScreenshotRoot . $sFileName. ".jpg";

      # - Screenshot
      open(fScreenshot, "+>$sScreenshot") || die "Failed to Open Error File";
      binmode(fScreenshot);
        print fScreenshot substr($sBuffer, 0, $Input{'CI_ScreenshotSize'});
      close fScreenshot;
      chmod(0664, $sScreenshot);

      # - Dream
      my $sDream = $CONST_LocalDreamRoot . $sFileName. ".Dream";
      open(fDream, "+>$sDream") || die "Failed to Open Error File";
      binmode(fDream);
        print fDream substr($sBuffer, $Input{'CI_ScreenshotSize'}, $Input{'CI_DreamSize'});
      close fDream;
      chmod(0664, $sDream);

[Unknown]

$filename = sprintf('W_%X', $dream_id);
if (preg_match('~[\w]+~', $filename, $match) == 0)
   die('Bad filename!');
$filename = $match[1];

$screenshot = LOCAL_SCREENSHOT_ROOT . $filename . '.jpg';

$fp = fopen($screenshot, 'wb');
if (!$fp)
   die('Failed to open screenshot file.');
fwrite($fp, substr($buffer, 0, $_REQUEST['CI_ScreenshotSize']));
fclose($fp);
chmod($screenshot, 0664);

$dream = LOCAL_DREAM_ROOT . $filename . '.Dream';

$fp = fopen($dream, 'wb');
if (!$fp)
   die('Failed to open dream file!');
fwrite($fp, substr($buffer, $_REQUEST['CI_ScreenshotSize'], $_REQUEST['CI_DreamSize']));
fclose($fp);
chmod($dream, 0664);

Hungarian notation sux0r.

-[Unknown]

Saleh

man, PHP is 10000 times easier to read than perl !! ;D

We don't need a reason to help people

Microcyb

Can we change your name from [Unknown] to [De Man]?


[Unknown]

I'm afraid that we cannot.... think of how many posts I would have to change the signature on!!

-[Unknown]

Microcyb

OK one last one ( I hope).
What would the PHP translation be of these lines:

exists $Input{'CI_Title'} || die 'Input Parameter Not Found CI_Title';
$hUtils->UnTaint_String(\$Input{'CI_DreamTitle'});


[Unknown]

if (!isset($_REQUEST['CI_Title']))
   die('Input parameter CI_Title not found!');
$utils->untaint_string(&$_REQUEST['CI_DreamTitle']);

More or less...

-[Unknown]

Douglas

Quote from: [Unknown] on November 09, 2004, 03:35:57 PMI'm afraid that we cannot.... think of how many posts I would have to change the signature on!!

-[Unknown]
str_replace("[Unknown]","[De Man]",$var);  :P
Doug Hazard
* Full Stack (Web) Developer for The Catholic Diocese of Richmond
(20+ Diocesan sites, 130+ Church sites & 24 School sites)
* Sports Photographer and Media Personality
* CFB Historian
* Tech Admin for one 1M+ post, one 2M+ post and one 10M+ post sites (last two are powered by multiple servers)
* WordPress Developer (Junkie / Guru / Maven / whatever)

Kender

Quote from: Douglas on November 09, 2004, 11:50:07 PM
Quote from: [Unknown] on November 09, 2004, 03:35:57 PMI'm afraid that we cannot.... think of how many posts I would have to change the signature on!!

-[Unknown]
str_replace("[Unknown]","[De Man]",$var);  :P
back up the database to an .sql file, then open in text editor find/replace all -> Find [unknown] == replace [Da Man]
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

eFishie

Quote from: Douglas on November 09, 2004, 11:50:07 PM
Quote from: [Unknown] on November 09, 2004, 03:35:57 PMI'm afraid that we cannot.... think of how many posts I would have to change the signature on!!

-[Unknown]
str_replace("[Unknown]","[De Man]",$var); :P

Wrong, David.

str_replace($var,'[Unknown]','[De Man]');

Double :P
--Jon

Abstraction Point Electronic Music Community - We don't bite! Really! I promise!

Check out my newest song: Alive

[Unknown]

Well, that is one thing about PHP... you always have to fight the different syntaxes...

I'm still not changing my name :P.

And, in response to your pm, Microcyb... I'm afraid I don't have the time to port that much code... sorry.

-[Unknown]

Advertisement: