Changeset 57
- Timestamp:
- 11/17/05 20:53:39
- Files:
-
- trunk/changelog.txt (modified) (1 diff)
- trunk/choicelist.php (modified) (1 diff)
- trunk/defaultsettings.php (modified) (1 diff)
- trunk/include/session.php (modified) (4 diffs)
- trunk/install/createtables.sql (modified) (1 diff)
- trunk/install/install.php (modified) (8 diffs)
- trunk/install/installxml.php (modified) (3 diffs)
- trunk/install/settings.sql (added)
- trunk/install/updatev0.61.sql (modified) (1 diff)
- trunk/install/updatexml.php (modified) (3 diffs)
- trunk/modules/base/adminsettings.php (modified) (1 diff)
- trunk/modules/base/include/adminsettings_include.php (modified) (3 diffs)
- trunk/modules/bms/install/install.php (modified) (1 diff)
- trunk/modules/bms/install/settings.sql (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/changelog.txt
r54 r57 29 29 - Added UPC to products. 30 30 - Fixed compatibilty problem with MySQL 5 and reserved words. 31 - Modified Snapshot to load snapshot sections from each individual module. 32 - Moved non MySQL settings to new settings table. 31 33 32 34 phpBMS v0.602/ BMS module v0.602 trunk/choicelist.php
r51 r57 42 42 $querystatement="DELETE FROM choices WHERE listname=\"".$listname."\" "; 43 43 $queryresult=mysql_query($querystatement,$dblink); 44 if(!$query statement)44 if(!$queryresult) 45 45 reportError(100,"SQL Statement Could not be executed."); 46 46 else trunk/defaultsettings.php
r10 r57 1 1 <?php /* ] 2 [ General ] 3 application_name = "phpBMS" 4 encryption_seed = "freeble" 5 record_limit = "50" 6 default_load_page = "modules/base/snapshot.php" 7 8 [ Invoice ] 9 invoice_default_printinstruc = "Thank You For Your Order." 10 11 [ mySQL ] 12 mysql_server = "localhost" 13 mysql_database = "phpbms" 14 mysql_user = "bms" 15 mysql_userpass = "bmspass" 16 17 [ Company ] 18 company_name = "Kreotek LLC" 19 company_address = "481 Rio Rancho Blvd. NE" 20 company_csz = "Rio Rancho, NM 87124" 21 company_phone = "505.994.6388" 22 23 [ Shipping ] 24 shipping_markup = "1.1" 25 shipping_postalcode = "87124" 26 27 [ Display ] 28 stylesheet = "mozilla" 2 mysql_server = "localhost" 3 mysql_database = "phpbms" 4 mysql_user = "bms" 5 mysql_userpass = "bmspass" 29 6 end] */ ?> trunk/include/session.php
r51 r57 44 44 } 45 45 46 function loadSettings(){ 47 global $dblink; 48 49 $querystatement="SELECT name,value FROM settings"; 50 $queryresult=mysql_query($querystatement,$dblink); 51 if(!$queryresult) reportError(100,("Could not retrieve settings. If you have not ran the update script for phpBMS, 52 please run it before logging in. Error Details:<br />".mysql_error($dblink)." ".$querystatement)); 53 while($therecord=mysql_fetch_array($queryresult)) 54 $_SESSION[$therecord["name"]]=$therecord["value"]; 55 } 56 46 57 //This function loads any variables written 47 58 // in settings.php into session variables. 48 59 //========================================= 49 function load Settings() {60 function loadMysqlSettings() { 50 61 51 62 $path=""; … … 71 82 if($endpos!=false) 72 83 $value=substr($value,$startpos+1,$endpos-$startpos-1); 73 $_SESSION[$key]=$value; 84 if(strpos($key,"mysql_")===0) 85 $_SESSION[$key]=$value; 74 86 } 75 87 } … … 110 122 session_start(); 111 123 error_reporting(E_ALL); 112 if (!isset($_SESSION["app_path"])) $mainpath=load Settings();124 if (!isset($_SESSION["app_path"])) $mainpath=loadMysqlSettings(); 113 125 else $mainpath=$_SESSION["app_path"]; 114 126 … … 129 141 if (!mysql_select_db($_SESSION["mysql_database"],$dblink)) 130 142 reportError(500,"Could not open database. Please check your settings.",true,$mainpath); 131 } 143 } 144 if(!isset($_SESSION["app_name"])) 145 loadSettings(); 132 146 }//end if 133 147 trunk/install/createtables.sql
r54 r57 204 204 KEY user (userid) 205 205 ) TYPE=MyISAM; 206 207 CREATE TABLE `settings` ( 208 `id` int(11) NOT NULL auto_increment, 209 `name` varchar(64) NOT NULL default '', 210 `value` varchar(255) default '', 211 PRIMARY KEY (`id`) 212 ) TYPE=MyISAM; trunk/install/install.php
r51 r57 96 96 97 97 <body> 98 <div class="bodyline" style="padding:4px;">98 <div align="center"><div class="bodyline" style="width:740px" align="left"> 99 99 <h1>phpBMS Installation Instructions</h1> 100 100 <h2>Application Requirements</h2> 101 <div class="box"> 101 102 <ul> 102 103 <li>MySQL 3.23.58 or higher</li> … … 104 105 <li>Web Server (Tested using Apache and IIS.)</li> 105 106 </ul> 106 107 108 109 <h2>Setting Up The Database</h2> 107 </div> 108 109 110 111 <h2>Set Up The Database</h2> 110 112 111 113 <div class="box"> 112 114 <h3>Step 1 - Set Database Connection Information</h3> 113 115 <div style="margin-left:10px;"> 114 There are two ways to provide the connection information phpBMS will need to interact with the MySQL database. 115 Providing the information by filling in the fields below can be quicker, but if phpBMS is not being hosted securely, 116 the MySQL login information can be compromised.</div> 117 118 <div style="float:right;width:40%;padding-top:0"> 119 <h4 style="margin-left:0;margin-bottom:1px;">Results</h4> 120 <div> 121 <textarea name="results" id="updatesettingsresults" style="width:100%;font-family:'Courier New', Courier, mono;font-size:11px;" rows="12"></textarea> 122 </div> 123 </div> 124 <h4 style="margin-right:42%">A) Enter Connection Information</h4> 125 126 <div style="margin-left:25px;margin-right:42%;"> 127 <div>Enter The mySQL connection information and then click the "Create Settings" button. This will create the settings file required to run phpBMS. It will also copy some other default files used throughout the program (logo picture used on reports, etc..)</div> 128 <div><em style="color:red;">(insecure if not done through SSL)</em></div> 129 <div> 130 MySQL Server<br> 131 <input type="text" name="mysqlserver" id="mysqlserver" size="32" value="localhost"> 132 </div> 133 <div> 134 MySQL Database<br> 135 <input type="text" name="mysqldb" id="mysqldb" size="32" value="phpbms"><br> 136 <em class=small>(If the database has not been created yet, it will be in step two.)</em> 137 </div> 138 <div> 139 MySQL User<br> 140 <input type="text" name="mysqluser" id="mysqluser" size="32" value=""> 141 </div> 142 <div> 143 MySQL Password<br> 144 <input type="password" name="mysqluserpass" id="mysqluserpass" size="32" value=""> 145 </div> 146 <div><input type="button" value="Create Settings" class="Buttons" onClick="runCommand('updatesettings')"></div> 147 </div> 148 149 <h4>B) Or, Manually Create the settings.php File</h4> 116 This step will require you to manually create the settings file. that is used by PHP to connect to your MySQL database. </div> 117 118 119 120 <h4> Create the settings.php File</h4> 150 121 <div style="margin-left:25px;"> 151 Copy the file <strong>defaultsettings.php</strong> and create the file <strong>settings.php</strong>. Make sure to modify the MySQL settings in the <strong>settings.php</strong> file. You can also modify any other settings at this time but the four 152 settings that are essential to connecting to the database are: 122 Make a copy the file <strong>defaultsettings.php</strong> (located in the web application root) and name the new file <strong>settings.php</strong>. Next, modify the following prarameters: 153 123 <ul class="small"> 154 <li><strong>mysql_server</strong>: the mysql server location (in most cases, this should be the same location as the web server, or "localhost ")<br><br> 155 <em style="color:red;">Note: If your database server is different then your web server, data security issues can occur.</em><br> 156 124 <li><strong>mysql_server</strong>: the mysql server location (in most cases, this should be the same location as the web server, or "localhost")<br> 125 <div class="small" style=" color:#DF0005"><strong>Note:</strong> If your database server is different then your web server, make sure you take any necessary security precautions.</div> 157 126 </li> 158 <li><strong>mysql_database</strong>: the name of the database to be used by phpBMS. If it has not been created yet, step two will create it .<br>127 <li><strong>mysql_database</strong>: the name of the database to be used by phpBMS. If it has not been created yet, step two will create it if your mysql user has rights o create the database. <br> 159 128 </li> 160 129 <li><strong>mysql_user</strong>: the name of the user PHP will use to access the database.<br> 161 130 </li> 162 <li><strong>mysql_userpass</strong>: the password for the user used toaccess the database.</li>131 <li><strong>mysql_userpass</strong>: the password for the user that access the database.</li> 163 132 </ul> 164 133 </div> … … 172 141 <h4 style="margin-right:42%">Test the Database Connection</h4> 173 142 <div style="margin-left:25px;margin-right:42%"> 174 Once the database connection information has been entered, test the connection. If connection fails, check175 to make sure the settings are correct.143 Once the <strong>settings.php</strong> file has been created and the database connection information has been entered, test the connection. If connection fails, check 144 to make sure the <strong>settings.php</strong> is setup correctly. 176 145 </div> 177 146 <div style="margin-left:25px;margin-right:42%"><input type="button" value="Test Connection" class="Buttons" onClick="runCommand('testconnection')"><br> </div> 178 147 </div> 179 148 <div> </div> 180 149 181 150 <div class="box"> … … 192 161 If you have already created the MySQL database, skip to step three. If not, click the "Create Database" button. 193 162 This will attempt to create the database set above. 194 </div>163 The user that you specified in the settings.php file must have rights to create the database. </div> 195 164 <div><input type="button" value="Create Database" class="Buttons" onClick="runCommand('createdatabase')"></div> 196 <div class= small><strong>Note:</strong> Some ISPs limit the number of mySQL databases you are allowed, or control database creation through a web application, or on a request basis. If you have any questions, contact your ISP.</div>165 <div class="small" style=" color:#DF0005"><strong>Note:</strong> Some ISPs limit the number of mySQL databases you are allowed, or control database creation through a web application, or on a request basis. If you have any questions, contact your ISP.</div> 197 166 <div> </div> 198 167 <div> </div> 199 168 </div> 200 169 </div> 201 170 <div> </div> 171 202 172 <div class="box" style="clear:right"> 203 173 <div style="float:right;width:40%;padding-top:0;"> 204 174 <h3 style="margin-left:0;margin-bottom:1px;">Results</h3> 205 175 <div> 206 <textarea name="results" id="populatedataresults" style="width:98%;font-family:'Courier New', Courier, mono;font-size:11px;" rows="1 0"></textarea>207 </div> 208 </div> 209 210 <h3 style="margin-right:42%">Step 3 - Create Base Tables and PopulateDefault Information </h3>176 <textarea name="results" id="populatedataresults" style="width:98%;font-family:'Courier New', Courier, mono;font-size:11px;" rows="12"></textarea> 177 </div> 178 </div> 179 180 <h3 style="margin-right:42%">Step 3 - Create Default Information </h3> 211 181 <div style="margin-left:10px;margin-right:42%"> 212 182 <div> 213 Next, phpBMS needs to create the base level tables and populate the tables with the basic information neededto183 Next, phpBMS needs to create the base level tables and populate the tables with the basic information that phpBMS needs to 214 184 work. 215 185 </div> … … 223 193 password: <strong>phpbms</strong> 224 194 </div> 225 <div ><em style="color:red;"><strong>Note:</strong> Change the password after the first successful login.</em></div>195 <div class="small" style=" color:#DF0005"><strong>Note:</strong> Make sure to change the encryptions seed and password after the first successful login.</div> 226 196 <div> </div> 227 197 </div> … … 229 199 230 200 231 <h2 style="clear:both;">Installing Additional Modules </h2> 232 <div> 233 The base phpBMS system contains only the basic framework, administration and notes capabilities. 234 Client and product management, invoicing and mass emailing capabilities are contained in a separate 235 BMS module. Modules are stored in the "modules" folder. To install the BMS module, proceed to step 4. 236 </div> 237 238 <div class="box"> 201 <h2 style="clear:both;">Install Additional Modules </h2> 202 <div class="box"> 203 <div> 204 The base phpBMS system contains <strong>only</strong> the bare framework, administration, and note/task/event capabilities. 205 Additional modules will add functionality such as client/prospect and product management, quote/order/invoice control, and mass e-mailing. The modules are installed separately in the next step. </div> 239 206 <div style="float:right;width:40%;padding-top:0;"> 240 207 <h3 style="margin-left:0;margin-bottom:1px;">Results</h3> 241 208 <div> 242 <textarea name="results" id="moduleresults" style="width: 100%;font-family:'Courier New', Courier, mono;font-size:11px;" rows="10"></textarea>209 <textarea name="results" id="moduleresults" style="width:98%;font-family:'Courier New', Courier, mono;font-size:11px;" rows="10"></textarea> 243 210 </div> 244 211 </div> 245 212 <h3 style="margin-right:42%;">Step 4 - Install Additional Modules</h3> 246 213 <div style="margin-left:10px;margin-right:42%"> 247 <div>To install a module, choosethe module form the list and click the "Install Module" button.</div>214 <div>To install a module, highlight the module form the list and click the "Install Module" button.</div> 248 215 <div> 249 216 Select a module to install<br> … … 259 226 </div> 260 227 261 <h2>Secur ingThe Application</h2>262 <div >228 <h2>Secure The Application</h2> 229 <div class="box"> 263 230 phpBMS can contain sensitive information, log in information and sensitive credit card information that could be exposed to the internet insecurely. 264 231 We recommend performing the following actions to secure phpBMS 265 <ul> 232 : 233 <ul> 266 234 <li> 267 235 <strong>Delete Installation/Disable Folders</strong> - Once the installation process has been completed for the base system and the BMS modules, 268 Either delete the installation folders, or make them inaccessible from the web server.<br> 236 Either delete the installation folders, or make them inaccessible by the web server and php.<br> 237 269 238 </li> 270 239 <li> … … 275 244 </ul> 276 245 </div> 277 <h2>Completing The Installation</h2> 278 <div>If phpBMS was installed successfully, go to the log in screen, use the administrative user name password to log in and complete the installation process</div> 279 <div><input type="button" id="login" name="login" value="Go to Log In Screen" class="Buttons" onClick="document.location='../'"></div> 280 281 </div> 246 <h2>Complete the Installation</h2> 247 <div class="box"> 248 If all of the above actions completed successfully, phpBMS was installed successfully. Go to the log in screen, use the administrative user name password (above) and log in to finish the installation process. After logging in, you may want to go to the administration section, and set up the basic settings for your application as well as change the admininstrative username and password. 249 <div><input type="button" id="login" name="login" value="Go to Log In Screen" class="Buttons" onClick="document.location='../'"></div> 250 </div> 251 252 253 </div></div> 282 254 </body> 283 255 </html> trunk/install/installxml.php
r51 r57 115 115 } 116 116 117 function writeSettings($server,$database,$user,$userpass){118 $settings["mysql_server"]=$server;119 $settings["mysql_database"]=$database;120 $settings["mysql_user"]=$user;121 $settings["mysql_userpass"]=$userpass;122 123 $settingsfile = @ fopen("../settings.php","r");124 if(!$settingsfile) return "Could not open settings.php file for reading";125 126 //create an array of all lines127 while( !feof($settingsfile)) {128 $newfile[]=fgets($settingsfile,1024);129 }130 fclose($settingsfile);131 132 $newfile[]="\n";133 foreach($settings as $settingname=>$settingvalue) {134 $infile=false;135 //next loop through the file, and if the setting is their, replace it136 for($i=0;$i<count($newfile);$i++){137 if (strpos(("D".$newfile[$i]),$settingname)==1) {138 $tabnumber=intval(5-strlen($settingname)/8);139 $newfile[$i]=$settingname.str_repeat(chr(9),$tabnumber)."= \"".str_replace(chr(10),"\\n",$settingvalue)."\"\n";140 $infile=true;141 break;142 }143 }144 }145 if(end($newfile)=="\n") array_pop($newfile);146 //now write the new file147 $settingsfile=NULL;148 $settingsfile = @ fopen("../settings.php","w");149 if(!$settingsfile) return "Could not open settings file for writing.";150 for($i=0;$i<count($newfile);$i++){151 fwrite($settingsfile,$newfile[$i],1024);152 }153 //fclose($settingsfile);154 155 return "settings.php file updated successfully";156 }//end function157 158 function createDefaultFiles(){159 $thereturn="Copying Default Files Successful\n";160 if(!copy("../defaultsettings.php","../settings.php"))161 $thereturn="Error Copying Default Settings File.";162 if(!copy("../report/defaultlogo.png","../report/logo.png"))163 $thereturn="Error Copying Default Logo Picture File.";164 return $thereturn;165 }166 117 167 118 $thereturn="Error Processing: No Command Given"; … … 170 121 171 122 switch($_GET["command"]){ 172 case "updatesettings":173 $thereturn=createDefaultFiles();174 $thereturn.=writeSettings($_GET["ms"],$_GET["mdb"],$_GET["mu"],$_GET["mup"]);175 break;176 177 123 178 124 case "testconnection": … … 222 168 $thereturn.=importData("tablesearchablefields"); 223 169 $thereturn.=importData("users"); 170 $thereturn.=importData("settings"); 224 171 $thereturn.="\nDone Importing Data\n===========================\n"; 225 172 trunk/install/updatev0.61.sql
r54 r57 11 11 UPDATE tablefindoptions SET search ="notes.type='EV' AND notes.createdby = {{$_SESSION['userinfo']['id']}} AND ((notes.startdate = curdate()) OR notes.`repeat`=1)" WHERE id=88 12 12 UPDATE tablefindoptions SET search ="notes.type='EV' AND notes.createdby = {{$_SESSION['userinfo']['id']}} AND ((notes.startdate = date_sub(curdate(),INTERVAL 1 DAY)) OR notes.`repeat`=1)" WHERE id=89 13 14 CREATE TABLE `settings` (`id` int(11) NOT NULL auto_increment, `name` varchar(64) NOT NULL default '',`value` varchar(255) default '', PRIMARY KEY (`id`)) TYPE=MyISAM; trunk/install/updatexml.php
r54 r57 88 88 function processSQLfile($filename){ 89 89 global $dblink; 90 90 91 91 $thefile = fopen($filename,"r"); 92 92 if(!$thefile) { … … 166 166 function runUpdate($currentVersion,$newVersion){ 167 167 global $dblink; 168 global $vars; 168 169 169 170 $thereturn=""; … … 248 249 $queryresult=mysql_query($querystatement,$dblink); 249 250 $thereturn.=" - modified base record in modules table\n"; 251 252 foreach($vars as $key=>$value){ 253 if (strpos($key,"mysql_")!==0){ 254 $querystatement="INSERT INTO settings (name,value) VALUES (\"".$key."\",\"".$value."\")"; 255 $queryresult=mysql_query($querystatement,$dblink); 256 } 257 } 258 $thereturn.="Moved non-mysql settings to new settings table.\n"; 250 259 251 260 $thereturn.="Update to 0.61 Finished\n\n"; trunk/modules/base/adminsettings.php
r56 r57 100 100 <legend>My<span style="text-transform:capitalize;">SQL</span></legend> 101 101 <div class="small important"> 102 <em> Changing the MySQL settings may break the web application. Be very careful when changing these settings.</em>102 <em>MysSQL settings must be updated manually by editing the settings.php file</em> 103 103 </div> 104 104 <label for="smysql_server"> 105 server name <em>(usually localhost)</em><br />106 < ?PHP field_text("smysql_server",$_SESSION["mysql_server"],1,"mySQL server name cannot be blank.","",Array("size"=>"32","maxlength"=>"128")); ?>105 server name<br /> 106 <input size="32" maxlength="128" value="<?php echo htmlQuotes($_SESSION["mysql_server"])?>" readonly class="uneditable"/> 107 107 </label> 108 108 <label for="smysql_database"> 109 database name <em>(usually phpbms)</em><br />110 < ?PHP field_text("smysql_database",$_SESSION["mysql_database"],1,"mySQL database name cannot be blank.","",Array("size"=>"32","maxlength"=>"128")); ?>109 database name<br /> 110 <input size="32" maxlength="128" value="<?php echo htmlQuotes($_SESSION["mysql_database"])?>" readonly class="uneditable"/> 111 111 </label> 112 112 <label for="smysql_user"> 113 113 mysql username<br /> 114 <input id="smysql_user" name="smysql_user" type="text" size="32" maxlength="128" value="<?php echo htmlQuotes($_SESSION["mysql_user"])?>"/>114 <input size="32" maxlength="128" value="<?php echo htmlQuotes($_SESSION["mysql_user"])?>" readonly class="uneditable"/> 115 115 </label> 116 116 <label for="smysql_userpass"> 117 117 mysql user password<br /> 118 <input id="smysql_userpass" name="smysql_userpass" type="text" size="32" maxlength="128" value="<?php echo $_SESSION["mysql_userpass"] ?>"/>118 <input size="32" maxlength="128" value="<?php echo htmlQuotes($_SESSION["mysql_userpass"])?>" readonly class="uneditable"/> 119 119 </label> 120 120 </fieldset> trunk/modules/base/include/adminsettings_include.php
r51 r57 38 38 // any settings you want saved 39 39 //========================================= 40 function write_settings($settings) { 41 $settingsfile = fopen("../../settings.php","r") or die ("Couldn't open Settings File"); 42 //create an array of all lines 43 while( !feof($settingsfile)) { 44 $newfile[]=fgets($settingsfile,1024); 40 function updateSettings($settings) { 41 global $dblink; 42 43 foreach($settings as $key=>$value){ 44 $querystatement="UPDATE settings set value=\"".$value."\" WHERE name=\"".$key."\""; 45 $queryresult=mysql_query($querystatement,$dblink); 46 if(!$queryresult) reportError(mysql_error($dblink)." - ".$querystatement); 45 47 } 46 fclose($settingsfile);47 48 $newfile[]="\n";49 foreach($settings as $settingname=>$settingvalue) {50 $infile=false;51 //next loop through the file, and if the setting is their, replace it52 for($i=0;$i<count($newfile);$i++){53 if (strpos(("D".$newfile[$i]),$settingname)==1) {54 $tabnumber=intval(5-strlen($settingvalue)/8);55 $newfile[$i]=$settingname.str_repeat(chr(9),$tabnumber)."= \"".str_replace(chr(10),"\\n",$settingvalue)."\"\n";56 $infile=true;57 break;58 }59 }//60 if(!$infile) {61 $tabnumber=intval(5-strlen($settingname)/8);62 $newfile[]=$settingname.str_repeat(chr(9),$tabnumber)."= \"".str_replace(chr(10),"\\n",$settingvalue)."\"\n";63 }64 }65 66 if(end($newfile)=="\n") array_pop($newfile);67 //now write the new file68 $settingsfile = fopen("../../settings.php","w") or die ("Couldn't open Settings File");69 for($i=0;$i<count($newfile);$i++){70 fwrite($settingsfile,$newfile[$i],1024);71 }72 fclose($settingsfile);73 48 }//end function 74 49 … … 77 52 $writesettings=Array(); 78 53 foreach($variables as $key=>$value){ 79 if($key!="command" && $key!="printedlogo" ){54 if($key!="command" && $key!="printedlogo" && strpos($key,"mysql_")!==0){ 80 55 if($_SESSION[substr($key,1)]!=$value){ 81 56 $writesettings[substr($key,1)]=$value; … … 94 69 95 70 // if changes, process settings 96 if(count($writesettings)>0) { write_settings($writesettings);} 71 if(count($writesettings)>0) 72 updateSettings($writesettings); 97 73 98 74 // deal with logo graphic. trunk/modules/bms/install/install.php
r51 r57 144 144 $thereturn.=importData("tablesearchablefields"); 145 145 $thereturn.=importData("usersearches"); 146 $thereturn.=importData("settings"); 146 147 147 148 $thereturn.="Done Importing Data\n===========================\n";