[Openfirst-cvscommit] base/includes/functions browserid.php,NONE,1.1.2.2 debug.php,NONE,1.6.2.2 form
Brought to you by:
xtimg
From: Jamie <ast...@us...> - 2005-08-24 21:53:34
|
Update of /cvsroot/openfirst/base/includes/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14968/includes/functions Added Files: Tag: REL1_1_BRANCH browserid.php debug.php forms.php mail.php wysiwyg.php Log Message: directory restructuring --- NEW FILE: wysiwyg.php --- <?php /* * openFIRST.base - config/functions/wysiwyg.php * * Copyright (C) 2003, * openFIRST Project * Original Author: David Di Biase<dav...@ea...> and DHTMLEditor Author: Hans-Jürgen Petrich <pe...@tr...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // A complete function to create the Javascript command for loading of the WYSIWYG function make_wysiwyg($fieldname,$height,$width,$init){ global $basepath; ?> <SCRIPT TYPE="text/javascript" language="JavaScript1.3"> <!-- !!!! important comment this !!!! document.dhtmlEditors_home='<?php echo $basepath; ?>/config/functions/wysiwyg/'; document.writeln('<'+'SCRIPT LANGUAGE="JavaScript" src="'+document.dhtmlEditors_home+'js/lib.js">'+'<'+'/SCRIPT'+'>'); document.writeln('<SCRIPT LANGUAGE="JavaScript" src="'+document.dhtmlEditors_home+'modules/button_html.js"></SCRIPT>'); // --> </SCRIPT> <textarea id="<?php echo $fieldname; ?>" name="<?php echo $fieldname; ?>" style="width:<?php echo $height; ?>px; height:<?php echo $width; ?>px;"><?php echo $init; ?></textarea> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- var myEditor = new dhtmlEditor; myEditor.registerApiModul(MODUL__toggleEditModeGetApiInfoArray('<?php echo $basepath; ?>/config/functions/wysiwyg/images/newdoc.gif')); myEditor.make_andReplaceTextarea('<?php echo $fieldname; ?>'); //--> </SCRIPT> <?php } ?> --- NEW FILE: mail.php --- <?php /* * openFIRST.base - config/functions/mail.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Tim Ginn <tim...@po...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // Purpose: Provide mail functions capable of dealing with multi-part messages. // Produces multi-part mail messages in a manner able to be used as a drop-in replacement for mail(); function multipartmail($to, $subject = "openFIRST Mailing", $message = "No message given.", $headers = "", $additionalparamaters = "") { global $header; global $footer; global $basepath; $fheader = ""; $ffooter = ""; $info = ""; $headers .= "Mime-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/alternative; boundary=openfirst-mail.boundry\r\n"; $textmessage = $message; while(stristr($textmessage,"<")) { $textmessage = str_replace(substr($textmessage, strpos($textmessage, "<"), strpos($textmessage, ">") - strpos($textmessage, "<") + 1), "", $textmessage); } $textmessage = str_replace("<", "<", str_replace(">", ">", $textmessage)); $info .= "--openfirst-mail.boundry Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit $textmessage --openfirst-mail.boundry Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit"; $fle = fopen($header, "r"); while(!feof($fle)) { $fheader .= fgets($fle); } fclose($fle); $fle = fopen($footer, "r"); while(!feof($fle)) { $ffooter .= fgets($fle); } fclose($fle); // Strip the PHP tags from the header. while(stristr($fheader,"<?")) { $fheader = str_replace(substr($fheader, strpos($fheader, "<?"), strpos($fheader, "?>") - strpos($fheader, "<?") + 2), "", $fheader); } while(stristr($ffooter,"<?")) { $ffooter = str_replace(substr($ffooter, strpos($ffooter, "<?"), strpos($ffooter, "?>") - strpos($ffooter, "<?") + 2), "", $ffooter); } // Strip the ASP tags from the header. while(stristr($fheader,"<%")) { $fheader = str_replace(substr($fheader, strpos($fheader, "<%"), strpos($fheader, "%>") - strpos($fheader, "<%") + 2), "", $fheader); } while(stristr($ffooter,"<%")) { $ffooter = str_replace(substr($ffooter, strpos($ffooter, "<%"), strpos($ffooter, "%>") - strpos($ffooter, "<%") + 2), "", $ffooter); } $fheader = str_replace("src=\"/", "src=\"http://" . $_SERVER["SERVER_NAME"] . "/" . $basepath, $fheader); $fheader = str_replace("src='/", "src=\"http://" . $_SERVER["SERVER_NAME"] . "/" . $basepath, $fheader); $fheader = str_replace("src=/", "src=\"http://" . $_SERVER["SERVER_NAME"] . "/" . $basepath, $fheader); $ffooter = str_replace("src=\"/", "src=\"http://" . $_SERVER["SERVER_NAME"] . "/" . $basepath, $ffooter); $ffooter = str_replace("src='/", "src=\"http://" . $_SERVER["SERVER_NAME"] . "/" . $basepath, $ffooter); $ffooter = str_replace("src=/", "src=\"http://" . $_SERVER["SERVER_NAME"] . "/" . $basepath, $ffooter); $info .= ("$fheader<pre>$message</pre>$ffooter"); return(mail($to, $subject, $info, $headers)); } ?> --- NEW FILE: browserid.php --- <?php /* * openFIRST.base - config/functions/browserid.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ //Functions for browser/platform identification function identify_platform($useragent="") { $return=""; if((bool) ini_get("browscap")){ //get OS info from browscap.ini $browser=get_browser($useragent); //restore error reporting level $return=$browser->platform; if ($return==""){ //returns the original user-agent string return $useragent; } } else { //browscap.ini disabled //returns the original user-agent string return $useragent; } //return platform ID return $return; } function identify_browser($useragent="") { if((bool) ini_get("browscap")){ $err_prev=error_reporting(E_ERROR); //get browser info from browscap.ini $browser=get_browser($useragent); //restore error reporting level error_reporting($err_prev); $return=""; //Get browser name $browsername=$browser->browser; if ($browsername==""){ //could not determine browser name, browscap.ini disabled //return the original user-agent string return $useragent; } else { if ($browsername=="IE"){ //Spell 'IE' as 'Internet Explorer' $browsername="Internet Explorer"; } //Get major version $ver=$browser->majorver; //remove # character at beginning of string if (substr($ver,0,1)=="#"){ $ver=substr($ver,1); } $return=$browsername." ".$ver."."; //Get minor version $ver=$browser->minorver; //remove # character at beginning of string if (substr($ver,0,1)=="#"){ $ver=substr($ver,1); } $return.=$ver; //Identify search engine if (isset($browser->crawler)){ if($browser->crawler==1){ $return.=" (Search Engine)"; } } } } else { //browscap.ini disabled //returns the original user-agent string return $useragent; } //return browser ID return $return; } ?> --- NEW FILE: forms.php --- <?php /* * openFIRST.base - config/functions/forms.php * * Copyright (C) 2003, * openFIRST Project * Original Author: David Di Biase <dav...@ea...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // Set function information function checkform($field){ $error = array(); // Loop through every single array in the function foreach($field as $fields=>$checkwith){ // While looping use one of these cases to perform the proper checking switch($checkwith){ // If field is a password then check as password and respond case "password": if(strlen($_POST[$fields]) < 5){ $error[] = "Password is too short, must be 5-6 characters in length. You entered: ".$_POST[$fields]; } break; // If field is an email address then check as email and respond case "email": if( ! eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@([a-z0-9]+([\.-][a-z0-9]+))*$",$_POST[$fields])) { $error[] = "E-mail field contains illegal characters. You entered: ".$_POST[$fields]; } else { $item = explode("@", $_POST[$fields]); if( gethostbyname($item["1"]) == $item["1"]) { $error[] = "Domain in e-mail address is illegal. You entered: ".$_POST[$fields]; } } break; // If field is set as ifempty then check if its empty and respond case "ifempty": if(empty($_POST[$fields])){ $error[] = "Empty field on form. You entered: ".$_POST[$fields]; } } } return $error; } // Set function values function formerrors($error){ // Check if requires error response if (! empty($error)){ // Create errors table echo "<table width=400 border=1 align=center cellpadding=1 cellspacing=0 bordercolor=#333333 bgcolor=#CCCCCC><tr><td><b>You have errors within your form:</b><br>"; // Display errors in form foreach($error as $value){ echo "- ".$value."<br>"; } // Close errors table echo "</td></tr></table>"; } } ?> --- NEW FILE: debug.php --- <?php /* * openFIRST.base - config/functions/debug.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Tim Ginn <tim...@po...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // Purpose: Provide some useful features for debugging certain problems. // This entire process is optional, of course. Anyone may easily // simply remove this file in order to eliminate the debugging. set_error_handler("ofirst_error_handler"); // Handles errors by displaying a message and contacting openFIRST // developers for assistance. function ofirst_error_handler($errno,$error,$file,$line) { global $dbasetype, $ostype, $sqlserver, $currentmodule, $user, $mailnotify, $mailfrom; if(! function_exists("md5_file")) { $checksum = "md5_file not supported by PHP version."; } else { $checksum = md5_file($_SERVER["PATH_TRANSLATED"]); } // Notify the appropriate local contact mail($mailnotify, "$error in $file on line $line", "Error Description: $error in $file on line $line There is additional information regarding this bug stored on the openFIRST Bugzilla Server at: http://bugzilla.openfirst.org/", "From: $mailfrom"); // Attempt to contact the openFIRST Bugzilla Server $bugzilla = fopen(str_replace(" ", "%20", "http://bugzilla.openfirst.org/openfirst/?module=$currentmodule&uri=" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . "&details=MD5: $checksum Database Type: $dbasetype Operating System: $ostype SQL Server: $sqlserver Current Module: $currentmodule Error Number: $errno &specifics=PHP_SELF: " . $_SERVER["PHP_SELF"] . " HTTP Host: " . $_SERVER["HTTP_HOST"] . " HTTP Referer: " . $_SERVER["HTTP_REFERER"] . " Translated Path: " . $_SERVER["PATH_TRANSLATED"] . " User (if exists): $user->user User Access Level: $user->membertype Error Description: $error in $file on line $line"), "r"); if(! $bugzilla) { // If a connection cannot be established to the Bugzilla server echo("Could not contact the openFIRST Bugzilla server."); echo("<h3><strong>$errno</strong> - <strong>$error</strong> in <strong>$file</strong> on line <strong>$line</strong></h3> <p><strong>The openFIRST system has encountered an error. This may be due to a misconfiguration on the behalf of the person installing it, or an error in the openFIRST code.</strong></p> <p>Debugging may be disabled by removing (config/functions/debug.php)"); } else { // If a connection is established to the Bugzilla server then rely // completely on it for the appropriate error message to show. while(!feof($bugzilla)) { $line = fgets($bugzilla, 2048); echo $line; } } } ?> |