]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/network_functions.php
Added ability to allow empty passwords, if the user does so, a random password will...
[mailer.git] / inc / libs / network_functions.php
index 95bba01b5cc79440cd29f03b3d75fc5b2bcd3650..c6a23f75eaa58e1311d413250359ffb71cb743dc 100644 (file)
@@ -14,8 +14,6 @@
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
@@ -55,7 +53,7 @@ function getCurrentNetworkId () {
 // Handle a (maybe) sent form here
 function doNetworkHandleForm () {
        // Was the form sent?
-       if ((isFormSent()) || (isFormSent('edit')) || (isFormSent('del')) || (isFormSent('change')) || (isFormSent('remove'))) {
+       if ((isFormSent()) || (isFormSent('edit')) || (isFormSent('delete')) || (isFormSent('change')) || (isFormSent('remove'))) {
                // Do we have a 'do'?
                if (isGetRequestParameterSet('do')) {
                        // Process the request
@@ -70,7 +68,7 @@ function doNetworkHandleForm () {
 // Processes an admin form
 function doAdminNetworkProcessForm () {
        // Form really sent?
-       if ((!isFormSent()) && (!isFormSent('edit')) && (!isFormSent('del')) && (!isFormSent('change')) && (!isFormSent('remove'))) {
+       if ((!isFormSent()) && (!isFormSent('edit')) && (!isFormSent('delete')) && (!isFormSent('change')) && (!isFormSent('remove'))) {
                // Abort here
                loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_FORM_NOT_SENT--}');
                return;
@@ -502,9 +500,9 @@ function generateNetworkTypeOptions ($id) {
        if (is_array($id)) $id = '';
 
        // Is this cached?
-       if (!isset($GLOBALS['network_type_options'][$id])) {
+       if (!isset($GLOBALS[__FUNCTION__][$id])) {
                // Generate output and cache it
-               $GLOBALS['network_type_options'][$id] = generateOptionList(
+               $GLOBALS[__FUNCTION__][$id] = generateOptionList(
                        'network_types',
                        'network_type_id',
                        'network_type_handle',
@@ -520,15 +518,65 @@ function generateNetworkTypeOptions ($id) {
        } // END - if
 
        // Return content
-       return $GLOBALS['network_type_options'][$id];
+       return $GLOBALS[__FUNCTION__][$id];
 }
 
-// Generator (somewhat getter) for request key options
-function generateNetworkRequestKeyOptions ($key) {
+// Generates an options list of all available (hard-coded) handlers
+function generateNetworkTypesAvailableOptions () {
        // Is it cached?
-       if (!isset($GLOBALS['network_request_param_key'][$key])) {
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Generate list
+               $GLOBALS[__FUNCTION__] = generateOptionList(
+                       '/ARRAY/',
+                       array(
+                               'banner',
+                               'banner_click',
+                               'banner_view',
+                               'button',
+                               'button_click',
+                               'button_view',
+                               'surfbar',
+                               'surfbar_click',
+                               'surfbar_view',
+                               'forcedbanner',
+                               'forcedtextlink',
+                               'textlink',
+                               'textlink_click',
+                               'textlink_view',
+                               'skybanner',
+                               'skybanner_click',
+                               'skybanner_view',
+                               'layer',
+                               'layer_click',
+                               'layer_view',
+                               'popup',
+                               'popdown',
+                               'textmail',
+                               'htmlmail',
+                               'lead',
+                               'sale',
+                               'payperactive',
+                               'pagepeel',
+                               'traffic'
+                       ),
+                       array(),
+                       '',
+                       '', '',
+                       $GLOBALS['network_types_disabled'],
+                       'translateNetworkTypeHandler'
+               );
+       } // END - if
+
+       // Return content
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Generates an options list (somewhat getter) ofr request keys
+function generateNetworkRequestKeyOptions () {
+       // Is it cached?
+       if (!isset($GLOBALS[__FUNCTION__])) {
                // Generate and cache it
-               $GLOBALS['network_request_param_key'][$key] = generateOptionList(
+               $GLOBALS[__FUNCTION__] = generateOptionList(
                        '/ARRAY/',
                        array(
                                'id',
@@ -547,39 +595,24 @@ function generateNetworkRequestKeyOptions ($key) {
                                'extra',
                                'country'
                        ),
-                       array(
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_ID--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_SID--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_HASH--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_PASSWORD--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_RELOAD--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_MAXIMUM_STAY--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_MINIMUM_STAY--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_CURRENCY--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_TYPE--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_REMAIN--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_REWARD--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_SIZE--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_EROTIC--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_EXTRA--}',
-                               '{--ADMIN_NETWORK_REQUEST_PARAMETER_COUNTRY--}'
-                       ),
-                       $key,
+                       array(),
+                       '',
                        '', '',
-                       $GLOBALS['network_params_disabled']
+                       $GLOBALS['network_params_disabled'],
+                       'translateNetworkRequestParameter'
                );
        } // END - if
 
        // Return content
-       return $GLOBALS['network_request_param_key'][$key];
+       return $GLOBALS[__FUNCTION__];
 }
 
 // Generator (somewhat getter) for (return) array translation
 function generateNetworkTranslationOptions ($default = '') {
        // Is it cached?
-       if (!isset($GLOBALS['network_translation'][$default])) {
+       if (!isset($GLOBALS[__FUNCTION__][$default])) {
                // Generate and cache it
-               $GLOBALS['network_translation'][$default] = generateOptionList(
+               $GLOBALS[__FUNCTION__][$default] = generateOptionList(
                        'network_translations',
                        'network_translation_id',
                        'network_translation_name',
@@ -592,15 +625,15 @@ function generateNetworkTranslationOptions ($default = '') {
        } // END - if
 
        // Return content
-       return $GLOBALS['network_translation'][$default];
+       return $GLOBALS[__FUNCTION__][$default];
 }
 
 // Generates an option list of request types
 function generateNetworkRequestTypeOptions ($default = '') {
        // Do we have cache?
-       if (!isset($GLOBALS['network_request_type'][$default])) {
+       if (!isset($GLOBALS[__FUNCTION__][$default])) {
                // Generate the list
-               $GLOBALS['network_request_type'][$default] = generateOptionList(
+               $GLOBALS[__FUNCTION__][$default] = generateOptionList(
                        '/ARRAY/',
                        array(
                                'GET',
@@ -615,7 +648,30 @@ function generateNetworkRequestTypeOptions ($default = '') {
        } // END - if
 
        // Return cache
-       return $GLOBALS['network_request_type'][$default];
+       return $GLOBALS[__FUNCTION__][$default];
+}
+
+// Generates an option list of network_active
+function generateNetworkActiveOptions ($default = '') {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__][$default])) {
+               // Generate the list
+               $GLOBALS[__FUNCTION__][$default] = generateOptionList(
+                       '/ARRAY/',
+                       array(
+                               'Y',
+                               'N'
+                       ),
+                       array(
+                               '{--YES--}',
+                               '{--NO--}'
+                       ),
+                       $default
+               );
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__][$default];
 }
 
 // Translates 'translate_name' for e.g. templates
@@ -631,9 +687,15 @@ function translateNetworkTypeHandler ($type) {
 }
 
 // Translates request type
-function translateNetworkRequestType ($name) {
+function translateNetworkRequestType ($type) {
+       // Get the message id
+       return getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($type) . '');
+}
+
+// Translates request parameter
+function translateNetworkRequestParameter ($param) {
        // Get the message id
-       return getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($name) . '');
+       return getMessage('ADMIN_NETWORK_REQUEST_PARAMETER_' . strtoupper($param) . '');
 }
 
 // Translates API index
@@ -656,7 +718,7 @@ ORDER BY
        `sort` ASC', __FUNCTION__, __LINE__);
 
                // Do we have entries?
-               if (SQL_NUMROWS($result) > 0) {
+               if (!SQL_HASZERONUMS($result)) {
                        // Get all entries
                        while ($row = SQL_FETCHARRAY($result)) {
                                // Add it to our global array
@@ -710,7 +772,7 @@ function doAdminNetworkProcessAddNetwork () {
        setPostRequestParameter('network_id', SQL_INSERTID());
 
        // Output message
-       if (SQL_AFFECTEDROWS() == 1) {
+       if (!SQL_HASZEROAFFECTED()) {
                // Successfully added
                loadTemplate('admin_network_added', false, postRequestArray());
        } else {
@@ -736,9 +798,9 @@ function doAdminNetworkProcessHandleNetwork () {
                                        if (isFormSent('edit')) {
                                                // Add row template for editing
                                                $OUT .= loadTemplate('admin_edit_networks_row', true, $networkData);
-                                       } elseif (isFormSent('del')) {
+                                       } elseif (isFormSent('delete')) {
                                                // Add row template for deleting
-                                               $OUT .= loadTemplate('admin_del_networks_row', true, $networkData);
+                                               $OUT .= loadTemplate('admin_delete_networks_row', true, $networkData);
                                        } else {
                                                // Problem!
                                                debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
@@ -752,8 +814,8 @@ function doAdminNetworkProcessHandleNetwork () {
                        // Output main template
                        if (isFormSent('edit')) {
                                loadTemplate('admin_edit_networks', false, $OUT);
-                       } elseif (isFormSent('del')) {
-                               loadTemplate('admin_del_networks', false, $OUT);
+                       } elseif (isFormSent('delete')) {
+                               loadTemplate('admin_delete_networks', false, $OUT);
                        } else {
                                // Problem!
                                debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
@@ -788,9 +850,9 @@ function doAdminNetworkProcessHandleNetworkType () {
                                        if (isFormSent('edit')) {
                                                // Add row template for deleting
                                                $OUT .= loadTemplate('admin_edit_network_types_row', true, $networkTypeData);
-                                       } elseif (isFormSent('del')) {
+                                       } elseif (isFormSent('delete')) {
                                                // Add row template for deleting
-                                               $OUT .= loadTemplate('admin_del_network_types_row', true, $networkTypeData);
+                                               $OUT .= loadTemplate('admin_delete_network_types_row', true, $networkTypeData);
                                        } else {
                                                // Problem!
                                                debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
@@ -804,8 +866,8 @@ function doAdminNetworkProcessHandleNetworkType () {
                        // Output main template
                        if (isFormSent('edit')) {
                                loadTemplate('admin_edit_network_types', false, $OUT);
-                       } elseif (isFormSent('del')) {
-                               loadTemplate('admin_del_network_types', false, $OUT);
+                       } elseif (isFormSent('delete')) {
+                               loadTemplate('admin_delete_network_types', false, $OUT);
                        } else {
                                // Problem!
                                debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
@@ -843,12 +905,12 @@ function doAdminNetworkProcessHandleRequestParams () {
                                        if (isFormSent('edit')) {
                                                // Add row template for deleting
                                                $OUT .= loadTemplate('admin_edit_network_params_row', true, $networkRequestData);
-                                       } elseif (isFormSent('del')) {
+                                       } elseif (isFormSent('delete')) {
                                                // Get type data
                                                $networkRequestData['network_type_data'] = getNetworkTypeDataById($networkRequestData['network_type_id']);
 
                                                // Add row template for deleting
-                                               $OUT .= loadTemplate('admin_del_network_params_row', true, $networkRequestData);
+                                               $OUT .= loadTemplate('admin_delete_network_params_row', true, $networkRequestData);
                                        } else {
                                                // Problem!
                                                debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
@@ -862,8 +924,8 @@ function doAdminNetworkProcessHandleRequestParams () {
                        // Output main template
                        if (isFormSent('edit')) {
                                loadTemplate('admin_edit_network_params', false, $OUT);
-                       } elseif (isFormSent('del')) {
-                               loadTemplate('admin_del_network_params', false, $OUT);
+                       } elseif (isFormSent('delete')) {
+                               loadTemplate('admin_delete_network_params', false, $OUT);
                        } else {
                                // Problem!
                                debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
@@ -983,7 +1045,7 @@ function doAdminNetworkProcessAddNetworkType () {
 )", __FUNCTION__, __LINE__);
 
        // Output message
-       if (SQL_AFFECTEDROWS() == 1) {
+       if (!SQL_HASZEROAFFECTED()) {
                // Successfully added
                loadTemplate('admin_network_type_added', false, postRequestArray());
        } else {
@@ -1181,7 +1243,7 @@ function doAdminNetworkProcessAddNetworkParam () {
 )", __FUNCTION__, __LINE__);
 
        // Output message
-       if (SQL_AFFECTEDROWS() == 1) {
+       if (!SQL_HASZEROAFFECTED()) {
                // Successfully added
                loadTemplate('admin_network_request_param_added', false, postRequestArray());
        } else {
@@ -1227,7 +1289,7 @@ function doAdminNetworkProcessAddNetworkApiTranslation () {
 )", __FUNCTION__, __LINE__);
 
        // Output message
-       if (SQL_AFFECTEDROWS() == 1) {
+       if (!SQL_HASZEROAFFECTED()) {
                // Successfully added
                loadTemplate('admin_network_api_translation_added', false, postRequestArray());
        } else {
@@ -1255,6 +1317,6 @@ function doExpressionNetwork ($data) {
        // Return it
        return $code;
 }
+
 // [EOF]
 ?>
-