Completed
Push — master ( 10bab4...a0a78b )
by Michael
02:06
created
include/config.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@
 block discarded – undo
24 24
 
25 25
 $moduleDirName = basename(dirname(__DIR__));
26 26
 $uploadFolders = [
27
-    NEWBB_UPLOAD_PATH,
28
-    NEWBB_UPLOAD_PATH . '/thumbs'
27
+	NEWBB_UPLOAD_PATH,
28
+	NEWBB_UPLOAD_PATH . '/thumbs'
29 29
 ];
30 30
 
31 31
 //$copyFiles = array(
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@
 block discarded – undo
20 20
  */
21 21
 
22 22
 // defined('XOOPS_ROOT_PATH') || die('Restricted access');
23
-require_once __DIR__ . '/common.php';
23
+require_once __DIR__.'/common.php';
24 24
 
25 25
 $moduleDirName = basename(dirname(__DIR__));
26 26
 $uploadFolders = [
27 27
     NEWBB_UPLOAD_PATH,
28
-    NEWBB_UPLOAD_PATH . '/thumbs'
28
+    NEWBB_UPLOAD_PATH.'/thumbs'
29 29
 ];
30 30
 
31 31
 //$copyFiles = array(
Please login to merge, or discard this patch.
include/functions.ini.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             if (isset($GLOBALS['xoopsModuleConfig'])) {
81 81
                 $moduleConfig = $GLOBALS['xoopsModuleConfig'];
82 82
             }
83
-        } else {
83
+        }else {
84 84
             /** @var XoopsModuleHandler $moduleHandler */
85 85
             $moduleHandler = xoops_getHandler('module');
86 86
             $module        = $moduleHandler->getByDirname($GLOBALS['moddirname']);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             }
94 94
             unset($configs);
95 95
         }
96
-        if ($customConfig = @include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/plugin.php') {
96
+        if ($customConfig = @include XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/plugin.php') {
97 97
             $moduleConfig = array_merge($moduleConfig, $customConfig);
98 98
         }
99 99
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
             if (!in_array(URL_DELIMITER, ['?', '/'])) {
107 107
                 die('Exit on security');
108 108
             }
109
-        } else {
109
+        }else {
110 110
             $moduleConfig = planet_load_config();
111 111
             if (empty($moduleConfig['do_urw'])) {
112 112
                 define('URL_DELIMITER', '?');
113
-            } else {
113
+            }else {
114 114
                 define('URL_DELIMITER', '/');
115 115
             }
116 116
         }
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -32,88 +32,88 @@
 block discarded – undo
32 32
 
33 33
 // defined('XOOPS_ROOT_PATH') || die('Restricted access');
34 34
 if (!defined('PLANET_INI')) {
35
-    exit();
35
+	exit();
36 36
 }
37 37
 
38 38
 if (!defined('PLANET_FUNCTIONS_INI')):
39
-    define('PLANET_FUNCTIONS_INI', 1);
39
+	define('PLANET_FUNCTIONS_INI', 1);
40 40
 
41
-    /**
42
-     * @param $name
43
-     * @return mixed
44
-     */
45
-    function planet_constant($name)
46
-    {
47
-        return mod_constant($name);
48
-    }
41
+	/**
42
+	 * @param $name
43
+	 * @return mixed
44
+	 */
45
+	function planet_constant($name)
46
+	{
47
+		return mod_constant($name);
48
+	}
49 49
 
50
-    /**
51
-     * @param      $name
52
-     * @param bool $isRel
53
-     * @return string
54
-     */
55
-    function planet_DB_prefix($name, $isRel = false)
56
-    {
57
-        return mod_DB_prefix($name, $isRel);
58
-    }
50
+	/**
51
+	 * @param      $name
52
+	 * @param bool $isRel
53
+	 * @return string
54
+	 */
55
+	function planet_DB_prefix($name, $isRel = false)
56
+	{
57
+		return mod_DB_prefix($name, $isRel);
58
+	}
59 59
 
60
-    /**
61
-     * @return bool
62
-     */
63
-    function planet_load_object()
64
-    {
65
-        return load_object();
66
-    }
60
+	/**
61
+	 * @return bool
62
+	 */
63
+	function planet_load_object()
64
+	{
65
+		return load_object();
66
+	}
67 67
 
68
-    /**
69
-     * @return array|mixed
70
-     */
71
-    function planet_load_config()
72
-    {
73
-        static $moduleConfig;
74
-        if (isset($moduleConfig)) {
75
-            return $moduleConfig;
76
-        }
68
+	/**
69
+	 * @return array|mixed
70
+	 */
71
+	function planet_load_config()
72
+	{
73
+		static $moduleConfig;
74
+		if (isset($moduleConfig)) {
75
+			return $moduleConfig;
76
+		}
77 77
 
78
-        if (is_object($GLOBALS['xoopsModule'])
79
-            && $GLOBALS['xoopsModule']->getVar('dirname') == $GLOBALS['moddirname']) {
80
-            if (isset($GLOBALS['xoopsModuleConfig'])) {
81
-                $moduleConfig = $GLOBALS['xoopsModuleConfig'];
82
-            }
83
-        } else {
84
-            /** @var XoopsModuleHandler $moduleHandler */
85
-            $moduleHandler = xoops_getHandler('module');
86
-            $module        = $moduleHandler->getByDirname($GLOBALS['moddirname']);
78
+		if (is_object($GLOBALS['xoopsModule'])
79
+			&& $GLOBALS['xoopsModule']->getVar('dirname') == $GLOBALS['moddirname']) {
80
+			if (isset($GLOBALS['xoopsModuleConfig'])) {
81
+				$moduleConfig = $GLOBALS['xoopsModuleConfig'];
82
+			}
83
+		} else {
84
+			/** @var XoopsModuleHandler $moduleHandler */
85
+			$moduleHandler = xoops_getHandler('module');
86
+			$module        = $moduleHandler->getByDirname($GLOBALS['moddirname']);
87 87
 
88
-            $configHandler = xoops_getHandler('config');
89
-            $criteria      = new \CriteriaCompo(new \Criteria('conf_modid', $module->getVar('mid')));
90
-            $configs       = $configHandler->getConfigs($criteria);
91
-            foreach (array_keys($configs) as $i) {
92
-                $moduleConfig[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput();
93
-            }
94
-            unset($configs);
95
-        }
96
-        if ($customConfig = @include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/plugin.php') {
97
-            $moduleConfig = array_merge($moduleConfig, $customConfig);
98
-        }
88
+			$configHandler = xoops_getHandler('config');
89
+			$criteria      = new \CriteriaCompo(new \Criteria('conf_modid', $module->getVar('mid')));
90
+			$configs       = $configHandler->getConfigs($criteria);
91
+			foreach (array_keys($configs) as $i) {
92
+				$moduleConfig[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput();
93
+			}
94
+			unset($configs);
95
+		}
96
+		if ($customConfig = @include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/plugin.php') {
97
+			$moduleConfig = array_merge($moduleConfig, $customConfig);
98
+		}
99 99
 
100
-        return $moduleConfig;
101
-    }
100
+		return $moduleConfig;
101
+	}
102 102
 
103
-    function planet_define_url_delimiter()
104
-    {
105
-        if (defined('URL_DELIMITER')) {
106
-            if (!in_array(URL_DELIMITER, ['?', '/'])) {
107
-                die('Exit on security');
108
-            }
109
-        } else {
110
-            $moduleConfig = planet_load_config();
111
-            if (empty($moduleConfig['do_urw'])) {
112
-                define('URL_DELIMITER', '?');
113
-            } else {
114
-                define('URL_DELIMITER', '/');
115
-            }
116
-        }
117
-    }
103
+	function planet_define_url_delimiter()
104
+	{
105
+		if (defined('URL_DELIMITER')) {
106
+			if (!in_array(URL_DELIMITER, ['?', '/'])) {
107
+				die('Exit on security');
108
+			}
109
+		} else {
110
+			$moduleConfig = planet_load_config();
111
+			if (empty($moduleConfig['do_urw'])) {
112
+				define('URL_DELIMITER', '?');
113
+			} else {
114
+				define('URL_DELIMITER', '/');
115
+			}
116
+		}
117
+	}
118 118
 
119 119
 endif;
Please login to merge, or discard this patch.
class/xml.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -81,100 +81,100 @@
 block discarded – undo
81 81
  * @link
82 82
  */
83 83
 if (!class_exists('Xmlfeed')) {
84
-    /**
85
-     * Class Bxmlfeed
86
-     */
87
-    class Bxmlfeed extends UniversalFeedCreator
88
-    {
89
-        public $version;
90
-        public $filename = '';
91
-
92
-        /**
93
-         * Bxmlfeed constructor.
94
-         * @param $version
95
-         */
96
-        public function __construct($version)
97
-        {
98
-            $this->filename = XOOPS_CACHE_PATH . '/feed.xml';
99
-            $this->version  = $version;
100
-        }
101
-
102
-        /**
103
-         * @param      $var
104
-         * @param      $val
105
-         * @param bool $encoding
106
-         */
107
-        public function setVar($var, $val, $encoding = false)
108
-        {
109
-            if (!empty($encoding)) {
110
-                $val = $this->convert_encoding($val);
111
-            }
112
-            $this->$var = $val;
113
-        }
114
-
115
-        /**
116
-         * @param $val
117
-         * @return array|mixed|string
118
-         */
119
-        public function convert_encoding($val)
120
-        {
121
-            if (is_array($val)) {
122
-                foreach (array_keys($val) as $key) {
123
-                    $val[$key] = $this->convert_encoding($val[$key]);
124
-                }
125
-            } else {
126
-                $val = XoopsLocal::convert_encoding($val, $this->encoding, _CHARSET);
127
-            }
128
-
129
-            return $val;
130
-        }
131
-
132
-        /**
133
-         * @param $var
134
-         * @return mixed
135
-         */
136
-        public function getVar($var)
137
-        {
138
-            return $this->$var;
139
-        }
140
-
141
-        /**
142
-         * @param $img
143
-         */
144
-        public function setImage(&$img)
145
-        {
146
-            $image = new FeedImage();
147
-            foreach ($img as $key => $val) {
148
-                $image->$key = $this->convert_encoding($val);
149
-            }
150
-            $this->setVar('image', $image);
151
-        }
152
-
153
-        /**
154
-         * @param $itm
155
-         */
156
-        public function _addItem(&$itm)
157
-        {
158
-            $item = new FeedItem();
159
-            foreach ($itm as $key => $val) {
160
-                $item->$key = $this->convert_encoding($val);
161
-            }
162
-            $this->addItem($item);
163
-        }
164
-
165
-        /**
166
-         * @param $items
167
-         */
168
-        public function addItems(&$items)
169
-        {
170
-            if (!is_array($items) || 0 == count($items)) {
171
-                return;
172
-            }
173
-            foreach ($items as $item) {
174
-                $this->_addItem($item);
175
-            }
176
-        }
177
-    }
84
+	/**
85
+	 * Class Bxmlfeed
86
+	 */
87
+	class Bxmlfeed extends UniversalFeedCreator
88
+	{
89
+		public $version;
90
+		public $filename = '';
91
+
92
+		/**
93
+		 * Bxmlfeed constructor.
94
+		 * @param $version
95
+		 */
96
+		public function __construct($version)
97
+		{
98
+			$this->filename = XOOPS_CACHE_PATH . '/feed.xml';
99
+			$this->version  = $version;
100
+		}
101
+
102
+		/**
103
+		 * @param      $var
104
+		 * @param      $val
105
+		 * @param bool $encoding
106
+		 */
107
+		public function setVar($var, $val, $encoding = false)
108
+		{
109
+			if (!empty($encoding)) {
110
+				$val = $this->convert_encoding($val);
111
+			}
112
+			$this->$var = $val;
113
+		}
114
+
115
+		/**
116
+		 * @param $val
117
+		 * @return array|mixed|string
118
+		 */
119
+		public function convert_encoding($val)
120
+		{
121
+			if (is_array($val)) {
122
+				foreach (array_keys($val) as $key) {
123
+					$val[$key] = $this->convert_encoding($val[$key]);
124
+				}
125
+			} else {
126
+				$val = XoopsLocal::convert_encoding($val, $this->encoding, _CHARSET);
127
+			}
128
+
129
+			return $val;
130
+		}
131
+
132
+		/**
133
+		 * @param $var
134
+		 * @return mixed
135
+		 */
136
+		public function getVar($var)
137
+		{
138
+			return $this->$var;
139
+		}
140
+
141
+		/**
142
+		 * @param $img
143
+		 */
144
+		public function setImage(&$img)
145
+		{
146
+			$image = new FeedImage();
147
+			foreach ($img as $key => $val) {
148
+				$image->$key = $this->convert_encoding($val);
149
+			}
150
+			$this->setVar('image', $image);
151
+		}
152
+
153
+		/**
154
+		 * @param $itm
155
+		 */
156
+		public function _addItem(&$itm)
157
+		{
158
+			$item = new FeedItem();
159
+			foreach ($itm as $key => $val) {
160
+				$item->$key = $this->convert_encoding($val);
161
+			}
162
+			$this->addItem($item);
163
+		}
164
+
165
+		/**
166
+		 * @param $items
167
+		 */
168
+		public function addItems(&$items)
169
+		{
170
+			if (!is_array($items) || 0 == count($items)) {
171
+				return;
172
+			}
173
+			foreach ($items as $item) {
174
+				$this->_addItem($item);
175
+			}
176
+		}
177
+	}
178 178
 }
179 179
 
180 180
 PlanetUtility::planetParseClass('
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 // ------------------------------------------------------------------------ //
27 27
 
28 28
 // defined('XOOPS_ROOT_PATH') || die('Restricted access');
29
-require_once __DIR__ . '/../include/vars.php';
29
+require_once __DIR__.'/../include/vars.php';
30 30
 //mod_loadFunctions('', $GLOBALS['moddirname']);
31 31
 
32 32
 /*** GENERAL USAGE *********************************************************
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
  */
65 65
 
66 66
 // your local timezone, set to "" to disable or for GMT
67
-$server_TZ = abs((int)($GLOBALS['xoopsConfig']['server_TZ'] * 3600.0));
68
-$prefix    = ($GLOBALS['xoopsConfig']['server_TZ'] < 0) ? '-' : '+';
69
-$TIME_ZONE = $prefix . date('H:i', $server_TZ);
67
+$server_TZ = abs((int) ($GLOBALS['xoopsConfig']['server_TZ']*3600.0));
68
+$prefix    = ($GLOBALS['xoopsConfig']['server_TZ']<0) ? '-' : '+';
69
+$TIME_ZONE = $prefix.date('H:i', $server_TZ);
70 70
 define('TIME_ZONE', $TIME_ZONE);
71 71
 // Version string.
72 72
 define('FEEDCREATOR_VERSION', 'ARTICLE @ XOOPS powered by FeedCreator');
73 73
 
74
-require_once __DIR__ . '/feedcreator.class.php';
74
+require_once __DIR__.'/feedcreator.class.php';
75 75
 
76 76
 /**
77 77
  * Description
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
          */
96 96
         public function __construct($version)
97 97
         {
98
-            $this->filename = XOOPS_CACHE_PATH . '/feed.xml';
98
+            $this->filename = XOOPS_CACHE_PATH.'/feed.xml';
99 99
             $this->version  = $version;
100 100
         }
101 101
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
                 foreach (array_keys($val) as $key) {
123 123
                     $val[$key] = $this->convert_encoding($val[$key]);
124 124
                 }
125
-            } else {
125
+            }else {
126 126
                 $val = XoopsLocal::convert_encoding($val, $this->encoding, _CHARSET);
127 127
             }
128 128
 
Please login to merge, or discard this patch.
class/Utility.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
          * @var mixed  $pattern
118 118
          * @var mixed  $replacement
119 119
          *
120
-         * @return bool true on success
120
+         * @return null|boolean true on success
121 121
          */
122 122
         public static function planetParseClass($class_string, $pattern = '', $replacement = '')
123 123
         {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
          * @var mixed  $pattern
154 154
          * @var mixed  $replacement
155 155
          *
156
-         * @return bool true on success
156
+         * @return null|boolean true on success
157 157
          */
158 158
         public static function planetParseFunction($function_string, $pattern = '', $replacement = '')
159 159
         {
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 
521 521
         /**
522 522
          * @param $url
523
-         * @return bool|string
523
+         * @return false|string
524 524
          */
525 525
         public static function planetFetchFopen($url)
526 526
         {
Please login to merge, or discard this patch.
Indentation   +522 added lines, -522 removed lines patch added patch discarded remove patch
@@ -34,535 +34,535 @@
 block discarded – undo
34 34
 
35 35
 $current_path = __FILE__;
36 36
 if (DIRECTORY_SEPARATOR !== '/') {
37
-    $current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path);
37
+	$current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path);
38 38
 }
39 39
 $url_arr               = explode('/', strstr($current_path, '/modules/'));
40 40
 $GLOBALS['moddirname'] = $url_arr[2];
41 41
 
42 42
 if (!defined('planet_FUNCTIONS')):
43
-    define('planet_FUNCTIONS', 1);
44
-
45
-    require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php';
46
-    require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
47
-    require_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php';
48
-
49
-    /**
50
-     * Class Utility
51
-     */
52
-    class Utility
53
-    {
54
-
55
-        /**
56
-         * Function to display messages
57
-         *
58
-         * @var mixed $messages
59
-         * @return bool
60
-         */
61
-        public static function planetDisplayMessage($message)
62
-        {
63
-            return mod_message($message);
64
-        }
65
-
66
-        /**
67
-         * Function to parse arguments for a page according to $_SERVER['REQUEST_URI']
68
-         *
69
-         * @var array $args_numeric array of numeric variable values
70
-         * @var array $args         array of indexed variables: name and value
71
-         * @var array $args_string  array of string variable values
72
-         *
73
-         * @return bool true on args parsed
74
-         */
75
-
76
-        /* known issues:
43
+	define('planet_FUNCTIONS', 1);
44
+
45
+	require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php';
46
+	require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
47
+	require_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php';
48
+
49
+	/**
50
+	 * Class Utility
51
+	 */
52
+	class Utility
53
+	{
54
+
55
+		/**
56
+		 * Function to display messages
57
+		 *
58
+		 * @var mixed $messages
59
+		 * @return bool
60
+		 */
61
+		public static function planetDisplayMessage($message)
62
+		{
63
+			return mod_message($message);
64
+		}
65
+
66
+		/**
67
+		 * Function to parse arguments for a page according to $_SERVER['REQUEST_URI']
68
+		 *
69
+		 * @var array $args_numeric array of numeric variable values
70
+		 * @var array $args         array of indexed variables: name and value
71
+		 * @var array $args_string  array of string variable values
72
+		 *
73
+		 * @return bool true on args parsed
74
+		 */
75
+
76
+		/* known issues:
77 77
          * - "/" in a string
78 78
          * - "&" in a string
79 79
         */
80
-        public static function planetParseArguments(&$args_numeric, &$args, &$args_string)
81
-        {
82
-            $args_abb     = [
83
-                'a' => 'article',
84
-                'b' => 'blog',
85
-                'c' => 'category',
86
-                'l' => 'list',
87
-                'o' => 'sort',
88
-                's' => 'start',
89
-                'u' => 'uid'
90
-            ];
91
-            $args         = [];
92
-            $args_numeric = [];
93
-            $args_string  = [];
94
-            if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
95
-                $vars = preg_split("/[\/|&]/", $matches[1]);
96
-                $vars = array_map('trim', $vars);
97
-                if (count($vars) > 0) {
98
-                    foreach ($vars as $var) {
99
-                        if (is_numeric($var)) {
100
-                            $args_numeric[] = $var;
101
-                        } elseif (false === strpos($var, '=')) {
102
-                            if (is_numeric(substr($var, 1))) {
103
-                                $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
104
-                            } else {
105
-                                $args_string[] = urldecode($var);
106
-                            }
107
-                        } else {
108
-                            parse_str($var, $args);
109
-                        }
110
-                    }
111
-                }
112
-            }
113
-
114
-            return (0 == count($args) + count($args_numeric) + count($args_string)) ? null : true;
115
-        }
116
-
117
-        /**
118
-         * Function to parse class prefix
119
-         *
120
-         * @var string $class_string string to be parsed
121
-         * @var mixed  $pattern
122
-         * @var mixed  $replacement
123
-         *
124
-         * @return bool true on success
125
-         */
126
-        public static function planetParseClass($class_string, $pattern = '', $replacement = '')
127
-        {
128
-            if (empty($class_string)) {
129
-                return;
130
-            }
131
-            $patterns     = ["/\[CLASS_PREFIX\]/"];
132
-            $replacements = [ucfirst(strtolower($GLOBALS['moddirname']))];
133
-            if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
134
-                $pattern     = [$pattern];
135
-                $replacement = [$replacement];
136
-            }
137
-            if (is_array($pattern) && count($pattern) > 0) {
138
-                $ii = 0;
139
-                foreach ($pattern as $pat) {
140
-                    if (!in_array($pat, $patterns)) {
141
-                        $patterns[]     = $pat;
142
-                        $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
143
-                    }
144
-                    ++$ii;
145
-                }
146
-            }
147
-            $class_string = preg_replace($patterns, $replacements, $class_string);
148
-            eval($class_string);
149
-
150
-            return true;
151
-        }
152
-
153
-        /**
154
-         * Function to parse function prefix
155
-         *
156
-         * @var string $function_string string to be parsed
157
-         * @var mixed  $pattern
158
-         * @var mixed  $replacement
159
-         *
160
-         * @return bool true on success
161
-         */
162
-        public static function planetParseFunction($function_string, $pattern = '', $replacement = '')
163
-        {
164
-            if (empty($function_string)) {
165
-                return;
166
-            }
167
-            $patterns     = ["/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"];
168
-            $replacements = [$GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']];
169
-            if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
170
-                $pattern     = [$pattern];
171
-                $replacement = [$replacement];
172
-            }
173
-            if (is_array($pattern) && count($pattern) > 0) {
174
-                $ii = 0;
175
-                foreach ($pattern as $pat) {
176
-                    if (!in_array($pat, $patterns)) {
177
-                        $patterns[]     = $pat;
178
-                        $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
179
-                    }
180
-                    ++$ii;
181
-                }
182
-            }
183
-            $function_string = preg_replace($patterns, $replacements, $function_string);
184
-            if (is_array($function_string)) {
185
-                eval($function_string);
186
-            }
187
-
188
-            return true;
189
-        }
190
-
191
-        /**
192
-         * Function to convert UNIX time to formatted time string
193
-         * @param        $time
194
-         * @param string $format
195
-         * @return string
196
-         */
197
-        public static function planetFormatTimestamp($time, $format = '')
198
-        {
199
-            if (empty($time)) {
200
-                return '';
201
-            }
202
-
203
-            return formatTimestamp($time, $format);
204
-        }
205
-
206
-        /**
207
-         * Function to a list of user names associated with their user IDs
208
-         * @param int  $userid
209
-         * @param int  $usereal
210
-         * @param bool $linked
211
-         * @return array
212
-         */
213
-        public static function &planetGetUnameFromId($userid, $usereal = 0, $linked = false)
214
-        {
215
-            if (!is_array($userid)) {
216
-                $userid = [$userid];
217
-            }
218
-            $users =& mod_getUnameFromIds($userid, $usereal, $linked);
219
-
220
-            return $users;
221
-        }
222
-
223
-        /**
224
-         * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space
225
-         *
226
-         * @var string $text raw content
227
-         *
228
-         * @return array associative array of link url and title
229
-         */
230
-        public static function &planetParseLinks($text)
231
-        {
232
-            $myts       = \MyTextSanitizer::getInstance();
233
-            $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text);
234
-            $links      = [];
235
-            if (count($link_array) > 0) {
236
-                foreach ($link_array as $link) {
237
-                    @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2));
238
-                    if (empty($url)) {
239
-                        continue;
240
-                    }
241
-                    //if(empty($title)) $title = $url;
242
-                    $links[] = ['url' => $url, 'title' => $myts->htmlSpecialChars($title)];
243
-                }
244
-            }
245
-
246
-            return $links;
247
-        }
248
-
249
-        /**
250
-         * @param $pagename
251
-         * @return string
252
-         */
253
-        public static function planetGetTemplate($pagename)
254
-        {
255
-            return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl';
256
-        }
257
-
258
-        /**
259
-         * @param int $currentoption
260
-         */
261
-        //public static function planet_adminmenu($currentoption = -1)
262
-        //{
263
-        //    loadModuleAdminMenu($currentoption, '');
264
-        //
265
-        //    return;
266
-        //}
267
-
268
-        /**
269
-         * Function to send a trackback
270
-         *
271
-         * @param $article
272
-         * @param $comment
273
-         * @return bool
274
-         */
275
-        public static function planetSendTrackback(&$article, &$comment)
276
-        {
277
-            $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
278
-            $blog_obj    = $blogHandler->get($article->getVar('blog_id'));
279
-            if (!$pattern = $blog_obj->getVar('blog_trackback')) {
280
-                return false;
281
-            }
282
-
283
-            @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern));
284
-            $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link'));
285
-
286
-            return static::planetTrackback($trackback_url, $article);
287
-        }
288
-
289
-        /**
290
-         * @param $trackback_url
291
-         * @param $article
292
-         * @return bool
293
-         */
294
-        public static function planetTrackback($trackback_url, $article)
295
-        {
296
-            global $myts, $xoopsConfig, $xoopsModule;
297
-            /** @var Planet\Helper $helper */
298
-            $helper = Planet\Helper::getInstance();
299
-
300
-            $title         = $article->getVar('art_title');
301
-            $excerpt       = $article->getVar('art_content');
302
-            $blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
303
-            $title         = xoops_utf8_encode($title);
304
-            $excerpt       = xoops_utf8_encode($excerpt);
305
-            $blog_name     = xoops_utf8_encode($blog_name);
306
-            $charset       = 'utf-8';
307
-            $title1        = urlencode($title);
308
-            $excerpt1      = urlencode($excerpt);
309
-            $name1         = urlencode($blog_name);
310
-            $url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id'));
311
-            $query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
312
-            $trackback_url = parse_url($trackback_url);
313
-
314
-            $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n";
315
-            $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
316
-            $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
317
-            $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
318
-            $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
319
-            $http_request .= "\r\n\r\n";
320
-            $http_request .= $query_string;
321
-            if ('' == $trackback_url['port']) {
322
-                $trackback_url['port'] = 80;
323
-            }
324
-            $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
325
-            @fwrite($fs, $http_request);
326
-            if ($helper->getConfig('do_debug')) {
327
-                $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
328
-                $fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
329
-                $fr         .= "CHARSET:$charset\n";
330
-                $fr         .= "NAME:$blog_name\n";
331
-                $fr         .= 'TITLE:' . $title . "\n";
332
-                $fr         .= "EXCERPT:$excerpt\n\n";
333
-                while (!@feof($fs)) {
334
-                    $fr .= @fgets($fs, 4096);
335
-                }
336
-                $fr .= "\n\n";
337
-
338
-                if ($fp = fopen($debug_file, 'a')) {
339
-                    fwrite($fp, $fr);
340
-                    fclose($fp);
341
-                } else {
342
-                }
343
-            }
344
-            @fclose($fs);
345
-
346
-            return true;
347
-        }
348
-
349
-        /**
350
-         * Function to ping servers
351
-         * @param $server
352
-         * @param $id
353
-         */
354
-        public static function planetGetPing($server, $id)
355
-        {
356
-            if (is_array($server)) {
357
-                foreach ($server as $serv) {
358
-                    PlanetUtility::planetGetPing($serv, $id);
359
-                }
360
-            }
361
-            require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php';
362
-
363
-            // using a timeout of 3 seconds should be enough to cover slow servers
364
-            $client            = new IXR_Client($server, false);
365
-            $client->timeout   = 3;
366
-            $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION;
367
-
368
-            // when set to true, this outputs debug messages by itself
369
-            $client->debug = false;
370
-
371
-            $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name'));
372
-            $home     = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/';
373
-            $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id;
374
-
375
-            if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping
376
-                $client->query('weblogUpdates.ping', $blogname, $home);
377
-            }
378
-        }
379
-
380
-        /**
381
-         * Function to respond to a trackback
382
-         * @param int    $error
383
-         * @param string $error_message
384
-         */
385
-        public static function planetRespondToTrackback($error = 0, $error_message = '')
386
-        {
387
-            $charset       = 'utf-8';
388
-            $error_message = xoops_utf8_encode($error_message);
389
-            header('Content-Type: text/xml; charset="' . $charset . '"');
390
-            if ($error) {
391
-                echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
392
-                echo "<response>\n";
393
-                echo "<error>1</error>\n";
394
-                echo "<message>$error_message</message>\n";
395
-                echo '</response>';
396
-                die();
397
-            } else {
398
-                echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
399
-                echo "<response>\n";
400
-                echo "<error>0</error>\n";
401
-                echo '</response>';
402
-            }
403
-        }
404
-
405
-        /**
406
-         * Function to set a cookie with module-specified name
407
-         *
408
-         * using customized serialization method
409
-         * @param        $name
410
-         * @param string $string
411
-         * @param int    $expire
412
-         */
413
-        public static function planetSetCookie($name, $string = '', $expire = 0)
414
-        {
415
-            if (is_array($string)) {
416
-                $value = [];
417
-                foreach ($string as $key => $val) {
418
-                    $value[] = $key . '|' . $val;
419
-                }
420
-                $string = implode(',', $value);
421
-            }
422
-            setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/');
423
-        }
424
-
425
-        /**
426
-         * @param      $name
427
-         * @param bool $isArray
428
-         * @return array|null
429
-         */
430
-        public static function planetGetCookie($name, $isArray = false)
431
-        {
432
-            $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null;
433
-            if ($isArray) {
434
-                $_value = $value ? explode(',', $value) : [];
435
-                $value  = [];
436
-                if (count($_value) > 0) {
437
-                    foreach ($_value as $string) {
438
-                        $key         = substr($string, 0, strpos($string, '|'));
439
-                        $val         = substr($string, strpos($string, '|') + 1);
440
-                        $value[$key] = $val;
441
-                    }
442
-                }
443
-                unset($_value);
444
-            }
445
-
446
-            return $value;
447
-        }
448
-
449
-        /**
450
-         * Function to filter text
451
-         *
452
-         * @param $document
453
-         * @return string filtered text
454
-         */
455
-        public static function &planetHtml2text(&$document)
456
-        {
457
-            $document = strip_tags($document);
458
-
459
-            return $document;
460
-        }
461
-
462
-        // Adapted from PMA_getIp() [phpmyadmin project]
463
-
464
-        /**
465
-         * @param bool $asString
466
-         * @return mixed
467
-         */
468
-        public static function planetGetIP($asString = false)
469
-        {
470
-            return mod_getIP($asString);
471
-        }
472
-
473
-        /**
474
-         * @param $url
475
-         * @return bool|mixed|string
476
-         */
477
-        public static function planetGetRemoteContent($url)
478
-        {
479
-            if ($data = static::planetFetchSnoopy($url)) {
480
-                return $data;
481
-            }
482
-            if ($data = static::planetFetchCURL($url)) {
483
-                return $data;
484
-            }
485
-            if ($data = static::planetFetchFopen($url)) {
486
-                return $data;
487
-            }
488
-
489
-            return false;
490
-        }
491
-
492
-        /**
493
-         * @param $url
494
-         * @return string
495
-         */
496
-        public static function planetFetchSnoopy($url)
497
-        {
498
-            require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
499
-            $snoopy = new Snoopy;
500
-            $data   = '';
501
-            if (@$snoopy->fetch($url)) {
502
-                $data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results;
503
-            }
504
-
505
-            return $data;
506
-        }
507
-
508
-        /**
509
-         * @param $url
510
-         * @return bool|mixed
511
-         */
512
-        public static function planetFetchCURL($url)
513
-        {
514
-            if (!function_exists('curl_init')) {
515
-                return false;
516
-            }
517
-            $ch = curl_init();    // initialize curl handle
518
-            curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
519
-            curl_setopt($ch, CURLOPT_FAILONERROR, 1);
520
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
521
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
522
-            curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s
523
-            $data = curl_exec($ch); // run the whole process
524
-            curl_close($ch);
525
-
526
-            return $data;
527
-        }
528
-
529
-        /**
530
-         * @param $url
531
-         * @return bool|string
532
-         */
533
-        public static function planetFetchFopen($url)
534
-        {
535
-            if (!$fp = @fopen($url, 'r')) {
536
-                return false;
537
-            }
538
-            $data = '';
539
-            while (!feof($fp)) {
540
-                $data .= fgets($fp, 1024);
541
-            }
542
-            fclose($fp);
543
-
544
-            return $data;
545
-        }
546
-
547
-        /**
548
-         * @param     $haystack
549
-         * @param     $needle
550
-         * @param int $offset
551
-         * @return bool|int
552
-         */
553
-        public static function planetStrrPos($haystack, $needle, $offset = 0)
554
-        {
555
-            if (5 == substr(PHP_VERSION, 0, 1)) {
556
-                return strrpos($haystack, $needle, $offset);
557
-            }
558
-            $index = strpos(strrev($haystack), strrev($needle));
559
-            if (false === $index) {
560
-                return false;
561
-            }
562
-            $index = strlen($haystack) - strlen($needle) - $index;
563
-
564
-            return $index;
565
-        }
566
-    }
80
+		public static function planetParseArguments(&$args_numeric, &$args, &$args_string)
81
+		{
82
+			$args_abb     = [
83
+				'a' => 'article',
84
+				'b' => 'blog',
85
+				'c' => 'category',
86
+				'l' => 'list',
87
+				'o' => 'sort',
88
+				's' => 'start',
89
+				'u' => 'uid'
90
+			];
91
+			$args         = [];
92
+			$args_numeric = [];
93
+			$args_string  = [];
94
+			if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
95
+				$vars = preg_split("/[\/|&]/", $matches[1]);
96
+				$vars = array_map('trim', $vars);
97
+				if (count($vars) > 0) {
98
+					foreach ($vars as $var) {
99
+						if (is_numeric($var)) {
100
+							$args_numeric[] = $var;
101
+						} elseif (false === strpos($var, '=')) {
102
+							if (is_numeric(substr($var, 1))) {
103
+								$args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
104
+							} else {
105
+								$args_string[] = urldecode($var);
106
+							}
107
+						} else {
108
+							parse_str($var, $args);
109
+						}
110
+					}
111
+				}
112
+			}
113
+
114
+			return (0 == count($args) + count($args_numeric) + count($args_string)) ? null : true;
115
+		}
116
+
117
+		/**
118
+		 * Function to parse class prefix
119
+		 *
120
+		 * @var string $class_string string to be parsed
121
+		 * @var mixed  $pattern
122
+		 * @var mixed  $replacement
123
+		 *
124
+		 * @return bool true on success
125
+		 */
126
+		public static function planetParseClass($class_string, $pattern = '', $replacement = '')
127
+		{
128
+			if (empty($class_string)) {
129
+				return;
130
+			}
131
+			$patterns     = ["/\[CLASS_PREFIX\]/"];
132
+			$replacements = [ucfirst(strtolower($GLOBALS['moddirname']))];
133
+			if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
134
+				$pattern     = [$pattern];
135
+				$replacement = [$replacement];
136
+			}
137
+			if (is_array($pattern) && count($pattern) > 0) {
138
+				$ii = 0;
139
+				foreach ($pattern as $pat) {
140
+					if (!in_array($pat, $patterns)) {
141
+						$patterns[]     = $pat;
142
+						$replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
143
+					}
144
+					++$ii;
145
+				}
146
+			}
147
+			$class_string = preg_replace($patterns, $replacements, $class_string);
148
+			eval($class_string);
149
+
150
+			return true;
151
+		}
152
+
153
+		/**
154
+		 * Function to parse function prefix
155
+		 *
156
+		 * @var string $function_string string to be parsed
157
+		 * @var mixed  $pattern
158
+		 * @var mixed  $replacement
159
+		 *
160
+		 * @return bool true on success
161
+		 */
162
+		public static function planetParseFunction($function_string, $pattern = '', $replacement = '')
163
+		{
164
+			if (empty($function_string)) {
165
+				return;
166
+			}
167
+			$patterns     = ["/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"];
168
+			$replacements = [$GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']];
169
+			if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
170
+				$pattern     = [$pattern];
171
+				$replacement = [$replacement];
172
+			}
173
+			if (is_array($pattern) && count($pattern) > 0) {
174
+				$ii = 0;
175
+				foreach ($pattern as $pat) {
176
+					if (!in_array($pat, $patterns)) {
177
+						$patterns[]     = $pat;
178
+						$replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
179
+					}
180
+					++$ii;
181
+				}
182
+			}
183
+			$function_string = preg_replace($patterns, $replacements, $function_string);
184
+			if (is_array($function_string)) {
185
+				eval($function_string);
186
+			}
187
+
188
+			return true;
189
+		}
190
+
191
+		/**
192
+		 * Function to convert UNIX time to formatted time string
193
+		 * @param        $time
194
+		 * @param string $format
195
+		 * @return string
196
+		 */
197
+		public static function planetFormatTimestamp($time, $format = '')
198
+		{
199
+			if (empty($time)) {
200
+				return '';
201
+			}
202
+
203
+			return formatTimestamp($time, $format);
204
+		}
205
+
206
+		/**
207
+		 * Function to a list of user names associated with their user IDs
208
+		 * @param int  $userid
209
+		 * @param int  $usereal
210
+		 * @param bool $linked
211
+		 * @return array
212
+		 */
213
+		public static function &planetGetUnameFromId($userid, $usereal = 0, $linked = false)
214
+		{
215
+			if (!is_array($userid)) {
216
+				$userid = [$userid];
217
+			}
218
+			$users =& mod_getUnameFromIds($userid, $usereal, $linked);
219
+
220
+			return $users;
221
+		}
222
+
223
+		/**
224
+		 * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space
225
+		 *
226
+		 * @var string $text raw content
227
+		 *
228
+		 * @return array associative array of link url and title
229
+		 */
230
+		public static function &planetParseLinks($text)
231
+		{
232
+			$myts       = \MyTextSanitizer::getInstance();
233
+			$link_array = preg_split("/(\r\n|\r|\n)( *)/", $text);
234
+			$links      = [];
235
+			if (count($link_array) > 0) {
236
+				foreach ($link_array as $link) {
237
+					@list($url, $title) = array_map('trim', preg_split('/ /', $link, 2));
238
+					if (empty($url)) {
239
+						continue;
240
+					}
241
+					//if(empty($title)) $title = $url;
242
+					$links[] = ['url' => $url, 'title' => $myts->htmlSpecialChars($title)];
243
+				}
244
+			}
245
+
246
+			return $links;
247
+		}
248
+
249
+		/**
250
+		 * @param $pagename
251
+		 * @return string
252
+		 */
253
+		public static function planetGetTemplate($pagename)
254
+		{
255
+			return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl';
256
+		}
257
+
258
+		/**
259
+		 * @param int $currentoption
260
+		 */
261
+		//public static function planet_adminmenu($currentoption = -1)
262
+		//{
263
+		//    loadModuleAdminMenu($currentoption, '');
264
+		//
265
+		//    return;
266
+		//}
267
+
268
+		/**
269
+		 * Function to send a trackback
270
+		 *
271
+		 * @param $article
272
+		 * @param $comment
273
+		 * @return bool
274
+		 */
275
+		public static function planetSendTrackback(&$article, &$comment)
276
+		{
277
+			$blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
278
+			$blog_obj    = $blogHandler->get($article->getVar('blog_id'));
279
+			if (!$pattern = $blog_obj->getVar('blog_trackback')) {
280
+				return false;
281
+			}
282
+
283
+			@list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern));
284
+			$trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link'));
285
+
286
+			return static::planetTrackback($trackback_url, $article);
287
+		}
288
+
289
+		/**
290
+		 * @param $trackback_url
291
+		 * @param $article
292
+		 * @return bool
293
+		 */
294
+		public static function planetTrackback($trackback_url, $article)
295
+		{
296
+			global $myts, $xoopsConfig, $xoopsModule;
297
+			/** @var Planet\Helper $helper */
298
+			$helper = Planet\Helper::getInstance();
299
+
300
+			$title         = $article->getVar('art_title');
301
+			$excerpt       = $article->getVar('art_content');
302
+			$blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
303
+			$title         = xoops_utf8_encode($title);
304
+			$excerpt       = xoops_utf8_encode($excerpt);
305
+			$blog_name     = xoops_utf8_encode($blog_name);
306
+			$charset       = 'utf-8';
307
+			$title1        = urlencode($title);
308
+			$excerpt1      = urlencode($excerpt);
309
+			$name1         = urlencode($blog_name);
310
+			$url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id'));
311
+			$query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
312
+			$trackback_url = parse_url($trackback_url);
313
+
314
+			$http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n";
315
+			$http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
316
+			$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
317
+			$http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
318
+			$http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
319
+			$http_request .= "\r\n\r\n";
320
+			$http_request .= $query_string;
321
+			if ('' == $trackback_url['port']) {
322
+				$trackback_url['port'] = 80;
323
+			}
324
+			$fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
325
+			@fwrite($fs, $http_request);
326
+			if ($helper->getConfig('do_debug')) {
327
+				$debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
328
+				$fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
329
+				$fr         .= "CHARSET:$charset\n";
330
+				$fr         .= "NAME:$blog_name\n";
331
+				$fr         .= 'TITLE:' . $title . "\n";
332
+				$fr         .= "EXCERPT:$excerpt\n\n";
333
+				while (!@feof($fs)) {
334
+					$fr .= @fgets($fs, 4096);
335
+				}
336
+				$fr .= "\n\n";
337
+
338
+				if ($fp = fopen($debug_file, 'a')) {
339
+					fwrite($fp, $fr);
340
+					fclose($fp);
341
+				} else {
342
+				}
343
+			}
344
+			@fclose($fs);
345
+
346
+			return true;
347
+		}
348
+
349
+		/**
350
+		 * Function to ping servers
351
+		 * @param $server
352
+		 * @param $id
353
+		 */
354
+		public static function planetGetPing($server, $id)
355
+		{
356
+			if (is_array($server)) {
357
+				foreach ($server as $serv) {
358
+					PlanetUtility::planetGetPing($serv, $id);
359
+				}
360
+			}
361
+			require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php';
362
+
363
+			// using a timeout of 3 seconds should be enough to cover slow servers
364
+			$client            = new IXR_Client($server, false);
365
+			$client->timeout   = 3;
366
+			$client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION;
367
+
368
+			// when set to true, this outputs debug messages by itself
369
+			$client->debug = false;
370
+
371
+			$blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name'));
372
+			$home     = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/';
373
+			$rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id;
374
+
375
+			if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping
376
+				$client->query('weblogUpdates.ping', $blogname, $home);
377
+			}
378
+		}
379
+
380
+		/**
381
+		 * Function to respond to a trackback
382
+		 * @param int    $error
383
+		 * @param string $error_message
384
+		 */
385
+		public static function planetRespondToTrackback($error = 0, $error_message = '')
386
+		{
387
+			$charset       = 'utf-8';
388
+			$error_message = xoops_utf8_encode($error_message);
389
+			header('Content-Type: text/xml; charset="' . $charset . '"');
390
+			if ($error) {
391
+				echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
392
+				echo "<response>\n";
393
+				echo "<error>1</error>\n";
394
+				echo "<message>$error_message</message>\n";
395
+				echo '</response>';
396
+				die();
397
+			} else {
398
+				echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
399
+				echo "<response>\n";
400
+				echo "<error>0</error>\n";
401
+				echo '</response>';
402
+			}
403
+		}
404
+
405
+		/**
406
+		 * Function to set a cookie with module-specified name
407
+		 *
408
+		 * using customized serialization method
409
+		 * @param        $name
410
+		 * @param string $string
411
+		 * @param int    $expire
412
+		 */
413
+		public static function planetSetCookie($name, $string = '', $expire = 0)
414
+		{
415
+			if (is_array($string)) {
416
+				$value = [];
417
+				foreach ($string as $key => $val) {
418
+					$value[] = $key . '|' . $val;
419
+				}
420
+				$string = implode(',', $value);
421
+			}
422
+			setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/');
423
+		}
424
+
425
+		/**
426
+		 * @param      $name
427
+		 * @param bool $isArray
428
+		 * @return array|null
429
+		 */
430
+		public static function planetGetCookie($name, $isArray = false)
431
+		{
432
+			$value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null;
433
+			if ($isArray) {
434
+				$_value = $value ? explode(',', $value) : [];
435
+				$value  = [];
436
+				if (count($_value) > 0) {
437
+					foreach ($_value as $string) {
438
+						$key         = substr($string, 0, strpos($string, '|'));
439
+						$val         = substr($string, strpos($string, '|') + 1);
440
+						$value[$key] = $val;
441
+					}
442
+				}
443
+				unset($_value);
444
+			}
445
+
446
+			return $value;
447
+		}
448
+
449
+		/**
450
+		 * Function to filter text
451
+		 *
452
+		 * @param $document
453
+		 * @return string filtered text
454
+		 */
455
+		public static function &planetHtml2text(&$document)
456
+		{
457
+			$document = strip_tags($document);
458
+
459
+			return $document;
460
+		}
461
+
462
+		// Adapted from PMA_getIp() [phpmyadmin project]
463
+
464
+		/**
465
+		 * @param bool $asString
466
+		 * @return mixed
467
+		 */
468
+		public static function planetGetIP($asString = false)
469
+		{
470
+			return mod_getIP($asString);
471
+		}
472
+
473
+		/**
474
+		 * @param $url
475
+		 * @return bool|mixed|string
476
+		 */
477
+		public static function planetGetRemoteContent($url)
478
+		{
479
+			if ($data = static::planetFetchSnoopy($url)) {
480
+				return $data;
481
+			}
482
+			if ($data = static::planetFetchCURL($url)) {
483
+				return $data;
484
+			}
485
+			if ($data = static::planetFetchFopen($url)) {
486
+				return $data;
487
+			}
488
+
489
+			return false;
490
+		}
491
+
492
+		/**
493
+		 * @param $url
494
+		 * @return string
495
+		 */
496
+		public static function planetFetchSnoopy($url)
497
+		{
498
+			require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
499
+			$snoopy = new Snoopy;
500
+			$data   = '';
501
+			if (@$snoopy->fetch($url)) {
502
+				$data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results;
503
+			}
504
+
505
+			return $data;
506
+		}
507
+
508
+		/**
509
+		 * @param $url
510
+		 * @return bool|mixed
511
+		 */
512
+		public static function planetFetchCURL($url)
513
+		{
514
+			if (!function_exists('curl_init')) {
515
+				return false;
516
+			}
517
+			$ch = curl_init();    // initialize curl handle
518
+			curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
519
+			curl_setopt($ch, CURLOPT_FAILONERROR, 1);
520
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
521
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
522
+			curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s
523
+			$data = curl_exec($ch); // run the whole process
524
+			curl_close($ch);
525
+
526
+			return $data;
527
+		}
528
+
529
+		/**
530
+		 * @param $url
531
+		 * @return bool|string
532
+		 */
533
+		public static function planetFetchFopen($url)
534
+		{
535
+			if (!$fp = @fopen($url, 'r')) {
536
+				return false;
537
+			}
538
+			$data = '';
539
+			while (!feof($fp)) {
540
+				$data .= fgets($fp, 1024);
541
+			}
542
+			fclose($fp);
543
+
544
+			return $data;
545
+		}
546
+
547
+		/**
548
+		 * @param     $haystack
549
+		 * @param     $needle
550
+		 * @param int $offset
551
+		 * @return bool|int
552
+		 */
553
+		public static function planetStrrPos($haystack, $needle, $offset = 0)
554
+		{
555
+			if (5 == substr(PHP_VERSION, 0, 1)) {
556
+				return strrpos($haystack, $needle, $offset);
557
+			}
558
+			$index = strpos(strrev($haystack), strrev($needle));
559
+			if (false === $index) {
560
+				return false;
561
+			}
562
+			$index = strlen($haystack) - strlen($needle) - $index;
563
+
564
+			return $index;
565
+		}
566
+	}
567 567
 
568 568
 endif;
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 if (!defined('planet_FUNCTIONS')):
43 43
     define('planet_FUNCTIONS', 1);
44 44
 
45
-    require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php';
46
-    require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
47
-    require_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php';
45
+    require XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/vars.php';
46
+    require_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
47
+    require_once XOOPS_ROOT_PATH.'/Frameworks/art/functions.php';
48 48
 
49 49
     /**
50 50
      * Class Utility
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         */
80 80
         public static function planetParseArguments(&$args_numeric, &$args, &$args_string)
81 81
         {
82
-            $args_abb     = [
82
+            $args_abb = [
83 83
                 'a' => 'article',
84 84
                 'b' => 'blog',
85 85
                 'c' => 'category',
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
             if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
95 95
                 $vars = preg_split("/[\/|&]/", $matches[1]);
96 96
                 $vars = array_map('trim', $vars);
97
-                if (count($vars) > 0) {
97
+                if (count($vars)>0) {
98 98
                     foreach ($vars as $var) {
99 99
                         if (is_numeric($var)) {
100 100
                             $args_numeric[] = $var;
101 101
                         } elseif (false === strpos($var, '=')) {
102 102
                             if (is_numeric(substr($var, 1))) {
103
-                                $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
104
-                            } else {
103
+                                $args[$args_abb[strtolower($var{0})]] = (int) substr($var, 1);
104
+                            }else {
105 105
                                 $args_string[] = urldecode($var);
106 106
                             }
107
-                        } else {
107
+                        }else {
108 108
                             parse_str($var, $args);
109 109
                         }
110 110
                     }
111 111
                 }
112 112
             }
113 113
 
114
-            return (0 == count($args) + count($args_numeric) + count($args_string)) ? null : true;
114
+            return (0 == count($args)+count($args_numeric)+count($args_string)) ? null : true;
115 115
         }
116 116
 
117 117
         /**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 $pattern     = [$pattern];
135 135
                 $replacement = [$replacement];
136 136
             }
137
-            if (is_array($pattern) && count($pattern) > 0) {
137
+            if (is_array($pattern) && count($pattern)>0) {
138 138
                 $ii = 0;
139 139
                 foreach ($pattern as $pat) {
140 140
                     if (!in_array($pat, $patterns)) {
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                 $pattern     = [$pattern];
171 171
                 $replacement = [$replacement];
172 172
             }
173
-            if (is_array($pattern) && count($pattern) > 0) {
173
+            if (is_array($pattern) && count($pattern)>0) {
174 174
                 $ii = 0;
175 175
                 foreach ($pattern as $pat) {
176 176
                     if (!in_array($pat, $patterns)) {
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             if (!is_array($userid)) {
216 216
                 $userid = [$userid];
217 217
             }
218
-            $users =& mod_getUnameFromIds($userid, $usereal, $linked);
218
+            $users = & mod_getUnameFromIds($userid, $usereal, $linked);
219 219
 
220 220
             return $users;
221 221
         }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
             $myts       = \MyTextSanitizer::getInstance();
233 233
             $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text);
234 234
             $links      = [];
235
-            if (count($link_array) > 0) {
235
+            if (count($link_array)>0) {
236 236
                 foreach ($link_array as $link) {
237 237
                     @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2));
238 238
                     if (empty($url)) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
          */
253 253
         public static function planetGetTemplate($pagename)
254 254
         {
255
-            return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl';
255
+            return $GLOBALS['VAR_PREFIX'].'_'.$pagename.'.tpl';
256 256
         }
257 257
 
258 258
         /**
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             }
282 282
 
283 283
             @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern));
284
-            $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link'));
284
+            $trackback_url = preg_replace('#'.$pat.'#', $rep, $article_obj->getVar('art_link'));
285 285
 
286 286
             return static::planetTrackback($trackback_url, $article);
287 287
         }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 
300 300
             $title         = $article->getVar('art_title');
301 301
             $excerpt       = $article->getVar('art_content');
302
-            $blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
302
+            $blog_name     = $xoopsConfig['sitename'].'-'.$xoopsModule->getVar('name');
303 303
             $title         = xoops_utf8_encode($title);
304 304
             $excerpt       = xoops_utf8_encode($excerpt);
305 305
             $blog_name     = xoops_utf8_encode($blog_name);
@@ -307,15 +307,15 @@  discard block
 block discarded – undo
307 307
             $title1        = urlencode($title);
308 308
             $excerpt1      = urlencode($excerpt);
309 309
             $name1         = urlencode($blog_name);
310
-            $url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id'));
310
+            $url           = urlencode(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.article.php'.URL_DELIMITER.''.$article->getVar('art_id'));
311 311
             $query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
312 312
             $trackback_url = parse_url($trackback_url);
313 313
 
314
-            $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n";
315
-            $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
316
-            $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
317
-            $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
318
-            $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
314
+            $http_request = 'POST '.$trackback_url['path'].($trackback_url['query'] ? '?'.$trackback_url['query'] : '')." HTTP/1.0\r\n";
315
+            $http_request .= 'Host: '.$trackback_url['host']."\r\n";
316
+            $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.$charset."\r\n";
317
+            $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
318
+            $http_request .= 'User-Agent: XOOPS Blogs/'.XOOPS_VERSION;
319 319
             $http_request .= "\r\n\r\n";
320 320
             $http_request .= $query_string;
321 321
             if ('' == $trackback_url['port']) {
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
             $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
325 325
             @fwrite($fs, $http_request);
326 326
             if ($helper->getConfig('do_debug')) {
327
-                $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
327
+                $debug_file = XOOPS_CACHE_PATH.'/'.$GLOBALS['moddirname'].'_trackback.log';
328 328
                 $fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
329 329
                 $fr         .= "CHARSET:$charset\n";
330 330
                 $fr         .= "NAME:$blog_name\n";
331
-                $fr         .= 'TITLE:' . $title . "\n";
331
+                $fr         .= 'TITLE:'.$title."\n";
332 332
                 $fr         .= "EXCERPT:$excerpt\n\n";
333 333
                 while (!@feof($fs)) {
334 334
                     $fr .= @fgets($fs, 4096);
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                 if ($fp = fopen($debug_file, 'a')) {
339 339
                     fwrite($fp, $fr);
340 340
                     fclose($fp);
341
-                } else {
341
+                }else {
342 342
                 }
343 343
             }
344 344
             @fclose($fs);
@@ -358,19 +358,19 @@  discard block
 block discarded – undo
358 358
                     PlanetUtility::planetGetPing($serv, $id);
359 359
                 }
360 360
             }
361
-            require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php';
361
+            require_once XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/class-IXR.php';
362 362
 
363 363
             // using a timeout of 3 seconds should be enough to cover slow servers
364 364
             $client            = new IXR_Client($server, false);
365 365
             $client->timeout   = 3;
366
-            $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION;
366
+            $client->useragent .= ' -- XOOPS Article/'.XOOPS_VERSION;
367 367
 
368 368
             // when set to true, this outputs debug messages by itself
369 369
             $client->debug = false;
370 370
 
371 371
             $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name'));
372
-            $home     = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/';
373
-            $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id;
372
+            $home     = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/';
373
+            $rss2_url = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php'.URL_DELIMITER.'rss2.0/'.$id;
374 374
 
375 375
             if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping
376 376
                 $client->query('weblogUpdates.ping', $blogname, $home);
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
         {
387 387
             $charset       = 'utf-8';
388 388
             $error_message = xoops_utf8_encode($error_message);
389
-            header('Content-Type: text/xml; charset="' . $charset . '"');
389
+            header('Content-Type: text/xml; charset="'.$charset.'"');
390 390
             if ($error) {
391
-                echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
391
+                echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n";
392 392
                 echo "<response>\n";
393 393
                 echo "<error>1</error>\n";
394 394
                 echo "<message>$error_message</message>\n";
395 395
                 echo '</response>';
396 396
                 die();
397
-            } else {
398
-                echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
397
+            }else {
398
+                echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n";
399 399
                 echo "<response>\n";
400 400
                 echo "<error>0</error>\n";
401 401
                 echo '</response>';
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
             if (is_array($string)) {
416 416
                 $value = [];
417 417
                 foreach ($string as $key => $val) {
418
-                    $value[] = $key . '|' . $val;
418
+                    $value[] = $key.'|'.$val;
419 419
                 }
420 420
                 $string = implode(',', $value);
421 421
             }
422
-            setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/');
422
+            setcookie($GLOBALS['VAR_PREFIX'].$name, $string, (int) $expire, '/');
423 423
         }
424 424
 
425 425
         /**
@@ -429,14 +429,14 @@  discard block
 block discarded – undo
429 429
          */
430 430
         public static function planetGetCookie($name, $isArray = false)
431 431
         {
432
-            $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null;
432
+            $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'].$name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'].$name] : null;
433 433
             if ($isArray) {
434 434
                 $_value = $value ? explode(',', $value) : [];
435 435
                 $value  = [];
436
-                if (count($_value) > 0) {
436
+                if (count($_value)>0) {
437 437
                     foreach ($_value as $string) {
438 438
                         $key         = substr($string, 0, strpos($string, '|'));
439
-                        $val         = substr($string, strpos($string, '|') + 1);
439
+                        $val         = substr($string, strpos($string, '|')+1);
440 440
                         $value[$key] = $val;
441 441
                     }
442 442
                 }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
          */
496 496
         public static function planetFetchSnoopy($url)
497 497
         {
498
-            require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
498
+            require_once XOOPS_ROOT_PATH.'/class/snoopy.php';
499 499
             $snoopy = new Snoopy;
500 500
             $data   = '';
501 501
             if (@$snoopy->fetch($url)) {
@@ -514,10 +514,10 @@  discard block
 block discarded – undo
514 514
             if (!function_exists('curl_init')) {
515 515
                 return false;
516 516
             }
517
-            $ch = curl_init();    // initialize curl handle
517
+            $ch = curl_init(); // initialize curl handle
518 518
             curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
519 519
             curl_setopt($ch, CURLOPT_FAILONERROR, 1);
520
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
520
+            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
521 521
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
522 522
             curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s
523 523
             $data = curl_exec($ch); // run the whole process
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
             if (false === $index) {
560 560
                 return false;
561 561
             }
562
-            $index = strlen($haystack) - strlen($needle) - $index;
562
+            $index = strlen($haystack)-strlen($needle)-$index;
563 563
 
564 564
             return $index;
565 565
         }
Please login to merge, or discard this patch.
action.article.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 
31 31
 $art_id = Request::getInt('article', Request::getInt('article', 0, 'POST'), 'GET');//(int)(isset($_GET['article']) ? $_GET['article'] : (isset($_POST['article']) ? $_POST['article'] : 0));
32 32
 if (empty($art_id)) {
33
-    redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID'));
33
+	redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID'));
34 34
 }
35 35
 if (!$xoopsUser->isAdmin()) {
36
-    redirect_header('javascript:history.go(-1);', 2, _NOPERM);
36
+	redirect_header('javascript:history.go(-1);', 2, _NOPERM);
37 37
 }
38 38
 include XOOPS_ROOT_PATH . '/header.php';
39 39
 include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
@@ -44,58 +44,58 @@  discard block
 block discarded – undo
44 44
 $op = Request::getCmd('op', 'check', 'POST');//isset($_POST['op']) ? $_POST['op'] : '';
45 45
 
46 46
 if ('del' === $op || !empty(Request::getString('del', '', 'POST'))) {
47
-    $articleHandler->delete($article_obj);
48
-    $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php';
49
-    $message  = planet_constant('MD_SAVED');
50
-    redirect_header($redirect, 2, $message);
47
+	$articleHandler->delete($article_obj);
48
+	$redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php';
49
+	$message  = planet_constant('MD_SAVED');
50
+	redirect_header($redirect, 2, $message);
51 51
 } elseif ('save' === $op) {
52
-    if (empty($_POST['art_content'])) {
53
-        redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_TEXTEMPTY'));
54
-    }
52
+	if (empty($_POST['art_content'])) {
53
+		redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_TEXTEMPTY'));
54
+	}
55 55
 
56
-    foreach ([
57
-                 'art_title',
58
-                 'art_link',
59
-                 'art_author',
60
-                 'art_content'
61
-             ] as $tag) {
62
-        if (@Request::getString('tag', '', 'POST') != $article_obj->getVar($tag)) {
63
-            $article_obj->setVar($tag, @Request::getString('tag', '', 'POST'));
64
-        }
65
-    }
56
+	foreach ([
57
+				 'art_title',
58
+				 'art_link',
59
+				 'art_author',
60
+				 'art_content'
61
+			 ] as $tag) {
62
+		if (@Request::getString('tag', '', 'POST') != $article_obj->getVar($tag)) {
63
+			$article_obj->setVar($tag, @Request::getString('tag', '', 'POST'));
64
+		}
65
+	}
66 66
 
67
-    $art_id_new = $articleHandler->insert($article_obj);
68
-    if (!$article_obj->getVar('art_id')) {
69
-        $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php';
70
-        $message  = planet_constant('MD_INSERTERROR');
71
-    } else {
72
-        $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_obj->getVar('art_id');
73
-        $message  = planet_constant('MD_SAVED');
74
-    }
75
-    redirect_header($redirect, 2, $message);
67
+	$art_id_new = $articleHandler->insert($article_obj);
68
+	if (!$article_obj->getVar('art_id')) {
69
+		$redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php';
70
+		$message  = planet_constant('MD_INSERTERROR');
71
+	} else {
72
+		$redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_obj->getVar('art_id');
73
+		$message  = planet_constant('MD_SAVED');
74
+	}
75
+	redirect_header($redirect, 2, $message);
76 76
 } else {
77
-    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
77
+	require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
78 78
 
79
-    $form = new \XoopsThemeForm(_EDIT, 'formarticle', xoops_getenv('PHP_SELF'), 'post', true);
79
+	$form = new \XoopsThemeForm(_EDIT, 'formarticle', xoops_getenv('PHP_SELF'), 'post', true);
80 80
 
81
-    $form->addElement(new \XoopsFormText(planet_constant('MD_TITLE'), 'art_title', 50, 255, $article_obj->getVar('art_title', 'E')), true);
82
-    $form->addElement(new \XoopsFormText(planet_constant('MD_LINK'), 'art_link', 50, 255, $article_obj->getVar('art_link', 'E')), true);
83
-    $form->addElement(new \XoopsFormText(planet_constant('MD_AUTHOR'), 'art_author', 80, 255, $article_obj->getVar('art_author', 'E')));
84
-    $form->addElement(new \XoopsFormTextArea(planet_constant('MD_CONTENT'), 'art_content', $article_obj->getVar('art_content', 'E')), true);
81
+	$form->addElement(new \XoopsFormText(planet_constant('MD_TITLE'), 'art_title', 50, 255, $article_obj->getVar('art_title', 'E')), true);
82
+	$form->addElement(new \XoopsFormText(planet_constant('MD_LINK'), 'art_link', 50, 255, $article_obj->getVar('art_link', 'E')), true);
83
+	$form->addElement(new \XoopsFormText(planet_constant('MD_AUTHOR'), 'art_author', 80, 255, $article_obj->getVar('art_author', 'E')));
84
+	$form->addElement(new \XoopsFormTextArea(planet_constant('MD_CONTENT'), 'art_content', $article_obj->getVar('art_content', 'E')), true);
85 85
 
86
-    $form->addElement(new \XoopsFormHidden('article', $art_id));
87
-    $form->addElement(new \XoopsFormHidden('op', 'save'));
86
+	$form->addElement(new \XoopsFormHidden('article', $art_id));
87
+	$form->addElement(new \XoopsFormHidden('op', 'save'));
88 88
 
89
-    $button_tray = new \XoopsFormElementTray('', '');
90
-    $butt_save   = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
91
-    $button_tray->addElement($butt_save);
92
-    $butt_del = new \XoopsFormButton('', 'del', _DELETE, 'submit');
93
-    $butt_del->setExtra("onClick='document.forms.formarticle.op.value=del'");
94
-    $button_tray->addElement($butt_del);
95
-    $butt_cancel = new \XoopsFormButton('', 'cancel', _CANCEL, 'button');
96
-    $butt_cancel->setExtra("onclick='window.document.location=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $art_id . "\"'");
97
-    $button_tray->addElement($butt_cancel);
98
-    $form->addElement($button_tray);
99
-    $form->display();
89
+	$button_tray = new \XoopsFormElementTray('', '');
90
+	$butt_save   = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
91
+	$button_tray->addElement($butt_save);
92
+	$butt_del = new \XoopsFormButton('', 'del', _DELETE, 'submit');
93
+	$butt_del->setExtra("onClick='document.forms.formarticle.op.value=del'");
94
+	$button_tray->addElement($butt_del);
95
+	$butt_cancel = new \XoopsFormButton('', 'cancel', _CANCEL, 'button');
96
+	$butt_cancel->setExtra("onclick='window.document.location=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $art_id . "\"'");
97
+	$button_tray->addElement($butt_cancel);
98
+	$form->addElement($button_tray);
99
+	$form->display();
100 100
 }
101 101
 include XOOPS_ROOT_PATH . '/footer.php';
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,26 +26,26 @@  discard block
 block discarded – undo
26 26
 // ------------------------------------------------------------------------ //
27 27
 use Xmf\Request;
28 28
 
29
-include __DIR__ . '/header.php';
29
+include __DIR__.'/header.php';
30 30
 
31
-$art_id = Request::getInt('article', Request::getInt('article', 0, 'POST'), 'GET');//(int)(isset($_GET['article']) ? $_GET['article'] : (isset($_POST['article']) ? $_POST['article'] : 0));
31
+$art_id = Request::getInt('article', Request::getInt('article', 0, 'POST'), 'GET'); //(int)(isset($_GET['article']) ? $_GET['article'] : (isset($_POST['article']) ? $_POST['article'] : 0));
32 32
 if (empty($art_id)) {
33 33
     redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID'));
34 34
 }
35 35
 if (!$xoopsUser->isAdmin()) {
36 36
     redirect_header('javascript:history.go(-1);', 2, _NOPERM);
37 37
 }
38
-include XOOPS_ROOT_PATH . '/header.php';
39
-include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
38
+include XOOPS_ROOT_PATH.'/header.php';
39
+include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php';
40 40
 
41 41
 $articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']);
42 42
 $article_obj    = $articleHandler->get($art_id);
43 43
 
44
-$op = Request::getCmd('op', 'check', 'POST');//isset($_POST['op']) ? $_POST['op'] : '';
44
+$op = Request::getCmd('op', 'check', 'POST'); //isset($_POST['op']) ? $_POST['op'] : '';
45 45
 
46 46
 if ('del' === $op || !empty(Request::getString('del', '', 'POST'))) {
47 47
     $articleHandler->delete($article_obj);
48
-    $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php';
48
+    $redirect = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php';
49 49
     $message  = planet_constant('MD_SAVED');
50 50
     redirect_header($redirect, 2, $message);
51 51
 } elseif ('save' === $op) {
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
 
67 67
     $art_id_new = $articleHandler->insert($article_obj);
68 68
     if (!$article_obj->getVar('art_id')) {
69
-        $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php';
69
+        $redirect = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php';
70 70
         $message  = planet_constant('MD_INSERTERROR');
71
-    } else {
72
-        $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_obj->getVar('art_id');
71
+    }else {
72
+        $redirect = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.article.php'.URL_DELIMITER.''.$article_obj->getVar('art_id');
73 73
         $message  = planet_constant('MD_SAVED');
74 74
     }
75 75
     redirect_header($redirect, 2, $message);
76
-} else {
77
-    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
76
+}else {
77
+    require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
78 78
 
79 79
     $form = new \XoopsThemeForm(_EDIT, 'formarticle', xoops_getenv('PHP_SELF'), 'post', true);
80 80
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
     $butt_del->setExtra("onClick='document.forms.formarticle.op.value=del'");
94 94
     $button_tray->addElement($butt_del);
95 95
     $butt_cancel = new \XoopsFormButton('', 'cancel', _CANCEL, 'button');
96
-    $butt_cancel->setExtra("onclick='window.document.location=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $art_id . "\"'");
96
+    $butt_cancel->setExtra("onclick='window.document.location=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.article.php'.URL_DELIMITER.''.$art_id."\"'");
97 97
     $button_tray->addElement($butt_cancel);
98 98
     $form->addElement($button_tray);
99 99
     $form->display();
100 100
 }
101
-include XOOPS_ROOT_PATH . '/footer.php';
101
+include XOOPS_ROOT_PATH.'/footer.php';
Please login to merge, or discard this patch.
tests/testdata/index.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -21,21 +21,21 @@
 block discarded – undo
21 21
 $op = \Xmf\Request::getCmd('op', '');
22 22
 
23 23
 switch ($op) {
24
-    case 'load':
25
-        loadSampleData();
26
-        break;
24
+	case 'load':
25
+		loadSampleData();
26
+		break;
27 27
 }
28 28
 
29 29
 // XMF TableLoad for SAMPLE data
30 30
 
31 31
 function loadSampleData()
32 32
 {
33
-    //    $moduleDirName = basename(dirname(__DIR__));
34
-    xoops_loadLanguage('comment');
35
-    $items = \Xmf\Yaml::readWrapped('quotes_data.yml');
33
+	//    $moduleDirName = basename(dirname(__DIR__));
34
+	xoops_loadLanguage('comment');
35
+	$items = \Xmf\Yaml::readWrapped('quotes_data.yml');
36 36
 
37
-    \Xmf\Database\TableLoad::truncateTable('randomquote_quotes');
38
-    \Xmf\Database\TableLoad::loadTableFromArray('randomquote_quotes', $items);
37
+	\Xmf\Database\TableLoad::truncateTable('randomquote_quotes');
38
+	\Xmf\Database\TableLoad::loadTableFromArray('randomquote_quotes', $items);
39 39
 
40
-    redirect_header('../admin/index.php', 1, _CM_ACTIVE);
40
+	redirect_header('../admin/index.php', 1, _CM_ACTIVE);
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
  * @author          Michael Beck (aka Mamba)
16 16
  */
17 17
 
18
-require_once __DIR__ . '/../../../mainfile.php';
18
+require_once __DIR__.'/../../../mainfile.php';
19 19
 
20 20
 
21 21
 $op = \Xmf\Request::getCmd('op', '');
Please login to merge, or discard this patch.
action.bookmark.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 $blog_id = Request::getInt('blog', Request::getInt('blog', 0, 'POST'), 'GET'); //(int)(isset($_GET['blog']) ? $_GET['blog'] : (isset($_POST['blog']) ? $_POST['blog'] : 0));
32 32
 
33 33
 if (!is_object($xoopsUser) || empty($blog_id)) {
34
-    redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID'));
34
+	redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID'));
35 35
 }
36 36
 
37 37
 $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']);
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 $criteria        = new \CriteriaCompo(new \Criteria('blog_id', $blog_id));
40 40
 $criteria->add(new \Criteria('bm_uid', $uid));
41 41
 if ($count = $bookmarkHandler->getCount($criteria)) {
42
-    $message = planet_constant('MD_ALREADYBOOKMARKED');
43
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'u' . $uid, 2, $message);
42
+	$message = planet_constant('MD_ALREADYBOOKMARKED');
43
+	redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'u' . $uid, 2, $message);
44 44
 }
45 45
 $bookmark_obj = $bookmarkHandler->create();
46 46
 $bookmark_obj->setVar('blog_id', $blog_id);
47 47
 $bookmark_obj->setVar('bm_uid', $uid);
48 48
 if (!$bookmark_id = $bookmarkHandler->insert($bookmark_obj, true)) {
49
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id, 2, planet_constant('MD_NOTSAVED'));
49
+	redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id, 2, planet_constant('MD_NOTSAVED'));
50 50
 }
51 51
 $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
52 52
 $blog_obj    = $blogHandler->get($blog_id);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 // ------------------------------------------------------------------------ //
27 27
 use Xmf\Request;
28 28
 
29
-include __DIR__ . '/header.php';
29
+include __DIR__.'/header.php';
30 30
 
31 31
 $blog_id = Request::getInt('blog', Request::getInt('blog', 0, 'POST'), 'GET'); //(int)(isset($_GET['blog']) ? $_GET['blog'] : (isset($_POST['blog']) ? $_POST['blog'] : 0));
32 32
 
@@ -40,19 +40,19 @@  discard block
 block discarded – undo
40 40
 $criteria->add(new \Criteria('bm_uid', $uid));
41 41
 if ($count = $bookmarkHandler->getCount($criteria)) {
42 42
     $message = planet_constant('MD_ALREADYBOOKMARKED');
43
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'u' . $uid, 2, $message);
43
+    redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'u'.$uid, 2, $message);
44 44
 }
45 45
 $bookmark_obj = $bookmarkHandler->create();
46 46
 $bookmark_obj->setVar('blog_id', $blog_id);
47 47
 $bookmark_obj->setVar('bm_uid', $uid);
48 48
 if (!$bookmark_id = $bookmarkHandler->insert($bookmark_obj, true)) {
49
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id, 2, planet_constant('MD_NOTSAVED'));
49
+    redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'b'.$blog_id, 2, planet_constant('MD_NOTSAVED'));
50 50
 }
51 51
 $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
52 52
 $blog_obj    = $blogHandler->get($blog_id);
53
-$marks       = $blog_obj->getVar('blog_marks') + 1;
54
-$blog_obj->setVar('blog_marks', $blog_obj->getVar('blog_marks') + 1);
53
+$marks       = $blog_obj->getVar('blog_marks')+1;
54
+$blog_obj->setVar('blog_marks', $blog_obj->getVar('blog_marks')+1);
55 55
 $blogHandler->insert($blog_obj, true);
56 56
 $message = planet_constant('MD_ACTIONDONE');
57
-redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message);
58
-include __DIR__ . '/footer.php';
57
+redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'b'.$blog_id, 2, $message);
58
+include __DIR__.'/footer.php';
Please login to merge, or discard this patch.
trackback.php 2 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -41,159 +41,159 @@
 block discarded – undo
41 41
 $charset    = trim(Request::getString('charset', '', 'POST'));//trim($_POST['charset']);
42 42
 
43 43
 if (empty($helper->getConfig('trackback_option'))) {
44
-    PlanetUtility::planetRespondToTrackback(1, 'Trackback is closed');
44
+	PlanetUtility::planetRespondToTrackback(1, 'Trackback is closed');
45 45
 }
46 46
 if (!strlen($title . $url . $blog_name)) {
47
-    PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID'));
47
+	PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID'));
48 48
 }
49 49
 
50 50
 if (!empty($article_id) && !empty($url)) {
51
-    $trackbackHandler = xoops_getModuleHandler('trackback', $GLOBALS['moddirname']);
52
-    $criteria         = new \CriteriaCompo(new \Criteria('art_id', $article_id));
53
-    $criteria->add(new \Criteria('tb_url', $url));
54
-    if ($trackbackHandler->getCount($criteria) > 0) {
55
-        PlanetUtility::planetRespondToTrackback(1, 'We already have a ping from that URI for this article.');
56
-    }
51
+	$trackbackHandler = xoops_getModuleHandler('trackback', $GLOBALS['moddirname']);
52
+	$criteria         = new \CriteriaCompo(new \Criteria('art_id', $article_id));
53
+	$criteria->add(new \Criteria('tb_url', $url));
54
+	if ($trackbackHandler->getCount($criteria) > 0) {
55
+		PlanetUtility::planetRespondToTrackback(1, 'We already have a ping from that URI for this article.');
56
+	}
57 57
 
58
-    $charset   = empty($charset) ? 'utf-8' : $charset;
59
-    $title     = XoopsLocal::convert_encoding($title, _CHARSET, $charset);
60
-    $excerpt   = XoopsLocal::convert_encoding($excerpt, _CHARSET, $charset);
61
-    $blog_name = XoopsLocal::convert_encoding($blog_name, _CHARSET, $charset);
62
-    $tb_status = (int)$helper->getConfig('trackback_option');
58
+	$charset   = empty($charset) ? 'utf-8' : $charset;
59
+	$title     = XoopsLocal::convert_encoding($title, _CHARSET, $charset);
60
+	$excerpt   = XoopsLocal::convert_encoding($excerpt, _CHARSET, $charset);
61
+	$blog_name = XoopsLocal::convert_encoding($blog_name, _CHARSET, $charset);
62
+	$tb_status = (int)$helper->getConfig('trackback_option');
63 63
 
64
-    $com_pid    = 0;
65
-    $com_itemid = $article_id;
66
-    $com_rootid = 0;
67
-    $com_title  = $title;
68
-    $com_text   = $excerpt;
69
-    $com_text   .= "\n\n[TRACKBACK]" . _POSTEDBY . ': ';
70
-    if (!empty($url)) {
71
-        $com_text .= '[url=' . $url . ']' . $blog_name . '[/url]';
72
-    } else {
73
-        $com_text .= $blog_name;
74
-    }
75
-    $com_modid = $xoopsModule->getVar('mid');
64
+	$com_pid    = 0;
65
+	$com_itemid = $article_id;
66
+	$com_rootid = 0;
67
+	$com_title  = $title;
68
+	$com_text   = $excerpt;
69
+	$com_text   .= "\n\n[TRACKBACK]" . _POSTEDBY . ': ';
70
+	if (!empty($url)) {
71
+		$com_text .= '[url=' . $url . ']' . $blog_name . '[/url]';
72
+	} else {
73
+		$com_text .= $blog_name;
74
+	}
75
+	$com_modid = $xoopsModule->getVar('mid');
76 76
 
77
-    $commentHandler = xoops_getHandler('comment');
78
-    $comment        = $commentHandler->create();
79
-    $comment->setVar('com_created', time());
80
-    $comment->setVar('com_pid', $com_pid);
81
-    $comment->setVar('com_itemid', $com_itemid);
82
-    $comment->setVar('com_rootid', $com_rootid);
83
-    $comment->setVar('com_ip', xoops_getenv('REMOTE_ADDR'));
84
-    switch ($tb_status) {
85
-        case 2:
86
-            $comment->setVar('com_status', 2);
87
-            $call_approvefunc = true;
88
-            $call_updatefunc  = true;
89
-            $notify_event     = 'comment';
90
-            break;
91
-        case 1:
92
-        default:
93
-            $comment->setVar('com_status', 1);
94
-            $notify_event = 'comment_submit';
95
-            break;
96
-    }
97
-    $comment->setVar('com_uid', 0);
98
-    $com_title = xoops_trim($com_title);
99
-    $com_title = empty($com_title) ? _NOTITLE : $com_title;
100
-    $comment->setVar('com_title', $com_title);
101
-    $comment->setVar('com_text', $com_text);
102
-    $comment->setVar('dohtml', 0);
103
-    $comment->setVar('dosmiley', 0);
104
-    $comment->setVar('doxcode', 1);
105
-    $comment->setVar('doimage', 0);
106
-    $comment->setVar('dobr', 1);
107
-    $comment->setVar('com_icon', '');
108
-    $comment->setVar('com_modified', time());
109
-    $comment->setVar('com_modid', $com_modid);
110
-    if (false != $commentHandler->insert($comment)) {
111
-        $newcid = $comment->getVar('com_id');
77
+	$commentHandler = xoops_getHandler('comment');
78
+	$comment        = $commentHandler->create();
79
+	$comment->setVar('com_created', time());
80
+	$comment->setVar('com_pid', $com_pid);
81
+	$comment->setVar('com_itemid', $com_itemid);
82
+	$comment->setVar('com_rootid', $com_rootid);
83
+	$comment->setVar('com_ip', xoops_getenv('REMOTE_ADDR'));
84
+	switch ($tb_status) {
85
+		case 2:
86
+			$comment->setVar('com_status', 2);
87
+			$call_approvefunc = true;
88
+			$call_updatefunc  = true;
89
+			$notify_event     = 'comment';
90
+			break;
91
+		case 1:
92
+		default:
93
+			$comment->setVar('com_status', 1);
94
+			$notify_event = 'comment_submit';
95
+			break;
96
+	}
97
+	$comment->setVar('com_uid', 0);
98
+	$com_title = xoops_trim($com_title);
99
+	$com_title = empty($com_title) ? _NOTITLE : $com_title;
100
+	$comment->setVar('com_title', $com_title);
101
+	$comment->setVar('com_text', $com_text);
102
+	$comment->setVar('dohtml', 0);
103
+	$comment->setVar('dosmiley', 0);
104
+	$comment->setVar('doxcode', 1);
105
+	$comment->setVar('doimage', 0);
106
+	$comment->setVar('dobr', 1);
107
+	$comment->setVar('com_icon', '');
108
+	$comment->setVar('com_modified', time());
109
+	$comment->setVar('com_modid', $com_modid);
110
+	if (false != $commentHandler->insert($comment)) {
111
+		$newcid = $comment->getVar('com_id');
112 112
 
113
-        // set own id as root id
114
-        $com_rootid = $newcid;
115
-        if (!$commentHandler->updateByField($comment, 'com_rootid', $com_rootid)) {
116
-            $commentHandler->delete($comment);
117
-            PlanetUtility::planetRespondToTrackback(1, xoops_error());
118
-        }
113
+		// set own id as root id
114
+		$com_rootid = $newcid;
115
+		if (!$commentHandler->updateByField($comment, 'com_rootid', $com_rootid)) {
116
+			$commentHandler->delete($comment);
117
+			PlanetUtility::planetRespondToTrackback(1, xoops_error());
118
+		}
119 119
 
120
-        // call custom approve function if any
121
-        if (false != $call_approvefunc && isset($comment_config['callback']['approve'])
122
-            && '' != trim($comment_config['callback']['approve'])) {
123
-            $skip = false;
124
-            if (!function_exists($comment_config['callback']['approve'])) {
125
-                if (isset($comment_config['callbackFile'])) {
126
-                    $callbackfile = trim($comment_config['callbackFile']);
127
-                    if ('' != $callbackfile
128
-                        && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) {
129
-                        require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile;
130
-                    }
131
-                    if (!function_exists($comment_config['callback']['approve'])) {
132
-                        $skip = true;
133
-                    }
134
-                } else {
135
-                    $skip = true;
136
-                }
137
-            }
138
-            if (!$skip) {
139
-                $comment_config['callback']['approve']($comment);
140
-            }
141
-        }
120
+		// call custom approve function if any
121
+		if (false != $call_approvefunc && isset($comment_config['callback']['approve'])
122
+			&& '' != trim($comment_config['callback']['approve'])) {
123
+			$skip = false;
124
+			if (!function_exists($comment_config['callback']['approve'])) {
125
+				if (isset($comment_config['callbackFile'])) {
126
+					$callbackfile = trim($comment_config['callbackFile']);
127
+					if ('' != $callbackfile
128
+						&& file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) {
129
+						require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile;
130
+					}
131
+					if (!function_exists($comment_config['callback']['approve'])) {
132
+						$skip = true;
133
+					}
134
+				} else {
135
+					$skip = true;
136
+				}
137
+			}
138
+			if (!$skip) {
139
+				$comment_config['callback']['approve']($comment);
140
+			}
141
+		}
142 142
 
143
-        // call custom update function if any
144
-        if (false != $call_updatefunc && isset($comment_config['callback']['update'])
145
-            && '' != trim($comment_config['callback']['update'])) {
146
-            $skip = false;
147
-            if (!function_exists($comment_config['callback']['update'])) {
148
-                if (isset($comment_config['callbackFile'])) {
149
-                    $callbackfile = trim($comment_config['callbackFile']);
150
-                    if ('' != $callbackfile
151
-                        && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) {
152
-                        require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile;
153
-                    }
154
-                    if (!function_exists($comment_config['callback']['update'])) {
155
-                        $skip = true;
156
-                    }
157
-                } else {
158
-                    $skip = true;
159
-                }
160
-            }
161
-            if (!$skip) {
162
-                $criteria = new \CriteriaCompo(new \Criteria('com_modid', $com_modid));
163
-                $criteria->add(new \Criteria('com_itemid', $com_itemid));
164
-                $criteria->add(new \Criteria('com_status', XOOPS_COMMENT_ACTIVE));
165
-                $comment_count = $commentHandler->getCount($criteria);
166
-                $func          = $comment_config['callback']['update'];
167
-                call_user_func_array($func, [$com_itemid, $comment_count, $comment->getVar('com_id')]);
168
-            }
169
-        }
143
+		// call custom update function if any
144
+		if (false != $call_updatefunc && isset($comment_config['callback']['update'])
145
+			&& '' != trim($comment_config['callback']['update'])) {
146
+			$skip = false;
147
+			if (!function_exists($comment_config['callback']['update'])) {
148
+				if (isset($comment_config['callbackFile'])) {
149
+					$callbackfile = trim($comment_config['callbackFile']);
150
+					if ('' != $callbackfile
151
+						&& file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) {
152
+						require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile;
153
+					}
154
+					if (!function_exists($comment_config['callback']['update'])) {
155
+						$skip = true;
156
+					}
157
+				} else {
158
+					$skip = true;
159
+				}
160
+			}
161
+			if (!$skip) {
162
+				$criteria = new \CriteriaCompo(new \Criteria('com_modid', $com_modid));
163
+				$criteria->add(new \Criteria('com_itemid', $com_itemid));
164
+				$criteria->add(new \Criteria('com_status', XOOPS_COMMENT_ACTIVE));
165
+				$comment_count = $commentHandler->getCount($criteria);
166
+				$func          = $comment_config['callback']['update'];
167
+				call_user_func_array($func, [$com_itemid, $comment_count, $comment->getVar('com_id')]);
168
+			}
169
+		}
170 170
 
171
-        // RMV-NOTIFY
172
-        // trigger notification event if necessary
173
-        if ($notify_event) {
174
-            $not_modid = $com_modid;
175
-            //            require_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
176
-            $not_catinfo  = notificationCommentCategoryInfo($not_modid);
177
-            $not_category = $not_catinfo['name'];
178
-            $not_itemid   = $com_itemid;
179
-            $not_event    = $notify_event;
180
-            // Build an ABSOLUTE URL to view the comment.  Make sure we
181
-            // point to a viewable page (i.e. not the system administration
182
-            // module).
183
-            $comment_tags = [];
184
-            $not_module   = $xoopsModule;
185
-            if (!isset($comment_url)) {
186
-                $com_config  = $not_module->getInfo('comments');
187
-                $comment_url = $com_config['pageName'] . '?';
188
-                $comment_url .= $com_config['itemName'];
189
-            }
190
-            $comment_tags['X_COMMENT_URL'] = XOOPS_URL . '/modules/' . $not_module->getVar('dirname') . '/' . $comment_url . '=' . $com_itemid . '&amp;com_id=' . $newcid . '&amp;com_rootid=' . $com_rootid . '&amp;com_mode=' . $com_mode . '&amp;com_order=' . $com_order . '#comment' . $newcid;
191
-            $notificationHandler           = xoops_getHandler('notification');
192
-            $notificationHandler->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid);
193
-        }
171
+		// RMV-NOTIFY
172
+		// trigger notification event if necessary
173
+		if ($notify_event) {
174
+			$not_modid = $com_modid;
175
+			//            require_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
176
+			$not_catinfo  = notificationCommentCategoryInfo($not_modid);
177
+			$not_category = $not_catinfo['name'];
178
+			$not_itemid   = $com_itemid;
179
+			$not_event    = $notify_event;
180
+			// Build an ABSOLUTE URL to view the comment.  Make sure we
181
+			// point to a viewable page (i.e. not the system administration
182
+			// module).
183
+			$comment_tags = [];
184
+			$not_module   = $xoopsModule;
185
+			if (!isset($comment_url)) {
186
+				$com_config  = $not_module->getInfo('comments');
187
+				$comment_url = $com_config['pageName'] . '?';
188
+				$comment_url .= $com_config['itemName'];
189
+			}
190
+			$comment_tags['X_COMMENT_URL'] = XOOPS_URL . '/modules/' . $not_module->getVar('dirname') . '/' . $comment_url . '=' . $com_itemid . '&amp;com_id=' . $newcid . '&amp;com_rootid=' . $com_rootid . '&amp;com_mode=' . $com_mode . '&amp;com_order=' . $com_order . '#comment' . $newcid;
191
+			$notificationHandler           = xoops_getHandler('notification');
192
+			$notificationHandler->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid);
193
+		}
194 194
 
195
-        PlanetUtility::planetRespondToTrackback(0);
196
-    } else {
197
-        PlanetUtility::planetRespondToTrackback(1, xoops_error($comment->getHtmlErrors()));
198
-    }
195
+		PlanetUtility::planetRespondToTrackback(0);
196
+	} else {
197
+		PlanetUtility::planetRespondToTrackback(1, xoops_error($comment->getHtmlErrors()));
198
+	}
199 199
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
 /** @var Planet\Helper $helper */
30 30
 $helper = Planet\Helper::getInstance();
31 31
 
32
-include __DIR__ . '/header.php';
32
+include __DIR__.'/header.php';
33 33
 
34 34
 // trackback is done by a POST
35 35
 $art_id     = explode('/', Request::getString('REQUEST_URI', '', 'SERVER'));
36
-$article_id = (int)$art_id[count($art_id) - 1];
37
-$url        = Request::getString('url', '', 'POST');//$_POST['url'];
38
-$title      = Request::getString('title', '', 'POST');//$_POST['title'];
39
-$excerpt    = Request::getString('excerpt', '', 'POST');//$_POST['excerpt'];
40
-$blog_name  = Request::getString('blog_name', '', 'POST');//$_POST['blog_name'];
41
-$charset    = trim(Request::getString('charset', '', 'POST'));//trim($_POST['charset']);
36
+$article_id = (int) $art_id[count($art_id)-1];
37
+$url        = Request::getString('url', '', 'POST'); //$_POST['url'];
38
+$title      = Request::getString('title', '', 'POST'); //$_POST['title'];
39
+$excerpt    = Request::getString('excerpt', '', 'POST'); //$_POST['excerpt'];
40
+$blog_name  = Request::getString('blog_name', '', 'POST'); //$_POST['blog_name'];
41
+$charset    = trim(Request::getString('charset', '', 'POST')); //trim($_POST['charset']);
42 42
 
43 43
 if (empty($helper->getConfig('trackback_option'))) {
44 44
     PlanetUtility::planetRespondToTrackback(1, 'Trackback is closed');
45 45
 }
46
-if (!strlen($title . $url . $blog_name)) {
46
+if (!strlen($title.$url.$blog_name)) {
47 47
     PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID'));
48 48
 }
49 49
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     $trackbackHandler = xoops_getModuleHandler('trackback', $GLOBALS['moddirname']);
52 52
     $criteria         = new \CriteriaCompo(new \Criteria('art_id', $article_id));
53 53
     $criteria->add(new \Criteria('tb_url', $url));
54
-    if ($trackbackHandler->getCount($criteria) > 0) {
54
+    if ($trackbackHandler->getCount($criteria)>0) {
55 55
         PlanetUtility::planetRespondToTrackback(1, 'We already have a ping from that URI for this article.');
56 56
     }
57 57
 
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
     $title     = XoopsLocal::convert_encoding($title, _CHARSET, $charset);
60 60
     $excerpt   = XoopsLocal::convert_encoding($excerpt, _CHARSET, $charset);
61 61
     $blog_name = XoopsLocal::convert_encoding($blog_name, _CHARSET, $charset);
62
-    $tb_status = (int)$helper->getConfig('trackback_option');
62
+    $tb_status = (int) $helper->getConfig('trackback_option');
63 63
 
64 64
     $com_pid    = 0;
65 65
     $com_itemid = $article_id;
66 66
     $com_rootid = 0;
67 67
     $com_title  = $title;
68 68
     $com_text   = $excerpt;
69
-    $com_text   .= "\n\n[TRACKBACK]" . _POSTEDBY . ': ';
69
+    $com_text .= "\n\n[TRACKBACK]"._POSTEDBY.': ';
70 70
     if (!empty($url)) {
71
-        $com_text .= '[url=' . $url . ']' . $blog_name . '[/url]';
72
-    } else {
71
+        $com_text .= '[url='.$url.']'.$blog_name.'[/url]';
72
+    }else {
73 73
         $com_text .= $blog_name;
74 74
     }
75 75
     $com_modid = $xoopsModule->getVar('mid');
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
                 if (isset($comment_config['callbackFile'])) {
126 126
                     $callbackfile = trim($comment_config['callbackFile']);
127 127
                     if ('' != $callbackfile
128
-                        && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) {
129
-                        require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile;
128
+                        && file_exists(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/'.$callbackfile)) {
129
+                        require_once XOOPS_ROOT_PATH.'/modules/'.$moddir.'/'.$callbackfile;
130 130
                     }
131 131
                     if (!function_exists($comment_config['callback']['approve'])) {
132 132
                         $skip = true;
133 133
                     }
134
-                } else {
134
+                }else {
135 135
                     $skip = true;
136 136
                 }
137 137
             }
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
                 if (isset($comment_config['callbackFile'])) {
149 149
                     $callbackfile = trim($comment_config['callbackFile']);
150 150
                     if ('' != $callbackfile
151
-                        && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) {
152
-                        require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile;
151
+                        && file_exists(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/'.$callbackfile)) {
152
+                        require_once XOOPS_ROOT_PATH.'/modules/'.$moddir.'/'.$callbackfile;
153 153
                     }
154 154
                     if (!function_exists($comment_config['callback']['update'])) {
155 155
                         $skip = true;
156 156
                     }
157
-                } else {
157
+                }else {
158 158
                     $skip = true;
159 159
                 }
160 160
             }
@@ -184,16 +184,16 @@  discard block
 block discarded – undo
184 184
             $not_module   = $xoopsModule;
185 185
             if (!isset($comment_url)) {
186 186
                 $com_config  = $not_module->getInfo('comments');
187
-                $comment_url = $com_config['pageName'] . '?';
187
+                $comment_url = $com_config['pageName'].'?';
188 188
                 $comment_url .= $com_config['itemName'];
189 189
             }
190
-            $comment_tags['X_COMMENT_URL'] = XOOPS_URL . '/modules/' . $not_module->getVar('dirname') . '/' . $comment_url . '=' . $com_itemid . '&amp;com_id=' . $newcid . '&amp;com_rootid=' . $com_rootid . '&amp;com_mode=' . $com_mode . '&amp;com_order=' . $com_order . '#comment' . $newcid;
190
+            $comment_tags['X_COMMENT_URL'] = XOOPS_URL.'/modules/'.$not_module->getVar('dirname').'/'.$comment_url.'='.$com_itemid.'&amp;com_id='.$newcid.'&amp;com_rootid='.$com_rootid.'&amp;com_mode='.$com_mode.'&amp;com_order='.$com_order.'#comment'.$newcid;
191 191
             $notificationHandler           = xoops_getHandler('notification');
192 192
             $notificationHandler->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid);
193 193
         }
194 194
 
195 195
         PlanetUtility::planetRespondToTrackback(0);
196
-    } else {
196
+    }else {
197 197
         PlanetUtility::planetRespondToTrackback(1, xoops_error($comment->getHtmlErrors()));
198 198
     }
199 199
 }
Please login to merge, or discard this patch.
action.rate.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -37,61 +37,61 @@
 block discarded – undo
37 37
 $blog_id    = Request::getInt('blog', Request::getInt('blog', 0, 'POST'), 'GET'); //(int)(!empty($_POST['blog']) ? $_POST['blog'] : (!empty($_GET['blog']) ? $_GET['blog'] : 0));
38 38
 
39 39
 if (empty($article_id) && empty($blog_id)) {
40
-    redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID'));
40
+	redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID'));
41 41
 }
42 42
 
43 43
 $articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']);
44 44
 $blogHandler    = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
45 45
 if (empty($helper->getConfig('anonymous_rate')) && !is_object($xoopsUser)) {
46
-    $message = planet_constant('MD_NOACCESS');
46
+	$message = planet_constant('MD_NOACCESS');
47 47
 } else {
48
-    $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
49
-    $ip  = PlanetUtility::planetGetIP();
50
-    if ($article_id > 0) {
51
-        $criteria = new \CriteriaCompo(new \Criteria('art_id', $article_id));
52
-    } else {
53
-        $criteria = new \CriteriaCompo(new \Criteria('blog_id', $blog_id));
54
-    }
55
-    if ($uid > 0) {
56
-        $criteria->add(new \Criteria('rate_uid', $uid));
57
-    } else {
58
-        $criteria->add(new \Criteria('rate_ip', $ip));
59
-        $criteria->add(new \Criteria('rate_time', time() - 24 * 3600, '>'));
60
-    }
61
-    $rateHandler = xoops_getModuleHandler('rate', $GLOBALS['moddirname']);
62
-    if ($count = $rateHandler->getCount($criteria)) {
63
-        $message = planet_constant('MD_ALREADYRATED');
64
-    } else {
65
-        $rate_obj = $rateHandler->create();
66
-        if ($article_id > 0) {
67
-            $rate_obj->setVar('art_id', $article_id);
68
-        } else {
69
-            $rate_obj->setVar('blog_id', $blog_id);
70
-        }
71
-        $rate_obj->setVar('rate_uid', $uid);
72
-        $rate_obj->setVar('rate_ip', $ip);
73
-        $rate_obj->setVar('rate_rating', $rate);
74
-        $rate_obj->setVar('rate_time', time());
75
-        if (!$rate_id = $rateHandler->insert($rate_obj, true)) {
76
-            redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_NOTSAVED'));
77
-        }
78
-        if ($article_id > 0) {
79
-            $article_obj = $articleHandler->get($article_id);
80
-            $article_obj->setVar('art_rating', $article_obj->getVar('art_rating') + $rate);
81
-            $article_obj->setVar('art_rates', $article_obj->getVar('art_rates') + 1);
82
-            $articleHandler->insert($article_obj, true);
83
-        } else {
84
-            $blog_obj = $blogHandler->get($blog_id);
85
-            $blog_obj->setVar('blog_rating', $blog_obj->getVar('blog_rating') + $rate);
86
-            $blog_obj->setVar('blog_rates', $blog_obj->getVar('blog_rates') + 1);
87
-            $blogHandler->insert($blog_obj, true);
88
-        }
89
-        $message = planet_constant('MD_ACTIONDONE');
90
-    }
48
+	$uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
49
+	$ip  = PlanetUtility::planetGetIP();
50
+	if ($article_id > 0) {
51
+		$criteria = new \CriteriaCompo(new \Criteria('art_id', $article_id));
52
+	} else {
53
+		$criteria = new \CriteriaCompo(new \Criteria('blog_id', $blog_id));
54
+	}
55
+	if ($uid > 0) {
56
+		$criteria->add(new \Criteria('rate_uid', $uid));
57
+	} else {
58
+		$criteria->add(new \Criteria('rate_ip', $ip));
59
+		$criteria->add(new \Criteria('rate_time', time() - 24 * 3600, '>'));
60
+	}
61
+	$rateHandler = xoops_getModuleHandler('rate', $GLOBALS['moddirname']);
62
+	if ($count = $rateHandler->getCount($criteria)) {
63
+		$message = planet_constant('MD_ALREADYRATED');
64
+	} else {
65
+		$rate_obj = $rateHandler->create();
66
+		if ($article_id > 0) {
67
+			$rate_obj->setVar('art_id', $article_id);
68
+		} else {
69
+			$rate_obj->setVar('blog_id', $blog_id);
70
+		}
71
+		$rate_obj->setVar('rate_uid', $uid);
72
+		$rate_obj->setVar('rate_ip', $ip);
73
+		$rate_obj->setVar('rate_rating', $rate);
74
+		$rate_obj->setVar('rate_time', time());
75
+		if (!$rate_id = $rateHandler->insert($rate_obj, true)) {
76
+			redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_NOTSAVED'));
77
+		}
78
+		if ($article_id > 0) {
79
+			$article_obj = $articleHandler->get($article_id);
80
+			$article_obj->setVar('art_rating', $article_obj->getVar('art_rating') + $rate);
81
+			$article_obj->setVar('art_rates', $article_obj->getVar('art_rates') + 1);
82
+			$articleHandler->insert($article_obj, true);
83
+		} else {
84
+			$blog_obj = $blogHandler->get($blog_id);
85
+			$blog_obj->setVar('blog_rating', $blog_obj->getVar('blog_rating') + $rate);
86
+			$blog_obj->setVar('blog_rates', $blog_obj->getVar('blog_rates') + 1);
87
+			$blogHandler->insert($blog_obj, true);
88
+		}
89
+		$message = planet_constant('MD_ACTIONDONE');
90
+	}
91 91
 }
92 92
 if ($article_id > 0) {
93
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_id, 2, $message);
93
+	redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_id, 2, $message);
94 94
 } else {
95
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message);
95
+	redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message);
96 96
 }
97 97
 include __DIR__ . '/footer.php';
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 use Xmf\Request;
28 28
 use XoopsModules\Planet;
29 29
 
30
-include __DIR__ . '/header.php';
30
+include __DIR__.'/header.php';
31 31
 
32 32
 /** @var Planet\Helper $helper */
33 33
 $helper = Planet\Helper::getInstance();
@@ -44,28 +44,28 @@  discard block
 block discarded – undo
44 44
 $blogHandler    = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
45 45
 if (empty($helper->getConfig('anonymous_rate')) && !is_object($xoopsUser)) {
46 46
     $message = planet_constant('MD_NOACCESS');
47
-} else {
47
+}else {
48 48
     $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
49 49
     $ip  = PlanetUtility::planetGetIP();
50
-    if ($article_id > 0) {
50
+    if ($article_id>0) {
51 51
         $criteria = new \CriteriaCompo(new \Criteria('art_id', $article_id));
52
-    } else {
52
+    }else {
53 53
         $criteria = new \CriteriaCompo(new \Criteria('blog_id', $blog_id));
54 54
     }
55
-    if ($uid > 0) {
55
+    if ($uid>0) {
56 56
         $criteria->add(new \Criteria('rate_uid', $uid));
57
-    } else {
57
+    }else {
58 58
         $criteria->add(new \Criteria('rate_ip', $ip));
59
-        $criteria->add(new \Criteria('rate_time', time() - 24 * 3600, '>'));
59
+        $criteria->add(new \Criteria('rate_time', time()-24*3600, '>'));
60 60
     }
61 61
     $rateHandler = xoops_getModuleHandler('rate', $GLOBALS['moddirname']);
62 62
     if ($count = $rateHandler->getCount($criteria)) {
63 63
         $message = planet_constant('MD_ALREADYRATED');
64
-    } else {
64
+    }else {
65 65
         $rate_obj = $rateHandler->create();
66
-        if ($article_id > 0) {
66
+        if ($article_id>0) {
67 67
             $rate_obj->setVar('art_id', $article_id);
68
-        } else {
68
+        }else {
69 69
             $rate_obj->setVar('blog_id', $blog_id);
70 70
         }
71 71
         $rate_obj->setVar('rate_uid', $uid);
@@ -75,23 +75,23 @@  discard block
 block discarded – undo
75 75
         if (!$rate_id = $rateHandler->insert($rate_obj, true)) {
76 76
             redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_NOTSAVED'));
77 77
         }
78
-        if ($article_id > 0) {
78
+        if ($article_id>0) {
79 79
             $article_obj = $articleHandler->get($article_id);
80
-            $article_obj->setVar('art_rating', $article_obj->getVar('art_rating') + $rate);
81
-            $article_obj->setVar('art_rates', $article_obj->getVar('art_rates') + 1);
80
+            $article_obj->setVar('art_rating', $article_obj->getVar('art_rating')+$rate);
81
+            $article_obj->setVar('art_rates', $article_obj->getVar('art_rates')+1);
82 82
             $articleHandler->insert($article_obj, true);
83
-        } else {
83
+        }else {
84 84
             $blog_obj = $blogHandler->get($blog_id);
85
-            $blog_obj->setVar('blog_rating', $blog_obj->getVar('blog_rating') + $rate);
86
-            $blog_obj->setVar('blog_rates', $blog_obj->getVar('blog_rates') + 1);
85
+            $blog_obj->setVar('blog_rating', $blog_obj->getVar('blog_rating')+$rate);
86
+            $blog_obj->setVar('blog_rates', $blog_obj->getVar('blog_rates')+1);
87 87
             $blogHandler->insert($blog_obj, true);
88 88
         }
89 89
         $message = planet_constant('MD_ACTIONDONE');
90 90
     }
91 91
 }
92
-if ($article_id > 0) {
93
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_id, 2, $message);
94
-} else {
95
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message);
92
+if ($article_id>0) {
93
+    redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.article.php'.URL_DELIMITER.''.$article_id, 2, $message);
94
+}else {
95
+    redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'b'.$blog_id, 2, $message);
96 96
 }
97
-include __DIR__ . '/footer.php';
97
+include __DIR__.'/footer.php';
Please login to merge, or discard this patch.