Completed
Pull Request — develop (#518)
by Agel_Nash
06:14
created
manager/includes/veriword.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 $modx->db->connect();
8 8
 $modx->getSettings();
9 9
 
10
-$vword = new VeriWord(148,60);
10
+$vword = new VeriWord(148, 60);
11 11
 $vword->output_image();
12 12
 $vword->destroy_image();
13 13
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 ## see sample.php for test and usage
44 44
 ## sample URL: http://www.program-ruti.org/veriword/
45 45
 ####
46
-class VeriWord {
46
+class VeriWord{
47 47
 
48 48
     /* path to font directory*/
49 49
     var $dir_font   = "ttf/";
@@ -53,45 +53,45 @@  discard block
 block discarded – undo
53 53
     var $im_width   = 0;
54 54
     var $im_height  = 0;
55 55
 
56
-    function __construct($w=200, $h=80) {
56
+    function __construct($w = 200, $h = 80){
57 57
         /* create session to set word for verification */
58 58
         startCMSSession();
59 59
         $this->set_veriword();
60
-        $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font;
60
+        $this->dir_font = dirname(__FILE__).'/'.$this->dir_font;
61 61
         $this->im_width         = $w;
62 62
         $this->im_height        = $h;
63 63
     }
64 64
 
65
-    function set_veriword() {
65
+    function set_veriword(){
66 66
         /* create session variable for verification,
67 67
            you may change the session variable name */
68 68
         $this->word             = $this->pick_word();
69 69
         $_SESSION['veriword']   = $this->word;
70 70
     }
71 71
 
72
-    function output_image() {
72
+    function output_image(){
73 73
         /* output the image as jpeg */
74 74
         $this->draw_image();
75 75
         header("Content-type: image/jpeg");
76 76
         imagejpeg($this->im);
77 77
     }
78 78
 
79
-    function pick_word() {
79
+    function pick_word(){
80 80
         global $modx;
81 81
         // set default words
82
-        $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
82
+        $words = "MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
83 83
         $words = $modx->config['captcha_words'] ? $modx->config['captcha_words'] : $words;
84 84
         $arr_words = array_filter(array_map('trim', explode(',', $words)));
85 85
 
86 86
         /* pick one randomly for text verification */
87
-        return (string) $arr_words[array_rand($arr_words)].rand(10,999);
87
+        return (string) $arr_words[array_rand($arr_words)].rand(10, 999);
88 88
     }
89 89
 
90
-    function draw_text() {
90
+    function draw_text(){
91 91
         $dir = dir($this->dir_font);
92 92
         $fontstmp = array();
93 93
         while (false !== ($file = $dir->read())) {
94
-            if(substr($file, -4) == '.ttf') {
94
+            if (substr($file, -4) == '.ttf') {
95 95
                 $fontstmp[] = $this->dir_font.$file;
96 96
             }
97 97
         }
@@ -99,35 +99,35 @@  discard block
 block discarded – undo
99 99
         $text_font = (string) $fontstmp[array_rand($fontstmp)];
100 100
 
101 101
         /* angle for text inclination */
102
-        $text_angle = rand(-9,9);
102
+        $text_angle = rand(-9, 9);
103 103
         /* initial text size */
104 104
         $text_size  = 30;
105 105
         /* calculate text width and height */
106
-        $box        = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word);
107
-        $text_width = $box[2]-$box[0]; //text width
108
-        $text_height= $box[5]-$box[3]; //text height
106
+        $box        = imagettfbbox($text_size, $text_angle, $text_font, $this->word);
107
+        $text_width = $box[2] - $box[0]; //text width
108
+        $text_height = $box[5] - $box[3]; //text height
109 109
 
110 110
         /* adjust text size */
111
-        $text_size  = round((20 * $this->im_width)/$text_width);
111
+        $text_size  = round((20 * $this->im_width) / $text_width);
112 112
 
113 113
         /* recalculate text width and height */
114
-        $box        = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word);
115
-        $text_width = $box[2]-$box[0]; //text width
116
-        $text_height= $box[5]-$box[3]; //text height
114
+        $box        = imagettfbbox($text_size, $text_angle, $text_font, $this->word);
115
+        $text_width = $box[2] - $box[0]; //text width
116
+        $text_height = $box[5] - $box[3]; //text height
117 117
 
118 118
         /* calculate center position of text */
119
-        $text_x         = ($this->im_width - $text_width)/2;
120
-        $text_y         = ($this->im_height - $text_height)/2;
119
+        $text_x         = ($this->im_width - $text_width) / 2;
120
+        $text_y         = ($this->im_height - $text_height) / 2;
121 121
 
122 122
         /* create canvas for text drawing */
123
-        $im_text        = imagecreate ($this->im_width, $this->im_height);
124
-        $bg_color       = imagecolorallocate ($im_text, 255, 255, 255);
123
+        $im_text        = imagecreate($this->im_width, $this->im_height);
124
+        $bg_color       = imagecolorallocate($im_text, 255, 255, 255);
125 125
 
126 126
         /* pick color for text */
127
-        $text_color     = imagecolorallocate ($im_text, 0, 51, 153);
127
+        $text_color     = imagecolorallocate($im_text, 0, 51, 153);
128 128
 
129 129
         /* draw text into canvas */
130
-        imagettftext    (   $im_text,
130
+        imagettftext($im_text,
131 131
                             $text_size,
132 132
                             $text_angle,
133 133
                             $text_x,
@@ -143,19 +143,19 @@  discard block
 block discarded – undo
143 143
     }
144 144
 
145 145
 
146
-    function draw_image() {
146
+    function draw_image(){
147 147
 
148 148
         /* pick one background image randomly from image directory */
149
-        $img_file       = $this->dir_noise."noise".rand(1,4).".jpg";
149
+        $img_file       = $this->dir_noise."noise".rand(1, 4).".jpg";
150 150
 
151 151
         /* create "noise" background image from your image stock*/
152
-        $noise_img      = @imagecreatefromjpeg ($img_file);
152
+        $noise_img      = @imagecreatefromjpeg($img_file);
153 153
         $noise_width    = imagesx($noise_img);
154 154
         $noise_height   = imagesy($noise_img);
155 155
 
156 156
         /* resize the background image to fit the size of image output */
157
-        $this->im       = imagecreatetruecolor($this->im_width,$this->im_height);
158
-        imagecopyresampled ($this->im,
157
+        $this->im       = imagecreatetruecolor($this->im_width, $this->im_height);
158
+        imagecopyresampled($this->im,
159 159
                             $noise_img,
160 160
                             0, 0, 0, 0,
161 161
                             $this->im_width,
@@ -164,17 +164,17 @@  discard block
 block discarded – undo
164 164
                             $noise_height);
165 165
 
166 166
         /* put text image into background image */
167
-        imagecopymerge (    $this->im,
167
+        imagecopymerge($this->im,
168 168
                             $this->draw_text(),
169 169
                             0, 0, 0, 0,
170 170
                             $this->im_width,
171 171
                             $this->im_height,
172
-                            70 );
172
+                            70);
173 173
 
174 174
         return $this->im;
175 175
     }
176 176
 
177
-    function destroy_image() {
177
+    function destroy_image(){
178 178
 
179 179
         imagedestroy($this->im);
180 180
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
43 43
 ## see sample.php for test and usage
44 44
 ## sample URL: http://www.program-ruti.org/veriword/
45 45
 ####
46
-class VeriWord {
46
+class VeriWord
47
+{
47 48
 
48 49
     /* path to font directory*/
49 50
     var $dir_font   = "ttf/";
@@ -53,7 +54,8 @@  discard block
 block discarded – undo
53 54
     var $im_width   = 0;
54 55
     var $im_height  = 0;
55 56
 
56
-    function __construct($w=200, $h=80) {
57
+    function __construct($w=200, $h=80)
58
+    {
57 59
         /* create session to set word for verification */
58 60
         startCMSSession();
59 61
         $this->set_veriword();
@@ -62,21 +64,24 @@  discard block
 block discarded – undo
62 64
         $this->im_height        = $h;
63 65
     }
64 66
 
65
-    function set_veriword() {
67
+    function set_veriword()
68
+    {
66 69
         /* create session variable for verification,
67 70
            you may change the session variable name */
68 71
         $this->word             = $this->pick_word();
69 72
         $_SESSION['veriword']   = $this->word;
70 73
     }
71 74
 
72
-    function output_image() {
75
+    function output_image()
76
+    {
73 77
         /* output the image as jpeg */
74 78
         $this->draw_image();
75 79
         header("Content-type: image/jpeg");
76 80
         imagejpeg($this->im);
77 81
     }
78 82
 
79
-    function pick_word() {
83
+    function pick_word()
84
+    {
80 85
         global $modx;
81 86
         // set default words
82 87
         $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
@@ -87,7 +92,8 @@  discard block
 block discarded – undo
87 92
         return (string) $arr_words[array_rand($arr_words)].rand(10,999);
88 93
     }
89 94
 
90
-    function draw_text() {
95
+    function draw_text()
96
+    {
91 97
         $dir = dir($this->dir_font);
92 98
         $fontstmp = array();
93 99
         while (false !== ($file = $dir->read())) {
@@ -143,7 +149,8 @@  discard block
 block discarded – undo
143 149
     }
144 150
 
145 151
 
146
-    function draw_image() {
152
+    function draw_image()
153
+    {
147 154
 
148 155
         /* pick one background image randomly from image directory */
149 156
         $img_file       = $this->dir_noise."noise".rand(1,4).".jpg";
@@ -174,7 +181,8 @@  discard block
 block discarded – undo
174 181
         return $this->im;
175 182
     }
176 183
 
177
-    function destroy_image() {
184
+    function destroy_image()
185
+    {
178 186
 
179 187
         imagedestroy($this->im);
180 188
 
Please login to merge, or discard this patch.
install/lang.php 3 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -16,35 +16,35 @@  discard block
 block discarded – undo
16 16
 $install_language = "english";
17 17
 
18 18
 $_langFiles= array (
19
- "en" => "english",
20
- "bg" => "bulgarian",
21
- "cs" => "czech",
22
- "da" => "danish",
23
- "fi" => "finnish-utf8",
24
- "fr" => "francais-utf8",
25
- "de" => "german",
26
- "he" => "hebrew",
27
- "it" => "italian",
28
- "ja" => "japanese-utf8",
29
- "nl" => "nederlands-utf8",
30
- "no" => "norwegian",
31
- "fa" => "persian",
32
- "pl" => "polish-utf8",
33
- "pt" => "portuguese-br-utf8",
19
+    "en" => "english",
20
+    "bg" => "bulgarian",
21
+    "cs" => "czech",
22
+    "da" => "danish",
23
+    "fi" => "finnish-utf8",
24
+    "fr" => "francais-utf8",
25
+    "de" => "german",
26
+    "he" => "hebrew",
27
+    "it" => "italian",
28
+    "ja" => "japanese-utf8",
29
+    "nl" => "nederlands-utf8",
30
+    "no" => "norwegian",
31
+    "fa" => "persian",
32
+    "pl" => "polish-utf8",
33
+    "pt" => "portuguese-br-utf8",
34 34
 // "pt" => "portuguese",
35
- "ru" => "russian-UTF8",
36
- "es" => "spanish-utf8",
37
- "sv" => "svenska"
35
+    "ru" => "russian-UTF8",
36
+    "es" => "spanish-utf8",
37
+    "sv" => "svenska"
38 38
 );
39 39
 $_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
40 40
 if (!empty($_langFiles[$_langISO6391]))  $install_language = $_langFiles[$_langISO6391];
41 41
 
42 42
 
43 43
 if (isset($_POST['language']) && !stristr($_POST['language'],"..")) {
44
-	$install_language = $_POST['language'];
44
+    $install_language = $_POST['language'];
45 45
 } else {
46
-	if (isset($_GET['language']) && !stristr($_GET['language'],".."))
47
-		$install_language = $_GET['language'];
46
+    if (isset($_GET['language']) && !stristr($_GET['language'],".."))
47
+        $install_language = $_GET['language'];
48 48
 }
49 49
 # load language file
50 50
 require_once("lang/english.inc.php"); // As fallback
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 $manager_language = $install_language;
54 54
 
55 55
 if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'],"..")) {
56
-	$manager_language = $_POST['managerlanguage'];
56
+    $manager_language = $_POST['managerlanguage'];
57 57
 } else {
58
-	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],".."))
59
-		$manager_language = $_GET['managerlanguage'];
58
+    if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],".."))
59
+        $manager_language = $_GET['managerlanguage'];
60 60
 }
61 61
 
62 62
 foreach($_lang as $k=>$v)
63 63
 {
64
-	if(strpos($v,'[+MGR_DIR+]')!==false)
65
-		$_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
64
+    if(strpos($v,'[+MGR_DIR+]')!==false)
65
+        $_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
66 66
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
  * Filename:       /install/lang.php
11 11
  */
12 12
 
13
-$_lang = array ();
13
+$_lang = array();
14 14
 
15 15
 #default fallback language file - english
16 16
 $install_language = "english";
17 17
 
18
-$_langFiles= array (
18
+$_langFiles = array(
19 19
  "en" => "english",
20 20
  "bg" => "bulgarian",
21 21
  "cs" => "czech",
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
  "es" => "spanish-utf8",
37 37
  "sv" => "svenska"
38 38
 );
39
-$_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
39
+$_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2);
40 40
 if (!empty($_langFiles[$_langISO6391]))  $install_language = $_langFiles[$_langISO6391];
41 41
 
42 42
 
43
-if (isset($_POST['language']) && !stristr($_POST['language'],"..")) {
43
+if (isset($_POST['language']) && !stristr($_POST['language'], "..")) {
44 44
 	$install_language = $_POST['language'];
45 45
 } else {
46
-	if (isset($_GET['language']) && !stristr($_GET['language'],".."))
46
+	if (isset($_GET['language']) && !stristr($_GET['language'], ".."))
47 47
 		$install_language = $_GET['language'];
48 48
 }
49 49
 # load language file
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 
53 53
 $manager_language = $install_language;
54 54
 
55
-if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'],"..")) {
55
+if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'], "..")) {
56 56
 	$manager_language = $_POST['managerlanguage'];
57 57
 } else {
58
-	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],".."))
58
+	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'], ".."))
59 59
 		$manager_language = $_GET['managerlanguage'];
60 60
 }
61 61
 
62
-foreach($_lang as $k=>$v)
62
+foreach ($_lang as $k=>$v)
63 63
 {
64
-	if(strpos($v,'[+MGR_DIR+]')!==false)
64
+	if (strpos($v, '[+MGR_DIR+]') !== false)
65 65
 		$_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
66 66
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,15 +37,18 @@  discard block
 block discarded – undo
37 37
  "sv" => "svenska"
38 38
 );
39 39
 $_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
40
-if (!empty($_langFiles[$_langISO6391]))  $install_language = $_langFiles[$_langISO6391];
40
+if (!empty($_langFiles[$_langISO6391])) {
41
+    $install_language = $_langFiles[$_langISO6391];
42
+}
41 43
 
42 44
 
43 45
 if (isset($_POST['language']) && !stristr($_POST['language'],"..")) {
44 46
 	$install_language = $_POST['language'];
45 47
 } else {
46
-	if (isset($_GET['language']) && !stristr($_GET['language'],".."))
47
-		$install_language = $_GET['language'];
48
-}
48
+	if (isset($_GET['language']) && !stristr($_GET['language'],"..")) {
49
+			$install_language = $_GET['language'];
50
+	}
51
+	}
49 52
 # load language file
50 53
 require_once("lang/english.inc.php"); // As fallback
51 54
 require_once("lang/".$install_language.".inc.php");
@@ -55,12 +58,13 @@  discard block
 block discarded – undo
55 58
 if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'],"..")) {
56 59
 	$manager_language = $_POST['managerlanguage'];
57 60
 } else {
58
-	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],".."))
59
-		$manager_language = $_GET['managerlanguage'];
60
-}
61
+	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],"..")) {
62
+			$manager_language = $_GET['managerlanguage'];
63
+	}
64
+	}
61 65
 
62
-foreach($_lang as $k=>$v)
63
-{
64
-	if(strpos($v,'[+MGR_DIR+]')!==false)
65
-		$_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
66
-}
66
+foreach($_lang as $k=>$v) {
67
+	if(strpos($v,'[+MGR_DIR+]')!==false) {
68
+			$_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
69
+	}
70
+	}
Please login to merge, or discard this patch.