Quick Search:

View

Revision:

Diff

Diff from 1862 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/oscommerce/includes/classes/database.php

Annotated File View

hpdl
1
1 <?php
2 /*
hpdl
15
3   $Id: database.php 1862 2009-03-06 23:34:07Z hpdl $
hpdl
1
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
1372
8   Copyright (c) 2007 osCommerce
hpdl
1
9
hpdl
1498
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
1
13 */
14
15   class osC_Database {
16     var $is_connected = false,
17         $link,
hpdl
368
18         $error_reporting = true,
19         $error = false,
hpdl
1
20         $error_number,
hpdl
368
21         $error_query,
hpdl
1
22         $server,
23         $username,
24         $password,
25         $debug = false,
26         $number_of_queries = 0,
hpdl
1372
27         $time_of_queries = 0,
28         $nextID = null,
29         $logging_transaction = false,
30         $logging_transaction_action = false;
hpdl
1
31
hpdl
1037
32     function &connect($server, $username, $password, $type = DB_DATABASE_CLASS) {
hpdl
1
33       require('database/' . $type . '.php');
34
35       $class = 'osC_Database_' . $type;
hpdl
368
36       $object = new $class($server, $username, $password);
hpdl
1
37
hpdl
368
38       return $object;
hpdl
1
39     }
40
41     function setConnected($boolean) {
42       if ($boolean === true) {
43         $this->is_connected = true;
44       } else {
45         $this->is_connected = false;
46       }
47     }
48
49     function isConnected() {
50       if ($this->is_connected === true) {
51         return true;
52       } else {
53         return false;
54       }
55     }
56
57     function &query($query) {
58       $osC_Database_Result =& new osC_Database_Result($this);
59       $osC_Database_Result->setQuery($query);
60
61       return $osC_Database_Result;
62     }
63
hpdl
368
64     function setError($error, $error_number = '', $query = '') {
hpdl
1
65       global $messageStack;
66
67       if ($this->error_reporting === true) {
68         $this->error = $error;
69         $this->error_number = $error_number;
hpdl
368
70         $this->error_query = $query;
hpdl
1
71
72         if (isset($messageStack)) {
73           $messageStack->add('debug', $this->getError());
74         }
75       }
76     }
77
78     function isError() {
79       if ($this->error === false) {
80         return false;
81       } else {
82         return true;
83       }
84     }
85
86     function getError() {
87       if ($this->isError()) {
88         $error = '';
89
90         if (!empty($this->error_number)) {
91           $error .= $this->error_number . ': ';
92         }
93
94         $error .= $this->error;
95
hpdl
368
96         if (!empty($this->error_query)) {
97           $error .= '; ' . htmlentities($this->error_query);
98         }
99
hpdl
1
100         return $error;
101       } else {
102         return false;
103       }
104     }
105
106     function setErrorReporting($boolean) {
107       if ($boolean === true) {
108         $this->error_reporting = true;
109       } else {
110         $this->error_reporting = false;
111       }
112     }
113
114     function setDebug($boolean) {
115       if ($boolean === true) {
116         $this->debug = true;
117       } else {
118         $this->debug = false;
119       }
120     }
121
122     function importSQL($sql_file, $database, $table_prefix = -1) {
123       if ($this->selectDatabase($database)) {
124         if (file_exists($sql_file)) {
125           $fd = fopen($sql_file, 'rb');
126           $import_queries = fread($fd, filesize($sql_file));
127           fclose($fd);
128         } else {
129           $this->setError(sprintf(ERROR_SQL_FILE_NONEXISTENT, $sql_file));
130
131           return false;
132         }
133
134         if (!get_cfg_var('safe_mode')) {
135           @set_time_limit(0);
136         }
137
138         $sql_queries = array();
139         $sql_length = strlen($import_queries);
140         $pos = strpos($import_queries, ';');
141
142         for ($i=$pos; $i<$sql_length; $i++) {
143 // remove comments
144           if ($import_queries[0] == '#') {
145             $import_queries = ltrim(substr($import_queries, strpos($import_queries, "\n")));
146             $sql_length = strlen($import_queries);
147             $i = strpos($import_queries, ';')-1;
148             continue;
149           }
150
151           if ($import_queries[($i+1)] == "\n") {
hpdl
658
152             $next = '';
153
hpdl
1
154             for ($j=($i+2); $j<$sql_length; $j++) {
155               if (!empty($import_queries[$j])) {
156                 $next = substr($import_queries, $j, 6);
157
158                 if ($next[0] == '#') {
159 // find out where the break position is so we can remove this line (#comment line)
160                   for ($k=$j; $k<$sql_length; $k++) {
161                     if ($import_queries[$k] == "\n") {
162                       break;
163                     }
164                   }
165
166                   $query = substr($import_queries, 0, $i+1);
167
168                   $import_queries = substr($import_queries, $k);
169
170 // join the query before the comment appeared, with the rest of the dump
171                   $import_queries = $query . $import_queries;
172                   $sql_length = strlen($import_queries);
173                   $i = strpos($import_queries, ';')-1;
174                   continue 2;
175                 }
176
177                 break;
178               }
179             }
180
181             if (empty($next)) { // get the last insert query
182               $next = 'insert';
183             }
184
185             if ((strtoupper($next) == 'DROP T') || (strtoupper($next) == 'CREATE') || (strtoupper($next) == 'INSERT')) {
186               $next = '';
187
188               $sql_query = substr($import_queries, 0, $i);
189
190               if ($table_prefix !== -1) {
191                 if (strtoupper(substr($sql_query, 0, 25)) == 'DROP TABLE IF EXISTS OSC_') {
192                   $sql_query = 'DROP TABLE IF EXISTS ' . $table_prefix . substr($sql_query, 25);
193                 } elseif (strtoupper(substr($sql_query, 0, 17)) == 'CREATE TABLE OSC_') {
194                   $sql_query = 'CREATE TABLE ' . $table_prefix . substr($sql_query, 17);
195                 } elseif (strtoupper(substr($sql_query, 0, 16)) == 'INSERT INTO OSC_') {
196                   $sql_query = 'INSERT INTO ' . $table_prefix . substr($sql_query, 16);
197                 }
198               }
199
hpdl
368
200               $sql_queries[] = trim($sql_query);
hpdl
1
201
202               $import_queries = ltrim(substr($import_queries, $i+1));
203               $sql_length = strlen($import_queries);
204               $i = strpos($import_queries, ';')-1;
205             }
206           }
207         }
208
209         for ($i=0, $n=sizeof($sql_queries); $i<$n; $i++) {
210           $this->simpleQuery($sql_queries[$i]);
hpdl
368
211
212           if ($this->isError()) {
213             break;
214           }
hpdl
1
215         }
216       }
217
218       if ($this->isError()) {
219         return false;
220       } else {
221         return true;
222       }
223     }
224
225     function hasCreatePermission($database) {
226       $db_created = false;
227
228       if (empty($database)) {
229         $this->setError(ERROR_DB_NO_DATABASE_SELECTED);
230
231         return false;
232       }
233
234       $this->setErrorReporting(false);
235
236       if ($this->selectDatabase($database) === false) {
237         $this->setErrorReporting(true);
238
239         if ($this->simpleQuery('create database ' . $database)) {
240           $db_created = true;
241         }
242       }
243
244       $this->setErrorReporting(true);
245
246       if ($this->isError() === false) {
247         if ($this->selectDatabase($database)) {
248           if ($this->simpleQuery('create table osCommerceTestTable1536f ( temp_id int )')) {
249             if ($db_created === true) {
250               $this->simpleQuery('drop database ' . $database);
251             } else {
252               $this->simpleQuery('drop table osCommerceTestTable1536f');
253             }
254           }
255         }
256       }
257
258       if ($this->isError()) {
259         return false;
260       } else {
261         return true;
262       }
263     }
264
265     function numberOfQueries() {
266       return $this->number_of_queries;
267     }
268
269     function timeOfQueries() {
270       return $this->time_of_queries;
271     }
272
273     function getMicroTime() {
274       list($usec, $sec) = explode(' ', microtime());
275
276       return ((float)$usec + (float)$sec);
277     }
278   }
279
280   class osC_Database_Result {
281     var $db_class,
282         $sql_query,
283         $query_handler,
284         $result,
285         $rows,
286         $affected_rows,
287         $cache_key,
288         $cache_expire,
289         $cache_data,
290         $cache_read = false,
291         $debug = false,
292         $batch_query = false,
293         $batch_number,
294         $batch_rows,
295         $batch_size,
296         $batch_to,
297         $batch_from,
hpdl
1372
298         $batch_select_field,
299         $logging = false,
300         $logging_module,
301         $logging_module_id,
302         $logging_fields = array(),
hpdl
1862
303         $logging_changed = array(),
304         $_db_tables = array();
hpdl
1
305
hpdl
1860
306     function __construct(&$db_class) {
hpdl
1
307       $this->db_class =& $db_class;
308     }
309
310     function setQuery($query) {
311       $this->sql_query = $query;
312     }
313
314     function appendQuery($query) {
315       $this->sql_query .= ' ' . $query;
316     }
317
318     function getQuery() {
319       return $this->sql_query;
320     }
321
322     function setDebug($boolean) {
323       if ($boolean === true) {
324         $this->debug = true;
325       } else {
326         $this->debug = false;
327       }
328     }
329
330     function valueMixed($column, $type = 'string') {
331       if (!isset($this->result)) {
332         $this->next();
333       }
334
335       switch ($type) {
336         case 'protected':
hpdl
757
337           return osc_output_string_protected($this->result[$column]);
hpdl
1
338           break;
339         case 'int':
340           return (int)$this->result[$column];
341           break;
342         case 'decimal':
343           return (float)$this->result[$column];
344           break;
345         case 'string':
346         default:
347           return $this->result[$column];
348       }
349     }
350
351     function value($column) {
352       return $this->valueMixed($column, 'string');
353     }
354
355     function valueProtected($column) {
356       return $this->valueMixed($column, 'protected');
357     }
358
359     function valueInt($column) {
360       return $this->valueMixed($column, 'int');
361     }
362
363     function valueDecimal($column) {
364       return $this->valueMixed($column, 'decimal');
365     }
366
hpdl
1372
367     function bindValueMixed($place_holder, $value, $type = 'string', $log = true) {
368       if ($log === true) {
369         $this->logging_fields[substr($place_holder, 1)] = $value;
370       }
371
hpdl
1
372       switch ($type) {
373         case 'int':
374           $value = intval($value);
375           break;
hpdl
368
376         case 'float':
377           $value = floatval($value);
378           break;
hpdl
1
379         case 'raw':
380           break;
381         case 'string':
382         default:
hpdl
1319
383           $value = "'" . $this->db_class->parseString(trim($value)) . "'";
hpdl
1
384       }
385
386       $this->bindReplace($place_holder, $value);
387     }
388
389     function bindReplace($place_holder, $value) {
390       $pos = strpos($this->sql_query, $place_holder);
391
392       if ($pos !== false) {
393         $length = strlen($place_holder);
394         $character_after_place_holder = substr($this->sql_query, $pos+$length, 1);
395
396         if (($character_after_place_holder === false) || ereg('[ ,)"]', $character_after_place_holder)) {
397           $this->sql_query = substr_replace($this->sql_query, $value, $pos, $length);
398         }
399       }
400     }
401
402     function bindValue($place_holder, $value) {
403       $this->bindValueMixed($place_holder, $value, 'string');
404     }
405
406     function bindInt($place_holder, $value) {
407       $this->bindValueMixed($place_holder, $value, 'int');
408     }
409
hpdl
368
410     function bindFloat($place_holder, $value) {
411       $this->bindValueMixed($place_holder, $value, 'float');
412     }
413
hpdl
1
414     function bindRaw($place_holder, $value) {
415       $this->bindValueMixed($place_holder, $value, 'raw');
416     }
417
hpdl
1862
418     function bindTable($place_holder, $value = null) {
419       if ( empty($value) ) { // remove :table_ from $place_holder and prefix it with the database name prefix value
420         if ( !isset($this->_db_tables[$place_holder]) ) {
421           $this->_db_tables[$place_holder] = DB_TABLE_PREFIX . substr($place_holder, 7);
422         }
423
424         $value = $this->_db_tables[$place_holder];
425       }
426
hpdl
1372
427       $this->bindValueMixed($place_holder, $value, 'raw', false);
hpdl
1
428     }
429
430     function next() {
431       if ($this->cache_read === true) {
432         list(, $this->result) = each($this->cache_data);
433       } else {
434         if (!isset($this->query_handler)) {
435           $this->execute();
436         }
437
438         $this->result = $this->db_class->next($this->query_handler);
439
440         if (isset($this->cache_key)) {
441           $this->cache_data[] = $this->result;
442         }
443       }
444
445       return $this->result;
446     }
447
448     function freeResult() {
449       global $osC_Cache;
450
451       if ($this->cache_read === false) {
452         if (eregi('^SELECT', $this->sql_query)) {
453           $this->db_class->freeResult($this->query_handler);
454         }
455
456         if (isset($this->cache_key)) {
hpdl
1860
457           $osC_Cache->write($this->cache_data, $this->cache_key);
hpdl
1
458         }
459       }
460
461       unset($this);
462     }
463
464     function numberOfRows() {
465       if (!isset($this->rows)) {
466         if (!isset($this->query_handler)) {
467           $this->execute();
468         }
469
470         if (isset($this->cache_key) && ($this->cache_read === true)) {
471           $this->rows = sizeof($this->cache_data);
472         } else {
473           $this->rows = $this->db_class->numberOfRows($this->query_handler);
474         }
475       }
476
477       return $this->rows;
478     }
479
480     function affectedRows() {
481       if (!isset($this->affected_rows)) {
482         if (!isset($this->query_handler)) {
483           $this->execute();
484         }
485
486         $this->affected_rows = $this->db_class->affectedRows();
487       }
488
489       return $this->affected_rows;
490     }
491
492     function execute() {
493       global $osC_Cache;
494
495       if (isset($this->cache_key)) {
496         if ($osC_Cache->read($this->cache_key, $this->cache_expire)) {
hpdl
1860
497           $this->cache_data = $osC_Cache->getCache();
hpdl
1
498
499           $this->cache_read = true;
500         }
501       }
502
503       if ($this->cache_read === false) {
hpdl
1372
504         if ($this->logging === true) {
505           $this->logging_action = substr($this->sql_query, 0, strpos($this->sql_query, ' '));
506
507           if ($this->logging_action == 'update') {
508             $db = split(' ', $this->sql_query, 3);
509             $this->logging_database = $db[1];
510
511             $test = $this->db_class->simpleQuery('select ' . implode(', ', array_keys($this->logging_fields)) . ' from ' . $this->logging_database . substr($this->sql_query, osc_strrpos_string($this->sql_query, ' where ')));
512
513             while ($result = $this->db_class->next($test)) {
514               foreach ($this->logging_fields as $key => $value) {
515                 if ($result[$key] != $value) {
516                   $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => $result[$key], 'new' => $value);
517                 }
518               }
519             }
520           } elseif ($this->logging_action == 'insert') {
521             $db = split(' ', $this->sql_query, 4);
522             $this->logging_database = $db[2];
523
524             foreach ($this->logging_fields as $key => $value) {
525               $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => '', 'new' => $value);
526             }
527           } elseif ($this->logging_action == 'delete') {
528             $db = split(' ', $this->sql_query, 4);
529             $this->logging_database = $db[2];
530
531             $del = $this->db_class->simpleQuery('select * from ' . $this->logging_database . ' ' . $db[3]);
532             while ($result = $this->db_class->next($del)) {
533               foreach ($result as $key => $value) {
534                 $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => $value, 'new' => '');
535               }
536             }
537           }
538         }
539
hpdl
1
540         $this->query_handler = $this->db_class->simpleQuery($this->sql_query, $this->debug);
541
hpdl
1372
542         if ($this->logging === true) {
543           if ($this->db_class->logging_transaction_action === false) {
544             $this->db_class->logging_transaction_action = $this->logging_action;
545           }
546
547           if ($this->affectedRows($this->query_handler) > 0) {
548             if (!empty($this->logging_changed)) {
549               if ( ($this->logging_action == 'insert') && !is_numeric($this->logging_module_id) ) {
550                 $this->logging_module_id = $this->db_class->nextID();
551                 $this->setNextID($this->logging_module_id);
552               }
553
554               if ( class_exists('osC_AdministratorsLog') ) {
555                 osC_AdministratorsLog::insert($this->logging_module, $this->db_class->logging_transaction_action, $this->logging_module_id, $this->logging_action, $this->logging_changed, $this->db_class->logging_transaction);
556               }
557             }
558           }
559         }
560
hpdl
1
561         if ($this->batch_query === true) {
hpdl
1385
562           $this->batch_size = $this->db_class->getBatchSize($this->sql_query, $this->batch_select_field);
hpdl
1
563
564           $this->batch_to = ($this->batch_rows * $this->batch_number);
565           if ($this->batch_to > $this->batch_size) {
566             $this->batch_to = $this->batch_size;
567           }
568
569           $this->batch_from = ($this->batch_rows * ($this->batch_number - 1));
570           if ($this->batch_to == 0) {
571             $this->batch_from = 0;
572           } else {
573             $this->batch_from++;
574           }
575         }
576
577         return $this->query_handler;
578       }
579     }
580
581     function executeRandom() {
582       return $this->query_handler = $this->db_class->randomQuery($this->sql_query);
583     }
584
585     function executeRandomMulti() {
586       return $this->query_handler = $this->db_class->randomQueryMulti($this->sql_query);
587     }
588
589     function setCache($key, $expire = 0) {
590       $this->cache_key = $key;
591       $this->cache_expire = $expire;
592     }
593
hpdl
1372
594     function setLogging($module, $id = null) {
595       $this->logging = true;
596       $this->logging_module = $module;
597       $this->logging_module_id = $id;
598     }
599
600     function setNextID($id) {
601       $this->db_class->nextID = $id;
602     }
603
hpdl
1
604     function toArray() {
605       if (!isset($this->result)) {
606         $this->next();
607       }
608
609       return $this->result;
610     }
611
hpdl
368
612     function prepareSearch($keywords, $columns, $embedded = false) {
613       if ($embedded === true) {
614         $this->sql_query .= ' and ';
615       }
616
617       $keywords_array = explode(' ', $keywords);
618
619       if ($this->db_class->use_fulltext === true) {
620         if ($this->db_class->use_fulltext_boolean === true) {
621           $keywords = '';
622
623           foreach ($keywords_array as $keyword) {
624             if ((substr($keyword, 0, 1) != '-') && (substr($keyword, 0, 1) != '+')) {
625               $keywords .= '+';
626             }
627
628             $keywords .= $keyword . ' ';
629           }
630
631           $keywords = substr($keywords, 0, -1);
632         }
633
634         $this->sql_query .= $this->db_class->prepareSearch($columns);
635         $this->bindValue(':keywords', $keywords);
636       } else {
637         foreach ($keywords_array as $keyword) {
638           $this->sql_query .= $this->db_class->prepareSearch($columns);
639
640           foreach ($columns as $column) {
641             $this->bindValue(':keyword', '%' . $keyword . '%');
642           }
643
644           $this->sql_query .= ' and ';
645         }
646
647         $this->sql_query = substr($this->sql_query, 0, -5);
648       }
649     }
650
hpdl
108
651     function setBatchLimit($batch_number = 1, $maximum_rows = 20, $select_field = '') {
hpdl
1
652       $this->batch_query = true;
hpdl
108
653       $this->batch_number = (is_numeric($batch_number) ? $batch_number : 1);
hpdl
1
654       $this->batch_rows = $maximum_rows;
655       $this->batch_select_field = (empty($select_field) ? '*' : $select_field);
656
hpdl
448
657       $from = max(($this->batch_number * $maximum_rows) - $maximum_rows, 0);
hpdl
1
658
659       $this->sql_query = $this->db_class->setBatchLimit($this->sql_query, $from, $maximum_rows);
660
661     }
662
hpdl
368
663     function getBatchSize() {
hpdl
1385
664       return $this->batch_size;
665     }
hpdl
1
666
hpdl
1385
667     function isBatchQuery() {
668       if ($this->batch_query === true) {
669         return true;
hpdl
1
670       }
671
hpdl
1385
672       return false;
hpdl
1
673     }
674
hpdl
1385
675     function getBatchTotalPages($text) {
hpdl
1
676       return sprintf($text, $this->batch_from, $this->batch_to, $this->batch_size);
677     }
678
hpdl
1385
679     function getBatchPageLinks($batch_keyword = 'page', $parameters = '', $with_pull_down_menu = true) {
680       $string = $this->getBatchPreviousPageLink($batch_keyword, $parameters);
681
682       if ( $with_pull_down_menu === true ) {
683         $string .= $this->getBatchPagesPullDownMenu($batch_keyword, $parameters);
684       }
685
686       $string .= $this->getBatchNextPageLink($batch_keyword, $parameters);
687
688       return $string;
689     }
690
691     function getBatchPagesPullDownMenu($batch_keyword = 'page', $parameters = '') {
hpdl
410
692       global $osC_Language;
693
hpdl
1
694       $number_of_pages = ceil($this->batch_size / $this->batch_rows);
695
hpdl
1385
696       if ( $number_of_pages > 1 ) {
hpdl
1
697         $pages_array = array();
hpdl
1385
698
699         for ( $i = 1; $i <= $number_of_pages; $i++ ) {
700           $pages_array[] = array('id' => $i,
701                                  'text' => $i);
hpdl
1
702         }
703
704         $hidden_parameter = '';
hpdl
1076
705
hpdl
1385
706         if ( !empty($parameters) ) {
hpdl
754
707           $parameters = explode('&', $parameters);
hpdl
1076
708
hpdl
1385
709           foreach ( $parameters as $parameter ) {
hpdl
1076
710             $keys = explode('=', $parameter, 2);
hpdl
1
711
hpdl
1385
712             if ( $keys[0] != $batch_keyword ) {
hpdl
1076
713               $hidden_parameter .= osc_draw_hidden_field($keys[0], (isset($keys[1]) ? $keys[1] : ''));
hpdl
1
714             }
715           }
716         }
717
hpdl
1385
718         $string = '<form action="' . osc_href_link(basename($_SERVER['SCRIPT_FILENAME'])) . '" action="get">' . $hidden_parameter .
719                   sprintf($osC_Language->get('result_set_current_page'), osc_draw_pull_down_menu($batch_keyword, $pages_array, $this->batch_number, 'onchange="this.form.submit();"'), $number_of_pages) .
720                   osc_draw_hidden_session_id_field() . '</form>';
721       } else {
722         $string = sprintf($osC_Language->get('result_set_current_page'), 1, 1);
723       }
hpdl
1
724
hpdl
1385
725       return $string;
726     }
hpdl
1
727
hpdl
1385
728     function getBatchPreviousPageLink($batch_keyword = 'page', $parameters = '') {
729       global $osC_Language;
hpdl
1
730
hpdl
1385
731       $get_parameter = '';
732
733       if ( !empty($parameters) ) {
734         $parameters = explode('&', $parameters);
735
736         foreach ( $parameters as $parameter ) {
737           $keys = explode('=', $parameter, 2);
738
739           if ( $keys[0] != $batch_keyword ) {
740             $get_parameter .= $keys[0] . (isset($keys[1]) ? '=' . $keys[1] : '') . '&';
741           }
hpdl
1
742         }
hpdl
1385
743       }
hpdl
1
744
hpdl
1385
745       if ( defined('OSC_IN_ADMIN') && ( OSC_IN_ADMIN === true ) ) {
746         $back_string = osc_icon('nav_back.png');
747         $back_grey_string = osc_icon('nav_back_grey.png');
hpdl
1
748       } else {
hpdl
1385
749         $back_string = $osC_Language->get('result_set_previous_page');
750         $back_grey_string = $osC_Language->get('result_set_previous_page');
hpdl
1
751       }
752
hpdl
1385
753       if ( $this->batch_number > 1 ) {
754         $string = osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $get_parameter . $batch_keyword . '=' . ($this->batch_number - 1)), $back_string);
755       } else {
756         $string = $back_grey_string;
757       }
758
759       $string .= '&nbsp;';
760
761       return $string;
hpdl
1
762     }
763
hpdl
1385
764     function getBatchNextPageLink($batch_keyword = 'page', $parameters = '') {
765       global $osC_Language;
766
767       $number_of_pages = ceil($this->batch_size / $this->batch_rows);
768
769       $get_parameter = '';
770
771       if ( !empty($parameters) ) {
772         $parameters = explode('&', $parameters);
773
774         foreach ( $parameters as $parameter ) {
775           $keys = explode('=', $parameter, 2);
776
777           if ( $keys[0] != $batch_keyword ) {
778             $get_parameter .= $keys[0] . (isset($keys[1]) ? '=' . $keys[1] : '') . '&';
779           }
780         }
hpdl
1
781       }
782
hpdl
1385
783       if ( defined('OSC_IN_ADMIN') && ( OSC_IN_ADMIN === true ) ) {
784         $forward_string = osc_icon('nav_forward.png');
785         $forward_grey_string = osc_icon('nav_forward_grey.png');
786       } else {
787         $forward_string = $osC_Language->get('result_set_next_page');
788         $forward_grey_string = $osC_Language->get('result_set_next_page');
789       }
790
791       $string = '&nbsp;';
792
793       if ( ( $this->batch_number < $number_of_pages ) && ( $number_of_pages != 1 ) ) {
794         $string .= osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $get_parameter . $batch_keyword . '=' . ($this->batch_number + 1)), $forward_string);
795       } else {
796         $string .= $forward_grey_string;
797       }
798
799       return $string;
hpdl
1
800     }
801   }
802 ?>