"Fossies" - the Fresh Open Source Software Archive

Member "ide.php-1.5.3/index.php" (28 Sep 2009, 20640 Bytes) of package /linux/www/old/ide.php-1.5.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 /*******************************************************************************\
    3 *    IDE.PHP, a web based editor for quick PHP development                     *
    4 *    Copyright (C) 2000  Johan Ekenberg                                        *
    5 *                                                                              *
    6 *    This program is free software; you can redistribute it and/or modify      *
    7 *    it under the terms of the GNU General Public License as published by      *
    8 *    the Free Software Foundation; either version 2 of the License, or         *
    9 *    (at your option) any later version.                                       *
   10 *                                                                              *
   11 *    This program is distributed in the hope that it will be useful,           *
   12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of            *
   13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
   14 *    GNU General Public License for more details.                              *
   15 *                                                                              *
   16 *    You should have received a copy of the GNU General Public License         *
   17 *    along with this program; if not, write to the Free Software               *
   18 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  *
   19 *                                                                              *
   20 *    To contact the author regarding this program,                             *
   21 *    please use this email address: <ide.php@ekenberg.se>                      *
   22 \*******************************************************************************/
   23 
   24 error_reporting(E_ERROR | E_WARNING | E_PARSE);
   25 set_magic_quotes_runtime(0);
   26 
   27 include ("./Page.phpclass");
   28 include ("./Conf.phpclass");
   29 
   30    $Ide = new Ide;
   31 
   32 class Ide {
   33    var $code, $alert_message, $success_message;
   34    var $IDE_homepage_url    = "http://www.ekenberg.se/php/ide/";
   35    var $GPL_link        = "<A HREF='http://www.gnu.org/copyleft/gpl.html'>GNU General Public License</A>";
   36    var $PHP_link        = "<A HREF='http://www.php.net'>PHP</A>";
   37    var $IDE_version     = "1 . 5";
   38 
   39 function Ide() {
   40    global $_POST, $HTTP_GET_VARS;
   41    $this->Conf = new Conf;
   42    $this->Out  = new Page;
   43 
   44 /*
   45 ** Remove slashes if necessary, put code in $this->code
   46 */
   47    if (isset($_POST['code'])) {
   48       if (get_magic_quotes_gpc()) {
   49          $this->code = stripslashes($_POST['code']);
   50       }
   51       else {
   52          $this->code = $_POST['code'];
   53       }
   54    }
   55 
   56 /*
   57 ** Get code from code file if not submitted through form.
   58 */ 
   59    if ((! isset($this->code)) && (file_exists($this->Conf->Code_file))) {
   60       $this->code = join ("", (file ($this->Conf->Code_file)) );
   61    }
   62 
   63 /*
   64 ** Since the code is displayed in a <TEXTAREA>, it can't contain the tag </TEXTAREA>,
   65 ** since that would break our editor :/ Thus we replace it with </ideTEXTAREA>
   66 ** and put it in $this->textarea_safe_code. The reverse substitution is first
   67 ** performed on $this->code, to restore any previous replacements.
   68 */
   69    $this->code          = eregi_replace("</ide(TEXTAREA)>", "</\\1>", $this->code);
   70    $this->textarea_safe_code    = $this->make_textarea_safe($this->code);
   71 
   72 /*
   73 ** Htmlentities are not literally shown inside TEXTAREA in some (all?) browsers.
   74 */
   75    if ($this->Conf->Protect_entities)
   76       $this->code       = eregi_replace("(&amp;)+&", "&", $this->code);
   77 
   78 /*
   79 ** Remove \r\f if desired, needed for cgi on UNIX
   80 */
   81    if ($this->Conf->Unix_newlines) {
   82       $this->code       = preg_replace("/[\r\f]/", "", $this->code);
   83    }
   84 
   85 /*
   86 ** What file are we working with?
   87 */
   88    $this->Conf->Current_file = $_POST['Current_file'] ? $_POST['Current_file'] : $this->Conf->Tmp_file;
   89 
   90 /*
   91 ** Check our environment.
   92 */
   93    if ($error = $this->Conf->Is_bad_environment()) {
   94       print $this->Out->html_top();
   95       print "<H3><BLOCKQUOTE>$error</BLOCKQUOTE></H2>\n";
   96       print $this->Out->html_bottom();
   97       exit;
   98    }
   99 
  100 /*
  101 ** Always save the code in our code and tmp files
  102 */
  103    if (isset($this->code)) {
  104       $FH_CODE = fopen ($this->Conf->Code_file, "w");
  105       $FH_TMP  = fopen ($this->Conf->Tmp_file, "w");
  106       fputs  ($FH_CODE, $this->code); 
  107       fputs  ($FH_TMP, $this->code);
  108       fclose ($FH_CODE);
  109       fclose ($FH_TMP);
  110    }
  111 
  112 /*
  113 ** These options are saved every time
  114 */
  115    $this->Conf->save_to_file(array('Eval_suffix'));
  116 
  117 /*
  118 ** Set file permissions as desired
  119 */
  120    if ($this->Conf->Eval_executable) {
  121       chmod ($this->Conf->Tmp_file, 0755);
  122    }
  123    else {
  124       chmod ($this->Conf->Tmp_file, 0644);
  125    }
  126 
  127 /*
  128 ** Print-and-exit-immediately stuff
  129 */
  130    if ($HTTP_GET_VARS['action'] == "fancy_view_source") {
  131       print $this->fancy_view_source();
  132       exit;
  133    }
  134 
  135    if ($_POST['action'] == "about") {
  136       print $this->Out->html_top();
  137       print $this->about_page();
  138       print $this->Out->html_bottom();
  139       exit;
  140    }
  141 
  142    if ($_POST['action'] == "options") {
  143       if ($_POST['options_action'] == "add_suffix") {
  144          $add_suffix = ereg_replace("^\.*(.+)", ".\\1", trim($_POST['add_remove_suffix']));
  145          if ($add_suffix && (! in_array($add_suffix, $this->Conf->Eval_suffix_list))) {
  146             $this->Conf->Eval_suffix_list[] = $add_suffix;
  147          }
  148          $this->options_page_save(array('Fancy_view_line_numbers', 'Protect_entities', 
  149                 'Eval_executable', 'Unix_newlines', 'Eval_suffix_list'));
  150       }
  151       elseif ($_POST['options_action'] == "remove_suffix") {
  152          $remove_suffix = ereg_replace("^\.*(.+)", ".\\1", trim($_POST['add_remove_suffix']));
  153          if ($remove_suffix && (in_array($remove_suffix, $this->Conf->Eval_suffix_list))) {
  154             reset ($this->Conf->Eval_suffix_list);
  155             for ($i=0; $i<sizeof($this->Conf->Eval_suffix_list); $i++) {
  156                if (ereg("^$remove_suffix$", $this->Conf->Eval_suffix_list[$i])) {
  157                   unset($this->Conf->Eval_suffix_list[$i]);
  158                }
  159             }
  160          }
  161          $this->options_page_save(array('Fancy_view_line_numbers', 'Protect_entities', 
  162                 'Eval_executable', 'Unix_newlines', 'Eval_suffix_list'));
  163       }
  164       print $this->Out->html_top();
  165       print $this->options_page();
  166       print $this->Out->html_bottom();
  167       exit;
  168    }
  169 
  170 /*
  171 ** Print top of page
  172 */
  173    print $this->Out->html_top();
  174 
  175 /*
  176 ** Act according to 'action'
  177 */
  178    if ($_POST['action'] == "eval") {
  179       print $this->js_open_code_window ($this->Conf->Tmp_file);
  180    }
  181    elseif ($_POST['action'] == "source_viewer") {
  182       print $this->js_open_code_window ("{$_SERVER['PHP_SELF']}?action=fancy_view_source&file={$this->Conf->Tmp_file}");
  183    }
  184    elseif ($_POST['action'] == "save_as") {
  185       if (! strlen($_POST['save_as_filename'])) {
  186          $this->alert_message = "Can't save file without a filename!!";
  187       }
  188       elseif ((! $_POST['overwrite_ok']) && (file_exists("{$this->Conf->Data_dir}/{$_POST['save_as_filename']}"))) {
  189          $this->alert_message = "The file <B>{$this->Conf->Data_dir}/{$_POST['save_as_filename']}</B> already exists! 
  190                    Please choose another name, or check \"Replace\".";
  191       }
  192       else {
  193          if ($FH_SAVEAS = @fopen ("{$this->Conf->Data_dir}/{$_POST['save_as_filename']}", "w")) {
  194             fputs  ($FH_SAVEAS, $this->code);
  195             fclose ($FH_SAVEAS);
  196             $this->success_message = "Current code was saved to file: <B>{$this->Conf->Data_dir}/{$_POST['save_as_filename']}</B>!";
  197          }
  198          else {
  199             $this->alert_message = "Could not save to file <B>{$this->Conf->Data_dir}/{$_POST['save_as_filename']}</B>: $php_errormsg";
  200          }
  201          $this->Conf->Current_file = "{$this->Conf->Data_dir}/{$_POST['save_as_filename']}";
  202       }
  203    }
  204    elseif ($_POST['action'] == "open_file") {
  205       $this->textarea_safe_code = join ("", (file ("{$this->Conf->Data_dir}/{$_POST['code_file_name']}")));
  206       if (get_magic_quotes_runtime()) $this->textarea_safe_code = stripslashes($this->textarea_safe_code);
  207       $this->textarea_safe_code = $this->make_textarea_safe($this->textarea_safe_code);
  208       $this->Conf->Current_file = "{$this->Conf->Data_dir}/{$_POST['code_file_name']}";
  209       $_POST['save_as_filename'] = $_POST['code_file_name'];
  210    }
  211    elseif ($_POST['action'] == "erase_file") {
  212       if (unlink ("{$this->Conf->Data_dir}/{$_POST['code_file_name']}")) {
  213          $this->Conf->Current_file = $this->Conf->Tmp_file;
  214          $_POST['save_as_filename'] = $_POST['overwrite_ok'] = "";
  215          $this->success_message = "The file <B>{$this->Conf->Data_dir}/{$_POST['code_file_name']}</B> was erased!"; 
  216       }
  217    }
  218    elseif ($_POST['action'] == "save_size") {
  219       $this->Conf->save_to_file(array('Code_cols', 'Code_rows'));
  220    }
  221    elseif ($_POST['action'] == "show_template") {
  222       $this->textarea_safe_code = $this->make_textarea_safe($this->Conf->Code_template);
  223    }
  224    elseif ($_POST['action'] == "save_as_template") {
  225       $this->Conf->Code_template = $this->code;
  226       $this->Conf->save_to_file(array('Code_template'));
  227    }
  228    elseif ($_POST['action'] == "save_options") {
  229       $this->options_page_save(array('Fancy_view_line_numbers', 'Protect_entities', 
  230                 'Eval_executable', 'Unix_newlines', 'Http_auth_username', 'Http_auth_password',));
  231       $this->success_message = "Ide.php options were saved!"; 
  232    }
  233 
  234 /*
  235 ** Print the main page and exit
  236 */
  237    print $this->main_page();
  238    print $this->Out->html_bottom();
  239    exit;
  240 }
  241 
  242 /*
  243 ** Functions
  244 */
  245 
  246 function options_page() {
  247    $fancy_view_line_numbers_checked = $this->Conf->Fancy_view_line_numbers ? "CHECKED" : "";
  248    $protect_entities_checked = $this->Conf->Protect_entities ? "CHECKED" : "";
  249    $eval_executable_checked = $this->Conf->Eval_executable ? "CHECKED" : "";
  250    $unix_newlines_checked = $this->Conf->Unix_newlines ? "CHECKED" : "";
  251    reset($this->Conf->Eval_suffix_list);
  252    $sections = array(
  253     "<P><INPUT TYPE='CHECKBOX' NAME='Fancy_view_line_numbers' VALUE='1' $fancy_view_line_numbers_checked>
  254        Print line numbers in 'Fancy view'</P>",
  255     "<P><INPUT TYPE='CHECKBOX' NAME='Protect_entities' VALUE='1' $protect_entities_checked>
  256        Protect HTML entities (IE4/5)</P>",
  257     "<P CLASS='indentall'>Suffix list:<BR><I>&nbsp;" . join(" &nbsp;", $this->Conf->Eval_suffix_list) . "</I></P>\n
  258      <P CLASS='indentall'>Add/remove suffix:
  259        <BR><INPUT TYPE='text' NAME='add_remove_suffix' SIZE='8'>
  260        &nbsp; <INPUT TYPE='submit' VALUE='Add' onClick='document.options_form.options_action.value=\"add_suffix\"; document.options_form.action.value=\"options\"'>
  261        <INPUT TYPE='submit' VALUE='Remove' onClick='document.options_form.options_action.value=\"remove_suffix\"; document.options_form.action.value=\"options\"'></P>\n
  262      <P><INPUT TYPE='CHECKBOX' NAME='Eval_executable' VALUE='1' $eval_executable_checked>Make executable (CGI on UNIX)</P>\n
  263      <P><INPUT TYPE='CHECKBOX' NAME='Unix_newlines' VALUE='1' $unix_newlines_checked>
  264        Use UNIX newlines (CGI on UNIX)</P>",
  265         "<P CLASS='indentall'>To make 'Fancy view' work under password protection:<P>
  266          <P CLASS='indentall'><TABLE BORDER='0' WIDTH='70%' CELLPADDING='0' CELLSPACING='0'>
  267          <TR><TD><P CLASS='noindent'>Username:</P></TD>
  268          <TD><P CLASS='noindent'>Password:</P></TD></TR>
  269          <TR><TD><INPUT TYPE='text' NAME='Http_auth_username' SIZE='12' VALUE='{$this->Conf->Http_auth_username}'></TD>
  270          <TD><INPUT TYPE='text' NAME='Http_auth_password' SIZE='12' VALUE='{$this->Conf->Http_auth_password}'></TD></TR></TABLE>
  271          </P>");
  272    $ret .= "<DIV ALIGN='CENTER'>\n";
  273    $ret .= "<H2>I D E . P H P &nbsp; O P T I O N S</H2></DIV>\n";
  274    $ret .= "<FORM NAME='options_form' METHOD='POST' ACTION='{$_SERVER['PHP_SELF']}'>\n";
  275    $ret .= "<INPUT TYPE='hidden' NAME='action' VALUE='save_options'>\n";
  276    $ret .= "<INPUT TYPE='hidden' NAME='options_action' VALUE=''>\n";
  277    while (list(,$content) = each($sections)) {
  278       $ret .= "<BR>\n";
  279       $ret .= $this->Out->info_box(400, $content);
  280    }
  281    $ret .= "<BR><DIV ALIGN='CENTER'>\n";
  282    $ret .= "<A HREF='javascript: document.options_form.submit()' CLASS='netscapesucks'>[ r e t u r n ]</A></DIV>\n";
  283    $ret .= "</FORM>\n";
  284    return($ret);
  285 }
  286 
  287 function about_page() {
  288    $sections = array(
  289     "<P><B>I d e . p h p &nbsp; v e r s i o n &nbsp; {$this->IDE_version}</B></P>\n",
  290     "<P>Ide.php is distributed under the {$this->GPL_link}</P>",
  291         "<P>Ide.php is developed by <A HREF='mailto:johan@ekenberg.se'>Johan Ekenberg</A>,
  292            a Swedish Internet consultant who, besides web development with {$this->PHP_link}, does a lot of Perl, C, Linux and bass playing.</P>\n",
  293         "<P>Visit the <A HREF='{$this->IDE_homepage_url}'>Ide.php homepage</A>.\n",
  294         "<P>Feedback and suggestions are always welcome, please use the address
  295            <A HREF='mailto:ide.php@ekenberg.se'>ide.php@ekenberg.se</A> for email related to Ide.php</P>");
  296 
  297    $ret .= "<DIV ALIGN='CENTER'>\n";
  298    $ret .= "<H2>A B O U T &nbsp; I D E . P H P</H2></DIV>\n";
  299 
  300    while (list(,$content) = each($sections)) {
  301       $ret .= "<BR>\n";
  302       $ret .= $this->Out->info_box(400, $content);
  303    }
  304    $ret .= "<BR><DIV ALIGN='CENTER'>\n";
  305    $ret .= "<A HREF='{$_SERVER['PHP_SELF']}' CLASS='netscapesucks'>[ r e t u r n ]</A></DIV>\n";
  306    return($ret);
  307 }
  308 
  309 function main_page() {
  310    global $_POST;
  311    $suffix_list_selected[$this->Conf->Eval_suffix] = "SELECTED";
  312    while (list(,$suffix) = each($this->Conf->Eval_suffix_list)) {
  313       $suffix_select_options .= "<OPTION VALUE='$suffix' {$suffix_list_selected[$suffix]}>$suffix\n";
  314    }
  315    $ret .= "<DIV ALIGN='CENTER'>\n";
  316    $ret .= "<H2>I D E . P H P</H2></DIV>\n";
  317    $ret .= "<FORM NAME='main_form' METHOD='POST' ACTION='{$_SERVER['PHP_SELF']}'>\n";
  318    $ret .= "<INPUT TYPE='hidden' NAME='action' VALUE=''>\n";
  319    $ret .= "<INPUT TYPE='hidden' NAME='Current_file' VALUE='{$this->Conf->Current_file}'>\n";
  320    $ret .= $this->Out->begin_invisible_table("", array("CELLPADDING='1'", "CELLSPACING='0'", "ALIGN='center'"));
  321    $ret .= "<TR><TD>\n";
  322    $ret .= "<FONT COLOR='{$this->Conf->Alert_message_color}' FACE='MS Sans Serif, Arial'>{$this->alert_message}</FONT>\n";
  323    $ret .= "<FONT COLOR='{$this->Conf->Success_message_color}' FACE='MS Sans Serif, Arial'>{$this->success_message}</FONT>\n";
  324    $ret .= "</TD</TR>\n";
  325    $ret .= "<TR><TD>\n";
  326    $ret .= $this->Out->start_box_table();
  327    $ret .= "<TR BGCOLOR='#FFE56A'><TD>\n";
  328    $ret .= "<INPUT TYPE='submit' VALUE='- RUN -' onClick='main_form.action.value=\"eval\"; main_form.submit()'></TD>\n";
  329    $ret .= "<TD ALIGN='center'>\n";
  330    $ret .= "<INPUT TYPE='submit' VALUE='Fancy view' onClick='main_form.action.value=\"source_viewer\"; main_form.submit()'></TD>\n";
  331    $ret .= "<TD ALIGN='center'>\n";
  332    $ret .= "<INPUT TYPE='submit' VALUE='Open tpl' onClick='main_form.action.value=\"show_template\"; return confirm(\"Replace current code with new template?\")'></TD>\n";
  333    $ret .= "<TD ALIGN='center'>\n";
  334    $ret .= "<INPUT TYPE='submit' VALUE='Save as tpl' onClick='main_form.action.value=\"save_as_template\"; return confirm(\"Replace current template?\")'></TD>\n";
  335    $ret .= "<TD ALIGN='center'>\n";
  336    $ret .= "<INPUT TYPE='submit' VALUE='Clear' onClick='if (confirm(\"Do you really want to clear the codearea??\")) {main_form.code.value=\"\"}; return false'></TD>\n";
  337    $ret .= "<TD ALIGN='right' COLSPAN='2'>\n";
  338    $ret .= "<SELECT NAME='code_file_name'>\n";
  339 
  340    $data_dir_obj = dir ($this->Conf->Data_dir);
  341    $selected[$this->Conf->Current_file] = "SELECTED";
  342    while (false !== ($entry = $data_dir_obj->read())) $my_files[] = $entry;
  343    sort($my_files);
  344    while (strlen($file=next($my_files))) {
  345       if (ereg("^\.{1,2}$", $file)) continue;
  346       $my_fullname = "{$data_dir_obj->path}/$file";
  347       $ret .= "<OPTION VALUE='$file' {$selected[$my_fullname]}>$my_fullname</OPTION>\n";
  348    }
  349    $data_dir_obj->close();
  350 
  351    $ret .= "</SELECT></TD></TR>\n";
  352    $ret .= "<TR BGCOLOR='#FFE56A'><TD COLSPAN='5' CLASS='netscapesucks'>\n";
  353    $ret .= "<INPUT TYPE='submit' VALUE='Save as' onClick='main_form.action.value=\"save_as\"; main_form.submit()'>\n";
  354    $ret .= "{$this->Conf->Data_dir}/<INPUT TYPE='text' NAME='save_as_filename' VALUE='{$_POST['save_as_filename']}'>\n";
  355    $ret .= "Replace: <INPUT TYPE='CHECKBOX' NAME='overwrite_ok' VALUE='CHECKED' {$_POST['overwrite_ok']}></TD>\n";
  356    $ret .= "<TD ALIGN='right' COLSPAN='2'>\n";
  357    $ret .= "<INPUT TYPE='submit' VALUE='Open' onClick='main_form.action.value=\"open_file\"'>\n";
  358    $ret .= "<INPUT TYPE='submit' VALUE='Erase' onClick='main_form.action.value=\"erase_file\"; return confirm(\"Erase: {$this->Conf->Data_dir}/\"+ main_form.code_file_name.value+ \" ?\")'>\n";
  359    $ret .= "</TD></TR>\n";
  360    $ret .= "<TR BGCOLOR='#FFE56A'><TD COLSPAN='7'>\n";
  361    $ret .= "<TEXTAREA COLS='{$this->Conf->Code_cols}' ROWS='{$this->Conf->Code_rows}' NAME='code'>{$this->textarea_safe_code}</TEXTAREA>\n";
  362    $ret .= "</TD></TR>\n";
  363    $ret .= "<TR BGCOLOR='#FFE56A'><TD COLSPAN='3' CLASS='netscapesucks'>\n";
  364    $ret .= "Rows: <INPUT TYPE='text' NAME='Code_rows' VALUE='{$this->Conf->Code_rows}' SIZE='3' MAXLENGTH='3' CLASS='netscapesucks2'>\n";
  365    $ret .= "Columns: <INPUT TYPE='text' NAME='Code_cols' VALUE='{$this->Conf->Code_cols}' SIZE='3' MAXLENGTH='3' CLASS='netscapesucks2'>\n";
  366    $ret .= "<INPUT TYPE='submit' VALUE='Save size' onClick='main_form.action.value=\"save_size\"; main_form.submit()'></TD>\n";
  367    $ret .= "<TD ALIGN='center' COLSPAN='2'><SPAN CLASS='netscapesucks'>Run as:</SPAN> <SELECT NAME='Eval_suffix'>$suffix_select_options</SELECT></TD>\n";
  368    $ret .= "<TD ALIGN='center'><INPUT TYPE='submit' VALUE='Options' onClick='main_form.action.value=\"options\"; main_form.submit()'></TD>\n";
  369    $ret .= "<TD ALIGN='right'><INPUT TYPE='submit' VALUE='About' onClick='main_form.action.value=\"about\"; main_form.submit()'>\n";
  370    $ret .= "</TD></TR>\n";
  371    $ret .= $this->Out->end_box_table();
  372    $ret .= "</TD></TR>\n";
  373    $ret .= $this->Out->end_invisible_table();
  374    $ret .= "</FORM>\n";
  375    return ($ret);
  376 }
  377 
  378 function fancy_view_source() {
  379    global $HTTP_GET_VARS;
  380    $row_num_spacer = "&nbsp;&nbsp;";
  381    $ret = "";
  382    if ($HTTP_GET_VARS['internal_request'] || (! $this->Conf->Fancy_view_line_numbers)) {
  383       show_source($HTTP_GET_VARS['file']);
  384       return;
  385    }
  386    else {
  387       if ($this->Conf->Http_auth_username && $this->Conf->Http_auth_password) {
  388          $internal_url = "http://{$this->Conf->Http_auth_username}:{$this->Conf->Http_auth_password}@{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?action=fancy_view_source&file={$this->Conf->Tmp_file}&internal_request=1";
  389       }
  390       else {
  391          $internal_url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?action=fancy_view_source&file={$this->Conf->Tmp_file}&internal_request=1";
  392       }
  393       if (! $code_array = @file($internal_url)) {
  394          $ret .= "<H2>An error occured</H2>
  395                   <P>If you are using password protection for Ide.php, please enter username and password in the 'Options' page.</P>";
  396       }
  397       else {
  398          $fancy_code_str = join("", $code_array);
  399          $fancy_code_array = split("<(br|BR)[[:space:]]*/*>", $fancy_code_str);
  400          if (sizeof($fancy_code_array)) {
  401             $row_num_width = strlen(sizeof($fancy_code_array));
  402             $ret .= ereg_replace("^<code>", "<code><FONT COLOR='{$this->Conf->Fancy_line_number_color}'>" . sprintf("%0{$row_num_width}d", 1) . "$row_num_spacer</FONT>", ereg_replace("[[:space:]]", "", $fancy_code_array[0]));
  403             for ($i=1;$i<sizeof($fancy_code_array);$i++) {
  404                $row_num = sprintf ("%0{$row_num_width}d", $i+1);
  405                $ret .= "\n<BR><FONT COLOR='{$this->Conf->Fancy_line_number_color}'>$row_num$row_num_spacer</FONT>" . trim($fancy_code_array[$i]);
  406             }
  407          }
  408       }
  409    }
  410    return ($ret);
  411 }
  412 
  413 function make_textarea_safe($code) {
  414    $safe_code = eregi_replace("</(TEXTAREA)>", "</ide\\1>", $code);   
  415    if ($this->Conf->Protect_entities)
  416       $safe_code = eregi_replace("&", "&amp;", $safe_code);
  417    return $safe_code;
  418 }
  419 
  420 function js_open_code_window ($url) {
  421    $ret = "";
  422    $ret .= "<SCRIPT LANGUAGE='JavaScript'>\n";
  423    $ret .= "var eval_window = window.open('$url','Foo');\n";
  424    $ret .= "eval_window.focus();\n";
  425    $ret .= "</SCRIPT>\n";
  426    return $ret;
  427 }
  428 
  429 function options_page_save($var_names_array) {
  430    global $_POST;
  431    $this->Conf->Fancy_view_line_numbers = $_POST['Fancy_view_line_numbers'] ? 1 : 0;
  432    $this->Conf->Protect_entities = $_POST['Protect_entities'] ? 1 : 0;
  433    $this->Conf->Eval_executable = $_POST['Eval_executable'] ? 1 : 0;
  434    $this->Conf->Unix_newlines = $_POST['Unix_newlines'] ? 1 : 0;
  435    $this->Conf->save_to_file($var_names_array);
  436 }
  437 
  438 }?>