From: <tim...@us...> - 2010-06-24 08:31:47
|
Revision: 3516 http://web-erp.svn.sourceforge.net/web-erp/?rev=3516&view=rev Author: tim_schofield Date: 2010-06-24 08:31:39 +0000 (Thu, 24 Jun 2010) Log Message: ----------- Update SMTP server details from the UI rather than hard code into the scripts. Modified Paths: -------------- trunk/doc/Change.log.html trunk/includes/GetConfig.php trunk/includes/htmlMimeMail.php trunk/includes/smtp.php trunk/index.php trunk/sql/mysql/upgrade3.11.1-3.12.sql Added Paths: ----------- trunk/SMTPServer.php Added: trunk/SMTPServer.php =================================================================== --- trunk/SMTPServer.php (rev 0) +++ trunk/SMTPServer.php 2010-06-24 08:31:39 UTC (rev 3516) @@ -0,0 +1,67 @@ +<?php + +$PageSecurity =15; + +include('includes/session.inc'); + +$title = _('SMTP Server details'); + +include('includes/header.inc'); + +echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/email.gif" title="' . + _('SMTP Server') . '" alt="">' . ' ' . _('SMTP Server Settings') . '</p>'; + +if (isset($_POST['submit'])) { + $sql='UPDATE emailsettings SET + host="'.$_POST['host'].'", + port='.$_POST['port'].', + heloaddress="'.$_POST['heloaddress'].'", + username="'.$_POST['username'].'", + password="'.$_POST['password'].'", + auth='.$_POST['auth']; + $result=DB_query($sql, $db); + prnMsg(_('The settings for the SMTP server have been successfully updated'), 'success'); + echo '<br>'; +} + +$sql='SELECT id, + host, + port, + heloaddress, + username, + password, + timeout, + auth + FROM emailsettings'; +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); +echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . "?" . SID . ">"; +echo '<table class=selection>'; +echo '<tr><td>'._('Server Host Name').'</td> + <td><input type=text name=host value='.$myrow['host'].'></td></tr>'; +echo '<tr><td>'._('SMTP port').'</td> + <td><input type=text name=port size=4 class=number value='.$myrow['port'].'></td></tr>'; +echo '<tr><td>'._('Helo Command').'</td> + <td><input type=text name=heloaddress value='.$myrow['heloaddress'].'></td></tr>'; +echo '<tr><td>'._('Authorisation Required').'</td><td>'; +echo '<select name=auth>'; +if ($myrow['auth']==1) { + echo '<option selected value=1>'._('True').'</option>'; + echo '<option value=0>'._('False').'</option>'; +} else { + echo '<option value=1>'._('True').'</option>'; + echo '<option selected value=0>'._('False').'</option>'; +} +echo '</select></td></tr>'; +echo '<tr><td>'._('User Name').'</td> + <td><input type=text name=username value='.$myrow['username'].'></td></tr>'; +echo '<tr><td>'._('Password').'</td> + <td><input type=password name=password value='.$myrow['password'].'></td></tr>'; +echo '<tr><td>'._('Timeout (seconds)').'</td> + <td><input type=text size=5 name=timeout class=number value='.$myrow['timeout'].'></td></tr>'; +echo '<tr><td colspan=2><div class=centre><input type="submit" name="submit" value="' . _('Update') . '"></div></td></tr>'; +echo '</table></form>'; + +include('includes/footer.inc'); + +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-06-23 15:52:46 UTC (rev 3515) +++ trunk/doc/Change.log.html 2010-06-24 08:31:39 UTC (rev 3516) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>24/06/10 Tim: Update SMTP server details from the UI rather than hard code into the scripts.</p> <p>23/06/10 Tim: View, accept, or reject any offers made.</p> <p>21/06/10 Pak Ricard: Z_ChangeStockCode.php - updated Z_ChangeStockCode.php as the last one broke due to the recent changes in contractBOM table (just changed the field name).</p> <p>18/06/10 Tim: AddCustomerNotes.php - Layout improvements</p> Modified: trunk/includes/GetConfig.php =================================================================== --- trunk/includes/GetConfig.php 2010-06-23 15:52:46 UTC (rev 3515) +++ trunk/includes/GetConfig.php 2010-06-24 08:31:39 UTC (rev 3516) @@ -62,6 +62,26 @@ } } //end if force reload or not set already +$sql='SELECT id, + host, + port, + heloaddress, + username, + password, + timeout, + auth + FROM emailsettings'; +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); + +$_SESSION['SMTPSettings']['host']=$myrow['host']; +$_SESSION['SMTPSettings']['port']=$myrow['port']; +$_SESSION['SMTPSettings']['heloaddress']=$myrow['heloaddress']; +$_SESSION['SMTPSettings']['username']=$myrow['username']; +$_SESSION['SMTPSettings']['password']=$myrow['password']; +$_SESSION['SMTPSettings']['timeout']=$myrow['timeout']; +$_SESSION['SMTPSettings']['auth']=$myrow['auth']; + /* Modified: trunk/includes/htmlMimeMail.php =================================================================== --- trunk/includes/htmlMimeMail.php 2010-06-23 15:52:46 UTC (rev 3515) +++ trunk/includes/htmlMimeMail.php 2010-06-24 08:31:39 UTC (rev 3516) @@ -137,12 +137,12 @@ $helo = 'localhost'; } - $this->smtp_params['host'] = 'localhost'; - $this->smtp_params['port'] = 25; - $this->smtp_params['helo'] = $helo; - $this->smtp_params['auth'] = false; - $this->smtp_params['user'] = ''; - $this->smtp_params['pass'] = ''; + $this->smtp_params['host'] = $_SESSION['SMTPSettings']['host']; + $this->smtp_params['port'] = $_SESSION['SMTPSettings']['port']; + $this->smtp_params['helo'] = $_SESSION['SMTPSettings']['heloaddress']; + $this->smtp_params['auth'] = $_SESSION['SMTPSettings']['auth']; + $this->smtp_params['user'] = html_entity_decode($_SESSION['SMTPSettings']['username']); + $this->smtp_params['pass'] = html_entity_decode($_SESSION['SMTPSettings']['password']); /** * Make sure the MIME version header is first. @@ -609,8 +609,8 @@ // Add message ID header srand((double)microtime()*10000000); - $message_id = sprintf('<%s.%s@%s>', base_convert(time(), 10, 36), base_convert(rand(), 10, 36), !empty($GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST']) ? $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'] : $GLOBALS['HTTP_SERVER_VARS']['SERVER_NAME']); - $this->headers['Message-ID'] = $message_id; +// $message_id = sprintf('<%s.%s@%s>', base_convert(time(), 10, 36), base_convert(rand(), 10, 36), !empty($GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST']) ? $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'] : $GLOBALS['HTTP_SERVER_VARS']['SERVER_NAME']); +// $this->headers['Message-ID'] = $message_id; $this->is_built = true; return true; Modified: trunk/includes/smtp.php =================================================================== --- trunk/includes/smtp.php 2010-06-23 15:52:46 UTC (rev 3515) +++ trunk/includes/smtp.php 2010-06-24 08:31:39 UTC (rev 3516) @@ -49,15 +49,15 @@ if(!defined('CRLF')) define('CRLF', "\r\n", TRUE); - $this->authenticated = FALSE; - $this->timeout = 5; + $this->authenticated = FALSE; + $this->timeout = $_SESSION['SMTPSettings']['timeout']; $this->status = SMTP_STATUS_NOT_CONNECTED; - $this->host = 'localhost'; - $this->port = 25; - $this->helo = 'localhost'; - $this->auth = FALSE; - $this->user = ''; - $this->pass = ''; + $this->host = $_SESSION['SMTPSettings']['host']; + $this->port = $_SESSION['SMTPSettings']['port']; + $this->helo = $_SESSION['SMTPSettings']['heloaddress']; + $this->auth = $_SESSION['SMTPSettings']['auth']; + $this->user = html_entity_decode($_SESSION['SMTPSettings']['username']); + $this->pass = html_entity_decode($_SESSION['SMTPSettings']['password']); $this->errors = array(); foreach($params as $key => $value){ @@ -67,7 +67,7 @@ /** * Connect function. This will, when called - * statically, create a new smtp object, + * statically, create a new smtp object, * call the connect function (ie this function) * and return it. When not called statically, * it will connect to the server and send @@ -92,7 +92,8 @@ $greeting = $this->get_data(); if(is_resource($this->connection)){ - return $this->auth ? $this->ehlo() : $this->helo(); + $return=$this->auth ? $this->ehlo() : $this->helo(); + return $return; }else{ $this->errors[] = 'Failed to connect to server: '.$errstr; return FALSE; @@ -156,7 +157,7 @@ return FALSE; } } - + /** * Function to implement HELO cmd */ @@ -173,7 +174,7 @@ return FALSE; } } - + /** * Function to implement EHLO cmd */ @@ -190,7 +191,7 @@ return FALSE; } } - + /** * Function to implement RSET cmd */ @@ -207,7 +208,7 @@ return FALSE; } } - + /** * Function to implement QUIT cmd */ @@ -226,7 +227,7 @@ return FALSE; } } - + /** * Function to implement AUTH cmd */ @@ -252,7 +253,7 @@ /** * Function that handles the MAIL FROM: cmd */ - + function mail($from){ if($this->is_connected() @@ -268,7 +269,7 @@ /** * Function that handles the RCPT TO: cmd */ - + function rcpt($to){ if($this->is_connected() @@ -292,7 +293,7 @@ if($this->is_connected() AND $this->send_data('DATA') AND substr(trim($error = $this->get_data()), 0, 3) === '354' ){ - + return TRUE; }else{ @@ -319,7 +320,7 @@ if(is_resource($this->connection)){ return fwrite($this->connection, $data.CRLF, strlen($data)+2); - + }else return FALSE; } @@ -349,7 +350,7 @@ /** * Sets a variable */ - + function set($var, $value){ $this->$var = $value; Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-06-23 15:52:46 UTC (rev 3515) +++ trunk/index.php 2010-06-24 08:31:39 UTC (rev 3516) @@ -991,6 +991,11 @@ <?php echo '<p>• <a href="' . $rootpath . '/FormDesigner.php">' . _('Form Layout Editor') . '</a></p>'; ?> </td> </tr> + <tr> + <td class="menu_group_item"> + <?php echo '<p>• <a href="' . $rootpath . '/SMTPServer.php">' . _('SMTP Server Details') . '</a></p>'; ?> + </td> + </tr> </table> </td> Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-23 15:52:46 UTC (rev 3515) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-24 08:31:39 UTC (rev 3516) @@ -248,4 +248,19 @@ CONSTRAINT `offers_ibfk_2` FOREIGN KEY (`stockid`) REFERENCES `stockmaster` (`stockid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `config` VALUES('PurchasingManagerEmail', ''); \ No newline at end of file +INSERT INTO `config` VALUES('PurchasingManagerEmail', ''); + +CREATE TABLE `emailsettings` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `host` varchar(30) NOT NULL, + `port` char(5) NOT NULL, + `heloaddress` varchar(20) NOT NULL, + `username` varchar(30) DEFAULT NULL, + `password` varchar(30) DEFAULT NULL, + `timeout` int(11) DEFAULT '5', + `companyname` varchar(50) DEFAULT NULL, + `auth` tinyint(1) DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO emailsettings VALUES(Null, 'localhost', 25, 'helo', '', '', 5, '', 0); \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |