From cvs w lms.org.pl Mon Feb 14 15:53:28 2011 From: cvs w lms.org.pl (LMS CVS) Date: Mon, 14 Feb 2011 15:53:28 +0100 (CET) Subject: [lms-commits] CVS update of lms/lib (dns.php) Message-ID: <20110214145329.0203E30278BD@eftep.altec.pl> Date: Monday, February 14, 2011 @ 15:53:28 Author: chilek Path: /cvsroot/lms/lib Modified: dns.php - PTR records are accepted in zones - fixed dot insertion with name '0' Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/lib/dns.php.diff?&r1=1.6&r2=1.7 Index: lms/lib/dns.php diff -u lms/lib/dns.php:1.6 lms/lib/dns.php:1.7 --- lms/lib/dns.php:1.6 Tue Jan 18 09:12:05 2011 +++ lms/lib/dns.php Mon Feb 14 15:53:28 2011 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: dns.php,v 1.6 2011/01/18 08:12:05 alec Exp $ + * $Id: dns.php,v 1.7 2011/02/14 14:53:28 chilek Exp $ */ $valid_tlds = array( @@ -228,8 +228,6 @@ if (!in_array($record['type'], $arpa_records)) $error['type'] = trans('Wrong record type!'); } - else if ($record['type'] == 'PTR') - $error['type'] = trans('You can\'t add PTR record to this domain!'); if ($error) return; @@ -282,11 +280,8 @@ $error['desc'] = trans('Field cannot be empty!'); break; case 'PTR': - if (preg_match('/in-addr\.arpa$/', $record['domainname'])) - { - if ($errorcontent = check_hostname_fqdn($record['domain'], false, true)) - $error['domain'] = $errorcontent; - } + if ($errorcontent = check_hostname_fqdn($record['domain'], false, true)) + $error['domain'] = $errorcontent; break; case 'SOA': foreach (array('serial', 'refresh', 'retry', 'expire', 'minttl') as $idx) From cvs w lms.org.pl Mon Feb 14 15:53:29 2011 From: cvs w lms.org.pl (LMS CVS) Date: Mon, 14 Feb 2011 15:53:29 +0100 (CET) Subject: [lms-commits] CVS update of lms/modules (recordadd.php, recordedit.php) Message-ID: <20110214145329.1BF9E30278CE@eftep.altec.pl> Date: Monday, February 14, 2011 @ 15:53:29 Author: chilek Path: /cvsroot/lms/modules Modified: recordadd.php recordedit.php - PTR records are accepted in zones - fixed dot insertion with name '0' Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/modules/recordadd.php.diff?&r1=1.14&r2=1.15 http://cvs.lms.org.pl/viewvc/Development/lms/modules/recordedit.php.diff?&r1=1.13&r2=1.14 Index: lms/modules/recordadd.php diff -u lms/modules/recordadd.php:1.14 lms/modules/recordadd.php:1.15 --- lms/modules/recordadd.php:1.14 Fri Apr 9 19:01:32 2010 +++ lms/modules/recordadd.php Mon Feb 14 15:53:28 2011 @@ -52,7 +52,7 @@ if (!$error) { - if (!empty($record['name'])) + if (strlen($record['name'])) $record['name'] = trim($record['name'], '.').'.'; $record['name'] .= $record['domainname']; Index: lms/modules/recordedit.php diff -u lms/modules/recordedit.php:1.13 lms/modules/recordedit.php:1.14 --- lms/modules/recordedit.php:1.13 Tue Apr 13 14:40:10 2010 +++ lms/modules/recordedit.php Mon Feb 14 15:53:28 2011 @@ -48,7 +48,7 @@ if (!$error) { - if (!empty($record['name'])) + if (strlen($record['name'])) $record['name'] = trim($record['name'],'.').'.'; $record['name'] .= $record['domainname']; From cvs w lms.org.pl Wed Feb 16 11:34:11 2011 From: cvs w lms.org.pl (LMS CVS) Date: Wed, 16 Feb 2011 11:34:11 +0100 (CET) Subject: [lms-commits] CVS update of lms/doc (ChangeLog) Message-ID: <20110216103411.1760E30278CE@eftep.altec.pl> Date: Wednesday, February 16, 2011 @ 11:34:11 Author: alec Path: /cvsroot/lms/doc Modified: ChangeLog - Fixed SQL query Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/doc/ChangeLog.diff?&r1=1.1537&r2=1.1538 Index: lms/doc/ChangeLog diff -u lms/doc/ChangeLog:1.1537 lms/doc/ChangeLog:1.1538 --- lms/doc/ChangeLog:1.1537 Sun Feb 6 10:41:37 2011 +++ lms/doc/ChangeLog Wed Feb 16 11:34:10 2011 @@ -1,4 +1,4 @@ -$Id: ChangeLog,v 1.1537 2011/02/06 09:41:37 alec Exp $ +$Id: ChangeLog,v 1.1538 2011/02/16 10:34:10 alec Exp $ version ? (????-??-??) @@ -8,6 +8,7 @@ instead of cash operation date (alec) - Fixed goto feature of the second scroller on the page (alec) - BTS#0000848: Fixed cash import history report when source is selected (alec) + - Fixed SQL query in lms-makewarnings (alec) version 1.11.11 Bray (2011-01-17) From cvs w lms.org.pl Wed Feb 16 11:34:10 2011 From: cvs w lms.org.pl (LMS CVS) Date: Wed, 16 Feb 2011 11:34:10 +0100 (CET) Subject: [lms-commits] CVS update of lms/bin (lms-makewarnings) Message-ID: <20110216103410.D4AE230278BD@eftep.altec.pl> Date: Wednesday, February 16, 2011 @ 11:34:10 Author: alec Path: /cvsroot/lms/bin Modified: lms-makewarnings - Fixed SQL query Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/bin/lms-makewarnings.diff?&r1=1.39&r2=1.40 Index: lms/bin/lms-makewarnings diff -u lms/bin/lms-makewarnings:1.39 lms/bin/lms-makewarnings:1.40 --- lms/bin/lms-makewarnings:1.39 Tue Jan 18 09:11:58 2011 +++ lms/bin/lms-makewarnings Wed Feb 16 11:34:10 2011 @@ -20,7 +20,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # -# $Id: lms-makewarnings,v 1.39 2011/01/18 08:11:58 alec Exp $ +# $Id: lms-makewarnings,v 1.40 2011/02/16 10:34:10 alec Exp $ use strict; use DBI; @@ -283,7 +283,15 @@ if($customergroupscount || !$inicustomergroups) { my $balance = $row->{'balance'}; - my $sdbq = $dbase->prepare("SELECT MAX(at) AS at, SUM((value * (100 - discount)) / 100) AS value FROM assignments, tariffs WHERE tariffid = tariffs.id AND period = ".MONTH." AND (datefrom <= $currtime OR datefrom = 0) AND (dateto >= $currtime OR dateto = 0) AND customerid = $row->{'id'} GROUP BY customerid HAVING SUM(value * ((100 - discount) / 100)) > 0"); + my $sdbq = $dbase->prepare("SELECT MAX(a.at) AS at, SUM((t.value * (100 - a.discount)) / 100) AS value + FROM assignments a, tariffs t + WHERE a.tariffid = t.id + AND a.customerid = $row->{'id'} + AND a.period = ".MONTH." + AND (a.datefrom <= $currtime OR a.datefrom = 0) + AND (a.dateto >= $currtime OR a.dateto = 0) + GROUP BY a.customerid + HAVING SUM(t.value * ((100 - t.discount) / 100)) > 0"); $sdbq->execute(); $srow = $sdbq->fetchrow_hashref(); $sdbq->finish(); From cvs w lms.org.pl Wed Feb 16 11:42:45 2011 From: cvs w lms.org.pl (LMS CVS) Date: Wed, 16 Feb 2011 11:42:45 +0100 (CET) Subject: [lms-commits] CVS update of lms/bin (lms-makewarnings) Message-ID: <20110216104245.D7A0B30278BD@eftep.altec.pl> Date: Wednesday, February 16, 2011 @ 11:42:45 Author: alec Path: /cvsroot/lms/bin Modified: lms-makewarnings - Fix SQL query again Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/bin/lms-makewarnings.diff?&r1=1.40&r2=1.41 Index: lms/bin/lms-makewarnings diff -u lms/bin/lms-makewarnings:1.40 lms/bin/lms-makewarnings:1.41 --- lms/bin/lms-makewarnings:1.40 Wed Feb 16 11:34:10 2011 +++ lms/bin/lms-makewarnings Wed Feb 16 11:42:45 2011 @@ -20,7 +20,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # -# $Id: lms-makewarnings,v 1.40 2011/02/16 10:34:10 alec Exp $ +# $Id: lms-makewarnings,v 1.41 2011/02/16 10:42:45 alec Exp $ use strict; use DBI; @@ -291,7 +291,7 @@ AND (a.datefrom <= $currtime OR a.datefrom = 0) AND (a.dateto >= $currtime OR a.dateto = 0) GROUP BY a.customerid - HAVING SUM(t.value * ((100 - t.discount) / 100)) > 0"); + HAVING SUM(t.value * ((100 - a.discount) / 100)) > 0"); $sdbq->execute(); $srow = $sdbq->fetchrow_hashref(); $sdbq->finish(); From cvs w lms.org.pl Wed Feb 16 13:37:35 2011 From: cvs w lms.org.pl (LMS CVS) Date: Wed, 16 Feb 2011 13:37:35 +0100 (CET) Subject: [lms-commits] CVS update of lms/doc (ChangeLog) Message-ID: <20110216123735.4490930278BD@eftep.altec.pl> Date: Wednesday, February 16, 2011 @ 13:37:35 Author: alec Path: /cvsroot/lms/doc Modified: ChangeLog - Fixed order of tables in database backup - Fixed printing of DB errors while recovering database backup Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/doc/ChangeLog.diff?&r1=1.1538&r2=1.1539 Index: lms/doc/ChangeLog diff -u lms/doc/ChangeLog:1.1538 lms/doc/ChangeLog:1.1539 --- lms/doc/ChangeLog:1.1538 Wed Feb 16 11:34:10 2011 +++ lms/doc/ChangeLog Wed Feb 16 13:37:34 2011 @@ -1,4 +1,4 @@ -$Id: ChangeLog,v 1.1538 2011/02/16 10:34:10 alec Exp $ +$Id: ChangeLog,v 1.1539 2011/02/16 12:37:34 alec Exp $ version ? (????-??-??) @@ -9,6 +9,8 @@ - Fixed goto feature of the second scroller on the page (alec) - BTS#0000848: Fixed cash import history report when source is selected (alec) - Fixed SQL query in lms-makewarnings (alec) + - Fixed order of tables in database backup (alec) + - Fixed printing of DB errors while recovering database backup (alec) version 1.11.11 Bray (2011-01-17) From cvs w lms.org.pl Wed Feb 16 13:37:35 2011 From: cvs w lms.org.pl (LMS CVS) Date: Wed, 16 Feb 2011 13:37:35 +0100 (CET) Subject: [lms-commits] CVS update of lms/modules (dbrecover.php) Message-ID: <20110216123735.A08B830278CF@eftep.altec.pl> Date: Wednesday, February 16, 2011 @ 13:37:35 Author: alec Path: /cvsroot/lms/modules Modified: dbrecover.php - Fixed order of tables in database backup - Fixed printing of DB errors while recovering database backup Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/modules/dbrecover.php.diff?&r1=1.57&r2=1.58 Index: lms/modules/dbrecover.php diff -u lms/modules/dbrecover.php:1.57 lms/modules/dbrecover.php:1.58 --- lms/modules/dbrecover.php:1.57 Tue Jan 18 09:12:22 2011 +++ lms/modules/dbrecover.php Wed Feb 16 13:37:35 2011 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: dbrecover.php,v 1.57 2011/01/18 08:12:22 alec Exp $ + * $Id: dbrecover.php,v 1.58 2011/02/16 12:37:35 alec Exp $ */ function DBLoad($filename=NULL) @@ -33,12 +33,12 @@ $finfo = pathinfo($filename); $ext = $finfo['extension']; - if ((extension_loaded('zlib'))&&($ext=='gz')) + if ($ext == 'gz' && extension_loaded('zlib')) $file = gzopen($filename,'r'); //jezeli chcemy gz to plik najpierw trzeba rozpakowac else $file = fopen($filename,'r'); - $DB->BeginTrans(); // przyspieszmy działanie jeżeli baza danych obsługuje transakcje + $DB->BeginTrans(); // przyspieszmy dziaĹ‚anie jeĹĽeli baza danych obsĹ‚uguje transakcje while(!feof($file)) { $line = fgets($file, 8192); @@ -55,9 +55,9 @@ else fclose($file); - // Okej, zróbmy parę bzdurek db depend :S + // Okej, zrĂłbmy parÄ™ bzdurek db depend :S // Postgres sux ! (warden) - // Tak, a łyżka na to 'niemożliwe' i poleciała za wann± potr±caj±c bannanem musztardę (lukasz) + // Tak, a Ĺ‚yĹĽka na to 'niemoĹĽliwe' i poleciaĹ‚a za wannÄ… potrÄ…cajÄ…c bannanem musztardÄ™ (lukasz) switch($CONFIG['database']['type']) { @@ -94,13 +94,15 @@ { DBLoad($CONFIG['directories']['backup_dir'].'/lms-'.$db.'.sql'); } - elseif ((extension_loaded('zlib'))&&(file_exists($CONFIG['directories']['backup_dir'].'/lms-'.$db.'.sql.gz'))) + elseif (extension_loaded('zlib') && file_exists($CONFIG['directories']['backup_dir'].'/lms-'.$db.'.sql.gz')) { DBLoad($CONFIG['directories']['backup_dir'].'/lms-'.$db.'.sql.gz'); } - - $SESSION->redirect('?m='.$SESSION->get('lastmodule')); -}else{ + + include(MODULES_DIR . '/dblist.php'); +// $SESSION->redirect('?m='.$SESSION->get('lastmodule')); +} +else { $layout['pagetitle'] = trans('Database Backup Recovery'); $SMARTY->display('header.html'); echo '

'.trans('Database Backup Recovery').'

'; From cvs w lms.org.pl Wed Feb 16 13:37:35 2011 From: cvs w lms.org.pl (LMS CVS) Date: Wed, 16 Feb 2011 13:37:35 +0100 (CET) Subject: [lms-commits] CVS update of lms/lib (LMS.class.php) Message-ID: <20110216123735.7F9DC30278CE@eftep.altec.pl> Date: Wednesday, February 16, 2011 @ 13:37:35 Author: alec Path: /cvsroot/lms/lib Modified: LMS.class.php - Fixed order of tables in database backup - Fixed printing of DB errors while recovering database backup Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/lib/LMS.class.php.diff?&r1=1.1049&r2=1.1050 Index: lms/lib/LMS.class.php diff -u lms/lib/LMS.class.php:1.1049 lms/lib/LMS.class.php:1.1050 --- lms/lib/LMS.class.php:1.1049 Tue Jan 18 09:12:05 2011 +++ lms/lib/LMS.class.php Wed Feb 16 13:37:35 2011 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: LMS.class.php,v 1.1049 2011/01/18 08:12:05 alec Exp $ + * $Id: LMS.class.php,v 1.1050 2011/02/16 12:37:35 alec Exp $ */ // LMS Class - contains internal LMS database functions used @@ -34,7 +34,7 @@ var $CONFIG; // table including lms.ini options var $cache = array(); // internal cache var $_version = '1.11-cvs'; // class version - var $_revision = '$Revision: 1.1049 $'; + var $_revision = '$Revision: 1.1050 $'; function LMS(&$DB, &$AUTH, &$CONFIG) // class variables setting { @@ -65,7 +65,7 @@ $this->DB->Execute('SET @lms_current_user=?', array($this->AUTH->id)); break; } - } + } /* * Logging @@ -91,26 +91,51 @@ function DBDump($filename=NULL, $gzipped=FALSE, $stats=FALSE) // dump database to file { - if(! $filename) + if (!$filename) return FALSE; - if (($gzipped)&&(extension_loaded('zlib'))) + + if ($gzipped && extension_loaded('zlib')) $dumpfile = gzopen($filename,'w'); else $dumpfile = fopen($filename,'w'); if($dumpfile) { - foreach($this->DB->ListTables() as $tablename) + $tables = $this->DB->ListTables(); + + foreach ($tables as $tablename) + { + // skip sessions table for security + if($tablename == 'sessions' || ($tablename == 'stats' && $stats == FALSE)) + continue; + + fputs($dumpfile, "DELETE FROM $tablename;\n"); + } + + // Since we're using foreign keys, order of tables is important + // Note: add all referenced tables to the list + $order = array('users', 'customers', 'customergroups', 'nodes', 'numberplans', + 'assignments', 'rtqueues', 'rttickets', 'rtmessages', 'domains', + 'cashsources', 'sourcefiles', 'ewx_channels'); + + foreach ($tables as $idx => $table) { + if (in_array($table, $order)) { + unset($tables[$idx]); + } + } + + $tables = array_merge($order, $tables); + + foreach ($tables as $tablename) { - // skip sessions table for security + // skip sessions table for security if($tablename == 'sessions' || ($tablename == 'stats' && $stats == FALSE)) continue; - - fputs($dumpfile,"DELETE FROM $tablename;\n"); + $this->DB->Execute('SELECT * FROM '.$tablename); while($row = $this->DB->_driver_fetchrow_assoc()) { - fputs($dumpfile,"INSERT INTO $tablename ("); + fputs($dumpfile, "INSERT INTO $tablename ("); foreach($row as $field => $value) { $fields[] = $field; @@ -127,7 +152,8 @@ unset($values); } } - if (($gzipped)&&(extension_loaded('zlib'))) + + if ($gzipped && extension_loaded('zlib')) gzclose($dumpfile); else fclose($dumpfile); From cvs w lms.org.pl Thu Feb 17 13:08:43 2011 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 17 Feb 2011 13:08:43 +0100 (CET) Subject: [lms-commits] CVS update of lms/lib/locale/pl (strings.php) Message-ID: <20110217120843.F2EC930278CF@eftep.altec.pl> Date: Thursday, February 17, 2011 @ 13:08:43 Author: alec Path: /cvsroot/lms/lib/locale/pl Modified: strings.php - Use tariff name+value as a unique key instead of just a name Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/lib/locale/pl/strings.php.diff?&r1=1.374&r2=1.375 Index: lms/lib/locale/pl/strings.php diff -u lms/lib/locale/pl/strings.php:1.374 lms/lib/locale/pl/strings.php:1.375 --- lms/lib/locale/pl/strings.php:1.374 Tue Jan 18 09:12:07 2011 +++ lms/lib/locale/pl/strings.php Thu Feb 17 13:08:43 2011 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: strings.php,v 1.374 2011/01/18 08:12:07 alec Exp $ + * $Id: strings.php,v 1.375 2011/02/17 12:08:43 alec Exp $ */ $_LANG['$0 ($1 addresses)'] = '$0 ($1 adresów)'; @@ -1243,7 +1243,6 @@ $_LANG['System information and management'] = 'Informacje o systemie i administracja'; $_LANG['System version:'] = 'Wersja systemu:'; $_LANG['Table of financial operations'] = 'Tabela operacji finansowych'; -$_LANG['Subscription $0 already exists!'] = 'Taryfa $0 już istnieje!'; $_LANG['Subscription Edit: $0'] = 'Edycja taryfy: $0'; $_LANG['Subscription Info: $0'] = 'Informacje o taryfie: $0'; $_LANG['Subscription List'] = 'Lista taryf'; @@ -1251,7 +1250,7 @@ $_LANG['Subscriptions and Network Finances Management'] = 'Taryfy i zarz±dzanie finansami sieci'; $_LANG['Subscriptions List'] = 'Lista taryf'; $_LANG['Subscription with assigned customers cannot be deleted!'] = 'Taryfa z przypisanymi klientami nie może zostać usunięta!'; -$_LANG['Subscription with specified name already exists!'] = 'Taryfa o okre¶lonej nazwie już istnieje!'; +$_LANG['Subscription with specified name and value already exists!'] = 'Taryfa o okre¶lonej nazwie i kwocie już istnieje!'; $_LANG['summaries hiding'] = 'ukrywanie zestawień'; $_LANG['Tax:'] = 'PTU:'; $_LANG['Tax Rate:'] = 'St. PTU:'; @@ -1357,7 +1356,6 @@ $_LANG['Value and description:'] = 'Warto¶ć i opis:'; $_LANG['Value of tax rate which will be selected by default on tax rates lists. Default: 22.0'] = 'Warto¶ć stawki procentowej, która ma być domy¶lnie zaznaczona na listach wyboru stawki. Domy¶lnie: 22.0'; $_LANG['Value of option "$0" must be a number grater than zero!'] = 'Warto¶ć opcji "$0" musi być większa od zera!'; -$_LANG['Value required!'] = 'Warto¶ć wymagana!'; $_LANG['View'] = 'Podgl±d'; $_LANG['waiting'] = 'oczekuj±cy'; $_LANG['Waiting:'] = 'Oczekuj±cy:'; From cvs w lms.org.pl Thu Feb 17 13:08:43 2011 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 17 Feb 2011 13:08:43 +0100 (CET) Subject: [lms-commits] CVS update of lms/doc (ChangeLog, lms.mysql, lms.pgsql) Message-ID: <20110217120843.8229B30278BD@eftep.altec.pl> Date: Thursday, February 17, 2011 @ 13:08:43 Author: alec Path: /cvsroot/lms/doc Modified: ChangeLog lms.mysql lms.pgsql - Use tariff name+value as a unique key instead of just a name Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/doc/ChangeLog.diff?&r1=1.1539&r2=1.1540 http://cvs.lms.org.pl/viewvc/Development/lms/doc/lms.mysql.diff?&r1=1.180&r2=1.181 http://cvs.lms.org.pl/viewvc/Development/lms/doc/lms.pgsql.diff?&r1=1.176&r2=1.177 Index: lms/doc/ChangeLog diff -u lms/doc/ChangeLog:1.1539 lms/doc/ChangeLog:1.1540 --- lms/doc/ChangeLog:1.1539 Wed Feb 16 13:37:34 2011 +++ lms/doc/ChangeLog Thu Feb 17 13:08:42 2011 @@ -1,4 +1,4 @@ -$Id: ChangeLog,v 1.1539 2011/02/16 12:37:34 alec Exp $ +$Id: ChangeLog,v 1.1540 2011/02/17 12:08:42 alec Exp $ version ? (????-??-??) @@ -11,6 +11,7 @@ - Fixed SQL query in lms-makewarnings (alec) - Fixed order of tables in database backup (alec) - Fixed printing of DB errors while recovering database backup (alec) + - Use tariff name+value as a unique key instead of just a name (alec) version 1.11.11 Bray (2011-01-17) Index: lms/doc/lms.mysql diff -u lms/doc/lms.mysql:1.180 lms/doc/lms.mysql:1.181 --- lms/doc/lms.mysql:1.180 Thu Dec 30 11:22:21 2010 +++ lms/doc/lms.mysql Thu Feb 17 13:08:42 2011 @@ -1,5 +1,5 @@ # -------------------------------------------------------- -# $Id: lms.mysql,v 1.180 2010/12/30 10:22:21 alec Exp $ +# $Id: lms.mysql,v 1.181 2011/02/17 12:08:42 alec Exp $ # -------------------------------------------------------- # -- Drop tables first, MySQL doesn't support CASCADE @@ -728,7 +728,7 @@ quota_sql_limit int(11) DEFAULT NULL, description text NOT NULL, PRIMARY KEY (id), - UNIQUE KEY name (name), + UNIQUE KEY name (name, value), INDEX type (type) ) ENGINE=InnoDB; @@ -1425,4 +1425,4 @@ # -------------------------------------------------------- -INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2010122700'); +INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2011021700'); Index: lms/doc/lms.pgsql diff -u lms/doc/lms.pgsql:1.176 lms/doc/lms.pgsql:1.177 --- lms/doc/lms.pgsql:1.176 Thu Dec 30 14:52:07 2010 +++ lms/doc/lms.pgsql Thu Feb 17 13:08:42 2011 @@ -1,4 +1,4 @@ -/* $Id: lms.pgsql,v 1.176 2010/12/30 13:52:07 alec Exp $ */ +/* $Id: lms.pgsql,v 1.177 2011/02/17 12:08:42 alec Exp $ */ /* -------------------------------------------------------- Structure of table "users" @@ -311,7 +311,7 @@ quota_sql_limit integer DEFAULT NULL, description text DEFAULT '' NOT NULL, PRIMARY KEY (id), - UNIQUE (name) + UNIQUE (name, value) ); CREATE INDEX tariffs_type_idx ON tariffs (type); @@ -1519,4 +1519,4 @@ INSERT INTO nastypes (name) VALUES ('usrhiper'); INSERT INTO nastypes (name) VALUES ('other'); -INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2010122700'); +INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2011021700'); From cvs w lms.org.pl Thu Feb 17 13:08:44 2011 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 17 Feb 2011 13:08:44 +0100 (CET) Subject: [lms-commits] CVS update of lms/lib/upgradedb (2 files) Message-ID: <20110217120844.1C77E30278D0@eftep.altec.pl> Date: Thursday, February 17, 2011 @ 13:08:44 Author: alec Path: /cvsroot/lms/lib/upgradedb Added: mysql.2011021700.php postgres.2011021700.php - Use tariff name+value as a unique key instead of just a name Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/lib/upgradedb/mysql.2011021700.php?rev=1.1 http://cvs.lms.org.pl/viewvc/Development/lms/lib/upgradedb/postgres.2011021700.php?rev=1.1 Index: lms/lib/upgradedb/mysql.2011021700.php diff -u /dev/null lms/lib/upgradedb/mysql.2011021700.php:1.1 --- /dev/null Thu Feb 17 13:08:44 2011 +++ lms/lib/upgradedb/mysql.2011021700.php Thu Feb 17 13:08:43 2011 @@ -0,0 +1,33 @@ +BeginTrans(); + +$DB->Execute("ALTER TABLE tariffs DROP KEY name"); +$DB->Execute("ALTER TABLE tariffs ADD UNIQUE KEY name (name, value)"); + +$DB->Execute("UPDATE dbinfo SET keyvalue = ? WHERE keytype = ?", array('2011021700', 'dbversion')); + +$DB->CommitTrans(); + +?> Index: lms/lib/upgradedb/postgres.2011021700.php diff -u /dev/null lms/lib/upgradedb/postgres.2011021700.php:1.1 --- /dev/null Thu Feb 17 13:08:44 2011 +++ lms/lib/upgradedb/postgres.2011021700.php Thu Feb 17 13:08:43 2011 @@ -0,0 +1,33 @@ +BeginTrans(); + +$DB->Execute("ALTER TABLE tariffs DROP CONSTRAINT tariffs_name_key"); +$DB->Execute("ALTER TABLE tariffs ADD UNIQUE(name, value)"); + +$DB->Execute("UPDATE dbinfo SET keyvalue = ? WHERE keytype = ?", array('2011021700', 'dbversion')); + +$DB->CommitTrans(); + +?> From cvs w lms.org.pl Thu Feb 17 13:08:43 2011 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 17 Feb 2011 13:08:43 +0100 (CET) Subject: [lms-commits] CVS update of lms/lib (LMS.class.php, upgradedb.php) Message-ID: <20110217120843.C6C8730278CE@eftep.altec.pl> Date: Thursday, February 17, 2011 @ 13:08:43 Author: alec Path: /cvsroot/lms/lib Modified: LMS.class.php upgradedb.php - Use tariff name+value as a unique key instead of just a name Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/lib/LMS.class.php.diff?&r1=1.1050&r2=1.1051 http://cvs.lms.org.pl/viewvc/Development/lms/lib/upgradedb.php.diff?&r1=1.185&r2=1.186 Index: lms/lib/LMS.class.php diff -u lms/lib/LMS.class.php:1.1050 lms/lib/LMS.class.php:1.1051 --- lms/lib/LMS.class.php:1.1050 Wed Feb 16 13:37:35 2011 +++ lms/lib/LMS.class.php Thu Feb 17 13:08:43 2011 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: LMS.class.php,v 1.1050 2011/02/16 12:37:35 alec Exp $ + * $Id: LMS.class.php,v 1.1051 2011/02/17 12:08:43 alec Exp $ */ // LMS Class - contains internal LMS database functions used @@ -34,7 +34,7 @@ var $CONFIG; // table including lms.ini options var $cache = array(); // internal cache var $_version = '1.11-cvs'; // class version - var $_revision = '$Revision: 1.1050 $'; + var $_revision = '$Revision: 1.1051 $'; function LMS(&$DB, &$AUTH, &$CONFIG) // class variables setting { @@ -2246,9 +2246,10 @@ return FALSE; } - function GetTariffIDByName($name) + function GetTariffIDByNameAndValue($name, $value) { - return $this->DB->GetOne('SELECT id FROM tariffs WHERE name=?', array($name)); + return $this->DB->GetOne('SELECT id FROM tariffs WHERE name = ? AND value = ?', + array($name, str_replace(',', '.', $value))); } function TariffAdd($tariff) Index: lms/lib/upgradedb.php diff -u lms/lib/upgradedb.php:1.185 lms/lib/upgradedb.php:1.186 --- lms/lib/upgradedb.php:1.185 Tue Jan 18 09:12:05 2011 +++ lms/lib/upgradedb.php Thu Feb 17 13:08:43 2011 @@ -21,10 +21,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: upgradedb.php,v 1.185 2011/01/18 08:12:05 alec Exp $ + * $Id: upgradedb.php,v 1.186 2011/02/17 12:08:43 alec Exp $ */ -define('DBVERSION', '2010122700'); // here should be always the newest version of database! +define('DBVERSION', '2011021700'); // here should be always the newest version of database! // it placed here to avoid read disk every time when we call this file. /* From cvs w lms.org.pl Thu Feb 17 13:08:44 2011 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 17 Feb 2011 13:08:44 +0100 (CET) Subject: [lms-commits] CVS update of lms/modules (3 files) Message-ID: <20110217120844.4BBD230278D1@eftep.altec.pl> Date: Thursday, February 17, 2011 @ 13:08:44 Author: alec Path: /cvsroot/lms/modules Modified: tariffadd.php tariffedit.php tarifflist.php - Use tariff name+value as a unique key instead of just a name Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/modules/tariffadd.php.diff?&r1=1.67&r2=1.68 http://cvs.lms.org.pl/viewvc/Development/lms/modules/tariffedit.php.diff?&r1=1.53&r2=1.54 http://cvs.lms.org.pl/viewvc/Development/lms/modules/tarifflist.php.diff?&r1=1.43&r2=1.44 Index: lms/modules/tariffadd.php diff -u lms/modules/tariffadd.php:1.67 lms/modules/tariffadd.php:1.68 --- lms/modules/tariffadd.php:1.67 Tue Jan 18 09:12:25 2011 +++ lms/modules/tariffadd.php Thu Feb 17 13:08:44 2011 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: tariffadd.php,v 1.67 2011/01/18 08:12:25 alec Exp $ + * $Id: tariffadd.php,v 1.68 2011/02/17 12:08:44 alec Exp $ */ if(isset($_POST['tariff'])) @@ -39,14 +39,15 @@ $tariff['value'] = str_replace(',','.',$tariff['value']); - if(!preg_match('/^[-]?[0-9.,]+$/', $tariff['value'])) + if (!preg_match('/^[-]?[0-9.,]+$/', $tariff['value'])) $error['value'] = trans('Incorrect subscription value!'); - if($tariff['name'] == '') + if ($tariff['name'] == '') $error['name'] = trans('Subscription name required!'); - else - if($LMS->GetTariffIDByName($tariff['name'])) - $error['name'] = trans('Subscription $0 already exists!',$tariff['name']); + else if (!$error) { + if ($LMS->GetTariffIDByNameAndValue($tariff['name'], $tariff['value'])) + $error['name'] = trans('Subscription with specified name and value already exists!'); + } $items = array('uprate', 'downrate', 'upceil', 'downceil', 'climit', 'plimit', 'dlimit'); Index: lms/modules/tariffedit.php diff -u lms/modules/tariffedit.php:1.53 lms/modules/tariffedit.php:1.54 --- lms/modules/tariffedit.php:1.53 Tue Jan 18 09:12:25 2011 +++ lms/modules/tariffedit.php Thu Feb 17 13:08:44 2011 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: tariffedit.php,v 1.53 2011/01/18 08:12:25 alec Exp $ + * $Id: tariffedit.php,v 1.54 2011/02/17 12:08:44 alec Exp $ */ if(!$LMS->TariffExists($_GET['id'])) @@ -37,23 +37,23 @@ foreach($tariff as $key => $value) $tariff[$key] = trim($value); + $tariff['id'] = $_GET['id']; $tariff['value'] = str_replace(',','.',$tariff['value']); - - if($tariff['value'] == '') - $error['value'] = trans('Value required!'); - elseif(!preg_match('/^[-]?[0-9.,]+$/', $tariff['value'])) + + if (!preg_match('/^[-]?[0-9.,]+$/', $tariff['value'])) $error['value'] = trans('Incorrect value!'); - if($tariff['name'] == '') + if ($tariff['name'] == '') $error['name'] = trans('Subscription name required!'); - elseif($LMS->GetTariffIDByName($tariff['name']) - && $tariff['name'] != $DB->GetOne('SELECT name FROM tariffs WHERE id=?', array($_GET['id']))) - { - $error['name'] = trans('Subscription with specified name already exists!'); + else if (!$error + && ($found_id = $LMS->GetTariffIDByNameAndValue($tariff['name'], $tariff['value'])) + && $found_id != $tariff['id'] + ) { + $error['name'] = trans('Subscription with specified name and value already exists!'); } $items = array('uprate', 'downrate', 'upceil', 'downceil', 'climit', 'plimit', 'dlimit'); - + foreach($items as $item) { if($tariff[$item]=='') @@ -98,7 +98,7 @@ 'quota_sh_limit', 'quota_mail_limit', 'quota_www_limit', 'quota_ftp_limit', 'quota_sql_limit', ); - + foreach($items as $item) { if(isset($limit[$item])) @@ -107,8 +107,6 @@ $error[$item] = trans('Integer value expected!'); } - $tariff['id'] = $_GET['id']; - if(!$error) { $LMS->TariffUpdate($tariff); @@ -117,7 +115,7 @@ } else $tariff = $LMS->GetTariff($_GET['id']); - + $layout['pagetitle'] = trans('Subscription Edit: $0',$tariff['name']); $SMARTY->assign('tariff',$tariff); Index: lms/modules/tarifflist.php diff -u lms/modules/tarifflist.php:1.43 lms/modules/tarifflist.php:1.44 --- lms/modules/tarifflist.php:1.43 Tue Jan 18 09:12:25 2011 +++ lms/modules/tarifflist.php Thu Feb 17 13:08:44 2011 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: tarifflist.php,v 1.43 2011/01/18 08:12:25 alec Exp $ + * $Id: tarifflist.php,v 1.44 2011/02/17 12:08:44 alec Exp $ */ function GetTariffList($order='name,asc', $type=NULL, $customergroupid=NULL) @@ -38,31 +38,31 @@ switch($order) { case 'id': - $sqlord = ' ORDER BY id'; + $sqlord = " ORDER BY id $direction"; break; case 'description': - $sqlord = ' ORDER BY t.description'; + $sqlord = " ORDER BY t.description $direction, t.name"; break; case 'value': - $sqlord = ' ORDER BY t.value'; + $sqlord = " ORDER BY t.value $direction, t.name"; break; case 'downrate': - $sqlord = ' ORDER BY t.downrate'; + $sqlord = " ORDER BY t.downrate $direction, t.name"; break; case 'downceil': - $sqlord = ' ORDER BY t.downceil'; + $sqlord = " ORDER BY t.downceil $direction, t.name"; break; case 'uprate': - $sqlord = ' ORDER BY t.uprate'; + $sqlord = " ORDER BY t.uprate $direction, t.name"; break; case 'upceil': - $sqlord = ' ORDER BY t.upceil'; + $sqlord = " ORDER BY t.upceil $direction, t.name"; break; case 'count': - $sqlord = ' ORDER BY customerscount'; + $sqlord = " ORDER BY customerscount $direction, t.name"; break; default: - $sqlord = ' ORDER BY t.name'; + $sqlord = " ORDER BY t.name, t.value DESC"; break; } @@ -100,7 +100,7 @@ ) a ON (a.tariffid = t.id) LEFT JOIN taxes ON (t.taxid = taxes.id)' .($type ? ' WHERE t.type = '.intval($type) : '') - .($sqlord != '' ? $sqlord.' '.$direction : ''))) + .($sqlord != '' ? $sqlord : ''))) { $unactive = $DB->GetAllByKey('SELECT tariffid, COUNT(*) AS count, SUM(CASE x.period From cvs w lms.org.pl Thu Feb 17 13:08:44 2011 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 17 Feb 2011 13:08:44 +0100 (CET) Subject: [lms-commits] CVS update of lms/templates (3 files) Message-ID: <20110217120844.7C9FE30278D2@eftep.altec.pl> Date: Thursday, February 17, 2011 @ 13:08:44 Author: alec Path: /cvsroot/lms/templates Modified: tariffadd.html tariffedit.html tarifflist.html - Use tariff name+value as a unique key instead of just a name Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/templates/tariffadd.html.diff?&r1=1.54&r2=1.55 http://cvs.lms.org.pl/viewvc/Development/lms/templates/tariffedit.html.diff?&r1=1.58&r2=1.59 http://cvs.lms.org.pl/viewvc/Development/lms/templates/tarifflist.html.diff?&r1=1.67&r2=1.68 Index: lms/templates/tariffadd.html diff -u lms/templates/tariffadd.html:1.54 lms/templates/tariffadd.html:1.55 --- lms/templates/tariffadd.html:1.54 Mon Dec 27 13:35:17 2010 +++ lms/templates/tariffadd.html Thu Feb 17 13:08:44 2011 @@ -1,5 +1,5 @@ {include file="header.html"} - +