New wrapper functions introduced, TODOs.txt updated
[mailer.git] / inc / libs / network_functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/04/2009 *
4  * ===================                          Last change: 11/04/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : network_functions.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Functions for ext-network                        *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Funktionen fuer ext-network                      *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Private setter for current network id
44 function setCurrentNetworkId ($id) {
45         $GLOBALS['current_network_id'] = bigintval($id);
46 }
47
48 // Private getter for current network id
49 function getCurrentNetworkId () {
50         return $GLOBALS['current_network_id'];
51 }
52
53 // Handle a (maybe) sent form here
54 function doNetworkHandleForm () {
55         // Was the form sent?
56         if ((isFormSent()) || (isFormSent('edit')) || (isFormSent('delete')) || (isFormSent('change')) || (isFormSent('remove'))) {
57                 // Do we have a 'do'?
58                 if (isGetRequestParameterSet('do')) {
59                         // Process the request
60                         doAdminNetworkProcessForm();
61                 } else {
62                         // No 'do' found
63                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_DO_404--}');
64                 }
65         } // END - if
66 }
67
68 // Processes an admin form
69 function doAdminNetworkProcessForm () {
70         // Form really sent?
71         if ((!isFormSent()) && (!isFormSent('edit')) && (!isFormSent('delete')) && (!isFormSent('change')) && (!isFormSent('remove'))) {
72                 // Abort here
73                 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_FORM_NOT_SENT--}');
74                 return;
75         } elseif (!isGetRequestParameterSet('do')) {
76                 // No 'do' found
77                 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_DO_404--}');
78                 return;
79         }
80
81         // Create function name
82         $functionName = sprintf("doAdminNetworkProcess%s", capitalizeUnderscoreString(getRequestParameter('do')));
83
84         // Is the function valid?
85         if (!function_exists($functionName)) {
86                 // Invalid function name
87                 debug_report_bug(__FUNCTION__, __LINE__, 'Invalid do ' . getRequestParameter('do') . ', function ' . $functionName .' does not exist.', false);
88         } // END - if
89
90         // Call-back the method handling our request
91         call_user_func($functionName);
92 }
93
94 // Checks wether the (short) network name is already used (valid)
95 function isNetworkNameValid ($name) {
96         // Query for it
97         $result = SQL_QUERY_ESC("SELECT `network_id` FROM `{?_MYSQL_PREFIX?}_network_data` WHERE `network_short_name`='%s' LIMIT 1",
98                 array($name), __FUNCTION__, __LINE__);
99
100         // Does it exist?
101         $isValid = (SQL_NUMROWS($result) == 1);
102
103         // Free result
104         SQL_FREERESULT($result);
105
106         // Return result
107         return $isValid;
108 }
109
110 // Checks wether the given network type is already used (valid)
111 function isNetworkTypeHandleValid ($type, $networkId) {
112         // Query for it
113         $result = SQL_QUERY_ESC("SELECT `network_type_id` FROM `{?_MYSQL_PREFIX?}_network_types` WHERE `network_id`=%s AND `network_type_handle`='%s' LIMIT 1",
114                 array($networkId, $type), __FUNCTION__, __LINE__);
115
116         // Does it exist?
117         $isValid = (SQL_NUMROWS($result) == 1);
118
119         // Free result
120         SQL_FREERESULT($result);
121
122         // Return result
123         return $isValid;
124 }
125
126 // Checks wether the given network request parameter is already used (valid)
127 function isNetworkRequestParameterValid ($key, $type, $networkId) {
128         // Query for it
129         $result = SQL_QUERY_ESC("SELECT `network_param_id` FROM `{?_MYSQL_PREFIX?}_network_request_params` WHERE `network_id`=%s AND `network_type_id`=%s AND `request_param_key`='%s' LIMIT 1",
130                 array($networkId, $type, $key), __FUNCTION__, __LINE__);
131
132         // Does it exist?
133         $isValid = (SQL_NUMROWS($result) == 1);
134
135         // Free result
136         SQL_FREERESULT($result);
137
138         // Return result
139         return $isValid;
140 }
141
142 // Checks wether the given network API array translation
143 function isNetworkApiTranslationValid ($key, $type, $networkId) {
144         // Query for it
145         $result = SQL_QUERY_ESC("SELECT `network_api_id` FROM `{?_MYSQL_PREFIX?}_network_api_translation` WHERE `network_id`=%s AND `network_type_id`=%s AND `network_api_index`='%s' LIMIT 1",
146                 array($networkId, $type, $key), __FUNCTION__, __LINE__);
147
148         // Does it exist?
149         $isValid = (SQL_NUMROWS($result) == 1);
150
151         // Free result
152         SQL_FREERESULT($result);
153
154         // Return result
155         return $isValid;
156 }
157
158 // "Getter" for a network's data by provided id number
159 function getNetworkDataById ($id, $column = '') {
160         // Ids lower one are not accepted
161         if ($id < 1) {
162                 // Not good, should be fixed
163                 debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $id . ' is smaller than 1.');
164         } // END - if
165
166         // Set current network id
167         setCurrentNetworkId($id);
168
169         // Is it cached?
170         if (!isset($GLOBALS['network_data'][$id])) {
171                 // By default we have no data
172                 $GLOBALS['network_data'][$id] = array();
173
174                 // Query for the network data
175                 $result = SQL_QUERY_ESC("SELECT
176         `network_id`, `network_short_name`, `network_title`, `network_reflink`, `network_data_seperator`, `network_row_seperator`, `network_request_type`, `network_charset`
177 FROM
178         `{?_MYSQL_PREFIX?}_network_data`
179 WHERE
180         `network_id`=%s
181 LIMIT 1",
182                         array(bigintval($id)), __FUNCTION__, __LINE__);
183
184                 // Do we have an entry?
185                 if (SQL_NUMROWS($result) == 1) {
186                         // Then get it
187                         $GLOBALS['network_data'][$id] = SQL_FETCHARRAY($result);
188                 } // END - if
189
190                 // Free result
191                 SQL_FREERESULT($result);
192         } // END - if
193
194         // Return result
195         if (empty($column)) {
196                 // Return array
197                 return $GLOBALS['network_data'][$id];
198         } else {
199                 // Return column
200                 return $GLOBALS['network_data'][$id][$column];
201         }
202 }
203
204 // "Getter" for a network's data by provided type id number
205 function getNetworkDataByTypeId ($id, $column = '') {
206         // Ids lower one are not accepted
207         if ($id < 1) {
208                 // Not good, should be fixed
209                 debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $id . ' is smaller than 1.');
210         } // END - if
211
212         // Set current network id
213         setCurrentNetworkId($id);
214
215         // Is it cached?
216         if (!isset($GLOBALS['network_data'][$id])) {
217                 // By default we have no data
218                 $GLOBALS['network_data'][$id] = array();
219
220                 // Query for the network data
221                 $result = SQL_QUERY_ESC("SELECT
222         d.`network_id`, d.`network_short_name`, d.`network_title`, d.`network_reflink`, d.`network_data_seperator`, d.`network_row_seperator`, d.`network_request_type`, d.`network_charset`,
223         t.`network_type_handle`, t.`network_type_api_url`, t.`network_type_click_url`, t.`network_type_banner_url`
224 FROM
225         `{?_MYSQL_PREFIX?}_network_data` AS d
226 LEFT JOIN
227         `{?_MYSQL_PREFIX?}_network_types` AS t
228 ON
229         d.`network_id`=t.`network_id`
230 WHERE
231         t.`network_type_id`=%s
232 LIMIT 1",
233                         array(bigintval($id)), __FUNCTION__, __LINE__);
234
235                 // Do we have an entry?
236                 if (SQL_NUMROWS($result) == 1) {
237                         // Then get it
238                         $GLOBALS['network_data'][$id] = SQL_FETCHARRAY($result);
239                 } // END - if
240
241                 // Free result
242                 SQL_FREERESULT($result);
243         } // END - if
244
245         // Return result
246         if (empty($column)) {
247                 // Return array
248                 return $GLOBALS['network_data'][$id];
249         } else {
250                 // Return column
251                 return $GLOBALS['network_data'][$id][$column];
252         }
253 }
254
255 // "Getter" for a network type data by provided id number
256 function getNetworkTypeDataById ($id) {
257         // Ids lower one are not accepted
258         if ($id < 1) {
259                 // Not good, should be fixed
260                 debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $id . ' is smaller than 1.');
261         } // END - if
262
263         // By default we have no data
264         $GLOBALS['network_type_data'][$id] = array();
265
266         // Query for the network data
267         $result = SQL_QUERY_ESC("SELECT
268         `network_type_id`, `network_id`, `network_type_handle`, `network_type_api_url`, `network_type_click_url`, `network_type_banner_url`
269 FROM
270         `{?_MYSQL_PREFIX?}_network_types`
271 WHERE
272         `network_type_id`=%s
273 LIMIT 1",
274                 array(bigintval($id)), __FUNCTION__, __LINE__);
275
276         // Do we have an entry?
277         if (SQL_NUMROWS($result) == 1) {
278                 // Then get it
279                 $GLOBALS['network_type_data'][$id] = SQL_FETCHARRAY($result);
280         } // END - if
281
282         // Free result
283         SQL_FREERESULT($result);
284
285         // Return result
286         return $GLOBALS['network_type_data'][$id];
287 }
288
289 // "Getter" for a network request parameter data by provided id number
290 function getNetworkRequestParamsDataById ($id) {
291         // Ids lower one are not accepted
292         if ($id < 1) {
293                 // Not good, should be fixed
294                 debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $id . ' is smaller than 1.');
295         } // END - if
296
297         // By default we have no data
298         $networkRequestData = array();
299
300         // Query for the network data
301         $result = SQL_QUERY_ESC("SELECT
302         `network_param_id`, `network_id`, `network_type_id`, `request_param_key`, `request_param_value`, `request_param_default`
303 FROM
304         `{?_MYSQL_PREFIX?}_network_request_params`
305 WHERE
306         `network_param_id`=%s
307 LIMIT 1",
308                 array(bigintval($id)), __FUNCTION__, __LINE__);
309
310         // Do we have an entry?
311         if (SQL_NUMROWS($result) == 1) {
312                 // Then get it
313                 $networkRequestData = SQL_FETCHARRAY($result);
314         } // END - if
315
316         // Free result
317         SQL_FREERESULT($result);
318
319         // Return result
320         return $networkRequestData;
321 }
322
323 // Updates given network (id) with data from array
324 function doNetworkUpdateDataByArray ($id, $networkData) {
325         // Ids lower one are not accepted
326         if ($id < 1) {
327                 // Not good, should be fixed
328                 debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $id . ' is smaller than 1.');
329         } // END - if
330
331         // Just call our inner method
332         return adminSaveSettings($networkData, '_network_data', sprintf("`network_id`=%s", bigintval($id)), array(), false, false);
333 }
334
335 // Updates given network type handler (id) with data from array
336 function doNetworkUpdateTypeByArray ($id, $networkTypeData) {
337         // Ids lower one are not accepted
338         if ($id < 1) {
339                 // Not good, should be fixed
340                 debug_report_bug(__FUNCTION__, __LINE__, 'Network type handler id ' . $id . ' is smaller than 1.');
341         } // END - if
342
343         // Just call our inner method
344         return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($id)), array(), false, false);
345 }
346
347 // Updates given network request parameters (id) with data from array
348 function doNetworkUpdateParamsByArray ($id, $networkParamData) {
349         // Ids lower one are not accepted
350         if ($id < 1) {
351                 // Not good, should be fixed
352                 debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $id . ' is smaller than 1.');
353         } // END - if
354
355         // Just call our inner method
356         return adminSaveSettings($networkParamData, '_network_request_params', sprintf("`network_param_id`=%s", bigintval($id)), array(), false, false);
357 }
358
359 // Removes given network entry
360 function doAdminRemoveNetworkEntry ($table, $column, $id, $limit = 1) {
361         // Remove the entry
362         SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_network_%s` WHERE `%s`=%s LIMIT %s",
363                 array($table, $column, $id, $limit), __FUNCTION__, __LINE__);
364
365         // Return affected rows
366         return SQL_AFFECTEDROWS();
367 }
368
369 // Generates a list of networks for given script and returns it
370 function generateAdminNetworkList () {
371         // Init output
372         $content = '';
373
374         // Query for all networks
375         $result = SQL_QUERY('SELECT
376         `network_id`, `network_short_name`, `network_title`
377 FROM
378         `{?_MYSQL_PREFIX?}_network_data`
379 ORDER BY
380         `network_short_name` ASC', __FUNCTION__, __LINE__);
381
382         // Do we have entries?
383         if (!SQL_HASZERONUMS($result)) {
384                 // List all entries
385                 $rows = array();
386                 while ($row = SQL_FETCHARRAY($result)) {
387                         // Is this valid, then add it
388                         if ((is_array($row)) && (isset($row['network_id']))) {
389                                 // Add entry
390                                 $rows[$row['network_id']] = $row;
391                         } // END - if
392                 } // END - while
393
394                 // Generate the selection box
395                 $content = generateSelectionBoxFromArray($rows, 'network', 'network_id');
396         } else {
397                 // Nothing selected
398                 $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
399         }
400
401         // Free the result
402         SQL_FREERESULT($result);
403
404         // Return the list
405         return $content;
406 }
407
408 // Generator (somewhat getter) for a list of network types for given network id
409 function generateAdminNetworkTypeList ($networkId) {
410         // Init content
411         $content = '';
412
413         // Query all types of this network
414         $result = SQL_QUERY_ESC("SELECT
415         `network_type_id`, `network_type_handle`
416 FROM
417         `{?_MYSQL_PREFIX?}_network_types`
418 WHERE
419         `network_id`=%s
420 ORDER BY
421         `network_type_handle` ASC",
422                 array(
423                         bigintval($networkId)
424                 ), __FUNCTION__, __LINE__);
425
426         // Do we have entries?
427         if (!SQL_HASZERONUMS($result)) {
428                 // List all entries
429                 $rows = array();
430                 while ($row = SQL_FETCHARRAY($result)) {
431                         // Is this valid, then add it
432                         if ((is_array($row)) && (isset($row['network_type_id']))) {
433                                 // Add entry
434                                 $rows[$row['network_type_id']] = $row;
435                         } // END - if
436                 } // END - while
437
438                 // Generate the selection box
439                 $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id');
440         } else {
441                 // Nothing selected
442                 $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
443         }
444
445         // Free the result
446         SQL_FREERESULT($result);
447
448         // Return content
449         return $content;
450 }
451
452 // Generator (somewhat getter) for a list of network types for all types
453 function generateAdminDistinctNetworkTypeList () {
454         // Init content
455         $content = '';
456
457         // Query all types of this network
458         $result = SQL_QUERY('SELECT
459         t.`network_type_id`, t.`network_type_handle`, d.`network_title`
460 FROM
461         `{?_MYSQL_PREFIX?}_network_types` AS t
462 LEFT JOIN
463         `{?_MYSQL_PREFIX?}_network_data` AS d
464 ON
465         t.`network_id`=d.`network_id`
466 ORDER BY
467         d.`network_short_name` ASC,
468         t.`network_type_handle` ASC', __FUNCTION__, __LINE__);
469
470         // Do we have entries?
471         if (!SQL_HASZERONUMS($result)) {
472                 // List all entries
473                 $rows = array();
474                 while ($row = SQL_FETCHARRAY($result)) {
475                         // Is this valid, then add it
476                         if ((is_array($row)) && (isset($row['network_type_id']))) {
477                                 // Add entry
478                                 $rows[$row['network_type_id']] = $row;
479                         } // END - if
480                 } // END - while
481
482                 // Generate the selection box
483                 $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id', '', '_title');
484         } else {
485                 // Nothing selected
486                 $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
487         }
488
489         // Free the result
490         SQL_FREERESULT($result);
491         //* DEBUG: */ die('<pre>'.encodeEntities($content).'</pre>');
492
493         // Return content
494         return $content;
495 }
496
497 // Generator (somewhat getter) for network type options
498 function generateNetworkTypeOptions ($id) {
499         // Is this an array, then we just came back from edit/delete actions
500         if (is_array($id)) $id = '';
501
502         // Is this cached?
503         if (!isset($GLOBALS[__FUNCTION__][$id])) {
504                 // Generate output and cache it
505                 $GLOBALS[__FUNCTION__][$id] = generateOptionList(
506                         'network_types',
507                         'network_type_id',
508                         'network_type_handle',
509                         $id,
510                         '',
511                         sprintf(
512                                 "WHERE `network_id`=%s",
513                                 bigintval(getRequestParameter('network'))
514                         ),
515                         '',
516                         'translateNetworkTypeHandler'
517                 );
518         } // END - if
519
520         // Return content
521         return $GLOBALS[__FUNCTION__][$id];
522 }
523
524 // Generates an options list of all available (hard-coded) handlers
525 function generateNetworkTypesAvailableOptions () {
526         // Is it cached?
527         if (!isset($GLOBALS[__FUNCTION__])) {
528                 // Generate list
529                 $GLOBALS[__FUNCTION__] = generateOptionList(
530                         '/ARRAY/',
531                         array(
532                                 'banner',
533                                 'banner_click',
534                                 'banner_view',
535                                 'button',
536                                 'button_click',
537                                 'button_view',
538                                 'surfbar',
539                                 'surfbar_click',
540                                 'surfbar_view',
541                                 'forcedbanner',
542                                 'forcedtextlink',
543                                 'textlink',
544                                 'textlink_click',
545                                 'textlink_view',
546                                 'skybanner',
547                                 'skybanner_click',
548                                 'skybanner_view',
549                                 'layer',
550                                 'layer_click',
551                                 'layer_view',
552                                 'popup',
553                                 'popdown',
554                                 'textmail',
555                                 'htmlmail',
556                                 'lead',
557                                 'sale',
558                                 'payperactive',
559                                 'pagepeel',
560                                 'traffic'
561                         ),
562                         array(),
563                         '',
564                         '', '',
565                         $GLOBALS['network_types_disabled'],
566                         'translateNetworkTypeHandler'
567                 );
568         } // END - if
569
570         // Return content
571         return $GLOBALS[__FUNCTION__];
572 }
573
574 // Generates an options list (somewhat getter) ofr request keys
575 function generateNetworkRequestKeyOptions () {
576         // Is it cached?
577         if (!isset($GLOBALS[__FUNCTION__])) {
578                 // Generate and cache it
579                 $GLOBALS[__FUNCTION__] = generateOptionList(
580                         '/ARRAY/',
581                         array(
582                                 'id',
583                                 'sid',
584                                 'hash',
585                                 'password',
586                                 'reload',
587                                 'maximum_stay',
588                                 'minimum_stay',
589                                 'currency',
590                                 'type',
591                                 'remain',
592                                 'reward',
593                                 'size',
594                                 'erotic',
595                                 'extra',
596                                 'country'
597                         ),
598                         array(),
599                         '',
600                         '', '',
601                         $GLOBALS['network_params_disabled'],
602                         'translateNetworkRequestParameter'
603                 );
604         } // END - if
605
606         // Return content
607         return $GLOBALS[__FUNCTION__];
608 }
609
610 // Generator (somewhat getter) for (return) array translation
611 function generateNetworkTranslationOptions ($default = '') {
612         // Is it cached?
613         if (!isset($GLOBALS[__FUNCTION__][$default])) {
614                 // Generate and cache it
615                 $GLOBALS[__FUNCTION__][$default] = generateOptionList(
616                         'network_translations',
617                         'network_translation_id',
618                         'network_translation_name',
619                         $default,
620                         '',
621                         '',
622                         $GLOBALS['network_translation_disabled'],
623                         'translateNetworkTranslationName'
624                 );
625         } // END - if
626
627         // Return content
628         return $GLOBALS[__FUNCTION__][$default];
629 }
630
631 // Generates an option list of request types
632 function generateNetworkRequestTypeOptions ($default = '') {
633         // Do we have cache?
634         if (!isset($GLOBALS[__FUNCTION__][$default])) {
635                 // Generate the list
636                 $GLOBALS[__FUNCTION__][$default] = generateOptionList(
637                         '/ARRAY/',
638                         array(
639                                 'GET',
640                                 'POST'
641                         ),
642                         array(
643                                 '{--ADMIN_NETWORK_REQUEST_TYPE_GET--}',
644                                 '{--ADMIN_NETWORK_REQUEST_TYPE_POST--}'
645                         ),
646                         $default
647                 );
648         } // END - if
649
650         // Return cache
651         return $GLOBALS[__FUNCTION__][$default];
652 }
653
654 // Generates an option list of network_active
655 function generateNetworkActiveOptions ($default = '') {
656         // Do we have cache?
657         if (!isset($GLOBALS[__FUNCTION__][$default])) {
658                 // Generate the list
659                 $GLOBALS[__FUNCTION__][$default] = generateOptionList(
660                         '/ARRAY/',
661                         array(
662                                 'Y',
663                                 'N'
664                         ),
665                         array(
666                                 '{--YES--}',
667                                 '{--NO--}'
668                         ),
669                         $default
670                 );
671         } // END - if
672
673         // Return cache
674         return $GLOBALS[__FUNCTION__][$default];
675 }
676
677 // Translates 'translate_name' for e.g. templates
678 function translateNetworkTranslationName ($name) {
679         // Get the message id
680         return getMessage('ADMIN_NETWORK_TRANSLATE_' . strtoupper($name) . '_NAME');
681 }
682
683 // Translates the network type handler (e.g. banner, paidmail) for templates
684 function translateNetworkTypeHandler ($type) {
685         // Get the message id
686         return getMessage('ADMIN_NETWORK_TYPES_' . strtoupper($type) . '');
687 }
688
689 // Translates request type
690 function translateNetworkRequestType ($type) {
691         // Get the message id
692         return getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($type) . '');
693 }
694
695 // Translates request parameter
696 function translateNetworkRequestParameter ($param) {
697         // Get the message id
698         return getMessage('ADMIN_NETWORK_REQUEST_PARAMETER_' . strtoupper($param) . '');
699 }
700
701 // Translates API index
702 function translateNetworkApiIndex ($index) {
703         // Do we have cache?
704         if (!isset($GLOBALS['network_api_index'])) {
705                 // Get an array of all API array indexes
706                 $GLOBALS['network_api_index'] = array();
707
708                 // Get all entries
709                 $result = SQL_QUERY('SELECT
710         `network_api_id`, `network_api_index`, `network_translation_name`
711 FROM
712         `{?_MYSQL_PREFIX?}_network_api_translation`
713 INNER JOIN
714         `{?_MYSQL_PREFIX?}_network_translations`
715 ON
716         `network_api_index`=`network_translation_id`
717 ORDER BY
718         `sort` ASC', __FUNCTION__, __LINE__);
719
720                 // Do we have entries?
721                 if (!SQL_HASZERONUMS($result)) {
722                         // Get all entries
723                         while ($row = SQL_FETCHARRAY($result)) {
724                                 // Add it to our global array
725                                 $GLOBALS['network_api_index'][$row['network_api_index']] = $row;
726                         } // END - while
727                 } // END - if
728
729                 // Free result
730                 SQL_FREERESULT($result);
731         } // END - if
732
733         // Default name is unknown
734         $name = 'unknown';
735
736         // Is the entry there?
737         if (isset($GLOBALS['network_api_index'][$index])) {
738                 // Then get the name
739                 $name = $GLOBALS['network_api_index'][$index]['network_translation_name'];
740         } // END - if
741
742         // Return translation
743         return translateNetworkTranslationName($name);
744 }
745
746 //------------------------------------------------------------------------------
747 //                             Call-back functions
748 //------------------------------------------------------------------------------
749
750 // Callback function to add new network
751 function doAdminNetworkProcessAddNetwork () {
752         // We can say here, the form is sent, so check if the network is already added
753         if (isNetworkNameValid(postRequestParameter('network_short_name'))) {
754                 // Already there
755                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_ALREADY_ADDED', postRequestParameter('network_short_name')));
756                 return false;
757         } // END - if
758
759         // Remove the 'ok' part
760         unsetPostRequestParameter('ok');
761
762         // Add the whole request to database
763         SQL_QUERY('INSERT INTO
764         `{?_MYSQL_PREFIX?}_network_data`
765 (
766         `' . implode('`,`', array_keys(postRequestArray())) . "`
767 ) VALUES (
768         '" . implode("','", array_values(postRequestArray())) . "'
769 )", __FUNCTION__, __LINE__);
770
771         // Add the id for output only
772         setPostRequestParameter('network_id', SQL_INSERTID());
773
774         // Output message
775         if (!SQL_HASZEROAFFECTED()) {
776                 // Successfully added
777                 loadTemplate('admin_network_added', false, postRequestArray());
778         } else {
779                 // Not added
780                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_DATA_NOT_ADDED', postRequestParameter('network_short_name')));
781         }
782 }
783
784 // Displays selected networks for editing
785 function doAdminNetworkProcessHandleNetwork () {
786         // Do we have selections?
787         if (ifPostContainsSelections()) {
788                 // Something has been selected, so start displaying one by one
789                 $OUT = '';
790                 foreach (postRequestParameter('sel') as $id => $sel) {
791                         // Is this selected?
792                         if ($sel == 1) {
793                                 // Load this network's data
794                                 $networkData = getNetworkDataById($id);
795
796                                 // Do we have found the network?
797                                 if (count($networkData) > 0) {
798                                         if (isFormSent('edit')) {
799                                                 // Add row template for editing
800                                                 $OUT .= loadTemplate('admin_edit_networks_row', true, $networkData);
801                                         } elseif (isFormSent('delete')) {
802                                                 // Add row template for deleting
803                                                 $OUT .= loadTemplate('admin_delete_networks_row', true, $networkData);
804                                         } else {
805                                                 // Problem!
806                                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
807                                         }
808                                 } // END - if
809                         } // END - if
810                 } // END - foreach
811
812                 // If we have no rows, we don't need to display the edit form
813                 if (!empty($OUT)) {
814                         // Output main template
815                         if (isFormSent('edit')) {
816                                 loadTemplate('admin_edit_networks', false, $OUT);
817                         } elseif (isFormSent('delete')) {
818                                 loadTemplate('admin_delete_networks', false, $OUT);
819                         } else {
820                                 // Problem!
821                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
822                         }
823
824                         // Don't display the list/add new form
825                         $GLOBALS['network_display'] = false;
826                 } else {
827                         // Nothing selected/found
828                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_FOUND--}');
829                 }
830         } // END - if
831 }
832
833 // Handle network type form
834 function doAdminNetworkProcessHandleNetworkType () {
835         // Do we have selections?
836         if (ifPostContainsSelections()) {
837                 // Load network data
838                 $networkData = getNetworkDataById(getRequestParameter('network'));
839
840                 // Something has been selected, so start displaying one by one
841                 $OUT = '';
842                 foreach (postRequestParameter('sel') as $id => $sel) {
843                         // Is this selected?
844                         if ($sel == 1) {
845                                 // Load this network's data
846                                 $networkTypeData = getNetworkTypeDataById($id);
847
848                                 // Do we have found the network?
849                                 if (count($networkTypeData) > 0) {
850                                         if (isFormSent('edit')) {
851                                                 // Add row template for deleting
852                                                 $OUT .= loadTemplate('admin_edit_network_types_row', true, $networkTypeData);
853                                         } elseif (isFormSent('delete')) {
854                                                 // Add row template for deleting
855                                                 $OUT .= loadTemplate('admin_delete_network_types_row', true, $networkTypeData);
856                                         } else {
857                                                 // Problem!
858                                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
859                                         }
860                                 } // END - if
861                         } // END - if
862                 } // END - foreach
863
864                 // If we have no rows, we don't need to display the edit form
865                 if (!empty($OUT)) {
866                         // Output main template
867                         if (isFormSent('edit')) {
868                                 loadTemplate('admin_edit_network_types', false, $OUT);
869                         } elseif (isFormSent('delete')) {
870                                 loadTemplate('admin_delete_network_types', false, $OUT);
871                         } else {
872                                 // Problem!
873                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
874                         }
875
876                         // Don't display the list/add new form
877                         $GLOBALS['network_display'] = false;
878                 } else {
879                         // Nothing selected/found
880                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_FOUND--}');
881                 }
882         } // END - if
883 }
884
885 // Handle network request parameter form
886 function doAdminNetworkProcessHandleRequestParams () {
887         // Do we have selections?
888         if (ifPostContainsSelections()) {
889                 // Init cache array
890                 $GLOBALS['network_params_disabled'] = array();
891
892                 // Load network data
893                 $networkData = getNetworkDataById(getRequestParameter('network'));
894
895                 // Something has been selected, so start displaying one by one
896                 $OUT = '';
897                 foreach (postRequestParameter('sel') as $id => $sel) {
898                         // Is this selected?
899                         if ($sel == 1) {
900                                 // Load this network's data
901                                 $networkRequestData = getNetworkRequestParamsDataById($id);
902
903                                 // Do we have found the network?
904                                 if (count($networkRequestData) > 0) {
905                                         if (isFormSent('edit')) {
906                                                 // Add row template for deleting
907                                                 $OUT .= loadTemplate('admin_edit_network_params_row', true, $networkRequestData);
908                                         } elseif (isFormSent('delete')) {
909                                                 // Get type data
910                                                 $networkRequestData['network_type_data'] = getNetworkTypeDataById($networkRequestData['network_type_id']);
911
912                                                 // Add row template for deleting
913                                                 $OUT .= loadTemplate('admin_delete_network_params_row', true, $networkRequestData);
914                                         } else {
915                                                 // Problem!
916                                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
917                                         }
918                                 } // END - if
919                         } // END - if
920                 } // END - foreach
921
922                 // If we have no rows, we don't need to display the edit form
923                 if (!empty($OUT)) {
924                         // Output main template
925                         if (isFormSent('edit')) {
926                                 loadTemplate('admin_edit_network_params', false, $OUT);
927                         } elseif (isFormSent('delete')) {
928                                 loadTemplate('admin_delete_network_params', false, $OUT);
929                         } else {
930                                 // Problem!
931                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
932                         }
933
934                         // Don't display the list/add new form
935                         $GLOBALS['network_display'] = false;
936                 } else {
937                         // Nothing selected/found
938                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_FOUND--}');
939                 }
940         } // END - if
941 }
942
943 // Changes given networks
944 function doAdminNetworkProcessChangeNetwork () {
945         // Do we have selections?
946         if (ifPostContainsSelections()) {
947                 // By default nothing is updated
948                 $updated = 0;
949
950                 // Something has been selected, so start updating them
951                 foreach (postRequestParameter('sel') as $id => $sel) {
952                         // Update this entry?
953                         if ($sel == 1) {
954                                 // Init data array
955                                 $networkData = array();
956
957                                 // Transfer whole array, except 'sel'
958                                 foreach (postRequestArray() as $key => $entry) {
959                                         // Skip 'sel' and submit button
960                                         if (in_array($key, array('sel', 'change'))) continue;
961
962                                         // Do we have this enty?
963                                         if (!isset($entry[$id])) {
964                                                 // Not found, needs fixing
965                                                 debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
966                                         } // END - if
967
968                                         // Add this entry
969                                         $networkData[$key] = $entry[$id];
970                                 } // END - foreach
971
972                                 // Update the network data
973                                 $updated += doNetworkUpdateDataByArray($id, $networkData);
974                         } // END - if
975                 } // END - foreach
976
977                 // Do we have updates?
978                 if ($updated > 0) {
979                         // Updates done
980                         displayMessage(getMaskedMessage('ADMIN_NETWORK_UPDATED', $updated));
981                 } else {
982                         // Nothing changed
983                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_CHANGED--}');
984                 }
985         } // END - if
986 }
987
988 // Removes given networks
989 function doAdminNetworkProcessRemoveNetwork () {
990         // Do we have selections?
991         if (ifPostContainsSelections()) {
992                 // By default nothing is removed
993                 $removed = 0;
994
995                 // Something has been selected, so start updating them
996                 foreach (postRequestParameter('sel') as $id => $sel) {
997                         // Update this entry?
998                         if ($sel == 1) {
999                                 // Remove this entry
1000                                 $removed += doAdminRemoveNetworkEntry('data', 'network_id', $id);
1001                         } // END - if
1002                 } // END - foreach
1003
1004                 // Do we have removes?
1005                 if ($removed > 0) {
1006                         // Removals done
1007                         displayMessage(getMaskedMessage('ADMIN_NETWORK_REMOVED', $removed));
1008                 } else {
1009                         // Nothing removed
1010                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_REMOVED--}');
1011                 }
1012         } // END - if
1013 }
1014
1015 // Add a network type handler if not yet found
1016 function doAdminNetworkProcessAddNetworkType () {
1017         // Is the network type handle already used with given network?
1018         if (isNetworkTypeHandleValid(postRequestParameter('network_type_handle'), getRequestParameter('network'))) {
1019                 // Already added
1020                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_HANDLE_ALREADY_ADDED', postRequestParameter('network_type_handle')));
1021
1022                 // ... so abort here
1023                 return false;
1024         } // END - if
1025
1026         // Remove the 'ok' part
1027         unsetPostRequestParameter('ok');
1028
1029         // Add id
1030         setPostRequestParameter('network_id', bigintval(getRequestParameter('network')));
1031
1032         // Is network_type_banner_url set?
1033         if (postRequestParameter('network_type_banner_url') == '') {
1034                 // Remove empty value to get a NULL for an optional entry
1035                 unsetPostRequestParameter('network_type_banner_url');
1036         } // END - if
1037
1038         // Add the whole request to database
1039         SQL_QUERY('INSERT INTO
1040         `{?_MYSQL_PREFIX?}_network_types`
1041 (
1042         `' . implode('`,`', array_keys(postRequestArray())) . "`
1043 ) VALUES (
1044         '" . implode("','", array_values(postRequestArray())) . "'
1045 )", __FUNCTION__, __LINE__);
1046
1047         // Output message
1048         if (!SQL_HASZEROAFFECTED()) {
1049                 // Successfully added
1050                 loadTemplate('admin_network_type_added', false, postRequestArray());
1051         } else {
1052                 // Not added
1053                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_NOT_ADDED', postRequestParameter('network_type_handle')));
1054         }
1055 }
1056
1057 // Changes given network type handlers
1058 function doAdminNetworkProcessChangeNetworkType () {
1059         // Do we have selections?
1060         if (ifPostContainsSelections()) {
1061                 // By default nothing is updated
1062                 $updated = 0;
1063
1064                 // Something has been selected, so start updating them
1065                 foreach (postRequestParameter('sel') as $id => $sel) {
1066                         // Update this entry?
1067                         if ($sel == 1) {
1068                                 // Init data array
1069                                 $networkTypeData = array();
1070
1071                                 // Transfer whole array, except 'sel'
1072                                 foreach (postRequestArray() as $key => $entry) {
1073                                         // Skip 'sel' and submit button
1074                                         if (in_array($key, array('sel', 'change'))) continue;
1075
1076                                         // Do we have this enty?
1077                                         if (!isset($entry[$id])) {
1078                                                 // Not found, needs fixing
1079                                                 debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
1080                                         } // END - if
1081
1082                                         // Fix empty network_type_banner_url to NULL
1083                                         if (($key == 'network_type_banner_url') && (trim($entry[$id]) == '')) {
1084                                                 // Set it to NULL
1085                                                 $entry[$id] = null;
1086                                         } // END - if
1087
1088                                         // Add this entry
1089                                         $networkTypeData[$key] = $entry[$id];
1090                                 } // END - foreach
1091
1092                                 // Update the network data
1093                                 $updated += doNetworkUpdateTypeByArray($id, $networkTypeData);
1094                         } // END - if
1095                 } // END - foreach
1096
1097                 // Do we have updates?
1098                 if ($updated > 0) {
1099                         // Updates done
1100                         displayMessage(getMaskedMessage('ADMIN_NETWORK_TYPES_UPDATED', $updated));
1101                 } else {
1102                         // Nothing changed
1103                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_CHANGED--}');
1104                 }
1105         } // END - if
1106 }
1107
1108 // Changes given network request parameters
1109 function doAdminNetworkProcessChangeNetworkParam () {
1110         // Do we have selections?
1111         if (ifPostContainsSelections()) {
1112                 // By default nothing is updated
1113                 $updated = 0;
1114
1115                 // Something has been selected, so start updating them
1116                 foreach (postRequestParameter('sel') as $id => $sel) {
1117                         // Update this entry?
1118                         if ($sel == 1) {
1119                                 // Init data array
1120                                 $networkParamsData = array();
1121
1122                                 // Transfer whole array, except 'sel'
1123                                 foreach (postRequestArray() as $key => $entry) {
1124                                         // Skip 'sel' and submit button
1125                                         if (in_array($key, array('sel', 'change'))) continue;
1126
1127                                         // Do we have this enty?
1128                                         if (!isset($entry[$id])) {
1129                                                 // Not found, needs fixing
1130                                                 debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
1131                                         } // END - if
1132
1133                                         // Fix empty request_param_default to NULL
1134                                         if (($key == 'request_param_default') && (trim($entry[$id]) == '')) {
1135                                                 // Set it to NULL
1136                                                 $entry[$id] = null;
1137                                         } // END - if
1138
1139                                         // Add this entry
1140                                         $networkParamsData[$key] = $entry[$id];
1141                                 } // END - foreach
1142
1143                                 // Update the network data
1144                                 $updated += doNetworkUpdateParamsByArray($id, $networkParamsData);
1145                         } // END - if
1146                 } // END - foreach
1147
1148                 // Do we have updates?
1149                 if ($updated > 0) {
1150                         // Updates done
1151                         displayMessage(getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_UPDATED', $updated));
1152                 } else {
1153                         // Nothing changed
1154                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_CHANGED--}');
1155                 }
1156         } // END - if
1157 }
1158
1159 // Removes given network type handlers
1160 function doAdminNetworkProcessRemoveNetworkType () {
1161         // Do we have selections?
1162         if (ifPostContainsSelections()) {
1163                 // By default nothing is removed
1164                 $removed = 0;
1165
1166                 // Something has been selected, so start updating them
1167                 foreach (postRequestParameter('sel') as $id => $sel) {
1168                         // Update this entry?
1169                         if ($sel == 1) {
1170                                 // Remove this entry
1171                                 $removed += doAdminRemoveNetworkEntry('types', 'network_type_id', $id);
1172                         } // END - if
1173                 } // END - foreach
1174
1175                 // Do we have removes?
1176                 if ($removed > 0) {
1177                         // Removals done
1178                         displayMessage(getMaskedMessage('ADMIN_NETWORK_TYPES_REMOVED', $removed));
1179                 } else {
1180                         // Nothing removed
1181                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_REMOVED--}');
1182                 }
1183         } // END - if
1184 }
1185
1186 // Removes given network request parameters
1187 function doAdminNetworkProcessRemoveNetworkParam () {
1188         // Do we have selections?
1189         if (ifPostContainsSelections()) {
1190                 // By default nothing is removed
1191                 $removed = 0;
1192
1193                 // Something has been selected, so start updating them
1194                 foreach (postRequestParameter('sel') as $id => $sel) {
1195                         // Update this entry?
1196                         if ($sel == 1) {
1197                                 // Remove this entry
1198                                 $removed += doAdminRemoveNetworkEntry('request_params', 'network_param_id', $id);
1199                         } // END - if
1200                 } // END - foreach
1201
1202                 // Do we have removes?
1203                 if ($removed > 0) {
1204                         // Removals done
1205                         displayMessage(getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_REMOVED', $removed));
1206                 } else {
1207                         // Nothing removed
1208                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_REMOVED--}');
1209                 }
1210         } // END - if
1211 }
1212
1213 // Adds a request parameter to given network and type
1214 function doAdminNetworkProcessAddNetworkParam () {
1215         // Is the request parameter already used with given network?
1216         if (isNetworkRequestParameterValid(postRequestParameter('request_param_key'), postRequestParameter('network_type_id'), getRequestParameter('network'))) {
1217                 // Already added
1218                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_ALREADY_ADDED', postRequestParameter('request_param_key')));
1219
1220                 // ... so abort here
1221                 return false;
1222         } // END - if
1223
1224         // Remove the 'ok' part
1225         unsetPostRequestParameter('ok');
1226
1227         // Add id
1228         setPostRequestParameter('network_id', bigintval(getRequestParameter('network')));
1229
1230         // Is request_param_default set?
1231         if (postRequestParameter('request_param_default') == '') {
1232                 // Remove empty value to get a NULL for an optional entry
1233                 unsetPostRequestParameter('request_param_default');
1234         } // END - if
1235
1236         // Add the whole request to database
1237         SQL_QUERY('INSERT INTO
1238         `{?_MYSQL_PREFIX?}_network_request_params`
1239 (
1240         `' . implode('`,`', array_keys(postRequestArray())) . "`
1241 ) VALUES (
1242         '" . implode("','", array_values(postRequestArray())) . "'
1243 )", __FUNCTION__, __LINE__);
1244
1245         // Output message
1246         if (!SQL_HASZEROAFFECTED()) {
1247                 // Successfully added
1248                 loadTemplate('admin_network_request_param_added', false, postRequestArray());
1249         } else {
1250                 // Not added
1251                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_NOT_ADDED', postRequestParameter('request_param_key')));
1252         }
1253 }
1254
1255 // Adds a API response array entry
1256 function doAdminNetworkProcessAddNetworkApiTranslation () {
1257         // Is the request parameter already used with given network?
1258         if (isNetworkApiTranslationValid(postRequestParameter('network_api_index'), postRequestParameter('network_type_id'), getRequestParameter('network'))) {
1259                 // Already added
1260                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_API_TRANSLATION_ALREADY_ADDED', postRequestParameter('network_api_index')));
1261
1262                 // ... so abort here
1263                 return false;
1264         } // END - if
1265
1266         // Remove the 'ok' part
1267         unsetPostRequestParameter('ok');
1268
1269         // Add id
1270         setPostRequestParameter('network_id', bigintval(getRequestParameter('network')));
1271
1272         // Add sorting
1273         setPostRequestParameter('sort', (countSumTotalData(
1274                 postRequestParameter('network_id'),
1275                 'network_api_translation',
1276                 'network_api_id',
1277                 'network_id',
1278                 true,
1279                 sprintf(" AND `network_type_id`=%s", bigintval(postRequestParameter('network_type_id')))
1280         ) + 1));
1281
1282         // Add the whole request to database
1283         SQL_QUERY('INSERT INTO
1284         `{?_MYSQL_PREFIX?}_network_api_translation`
1285 (
1286         `' . implode('`,`', array_keys(postRequestArray())) . "`
1287 ) VALUES (
1288         '" . implode("','", array_values(postRequestArray())) . "'
1289 )", __FUNCTION__, __LINE__);
1290
1291         // Output message
1292         if (!SQL_HASZEROAFFECTED()) {
1293                 // Successfully added
1294                 loadTemplate('admin_network_api_translation_added', false, postRequestArray());
1295         } else {
1296                 // Not added
1297                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_API_TRANSLATION_NOT_ADDED', postRequestParameter('network_api_index')));
1298         }
1299 }
1300
1301 // Do expression code for this extension
1302 function doExpressionNetwork ($data) {
1303         // Construct replacer
1304         $replacer = sprintf(
1305                 "{DQUOTE} . %s(%s, '%s') . {DQUOTE}",
1306                 $data['callback'],
1307                 $data['matches'][4][$data['key']],
1308                 $data['extra_func']
1309         );
1310
1311         // Replace %network% with the current network id
1312         $replacer = str_replace('%network%', getCurrentNetworkId(), $replacer);
1313
1314         // Replace the code
1315         $code = replaceExpressionCode($data, $replacer);
1316
1317         // Return it
1318         return $code;
1319 }
1320
1321 // [EOF]
1322 ?>