Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@olleolleolle
Created August 10, 2010 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olleolleolle/8525ade0ba31171bf618 to your computer and use it in GitHub Desktop.
Save olleolleolle/8525ade0ba31171bf618 to your computer and use it in GitHub Desktop.
Stop calling set_magic_quotes_runtime
Index: /Users/olle/opensource/php/PhpDocumentor-trunk/phpDocumentor/Converters/PDF/default/class.pdf.php
===================================================================
--- /Users/olle/opensource/php/PhpDocumentor-trunk/phpDocumentor/Converters/PDF/default/class.pdf.php (revision 302079)
+++ /Users/olle/opensource/php/PhpDocumentor-trunk/phpDocumentor/Converters/PDF/default/class.pdf.php (working copy)
@@ -1514,9 +1514,10 @@
// simple utility to convert them from pfa to pfb.
$fp = fopen($fbfile,'rb');
$tmp = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
+ if ($tmp === 1) {
+ throw new Exception('magic_quotes_runtime must be 0 to be able to read PFB file');
+ }
$data = fread($fp,filesize($fbfile));
- set_magic_quotes_runtime($tmp);
fclose($fp);
// create the font descriptor
@@ -2641,7 +2642,9 @@
// read in a png file, interpret it, then add to the system
$error=0;
$tmp = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
+ if ($tmp === 1) {
+ throw new Exception('magic_quotes_runtime must be 0 to be able to read PNG file');
+ }
$fp = @fopen($file,'rb');
if ($fp){
$data='';
@@ -2653,7 +2656,6 @@
$error = 1;
$errormsg = 'trouble opening file: '.$file;
}
- set_magic_quotes_runtime($tmp);
if (!$error){
$header = chr(137).chr(80).chr(78).chr(71).chr(13).chr(10).chr(26).chr(10);
@@ -2856,9 +2858,10 @@
$fp=fopen($img,'rb');
$tmp = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
+ if ($tmp === 1) {
+ throw new Exception('magic_quotes_runtime must be 0 to be able to read JPEG file');
+ }
$data = fread($fp,filesize($img));
- set_magic_quotes_runtime($tmp);
fclose($fp);
@@ -2907,7 +2910,9 @@
$fp=fopen($tmpName,'rb');
$tmp = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
+ if ($tmp === 1) {
+ throw new Exception('magic_quotes_runtime must be 0 to be able to read image file');
+ }
$fp = @fopen($tmpName,'rb');
if ($fp){
$data='';
@@ -2920,7 +2925,6 @@
$errormsg = 'trouble opening file';
}
// $data = fread($fp,filesize($tmpName));
- set_magic_quotes_runtime($tmp);
// fclose($fp);
unlink($tmpName);
$this->addJpegImage_common($data,$x,$y,$w,$h,$imageWidth,$imageHeight);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment