From: <tim...@us...> - 2010-02-12 10:31:40
|
Revision: 3341 http://web-erp.svn.sourceforge.net/web-erp/?rev=3341&view=rev Author: tim_schofield Date: 2010-02-12 10:31:30 +0000 (Fri, 12 Feb 2010) Log Message: ----------- Replace deprecated function eregi Modified Paths: -------------- trunk/doc/Change.log.html trunk/install/save.php Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-02-08 14:39:54 UTC (rev 3340) +++ trunk/doc/Change.log.html 2010-02-12 10:31:30 UTC (rev 3341) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>12/02/10 Tim: Save.php - Replace deprecated function eregi</p> <p>08/02/10 Tim: Change the default font family to Arial</p> <p>05/02/10 Tim: PO_AuthorisationLevels.php - If authoriastion limit is blank, then use a zero value</p> <p>03/02/10 Tim: Payments.php - Correctly show escaped characters in narrative while item hasn't been posted</p> Modified: trunk/install/save.php =================================================================== --- trunk/install/save.php 2010-02-08 14:39:54 UTC (rev 3340) +++ trunk/install/save.php 2010-02-12 10:31:30 UTC (rev 3341) @@ -35,7 +35,7 @@ } function set_error($message) { - + if(isset($message) AND $message != '') { // Copy values entered into session so user doesn't have to re-enter everything if(isset($_POST['company_name'])) { @@ -44,7 +44,7 @@ $_SESSION['operating_system'] = 'linux'; } else { $_SESSION['operating_system'] = $_POST['operating_system']; - } + } if(!isset($_POST['world_writeable'])) { $_SESSION['world_writeable'] = false; } else { @@ -74,7 +74,7 @@ function default_file_mode($temp_dir) { $v = explode(".",PHP_VERSION); $v = $v[0].$v[1]; - + if($v > 41 && is_writable($temp_dir)) { $filename = $temp_dir.'/test_permissions.txt'; $handle = fopen($filename, 'w'); @@ -103,6 +103,9 @@ return $default_dir_mode; } +function is_valid_email($email) { + return preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9_-.]+.[a-zA-Z]+/", $email) > 0; +} if (isset($_POST['path_to_root'])) { $path_to_root = $_POST['path_to_root']; @@ -165,22 +168,22 @@ // Check if user has entered a database host if (!isset($_POST['database_host']) || $_POST['database_host'] == '') { set_error('Please enter a database host name'); -} +} // Check if user has entered a database username if (!isset($_POST['database_username']) || $_POST['database_username'] == '') { set_error('Please enter a database username'); -} +} // Check if user has entered a database password if (!isset($_POST['database_password'])) { set_error('Please enter a database password'); -} +} // Check if user has entered a database name if (!isset($_POST['company_name']) || $_POST['company_name'] == '') { set_error('Please enter a company name'); } else { $_POST['company_name'] = Replace_Dodgy_Characters($_POST['company_name']); } - + if (!isset($_POST['timezone']) || $_POST['timezone'] == ''){ set_error('Please enter timezone'); } @@ -194,14 +197,14 @@ if (!isset($_POST['admin_email']) || $_POST['admin_email'] == ''){ set_error('Please enter an email for the Administrator account'); } else { - if (eregi("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", $_POST['admin_email'])==false) { + if (is_valid_email($_POST['admin_email'])==false) { set_error('Please enter a valid email address for the Administrator account'); } } // Get the two admin passwords entered, and check that they match if (!isset($_POST['admin_password']) || $_POST['admin_password'] == '') { set_error('Please enter a password for the Administrator account'); -} +} if (!isset($_POST['admin_repassword']) || $_POST['admin_repassword'] == '') { set_error('Please make sure you re-enter the password for the Administrator account'); } @@ -213,7 +216,7 @@ $config_filename = $path_to_root . '/config.php'; // only make a new company directory structure if we are kicking off a new company // no need to bother if just setting up the demo data -if ($_POST['DemoData']==false){ +if ($_POST['DemoData']==false){ $Result = mkdir($path_to_root . '/companies/' . $_POST['company_name']); $Result = mkdir($path_to_root . '/companies/' . $_POST['company_name'] . '/part_pics'); $Result = mkdir($path_to_root . '/companies/' . $_POST['company_name'] . '/EDI_Incoming_Orders'); @@ -232,8 +235,8 @@ if (substr($ConfigDistributionFile[$i], 0, 8) == '$Version'){ $VersionString = $ConfigDistributionFile[$i]; } -} -//$msg holds the text of the new config.php file +} +//$msg holds the text of the new config.php file $msg = "<?php\n\n"; $msg .= "/* \$Revision: 1.7 $ */\n"; $msg .= "// User configurable variables\n"; @@ -246,15 +249,15 @@ $msg .= $VersionString . "\n\n"; $msg .= "// Connection information for the database\n"; $msg .= "// \$host is the computer ip address or name where the database is located\n"; -$msg .= "// assuming that the web server is also the sql server\n"; +$msg .= "// assuming that the web server is also the sql server\n"; $msg .= "\$host = '" . $_POST['database_host'] . "';\n\n"; -$msg .= "// assuming that the web server is also the sql server\n"; +$msg .= "// assuming that the web server is also the sql server\n"; $msg .= "\$dbType = 'mysqli';\n"; -$msg .= "// assuming that the web server is also the sql server\n"; +$msg .= "// assuming that the web server is also the sql server\n"; $msg .= "\$dbuser = '" . $_POST['database_username'] . "';\n"; -$msg .= "// assuming that the web server is also the sql server\n"; +$msg .= "// assuming that the web server is also the sql server\n"; $msg .= "\$dbpassword = '" . $_POST['database_password'] . "';\n"; $msg .= "// The timezone of the business - this allows the possibility of having;\n"; @@ -271,16 +274,16 @@ $msg .= "\$CryptFunction = 'sha1';\n"; $msg .= "\$DefaultClock = 12;\n"; -$msg .= "\$rootpath = dirname(\$_SERVER['PHP_SELF']);\n"; -$msg .= "if (isset(\$DirectoryLevelsDeep)){\n"; -$msg .= " for (\$i=0;\$i<\$DirectoryLevelsDeep;\$i++){\n"; -$msg .= "\$rootpath = substr(\$rootpath,0, strrpos(\$rootpath,'/'));\n"; -$msg .= "} }\n"; +$msg .= "\$rootpath = dirname(\$_SERVER['PHP_SELF']);\n"; +$msg .= "if (isset(\$DirectoryLevelsDeep)){\n"; +$msg .= " for (\$i=0;\$i<\$DirectoryLevelsDeep;\$i++){\n"; +$msg .= "\$rootpath = substr(\$rootpath,0, strrpos(\$rootpath,'/'));\n"; +$msg .= "} }\n"; -$msg .= "if (\$rootpath == '/' OR \$rootpath == '\\\') {;\n"; -$msg .= "\$rootpath = '';\n"; -$msg .= "}\n"; -$msg .= "error_reporting (E_ALL & ~E_NOTICE);\n"; +$msg .= "if (\$rootpath == '/' OR \$rootpath == '\\\') {;\n"; +$msg .= "\$rootpath = '';\n"; +$msg .= "}\n"; +$msg .= "error_reporting (E_ALL & ~E_NOTICE);\n"; $msg .= "?>"; if (!$zp = fopen($path_to_root . '/config.php', 'w')){ @@ -302,7 +305,7 @@ } if($_POST['install_tables'] == true){ - + /* Need to read in the sql script and process the queries to initate a new DB */ if ($_POST['DemoData'] == true){ //installing the demo data $SQLScriptFile = file($path_to_root . '/sql/mysql/weberp-demo.sql'); @@ -316,15 +319,15 @@ $ScriptFileEntries = sizeof($SQLScriptFile); $SQL =''; $InAFunction = false; - + for ($i=0; $i<$ScriptFileEntries; $i++) { - + $SQLScriptFile[$i] = trim($SQLScriptFile[$i]); - //ignore lines that start with -- or USE or /* - if (substr($SQLScriptFile[$i], 0, 2) != '--' - AND strstr($SQLScriptFile[$i],'/*')==FALSE + //ignore lines that start with -- or USE or /* + if (substr($SQLScriptFile[$i], 0, 2) != '--' + AND strstr($SQLScriptFile[$i],'/*')==FALSE AND strlen($SQLScriptFile[$i])>1){ - + $SQL .= ' ' . $SQLScriptFile[$i]; //check if this line kicks off a function definition - pg chokes otherwise @@ -340,18 +343,18 @@ $result = mysqli_query($db,$SQL); $SQL=''; } - + } //end if its a valid sql line not a comment } //end of for loop around the lines of the sql script -} -$sql = "UPDATE www_users - SET password = '" . sha1($_POST['admin_password']) . "', - email = '".mysqli_real_escape_string($db, $_POST['admin_email']) ."' +} +$sql = "UPDATE www_users + SET password = '" . sha1($_POST['admin_password']) . "', + email = '".mysqli_real_escape_string($db, $_POST['admin_email']) ."' WHERE user_id = 'admin'"; mysqli_query($db,$sql); -$sql = "UPDATE companies - SET coyname = '". mysqli_real_escape_string($db, $_POST['company_name']) . "' - WHERE coycode = 1"; +$sql = "UPDATE companies + SET coyname = '". mysqli_real_escape_string($db, $_POST['company_name']) . "' + WHERE coycode = 1"; mysqli_query($db,$sql); session_unset(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |