Completed
Branch master (2d4977)
by Michael
03:20
created
include/functions.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     //Verifies that a MySQL table exists
156 156
     $xoopsDB = & XoopsDatabaseFactory::getDatabaseConnection();
157 157
     $realname = $xoopsDB->prefix($table);
158
-    $sql = "SHOW TABLES FROM ".XOOPS_DB_NAME;
158
+    $sql = "SHOW TABLES FROM " . XOOPS_DB_NAME;
159 159
     $ret = $xoopsDB->queryF($sql);
160 160
     while (list ($m_table) = $xoopsDB->fetchRow($ret)) {
161 161
         if ($m_table == $realname) {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
     // truncate the original string to a length of $length
238 238
     // minus the position of the last space
239 239
     // plus the length of the $trimmarker
240
-    $truncated_string = xoops_substr($str, $start, $length - $position_of_space +strlen($trimmarker), $trimmarker);
240
+    $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker);
241 241
     return $truncated_string;
242 242
 }
243 243
 function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined') {
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
         }
340 340
         $attr = " width='$width' height='$height'";
341 341
     }
342
-    return array (
342
+    return array(
343 343
     $width,
344 344
     $height,
345 345
     $type,
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 function &smart_getModuleInfo($moduleName = false) {
350 350
     static $smartModules;
351 351
     if (isset ($smartModules[$moduleName])) {
352
-        $ret =& $smartModules[$moduleName];
352
+        $ret = & $smartModules[$moduleName];
353 353
         return $ret;
354 354
     }
355 355
     global $xoopsModule;
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
         return unlink($dirname);
412 412
     }
413 413
 }
414
-function smart_formatErrors($errors = array ()) {
414
+function smart_formatErrors($errors = array()) {
415 415
     $ret = '';
416 416
     foreach ($errors as $key => $value) {
417 417
         $ret .= "<br /> - " . $value;
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
  * @param integer $name :  0 Use Usenamer 1 Use realname
426 426
  * @return
427 427
  */
428
-function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array (), $withContact = false) {
428
+function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array(), $withContact = false) {
429 429
     if (!is_numeric($userid)) {
430 430
         return $userid;
431 431
     }
432 432
     $userid = intval($userid);
433 433
     if ($userid > 0) {
434
-        if ($users == array ()) {
434
+        if ($users == array()) {
435 435
             //fetching users
436 436
             $member_handler = & xoops_gethandler('member');
437 437
             $user = & $member_handler->getUser($userid);
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     $adminmenu = array();
483 483
     include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php';
484 484
     $tpl = new XoopsTpl();
485
-    $tpl->assign(array (
485
+    $tpl->assign(array(
486 486
         'headermenu' => $headermenu,
487 487
         'adminmenu' => $adminmenu,
488 488
         'current' => $currentoption,
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
         $querystring = '?' . $querystring;
588 588
     }
589 589
     $currenturl = $http . $httphost . $phpself . $querystring;
590
-    $urls = array ();
590
+    $urls = array();
591 591
     $urls['http'] = $http;
592 592
     $urls['httphost'] = $httphost;
593 593
     $urls['phpself'] = $phpself;
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
         elseif (!empty ($height)) {
715 715
             $width = $dimension[0] * $height / $dimension[1];
716 716
         } else {
717
-            list ($width, $height) = array (
717
+            list ($width, $height) = array(
718 718
             $dimension[0],
719 719
             $dimension[1]
720 720
             );
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
         }
743 743
         $class = 'Xoops' . ucfirst($name) . 'Handler';
744 744
         if (class_exists($class)) {
745
-            $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops');
745
+            $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops');
746 746
         }
747 747
     }
748 748
     if (!isset ($handlers[$name]) && !$optional) {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 }
756 756
 function smart_sanitizeAdsenses_callback($matches) {
757 757
     global $smartobject_adsense_handler;
758
-    if (isset($smartobject_adsense_handler->objects[$matches[1]])){
758
+    if (isset($smartobject_adsense_handler->objects[$matches[1]])) {
759 759
         $adsenseObj = $smartobject_adsense_handler->objects[$matches[1]];
760 760
         $ret = $adsenseObj->render();
761 761
         return $ret;
@@ -765,8 +765,8 @@  discard block
 block discarded – undo
765 765
 }
766 766
 function smart_sanitizeAdsenses($text) {
767 767
 
768
-    $patterns = array ();
769
-    $replacements = array ();
768
+    $patterns = array();
769
+    $replacements = array();
770 770
 
771 771
     $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU";
772 772
     $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text);
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 }
775 775
 function smart_sanitizeCustomtags_callback($matches) {
776 776
     global $smartobject_customtag_handler;
777
-    if (isset($smartobject_customtag_handler->objects[$matches[1]])){
777
+    if (isset($smartobject_customtag_handler->objects[$matches[1]])) {
778 778
         $customObj = $smartobject_customtag_handler->objects[$matches[1]];
779 779
         $ret = $customObj->renderWithPhp();
780 780
         return $ret;
@@ -783,8 +783,8 @@  discard block
 block discarded – undo
783 783
     }
784 784
 }
785 785
 function smart_sanitizeCustomtags($text) {
786
-    $patterns = array ();
787
-    $replacements = array ();
786
+    $patterns = array();
787
+    $replacements = array();
788 788
 
789 789
     $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU";
790 790
     $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text);
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
     $text = str_replace('\n', ' ', $text);
831 831
     $text = str_replace('&#8213;', ' ', $text);
832 832
 
833
-    if ($keyword){
833
+    if ($keyword) {
834 834
         $text = str_replace('.', ' ', $text);
835 835
         $text = str_replace(',', ' ', $text);
836 836
         $text = str_replace('\'', ' ', $text);
@@ -848,11 +848,11 @@  discard block
 block discarded – undo
848 848
     // and white space. It will also convert some
849 849
     // common HTML entities to their text equivalent.
850 850
     // Credits : newbb2
851
-    $search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript
852
-	"'<img.*?/>'si",       // Strip out img tags
853
-	"'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
854
-	"'([\r\n])[\s]+'",                // Strip out white space
855
-	"'&(quot|#34);'i",                // Replace HTML entities
851
+    $search = array("'<script[^>]*?>.*?</script>'si", // Strip out javascript
852
+	"'<img.*?/>'si", // Strip out img tags
853
+	"'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags
854
+	"'([\r\n])[\s]+'", // Strip out white space
855
+	"'&(quot|#34);'i", // Replace HTML entities
856 856
 	"'&(amp|#38);'i",
857 857
 	"'&(lt|#60);'i",
858 858
 	"'&(gt|#62);'i",
@@ -861,9 +861,9 @@  discard block
 block discarded – undo
861 861
 	"'&(cent|#162);'i",
862 862
 	"'&(pound|#163);'i",
863 863
 	"'&(copy|#169);'i",
864
-	"'&#(\d+);'e");                    // evaluate as php
864
+	"'&#(\d+);'e"); // evaluate as php
865 865
 
866
-    $replace = array ("",
866
+    $replace = array("",
867 867
 	"",
868 868
 	"",
869 869
 	"\\1",
@@ -888,35 +888,35 @@  discard block
 block discarded – undo
888 888
  * Use this snippet to extract any float out of a string. You can choose how a single dot is treated with the (bool) 'single_dot_as_decimal' directive.
889 889
  * This function should be able to cover almost all floats that appear in an european environment.
890 890
  */
891
-function smart_getfloat($str, $set=FALSE){
892
-    if(preg_match("/([0-9\.,-]+)/", $str, $match)) {
891
+function smart_getfloat($str, $set = FALSE) {
892
+    if (preg_match("/([0-9\.,-]+)/", $str, $match)) {
893 893
         // Found number in $str, so set $str that number
894 894
         $str = $match[0];
895
-        if(strstr($str, ',')){
895
+        if (strstr($str, ',')) {
896 896
             // A comma exists, that makes it easy, cos we assume it separates the decimal part.
897
-            $str = str_replace('.', '', $str);    // Erase thousand seps
898
-            $str = str_replace(',', '.', $str);    // Convert , to . for floatval command
897
+            $str = str_replace('.', '', $str); // Erase thousand seps
898
+            $str = str_replace(',', '.', $str); // Convert , to . for floatval command
899 899
             return floatval($str);
900
-        }else{
900
+        } else {
901 901
             // No comma exists, so we have to decide, how a single dot shall be treated
902
-            if(preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == TRUE && $set['single_dot_as_decimal'] == TRUE){
902
+            if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == TRUE && $set['single_dot_as_decimal'] == TRUE) {
903 903
                 // Treat single dot as decimal separator
904 904
 
905 905
                 return floatval($str);
906 906
             } else {//echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br/><br/> ";
907 907
                 // Else, treat all dots as thousand seps
908
-                $str = str_replace('.', '', $str);    // Erase thousand seps
908
+                $str = str_replace('.', '', $str); // Erase thousand seps
909 909
                 return floatval($str);
910 910
             }
911 911
         }
912
-    }else{
912
+    } else {
913 913
         // No number found, return zero
914 914
         return 0;
915 915
     }
916 916
 }
917 917
 
918
-function smart_currency($var, $currencyObj=false) {
919
-    $ret = smart_getfloat($var,  array('single_dot_as_decimal'=> TRUE));
918
+function smart_currency($var, $currencyObj = false) {
919
+    $ret = smart_getfloat($var, array('single_dot_as_decimal'=> TRUE));
920 920
     $ret = round($ret, 2);
921 921
     // make sur we have at least .00 in the $var
922 922
     $decimal_section_original = strstr($ret, '.');
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
     if ($decimal_section) {
925 925
         if (strlen($decimal_section) == 1) {
926 926
             $decimal_section = '.00';
927
-        } elseif(strlen($decimal_section) == 2) {
927
+        } elseif (strlen($decimal_section) == 2) {
928 928
             $decimal_section = $decimal_section . '0';
929 929
         }
930 930
         $ret = str_replace($decimal_section_original, $decimal_section, $ret);
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
     return smart_currency($var);
942 942
 }
943 943
 
944
-function smart_getModuleAdminLink($moduleName=false) {
944
+function smart_getModuleAdminLink($moduleName = false) {
945 945
     global $xoopsModule;
946 946
     if (!$moduleName && (isset ($xoopsModule) && is_object($xoopsModule))) {
947 947
         $moduleName = $xoopsModule->getVar('dirname');
948 948
     }
949 949
     $ret = '';
950 950
     if ($moduleName) {
951
-        $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" ._CO_SOBJECT_ADMIN_PAGE . "</a>";
951
+        $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . "</a>";
952 952
     }
953 953
     return $ret;
954 954
 }
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
     $xoopseditor_handler = XoopsEditorHandler::getInstance();
963 963
     $aList = $xoopseditor_handler->getList();
964 964
     $ret = array();
965
-    foreach($aList as $k=>$v) {
965
+    foreach ($aList as $k=>$v) {
966 966
         $ret[$v] = $k;
967 967
     }
968 968
     return $ret;
Please login to merge, or discard this patch.
include/adsense.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 function smart_adsense_initiate_smartytags() {
14 14
     global $xoopsTpl, $smartobject_adsense_handler;
15 15
     if (is_object($xoopsTpl)) {
16
-        foreach($smartobject_adsense_handler->objects as $k=>$v) {
16
+        foreach ($smartobject_adsense_handler->objects as $k=>$v) {
17 17
             $xoopsTpl->assign('adsense_' . $k, $v->render());
18 18
         }
19 19
     }
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php');
24 24
 }
25 25
 
26
-include_once XOOPS_ROOT_PATH."/modules/smartobject/include/functions.php";
26
+include_once XOOPS_ROOT_PATH . "/modules/smartobject/include/functions.php";
27 27
 include_once(SMARTOBJECT_ROOT_PATH . "class/adsense.php");
28 28
 
29 29
 $smartobject_adsense_handler = xoops_getModuleHandler('adsense', 'smartobject');
Please login to merge, or discard this patch.
include/currency.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     $smartobject_currenciesObj = $smartobject_currency_handler->getCurrencies();
23 23
 }
24 24
 if (!$smartobject_currenciesArray) {
25
-    foreach($smartobject_currenciesObj as $currencyid=>$currencyObj) {
25
+    foreach ($smartobject_currenciesObj as $currencyid=>$currencyObj) {
26 26
         if ($currencyObj->getVar('default_currency', 'e')) {
27 27
             $smartobject_default_currency = $currencyObj;
28 28
         }
Please login to merge, or discard this patch.
include/customtag.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 function smart_customtag_initiate() {
14 14
     global $xoopsTpl, $smartobject_customtag_handler;
15 15
     if (is_object($xoopsTpl)) {
16
-        foreach($smartobject_customtag_handler->objects as $k=>$v) {
16
+        foreach ($smartobject_customtag_handler->objects as $k=>$v) {
17 17
             $xoopsTpl->assign($k, $v->render());
18 18
         }
19 19
     }
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 smart_loadLanguageFile('smartobject', 'customtag');
27 27
 
28
-include_once XOOPS_ROOT_PATH."/modules/smartobject/include/functions.php";
28
+include_once XOOPS_ROOT_PATH . "/modules/smartobject/include/functions.php";
29 29
 include_once(SMARTOBJECT_ROOT_PATH . "class/customtag.php");
30 30
 
31 31
 $smartobject_customtag_handler = xoops_getModuleHandler('customtag', 'smartobject');
Please login to merge, or discard this patch.
include/xoops_core_common_functions.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 /* Debug functions to help developers :-)
15 15
  * Author : The SmartFactory
16 16
  */
17
-function xoops_debug_dumbQuery($msg='') {
17
+function xoops_debug_dumbQuery($msg = '') {
18 18
     global $xoopsDB;
19 19
     $xoopsDB->query('SELECT * ' . $msg . ' FROM dudewhereismycar2');
20 20
 }
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
     $smartfactory_query_count = 0;
27 27
 }
28 28
 
29
-function xoops_debug_getQueryCount($msg='')
29
+function xoops_debug_getQueryCount($msg = '')
30 30
 {
31 31
     global $smartfactory_query_count;
32 32
     return xoops_debug("xoops debug Query count ($msg): $smartfactory_query_count");
33 33
 }
34 34
 
35
-function xoops_debug($msg, $exit=false)
35
+function xoops_debug($msg, $exit = false)
36 36
 {
37 37
     echo "<div style='padding: 5px; color: red; font-weight: bold'>debug :: $msg</div>";
38 38
     if ($exit) {
Please login to merge, or discard this patch.
include/captcha/captcha.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 class XoopsCaptcha {
15 15
     var $active	= true;
16
-    var $mode 	= "text";	// potential values: image, text
16
+    var $mode = "text"; // potential values: image, text
17 17
     var $config	= array();
18 18
 
19 19
     var $message = array(); // Logging error messages
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     function XoopsCaptcha()
22 22
     {
23 23
         // Loading default preferences
24
-        $this->config = @include dirname(__FILE__)."/config.php";
24
+        $this->config = @include dirname(__FILE__) . "/config.php";
25 25
 
26 26
         $this->setMode($this->config["mode"]);
27 27
     }
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     function &instance()
30 30
     {
31 31
         static $instance;
32
-        if(!isset($instance)) {
32
+        if (!isset($instance)) {
33 33
             $instance = new XoopsCaptcha();
34 34
         }
35 35
         return $instance;
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 
38 38
     function setConfig($name, $val)
39 39
     {
40
-        if($name == "mode") {
40
+        if ($name == "mode") {
41 41
             $this->setMode($val);
42
-        }elseif(isset($this->$name)) {
42
+        }elseif (isset($this->$name)) {
43 43
             $this->$name = $val;
44
-        }else {
44
+        } else {
45 45
             $this->config[$name] = $val;
46 46
         }
47 47
         return true;
@@ -56,21 +56,21 @@  discard block
 block discarded – undo
56 56
      */
57 57
     function setMode($mode = null)
58 58
     {
59
-        if( !empty($mode) && in_array($mode, array("text", "image")) ) {
59
+        if (!empty($mode) && in_array($mode, array("text", "image"))) {
60 60
             $this->mode = $mode;
61 61
 
62
-            if($this->mode != "image") {
62
+            if ($this->mode != "image") {
63 63
                 return;
64 64
             }
65 65
         }
66 66
 
67 67
         // Disable image mode
68
-        if(!extension_loaded('gd')) {
68
+        if (!extension_loaded('gd')) {
69 69
             $this->mode = "text";
70
-        }else{
70
+        } else {
71 71
             $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox");
72
-            foreach($required_functions as $func) {
73
-                if(!function_exists($func)) {
72
+            foreach ($required_functions as $func) {
73
+                if (!function_exists($func)) {
74 74
                     $this->mode = "text";
75 75
                     break;
76 76
                 }
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
     function init($name = 'xoopscaptcha', $skipmember = null, $num_chars = null, $fontsize_min = null, $fontsize_max = null, $background_type = null, $background_num = null)
86 86
     {
87 87
         // Loading RUN-TIME settings
88
-        foreach(array_keys($this->config) as $key) {
89
-            if(isset(${$key}) && ${$key} !== null) {
88
+        foreach (array_keys($this->config) as $key) {
89
+            if (isset(${$key}) && ${$key} !== null) {
90 90
                 $this->config[$key] = ${$key};
91 91
             }
92 92
         }
93 93
         $this->config["name"] = $name;
94 94
 
95 95
         // Skip CAPTCHA for member if set
96
-        if($this->config["skipmember"] && is_object($GLOBALS["xoopsUser"])) {
96
+        if ($this->config["skipmember"] && is_object($GLOBALS["xoopsUser"])) {
97 97
             $this->active = false;
98 98
         }
99 99
     }
@@ -105,34 +105,34 @@  discard block
 block discarded – undo
105 105
     {
106 106
         $sessionName	= @$_SESSION['XoopsCaptcha_name'];
107 107
         $skipMember		= ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember;
108
-        $maxAttempts	= intval( @$_SESSION['XoopsCaptcha_maxattempts'] );
108
+        $maxAttempts	= intval(@$_SESSION['XoopsCaptcha_maxattempts']);
109 109
 
110 110
         $is_valid = false;
111 111
 
112 112
         // Skip CAPTCHA for member if set
113
-        if( is_object($GLOBALS["xoopsUser"]) && !empty($skipMember) ) {
113
+        if (is_object($GLOBALS["xoopsUser"]) && !empty($skipMember)) {
114 114
             $is_valid = true;
115 115
             // Kill too many attempts
116
-        }elseif(!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_'.$sessionName] > $maxAttempts) {
116
+        }elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) {
117 117
             $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
118 118
 
119 119
             // Verify the code
120
-        }elseif(!empty($_SESSION['XoopsCaptcha_sessioncode'])){
120
+        }elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) {
121 121
             $func = ($this->config["casesensitive"]) ? "strcmp" : "strcasecmp";
122
-            $is_valid = ! $func( trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']);
122
+            $is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']);
123 123
         }
124 124
 
125
-        if(!empty($maxAttempts)) {
126
-            if(!$is_valid) {
125
+        if (!empty($maxAttempts)) {
126
+            if (!$is_valid) {
127 127
                 // Increase the attempt records on failure
128
-                $_SESSION['XoopsCaptcha_attempt_'.$sessionName]++;
128
+                $_SESSION['XoopsCaptcha_attempt_' . $sessionName]++;
129 129
                 // Log the error message
130 130
                 $this->message[] = XOOPS_CAPTCHA_INVALID_CODE;
131 131
 
132
-            }else{
132
+            } else {
133 133
 
134 134
                 // reset attempt records on success
135
-                $_SESSION['XoopsCaptcha_attempt_'.$sessionName] = null;
135
+                $_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null;
136 136
             }
137 137
         }
138 138
         $this->destroyGarbage(true);
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
      */
156 156
     function destroyGarbage($clearSession = false)
157 157
     {
158
-        require_once dirname(__FILE__)."/".$this->mode.".php";
159
-        $class = "XoopsCaptcha".ucfirst($this->mode);
158
+        require_once dirname(__FILE__) . "/" . $this->mode . ".php";
159
+        $class = "XoopsCaptcha" . ucfirst($this->mode);
160 160
         $captcha_handler = new $class();
161
-        if(method_exists($captcha_handler, "destroyGarbage")) {
161
+        if (method_exists($captcha_handler, "destroyGarbage")) {
162 162
             $captcha_handler->loadConfig($this->config);
163 163
             $captcha_handler->destroyGarbage();
164 164
         }
165 165
 
166
-        if($clearSession) {
166
+        if ($clearSession) {
167 167
             $_SESSION['XoopsCaptcha_name'] = null;
168 168
             $_SESSION['XoopsCaptcha_skipmember'] = null;
169 169
             $_SESSION['XoopsCaptcha_sessioncode'] = null;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     {
178 178
         $form = "";
179 179
 
180
-        if( !$this->active || empty($this->config["name"]) ) {
180
+        if (!$this->active || empty($this->config["name"])) {
181 181
             return $form;
182 182
         }
183 183
 
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
          */
193 193
 
194 194
         // Fail on too many attempts
195
-        if(!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_'.$this->config["name"]] > $maxAttempts) {
195
+        if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config["name"]] > $maxAttempts) {
196 196
             $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
197 197
             // Load the form element
198
-        }else{
198
+        } else {
199 199
             $form = $this->loadForm();
200 200
         }
201 201
 
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 
205 205
     function loadForm()
206 206
     {
207
-        require_once dirname(__FILE__)."/".$this->mode.".php";
208
-        $class = "XoopsCaptcha".ucfirst($this->mode);
207
+        require_once dirname(__FILE__) . "/" . $this->mode . ".php";
208
+        $class = "XoopsCaptcha" . ucfirst($this->mode);
209 209
         $captcha_handler = new $class();
210 210
         $captcha_handler->loadConfig($this->config);
211 211
 
Please login to merge, or discard this patch.
include/captcha/image.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 
8 8
 class XoopsCaptchaImage {
9
-    var $config	= array();
9
+    var $config = array();
10 10
 
11 11
     function XoopsCaptchaImage()
12 12
     {
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     function &instance()
17 17
     {
18 18
         static $instance;
19
-        if(!isset($instance)) {
19
+        if (!isset($instance)) {
20 20
             $instance = new XoopsCaptchaImage();
21 21
         }
22 22
         return $instance;
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
     function loadConfig($config = array())
29 29
     {
30 30
         // Loading default preferences
31
-        $this->config =& $config;
31
+        $this->config = & $config;
32 32
     }
33 33
 
34 34
     function render()
35 35
     {
36
-        $form = "<input type='text' name='".$this->config["name"]."' id='".$this->config["name"]."' size='" . $this->config["num_chars"] . "' maxlength='" . $this->config["num_chars"] . "' value='' /> &nbsp; ". $this->loadImage();
36
+        $form = "<input type='text' name='" . $this->config["name"] . "' id='" . $this->config["name"] . "' size='" . $this->config["num_chars"] . "' maxlength='" . $this->config["num_chars"] . "' value='' /> &nbsp; " . $this->loadImage();
37 37
         $rule = htmlspecialchars(XOOPS_CAPTCHA_REFRESH, ENT_QUOTES);
38
-        if($this->config["maxattempt"]) {
39
-            $rule .=  " | ". sprintf( constant("XOOPS_CAPTCHA_MAXATTEMPTS"), $this->config["maxattempt"] );
38
+        if ($this->config["maxattempt"]) {
39
+            $rule .= " | " . sprintf(constant("XOOPS_CAPTCHA_MAXATTEMPTS"), $this->config["maxattempt"]);
40 40
         }
41 41
         $form .= "&nbsp;&nbsp;<small>{$rule}</small>";
42 42
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     function loadImage()
48 48
     {
49 49
         $rule = $this->config["casesensitive"] ? constant("XOOPS_CAPTCHA_RULE_CASESENSITIVE") : constant("XOOPS_CAPTCHA_RULE_CASEINSENSITIVE");
50
-        $ret = "<img id='captcha' src='" . XOOPS_URL. "/". $this->config["imageurl"]. "' onclick=\"this.src='" . XOOPS_URL. "/". $this->config["imageurl"]. "?refresh='+Math.random()"."\" align='absmiddle'  style='cursor: pointer;' alt='".htmlspecialchars($rule, ENT_QUOTES)."' />";
50
+        $ret = "<img id='captcha' src='" . XOOPS_URL . "/" . $this->config["imageurl"] . "' onclick=\"this.src='" . XOOPS_URL . "/" . $this->config["imageurl"] . "?refresh='+Math.random()" . "\" align='absmiddle'  style='cursor: pointer;' alt='" . htmlspecialchars($rule, ENT_QUOTES) . "' />";
51 51
 
52 52
         return $ret;
53 53
     }
Please login to merge, or discard this patch.
include/captcha/scripts/img.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 error_reporting(0);
10 10
 $xoopsLogger->activated = false;
11 11
 
12
-if(empty($_SERVER['HTTP_REFERER']) || !preg_match("/^".preg_quote(XOOPS_URL, '/')."/", $_SERVER['HTTP_REFERER'])) {
12
+if (empty($_SERVER['HTTP_REFERER']) || !preg_match("/^" . preg_quote(XOOPS_URL, '/') . "/", $_SERVER['HTTP_REFERER'])) {
13 13
     exit();
14 14
 }
15 15
 
16 16
 class XoopsCaptchaImageHandler {
17
-    var $config	= array();
17
+    var $config = array();
18 18
     //var $mode = "gd"; // GD or bmp
19 19
     var $code;
20 20
     var $invalid = false;
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
 
27 27
     function XoopsCaptchaImageHandler()
28 28
     {
29
-        if(empty($_SESSION['XoopsCaptcha_name'])) {
29
+        if (empty($_SESSION['XoopsCaptcha_name'])) {
30 30
             $this->invalid = true;
31 31
         }
32 32
 
33
-        if(!extension_loaded('gd')) {
33
+        if (!extension_loaded('gd')) {
34 34
             $this->mode = "bmp";
35
-        }else{
35
+        } else {
36 36
             $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox");
37
-            foreach($required_functions as $func) {
38
-                if(!function_exists($func)) {
37
+            foreach ($required_functions as $func) {
38
+                if (!function_exists($func)) {
39 39
                     $this->mode = "bmp";
40 40
                     break;
41 41
                 }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     function setConfig($config = array())
50 50
     {
51 51
         // Loading default preferences
52
-        $this->config =& $config;
52
+        $this->config = & $config;
53 53
     }
54 54
 
55 55
     function loadImage()
@@ -64,34 +64,34 @@  discard block
 block discarded – undo
64 64
      */
65 65
     function createCode()
66 66
     {
67
-        if($this->invalid) {
67
+        if ($this->invalid) {
68 68
             return;
69 69
         }
70 70
 
71
-        if($this->mode == "bmp") {
71
+        if ($this->mode == "bmp") {
72 72
             $this->config["num_chars"] = 4;
73
-            $this->code = rand( pow(10, $this->config["num_chars"] - 1), intval( str_pad("9", $this->config["num_chars"], "9") ) );
74
-        }else{
75
-            $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config["num_chars"] );
73
+            $this->code = rand(pow(10, $this->config["num_chars"] - 1), intval(str_pad("9", $this->config["num_chars"], "9")));
74
+        } else {
75
+            $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config["num_chars"]);
76 76
             if (!$this->config["casesensitive"]) {
77
-                $this->code = strtoupper( $this->code );
77
+                $this->code = strtoupper($this->code);
78 78
             }
79 79
         }
80 80
     }
81 81
 
82 82
     function setCode()
83 83
     {
84
-        if($this->invalid) {
84
+        if ($this->invalid) {
85 85
             return;
86 86
         }
87 87
 
88
-        $_SESSION['XoopsCaptcha_sessioncode'] = strval( $this->code );
89
-        $maxAttempts = intval( @$_SESSION['XoopsCaptcha_maxattempts'] );
88
+        $_SESSION['XoopsCaptcha_sessioncode'] = strval($this->code);
89
+        $maxAttempts = intval(@$_SESSION['XoopsCaptcha_maxattempts']);
90 90
 
91 91
         // Increase the attempt records on refresh
92
-        if(!empty($maxAttempts)) {
93
-            $_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']]++;
94
-            if($_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']] > $maxAttempts) {
92
+        if (!empty($maxAttempts)) {
93
+            $_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++;
94
+            if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) {
95 95
                 $this->invalid = true;
96 96
             }
97 97
         }
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 
100 100
     function createImage($file = "")
101 101
     {
102
-        if($this->invalid) {
102
+        if ($this->invalid) {
103 103
             header("Content-type: image/gif");
104
-            readfile(XOOPS_ROOT_PATH."/images/subject/icon2.gif");
104
+            readfile(XOOPS_ROOT_PATH . "/images/subject/icon2.gif");
105 105
             return;
106 106
         }
107 107
 
108
-        if($this->mode == "bmp") {
108
+        if ($this->mode == "bmp") {
109 109
             return $this->createImageBmp();
110
-        }else{
110
+        } else {
111 111
             return $this->createImageGd();
112 112
         }
113 113
     }
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
         $this->drawBorder();
166 166
         $this->drawCode();
167 167
 
168
-        if(empty($file)) {
168
+        if (empty($file)) {
169 169
             header("Content-type: image/jpeg");
170
-            imagejpeg ($this->oImage);
171
-        }else{
172
-            imagejpeg ($this->oImage, XOOPS_ROOT_PATH. "/". $this->config["imagepath"]. "/". $file . ".jpg");
170
+            imagejpeg($this->oImage);
171
+        } else {
172
+            imagejpeg($this->oImage, XOOPS_ROOT_PATH . "/" . $this->config["imagepath"] . "/" . $file . ".jpg");
173 173
         }
174 174
         imagedestroy($this->oImage);
175 175
     }
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
          }
186 186
          }
187 187
          */
188
-        require_once XOOPS_ROOT_PATH."/class/xoopslists.php";
189
-        $file_path = $this->config["rootpath"]."/{$name}";
188
+        require_once XOOPS_ROOT_PATH . "/class/xoopslists.php";
189
+        $file_path = $this->config["rootpath"] . "/{$name}";
190 190
         $files = XoopsLists::getFileListAsArray($file_path);
191
-        foreach( $files as $item) {
192
-            if ( empty($extension) || preg_match("/(\.{$extension})$/i",$item) ) {
191
+        foreach ($files as $item) {
192
+            if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) {
193 193
                 $items[] = $item;
194 194
             }
195 195
         }
196
-        if(function_exists("mod_createCacheFile")) {
196
+        if (function_exists("mod_createCacheFile")) {
197 197
             mod_createCacheFile($items, "captcha_{$name}", "captcha");
198 198
         }
199 199
         return $items;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     function loadFont()
203 203
     {
204 204
         $fonts = $this->_getList("fonts", "ttf");
205
-        $this->font = $this->config["rootpath"]."/fonts/".$fonts[array_rand($fonts)];
205
+        $this->font = $this->config["rootpath"] . "/fonts/" . $fonts[array_rand($fonts)];
206 206
     }
207 207
 
208 208
     function setImageSize()
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
         for ($Angle = -30; $Angle <= 30; $Angle++) {
216 216
             for ($i = 65; $i <= 90; $i++) {
217 217
                 $CharDetails = imageftbbox($FontSize, $Angle, $this->font, chr($i), array());
218
-                $_MaxCharWidth  = abs($CharDetails[0] + $CharDetails[2]);
219
-                if ($_MaxCharWidth > $MaxCharWidth ) {
218
+                $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]);
219
+                if ($_MaxCharWidth > $MaxCharWidth) {
220 220
                     $MaxCharWidth = $_MaxCharWidth;
221 221
                 }
222
-                $_MaxCharHeight  = abs($CharDetails[1] + $CharDetails[5]);
223
-                if ($_MaxCharHeight > $MaxCharHeight ) {
222
+                $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]);
223
+                if ($_MaxCharHeight > $MaxCharHeight) {
224 224
                     $MaxCharHeight = $_MaxCharHeight;
225 225
                 }
226 226
             }
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
         imagedestroy($oImage);
229 229
 
230 230
         $this->height = $MaxCharHeight + 2;
231
-        $this->spacing = (int)( ($this->config["num_chars"] * $MaxCharWidth) / $this->config["num_chars"]);
232
-        $this->width = ($this->config["num_chars"] * $MaxCharWidth) + ($this->spacing/2);
231
+        $this->spacing = (int) (($this->config["num_chars"] * $MaxCharWidth) / $this->config["num_chars"]);
232
+        $this->width = ($this->config["num_chars"] * $MaxCharWidth) + ($this->spacing / 2);
233 233
     }
234 234
 
235 235
     /**
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
     function loadBackground()
241 241
     {
242 242
         $RandBackground = null;
243
-        if( $backgrounds = $this->_getList("backgrounds", "(gif|jpg|png)") ) {
244
-            $RandBackground = $this->config["rootpath"]."/backgrounds/".$backgrounds[array_rand($backgrounds)];
243
+        if ($backgrounds = $this->_getList("backgrounds", "(gif|jpg|png)")) {
244
+            $RandBackground = $this->config["rootpath"] . "/backgrounds/" . $backgrounds[array_rand($backgrounds)];
245 245
         }
246 246
         return $RandBackground;
247 247
     }
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
      */
252 252
     function createFromFile()
253 253
     {
254
-        if ( $RandImage = $this->loadBackground() ) {
254
+        if ($RandImage = $this->loadBackground()) {
255 255
             $ImageType = @getimagesize($RandImage);
256
-            switch ( @$ImageType[2] ) {
256
+            switch (@$ImageType[2]) {
257 257
                 case 1:
258 258
                     $BackgroundImage = imagecreatefromgif($RandImage);
259 259
                     break;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                     break;
268 268
             }
269 269
         }
270
-        if(!empty($BackgroundImage)){
270
+        if (!empty($BackgroundImage)) {
271 271
             imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage));
272 272
             imagedestroy($BackgroundImage);
273 273
         } else {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      */
281 281
     function drawCode()
282 282
     {
283
-        for ($i = 0; $i < $this->config["num_chars"] ; $i++) {
283
+        for ($i = 0; $i < $this->config["num_chars"]; $i++) {
284 284
             // select random greyscale colour
285 285
             $text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
286 286
 
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
             $FontSize = mt_rand($this->config["fontsize_min"], $this->config["fontsize_max"]);
295 295
 
296 296
             $CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], array());
297
-            $CharHeight = abs( $CharDetails[1] + $CharDetails[5] );
297
+            $CharHeight = abs($CharDetails[1] + $CharDetails[5]);
298 298
 
299 299
             // calculate character starting coordinates
300
-            $posX = ($this->spacing/2) + ($i * $this->spacing);
300
+            $posX = ($this->spacing / 2) + ($i * $this->spacing);
301 301
             $posY = 2 + ($this->height / 2) + ($CharHeight / 4);
302 302
 
303 303
             imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], array());
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
     function drawBorder()
311 311
     {
312 312
         $rgb = rand(50, 150);
313
-        $border_color = imagecolorallocate ($this->oImage, $rgb, $rgb, $rgb);
314
-        imagerectangle($this->oImage, 0, 0, $this->width-1, $this->height-1, $border_color);
313
+        $border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb);
314
+        imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color);
315 315
     }
316 316
 
317 317
     /**
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
      */
320 320
     function drawCircles()
321 321
     {
322
-        for($i = 1; $i <= $this->config["background_num"]; $i++){
323
-            $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255));
324
-            imagefilledellipse($this->oImage, mt_rand(0,$this->width-10), mt_rand(0,$this->height-3), mt_rand(10,20), mt_rand(20,30),$randomcolor);
322
+        for ($i = 1; $i <= $this->config["background_num"]; $i++) {
323
+            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
324
+            imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor);
325 325
         }
326 326
     }
327 327
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
     function drawLines()
332 332
     {
333 333
         for ($i = 0; $i < $this->config["background_num"]; $i++) {
334
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190,255), mt_rand(190,255), mt_rand(190,255));
334
+            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
335 335
             imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
336 336
         }
337 337
     }
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
     function drawRectangles()
343 343
     {
344 344
         for ($i = 1; $i <= $this->config["background_num"]; $i++) {
345
-            $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255));
346
-            imagefilledrectangle($this->oImage, mt_rand(0,$this->width), mt_rand(0,$this->height), mt_rand(0, $this->width), mt_rand(0,$this->height),  $randomcolor);
345
+            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
346
+            imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
347 347
         }
348 348
     }
349 349
 
@@ -352,14 +352,14 @@  discard block
 block discarded – undo
352 352
      */
353 353
     function drawBars()
354 354
     {
355
-        for ($i= 0 ; $i <= $this->height;) {
356
-            $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255));
357
-            imageline( $this->oImage, 0, $i, $this->width, $i, $randomcolor );
355
+        for ($i = 0; $i <= $this->height;) {
356
+            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
357
+            imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor);
358 358
             $i = $i + 2.5;
359 359
         }
360
-        for ($i = 0;$i <= $this->width;) {
361
-            $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255));
362
-            imageline( $this->oImage, $i, 0, $i, $this->height, $randomcolor );
360
+        for ($i = 0; $i <= $this->width;) {
361
+            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
362
+            imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor);
363 363
             $i = $i + 2.5;
364 364
         }
365 365
     }
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
      */
370 370
     function drawEllipses()
371 371
     {
372
-        for($i = 1; $i <= $this->config["background_num"]; $i++){
373
-            $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255));
374
-            imageellipse($this->oImage, mt_rand(0,$this->width), mt_rand(0,$this->height), mt_rand(0,$this->width), mt_rand(0,$this->height), $randomcolor);
372
+        for ($i = 1; $i <= $this->config["background_num"]; $i++) {
373
+            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
374
+            imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
375 375
         }
376 376
     }
377 377
 
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
      */
381 381
     function drawPolygons()
382 382
     {
383
-        for($i = 1; $i <= $this->config["background_num"]; $i++){
384
-            $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255));
383
+        for ($i = 1; $i <= $this->config["background_num"]; $i++) {
384
+            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
385 385
             $coords = array();
386
-            for ($j=1; $j <= $this->config["polygon_point"]; $j++) {
387
-                $coords[] = mt_rand(0,$this->width);
388
-                $coords[] = mt_rand(0,$this->height);
386
+            for ($j = 1; $j <= $this->config["polygon_point"]; $j++) {
387
+                $coords[] = mt_rand(0, $this->width);
388
+                $coords[] = mt_rand(0, $this->height);
389 389
             }
390 390
             imagefilledpolygon($this->oImage, $coords, $this->config["polygon_point"], $randomcolor);
391 391
         }
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
     {
400 400
         $image = "";
401 401
 
402
-        if(empty($file)) {
402
+        if (empty($file)) {
403 403
             header("Content-type: image/bmp");
404 404
             echo $image;
405
-        }else{
405
+        } else {
406 406
             return $image;
407 407
         }
408 408
     }
Please login to merge, or discard this patch.
include/captcha/formcaptcha.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	die("XOOPS root path not defined");
16 16
 }
17 17
 
18
-require_once XOOPS_ROOT_PATH."/class/xoopsform/formelement.php";
18
+require_once XOOPS_ROOT_PATH . "/class/xoopsform/formelement.php";
19 19
 
20 20
 /*
21 21
  * Usage
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 */
53 53
 	function XoopsFormCaptcha($caption = '', $name = 'xoopscaptcha', $skipmember = null, $numchar = null, $minfontsize = null, $maxfontsize = null, $backgroundtype = null, $backgroundnum = null) {
54
-		if(!class_exists("XoopsCaptcaha")) {
55
-			require_once SMARTOBJECT_ROOT_PATH."/include/captcha/captcha.php";
54
+		if (!class_exists("XoopsCaptcaha")) {
55
+			require_once SMARTOBJECT_ROOT_PATH . "/include/captcha/captcha.php";
56 56
 		}
57 57
 
58
-		$this->_captchaHandler =& XoopsCaptcha::instance();
58
+		$this->_captchaHandler = & XoopsCaptcha::instance();
59 59
 		$this->_captchaHandler->init($name, $skipmember, $numchar, $minfontsize, $maxfontsize, $backgroundtype, $backgroundnum);
60
-		if(!$this->_captchaHandler->active) {
60
+		if (!$this->_captchaHandler->active) {
61 61
 			$this->setHidden();
62
-		}else{
62
+		} else {
63 63
 			$caption = !empty($caption) ? $caption : $this->_captchaHandler->getCaption();
64 64
 			$this->setCaption($caption);
65 65
 		}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 	function render()
74 74
 	{
75
-		if(!$this->isHidden()) {
75
+		if (!$this->isHidden()) {
76 76
 			return $this->_captchaHandler->render();
77 77
 		}
78 78
 	}
Please login to merge, or discard this patch.