Hi;
I have a file editing app in the works that is supposed to work with
custom CSM system I
am working on.
I noticed that in my source code text editor (BBEdit on Mac), the
function name saveFile
is highlighted as if it is built in.
I queried php.net for it and got references to member functions of
other class definitions.
Since this method is defined within my custom class def, I presume
there would be no conflict?
The class I wrote for this is NOT an extension of any other classes
and I have no other class
that extend from it. My saveFile method is called statically as a
private member function from
within the the class.
It is working as is, as expected, but I presume that I might run into
some liabilities related to
this.
Thanks for time and attention
JK
Code:
class _LAB
{
private static $_input = array();
public function __construct($_input)
{
self::$_input = $_input; // $_GET || $_POST vars
}
public function caller()
{
switch(self::$_input['act'])
{
case 'getFile':
return self::showScript();
break;
case 'write';
return self::saveFile();
break;
case 'exec';
return self::runExec();
break;
case 'iWrite';
return self::fileWrite();
break;
case 'newFile';
return self::newFileWrite();
break;
default:
return "_LAB->caller error: unacceptiible post
value for act";
break;
}
}
// ...etc...
private function saveFile()
{
// html textarea seems to send "\n\r" line breaks.
// html textarea markup can be loaded into a
containing textarea element IF
// the closing tag forward slash IS ESCAPED: <\/
textarea>,
// other wise the browser will freak out and smear
markup and code all over the window.
// I have had no other problem loading html markup
into a textarea in another html page for editing.
$_script = str_replace("\r", "", stripslashes(self::
$_input['FT']));
$_tmp = explode('-', self::$_input['doFile']);
$_fileToWrite = getcwd().$_tmp[1];
$_fileTrunk = basename(getcwd()).$_tmp[1];
if(is_writable($_fileToWrite))
{
$_fw = fopen($_fileToWrite, 'w');
fwrite($_fw, $_script);
fclose($_fw);
return self::showScript();
}
else
{
return "_LAB->saveFile error: ".$_fileTrunk." not
writable by web server user";
}
}
// etc...
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php