exploring show_source

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kAsPeR
Forum Newbie
Posts: 2
Joined: Fri Sep 26, 2003 10:48 pm
Location: wouldn't u like to know...

exploring show_source

Post by kAsPeR »

hm...well, i can't get this code to work...even after overriding safe_mode(i'm on tripod uk)
ne one have ne suggestions?

...btw, blah.php is this program that's running the code...

Code: Select all

<?php
ini_set("safe_mode", "0");
ob_start();
// Show source of file
show_source ( 'blah.php' );
$contents = ob_get_contents();
ob_end_clean();

$contents = explode('<br>', @contents);
echo '<html><body>';
foreach ($contents as $line){
    echo '<font color="cccccc"><ul>'.$line.'</ul></font><br>';
}
echo '</body></html>';
?>
?>
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Code: Select all

$contents = explode('<br>', @contents);
and @ ?
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

make sure you change the @content to $content cuz that doesn't seem to be a function anyways
kAsPeR
Forum Newbie
Posts: 2
Joined: Fri Sep 26, 2003 10:48 pm
Location: wouldn't u like to know...

Post by kAsPeR »

k...well, this is my new code...does the same thing tho....

Code: Select all

<?php
ini_set("safe_mode", "0");
ob_start();
// Show source of file
show_source ( 'blah.php' );
$contents = ob_get_contents();
ob_end_clean();

$explode_contents = explode('<br>', $contents);
echo '<html><body>';
foreach ($explode_contents as $line){
    echo '<font color="cccccc"><ul>'.$line.'</ul></font><br>';
}
echo '</body></html>';
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you can't change the safemode settings via ini_set()
http://php.net/manual/en/features.safe-mode.php wrote:safe_mode "0" PHP_INI_SYSTEM
safe_mode_gid "0" PHP_INI_SYSTEM
safe_mode_include_dir NULL PHP_INI_SYSTEM
safe_mode_exec_dir "" PHP_INI_SYSTEM
safe_mode_allowed_env_vars PHP_ PHP_INI_SYSTEM
safe_mode_protected_env_vars LD_LIBRARY_PATH PHP_INI_SYSTEM
open_basedir NULL PHP_INI_SYSTEM
disable_functions "" PHP_INI_SYSTEM
disable_classes "" PHP_INI_SYSTEM
and
http://php.net/manual/en/configuration.changes.php#configuration.changes.other wrote:PHP_INI_SYSTEM 4 Entry can be set in php.ini or httpd.conf
wouldn't make much sense otherwise (from the provider's point of view)

But if your script can get the file's content somehow mixed highlight_string ( string str [, bool return]) might be useful

btw:
http://php.net/nl2br wrote:Note: Starting with PHP 4.0.5, nl2br() is now XHTML compliant.
and that's true for show_source et al. as well. <br /> is used instead of <br>
Post Reply