@@ -19,17 +19,17 @@ |
||
19 | 19 | |
20 | 20 | # checked captcha |
21 | 21 | if(isset($roocms->sess['captcha']) && mb_strlen($roocms->sess['captcha']) == 5) { |
22 | - $captcha_code = $roocms->sess['captcha']; |
|
22 | + $captcha_code = $roocms->sess['captcha']; |
|
23 | 23 | } |
24 | 24 | else { |
25 | - $captcha_code = randcode(5,"123456789ABCEFHJKLMNPRSTVUWXZ"); |
|
26 | - $_SESSION['captcha'] = $captcha_code; |
|
25 | + $captcha_code = randcode(5,"123456789ABCEFHJKLMNPRSTVUWXZ"); |
|
26 | + $_SESSION['captcha'] = $captcha_code; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | #renew code |
30 | 30 | if(isset($get->_I_have_bad_sight)) { |
31 | - $captcha_code = randcode(5,"123456789ABCEFHJKLMNPRSTVUWXZ"); |
|
32 | - $_SESSION['captcha'] = $captcha_code; |
|
31 | + $captcha_code = randcode(5,"123456789ABCEFHJKLMNPRSTVUWXZ"); |
|
32 | + $_SESSION['captcha'] = $captcha_code; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | # no cache |
@@ -34,7 +34,7 @@ |
||
34 | 34 | |
35 | 35 | # no cache |
36 | 36 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
37 | -header("Cache-Control: post-check=0, pre-check=0", false); |
|
37 | +header("Cache-Control: post-check=0, pre-check=0", FALSE); |
|
38 | 38 | |
39 | 39 | # load aRCaptcha |
40 | 40 | require_once(_LIB."/captcha.php"); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | // Anti Hack |
16 | 16 | //--------------------------------------------------------- |
17 | 17 | if(!defined('RooCMS')) { |
18 | - die('Access Denied'); |
|
18 | + die('Access Denied'); |
|
19 | 19 | } |
20 | 20 | //######################################################### |
21 | 21 | |
@@ -30,24 +30,24 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function randcode($ns, $symbols="ABCEFHKLMNPRSTVXYZ123456789") { |
32 | 32 | |
33 | - if(trim($symbols) == "") { |
|
34 | - $symbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
|
35 | - } |
|
33 | + if(trim($symbols) == "") { |
|
34 | + $symbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
|
35 | + } |
|
36 | 36 | |
37 | - settype($symbols, "string"); |
|
37 | + settype($symbols, "string"); |
|
38 | 38 | |
39 | - $code = ""; $i = 0; |
|
39 | + $code = ""; $i = 0; |
|
40 | 40 | |
41 | - while ($i < $ns) { |
|
42 | - $a = rand(0,1); |
|
43 | - mt_srand(); srand(); |
|
44 | - $code .= ($a == 1) |
|
45 | - ? $symbols[mt_rand(0, mb_strlen($symbols) - 1)] |
|
46 | - : $symbols[rand(0, mb_strlen($symbols) - 1)] ; |
|
47 | - $i++; |
|
48 | - } |
|
41 | + while ($i < $ns) { |
|
42 | + $a = rand(0,1); |
|
43 | + mt_srand(); srand(); |
|
44 | + $code .= ($a == 1) |
|
45 | + ? $symbols[mt_rand(0, mb_strlen($symbols) - 1)] |
|
46 | + : $symbols[rand(0, mb_strlen($symbols) - 1)] ; |
|
47 | + $i++; |
|
48 | + } |
|
49 | 49 | |
50 | - return $code; |
|
50 | + return $code; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @return string |
59 | 59 | */ |
60 | 60 | function mb_ucfirst($string) { |
61 | - return mb_strtoupper(mb_substr($string, 0, 1)).mb_strtolower(mb_substr($string, 1)); |
|
61 | + return mb_strtoupper(mb_substr($string, 0, 1)).mb_strtolower(mb_substr($string, 1)); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -69,34 +69,34 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function go($address, $code=301) { |
71 | 71 | |
72 | - switch($code) { |
|
73 | - case 300: |
|
74 | - header($_SERVER['SERVER_PROTOCOL'].' 300 Multiple Choices'); |
|
75 | - break; |
|
72 | + switch($code) { |
|
73 | + case 300: |
|
74 | + header($_SERVER['SERVER_PROTOCOL'].' 300 Multiple Choices'); |
|
75 | + break; |
|
76 | 76 | |
77 | - case 302: |
|
78 | - header($_SERVER['SERVER_PROTOCOL'].' 302 Found'); |
|
79 | - break; |
|
77 | + case 302: |
|
78 | + header($_SERVER['SERVER_PROTOCOL'].' 302 Found'); |
|
79 | + break; |
|
80 | 80 | |
81 | - case 303: |
|
82 | - header($_SERVER['SERVER_PROTOCOL'].' 303 See Other'); |
|
83 | - break; |
|
81 | + case 303: |
|
82 | + header($_SERVER['SERVER_PROTOCOL'].' 303 See Other'); |
|
83 | + break; |
|
84 | 84 | |
85 | - case 304: |
|
86 | - header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified'); |
|
87 | - break; |
|
85 | + case 304: |
|
86 | + header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified'); |
|
87 | + break; |
|
88 | 88 | |
89 | - case 307: |
|
90 | - header($_SERVER['SERVER_PROTOCOL'].' 307 Temporary Redirect'); |
|
91 | - break; |
|
89 | + case 307: |
|
90 | + header($_SERVER['SERVER_PROTOCOL'].' 307 Temporary Redirect'); |
|
91 | + break; |
|
92 | 92 | |
93 | - default: |
|
94 | - header($_SERVER['SERVER_PROTOCOL'].' 301 Moved Permanently'); |
|
95 | - break; |
|
96 | - } |
|
93 | + default: |
|
94 | + header($_SERVER['SERVER_PROTOCOL'].' 301 Moved Permanently'); |
|
95 | + break; |
|
96 | + } |
|
97 | 97 | |
98 | - header("Location: ".$address); |
|
99 | - exit; |
|
98 | + header("Location: ".$address); |
|
99 | + exit; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * Move back |
105 | 105 | */ |
106 | 106 | function goback() { |
107 | - go(getenv("HTTP_REFERER")); |
|
108 | - exit; |
|
107 | + go(getenv("HTTP_REFERER")); |
|
108 | + exit; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | */ |
115 | 115 | function nocache() { |
116 | 116 | |
117 | - $expires = time() + (60*60*24); |
|
117 | + $expires = time() + (60*60*24); |
|
118 | 118 | |
119 | - header("Expires: ".gmdate("D, d M Y H:i:s", $expires)." GMT"); |
|
120 | - header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
121 | - header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
|
122 | - header("Cache-Control: post-check=0, pre-check=0", false); |
|
123 | - header("Pragma: no-cache"); |
|
119 | + header("Expires: ".gmdate("D, d M Y H:i:s", $expires)." GMT"); |
|
120 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
121 | + header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
|
122 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
123 | + header("Pragma: no-cache"); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @return string - code response |
132 | 132 | */ |
133 | 133 | function get_http_response_code($url) { |
134 | - $headers = get_headers($url); |
|
135 | - return mb_substr($headers[0], 9, 3); |
|
134 | + $headers = get_headers($url); |
|
135 | + return mb_substr($headers[0], 9, 3); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | * @return string - data from file |
144 | 144 | */ |
145 | 145 | function file_read($file) { |
146 | - $buffer = ""; |
|
146 | + $buffer = ""; |
|
147 | 147 | |
148 | - if(is_file($file)) { |
|
149 | - $buffer .= file_get_contents($file); |
|
150 | - } |
|
148 | + if(is_file($file)) { |
|
149 | + $buffer .= file_get_contents($file); |
|
150 | + } |
|
151 | 151 | |
152 | - return $buffer; |
|
152 | + return $buffer; |
|
153 | 153 | } |
@@ -119,7 +119,7 @@ |
||
119 | 119 | header("Expires: ".gmdate("D, d M Y H:i:s", $expires)." GMT"); |
120 | 120 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
121 | 121 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
122 | - header("Cache-Control: post-check=0, pre-check=0", false); |
|
122 | + header("Cache-Control: post-check=0, pre-check=0", FALSE); |
|
123 | 123 | header("Pragma: no-cache"); |
124 | 124 | } |
125 | 125 |
@@ -17,154 +17,154 @@ discard block |
||
17 | 17 | |
18 | 18 | class aRCaptcha { |
19 | 19 | |
20 | - # code |
|
21 | - private static $code = "00000"; |
|
22 | - private static $code_length = 5; |
|
23 | - private static $letter_width = 0; |
|
20 | + # code |
|
21 | + private static $code = "00000"; |
|
22 | + private static $code_length = 5; |
|
23 | + private static $letter_width = 0; |
|
24 | 24 | |
25 | - # options for string |
|
26 | - private static $use_number = true; |
|
27 | - private static $use_upper_letter = true; |
|
28 | - private static $use_lower_letter = false; |
|
25 | + # options for string |
|
26 | + private static $use_number = true; |
|
27 | + private static $use_upper_letter = true; |
|
28 | + private static $use_lower_letter = false; |
|
29 | 29 | |
30 | - # options for images |
|
30 | + # options for images |
|
31 | 31 | |
32 | - # bg color |
|
33 | - private static $bgcolor = array(254, 254, 254); |
|
32 | + # bg color |
|
33 | + private static $bgcolor = array(254, 254, 254); |
|
34 | 34 | |
35 | - # sizes |
|
36 | - private static $width = 180; |
|
37 | - private static $height = 85; |
|
35 | + # sizes |
|
36 | + private static $width = 180; |
|
37 | + private static $height = 85; |
|
38 | 38 | |
39 | - # user settings |
|
40 | - private static $use_polygons = false; |
|
41 | - private static $use_fontsnoise = true; |
|
42 | - private static $shuffle_font = false; |
|
39 | + # user settings |
|
40 | + private static $use_polygons = false; |
|
41 | + private static $use_fontsnoise = true; |
|
42 | + private static $shuffle_font = false; |
|
43 | 43 | |
44 | - # palette |
|
45 | - private static $palette = "aR-Captcha"; |
|
46 | - private static $randoms = array(0,20); |
|
44 | + # palette |
|
45 | + private static $palette = "aR-Captcha"; |
|
46 | + private static $randoms = array(0,20); |
|
47 | 47 | |
48 | - # fonts path |
|
49 | - private static $font_path = "fonts"; |
|
48 | + # fonts path |
|
49 | + private static $font_path = "fonts"; |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Show |
|
54 | - * |
|
55 | - * @param string $code |
|
56 | - */ |
|
57 | - public static function show($code="000000") { |
|
52 | + /** |
|
53 | + * Show |
|
54 | + * |
|
55 | + * @param string $code |
|
56 | + */ |
|
57 | + public static function show($code="000000") { |
|
58 | 58 | |
59 | - self::set_code($code); |
|
59 | + self::set_code($code); |
|
60 | 60 | |
61 | - # get |
|
62 | - $captcha = self::captcha(); |
|
61 | + # get |
|
62 | + $captcha = self::captcha(); |
|
63 | 63 | |
64 | - # draw |
|
65 | - header("Content-type: image/jpeg"); |
|
66 | - imagejpeg($captcha); |
|
67 | - imagedestroy($captcha); |
|
68 | - } |
|
64 | + # draw |
|
65 | + header("Content-type: image/jpeg"); |
|
66 | + imagejpeg($captcha); |
|
67 | + imagedestroy($captcha); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * CRAFT CAPTCHA |
|
73 | - * |
|
74 | - * @return false|mixed|resource |
|
75 | - */ |
|
76 | - private static function captcha() { |
|
71 | + /** |
|
72 | + * CRAFT CAPTCHA |
|
73 | + * |
|
74 | + * @return false|mixed|resource |
|
75 | + */ |
|
76 | + private static function captcha() { |
|
77 | 77 | |
78 | - $captcha = imagecreatetruecolor(self::$width, self::$height); |
|
79 | - $bg = imagecolorallocate($captcha, self::$bgcolor[0], self::$bgcolor[1], self::$bgcolor[2]); |
|
80 | - imagefill($captcha, 0, 0, $bg); |
|
78 | + $captcha = imagecreatetruecolor(self::$width, self::$height); |
|
79 | + $bg = imagecolorallocate($captcha, self::$bgcolor[0], self::$bgcolor[1], self::$bgcolor[2]); |
|
80 | + imagefill($captcha, 0, 0, $bg); |
|
81 | 81 | |
82 | 82 | |
83 | - # NOISE |
|
84 | - if(self::$use_polygons && is_resource($captcha)) { |
|
85 | - $captcha = self::polygons($captcha); |
|
86 | - } |
|
83 | + # NOISE |
|
84 | + if(self::$use_polygons && is_resource($captcha)) { |
|
85 | + $captcha = self::polygons($captcha); |
|
86 | + } |
|
87 | 87 | |
88 | - if(self::$use_fontsnoise && is_resource($captcha)) { |
|
89 | - $captcha = self::fontsnoise($captcha); |
|
90 | - } |
|
88 | + if(self::$use_fontsnoise && is_resource($captcha)) { |
|
89 | + $captcha = self::fontsnoise($captcha); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - # letters |
|
94 | - $captcha = self::letters($captcha); |
|
93 | + # letters |
|
94 | + $captcha = self::letters($captcha); |
|
95 | 95 | |
96 | - return $captcha; |
|
97 | - } |
|
96 | + return $captcha; |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * Set code string on image (use ttf font) |
|
102 | - * |
|
103 | - * @param resource $captcha - resource image |
|
104 | - * |
|
105 | - * @return resource|false |
|
106 | - */ |
|
107 | - private static function letters($captcha) { |
|
100 | + /** |
|
101 | + * Set code string on image (use ttf font) |
|
102 | + * |
|
103 | + * @param resource $captcha - resource image |
|
104 | + * |
|
105 | + * @return resource|false |
|
106 | + */ |
|
107 | + private static function letters($captcha) { |
|
108 | 108 | |
109 | - # get font |
|
110 | - $font = self::get_font(); |
|
109 | + # get font |
|
110 | + $font = self::get_font(); |
|
111 | 111 | |
112 | - $shift = 4; |
|
113 | - for($l=0;$l<=self::$code_length-1;$l++) { |
|
114 | - list($r,$g,$b) = self::get_random_rgb(); |
|
115 | - $color = imagecolorallocatealpha($captcha, $r, $g, $b, mt_rand(0,25)); |
|
116 | - //$colorsh = imagecolorallocatealpha($captcha, $r/2, $g/2, $b/2, mt_rand(25,50)); |
|
112 | + $shift = 4; |
|
113 | + for($l=0;$l<=self::$code_length-1;$l++) { |
|
114 | + list($r,$g,$b) = self::get_random_rgb(); |
|
115 | + $color = imagecolorallocatealpha($captcha, $r, $g, $b, mt_rand(0,25)); |
|
116 | + //$colorsh = imagecolorallocatealpha($captcha, $r/2, $g/2, $b/2, mt_rand(25,50)); |
|
117 | 117 | |
118 | - $angle = mt_rand(-15,15); |
|
118 | + $angle = mt_rand(-15,15); |
|
119 | 119 | |
120 | - $y = mt_rand(round(self::$height/1.4), self::$height); |
|
121 | - $size = mt_rand(floor(self::$height/2.25), ceil(self::$height/1.20)); |
|
120 | + $y = mt_rand(round(self::$height/1.4), self::$height); |
|
121 | + $size = mt_rand(floor(self::$height/2.25), ceil(self::$height/1.20)); |
|
122 | 122 | |
123 | - $letter = mb_substr(self::$code, $l, 1); |
|
123 | + $letter = mb_substr(self::$code, $l, 1); |
|
124 | 124 | |
125 | - switch($l) { |
|
126 | - case 0: |
|
127 | - $position = mt_rand($shift - round(self::$letter_width * .05), $shift + round(self::$letter_width * .25)); |
|
128 | - break; |
|
125 | + switch($l) { |
|
126 | + case 0: |
|
127 | + $position = mt_rand($shift - round(self::$letter_width * .05), $shift + round(self::$letter_width * .25)); |
|
128 | + break; |
|
129 | 129 | |
130 | - case self::$code_length-1: |
|
131 | - $position = mt_rand($shift - round(self::$letter_width * .25), $shift + round(self::$letter_width * .05)); |
|
132 | - break; |
|
130 | + case self::$code_length-1: |
|
131 | + $position = mt_rand($shift - round(self::$letter_width * .25), $shift + round(self::$letter_width * .05)); |
|
132 | + break; |
|
133 | 133 | |
134 | - default: |
|
135 | - $position = mt_rand($shift - round(self::$letter_width * .25), $shift + round(self::$letter_width * .25)); |
|
136 | - break; |
|
137 | - } |
|
134 | + default: |
|
135 | + $position = mt_rand($shift - round(self::$letter_width * .25), $shift + round(self::$letter_width * .25)); |
|
136 | + break; |
|
137 | + } |
|
138 | 138 | |
139 | - //imagettftext($captcha, $size, $angle, $position, $y-1, $colorsh, $font['file'], $letter); |
|
140 | - imagettftext($captcha, $size, $angle, $position, $y, $color, $font['file'], $letter); |
|
139 | + //imagettftext($captcha, $size, $angle, $position, $y-1, $colorsh, $font['file'], $letter); |
|
140 | + imagettftext($captcha, $size, $angle, $position, $y, $color, $font['file'], $letter); |
|
141 | 141 | |
142 | - if(self::$shuffle_font) { |
|
143 | - $font = self::get_font(); |
|
144 | - } |
|
142 | + if(self::$shuffle_font) { |
|
143 | + $font = self::get_font(); |
|
144 | + } |
|
145 | 145 | |
146 | - $shift += self::$letter_width; |
|
147 | - } |
|
146 | + $shift += self::$letter_width; |
|
147 | + } |
|
148 | 148 | |
149 | - return $captcha; |
|
150 | - } |
|
149 | + return $captcha; |
|
150 | + } |
|
151 | 151 | |
152 | 152 | |
153 | - /** |
|
154 | - * Draw lines on captcha background |
|
155 | - * |
|
156 | - * @param resource $captcha |
|
157 | - * |
|
158 | - * @return resource|false |
|
159 | - */ |
|
160 | - private static function polygons($captcha) { |
|
153 | + /** |
|
154 | + * Draw lines on captcha background |
|
155 | + * |
|
156 | + * @param resource $captcha |
|
157 | + * |
|
158 | + * @return resource|false |
|
159 | + */ |
|
160 | + private static function polygons($captcha) { |
|
161 | 161 | |
162 | - $min = min(self::$width, self::$height); |
|
163 | - $max = max(self::$width, self::$height); |
|
162 | + $min = min(self::$width, self::$height); |
|
163 | + $max = max(self::$width, self::$height); |
|
164 | 164 | |
165 | - $scream = mt_rand(1,self::$code_length); |
|
165 | + $scream = mt_rand(1,self::$code_length); |
|
166 | 166 | |
167 | - /*for($i=0;$i<=$scream;$i++) { |
|
167 | + /*for($i=0;$i<=$scream;$i++) { |
|
168 | 168 | list($r,$g,$b) = self::get_random_rgb(); |
169 | 169 | $color = imagecolorallocatealpha($captcha, $r, $g, $b, 10); |
170 | 170 | |
@@ -178,165 +178,165 @@ discard block |
||
178 | 178 | imagepolygon($captcha, $points, $p, $color); |
179 | 179 | }*/ |
180 | 180 | |
181 | - for($i=0;$i<=$scream;$i++) { |
|
182 | - list($r,$g,$b) = self::get_random_rgb(); |
|
183 | - $color = imagecolorallocatealpha($captcha, $r, $g, $b, 10); |
|
181 | + for($i=0;$i<=$scream;$i++) { |
|
182 | + list($r,$g,$b) = self::get_random_rgb(); |
|
183 | + $color = imagecolorallocatealpha($captcha, $r, $g, $b, 10); |
|
184 | 184 | |
185 | - $points = array(); |
|
186 | - for($s=0;$s<=2;$s++) { |
|
187 | - $points[] = mt_rand(0,self::$width); mt_srand(); |
|
188 | - $points[] = mt_rand(0,self::$height); mt_srand(); |
|
189 | - } |
|
190 | - imagesetthickness($captcha, mt_rand(3,5)); |
|
191 | - imagepolygon($captcha, $points, 2, $color); |
|
192 | - } |
|
185 | + $points = array(); |
|
186 | + for($s=0;$s<=2;$s++) { |
|
187 | + $points[] = mt_rand(0,self::$width); mt_srand(); |
|
188 | + $points[] = mt_rand(0,self::$height); mt_srand(); |
|
189 | + } |
|
190 | + imagesetthickness($captcha, mt_rand(3,5)); |
|
191 | + imagepolygon($captcha, $points, 2, $color); |
|
192 | + } |
|
193 | 193 | |
194 | - return $captcha; |
|
195 | - } |
|
194 | + return $captcha; |
|
195 | + } |
|
196 | 196 | |
197 | 197 | |
198 | - /** |
|
199 | - * Draw letters on BG Captcha |
|
200 | - * |
|
201 | - * @param resource $captcha |
|
202 | - * |
|
203 | - * @return resource |
|
204 | - */ |
|
205 | - private static function fontsnoise($captcha) { |
|
198 | + /** |
|
199 | + * Draw letters on BG Captcha |
|
200 | + * |
|
201 | + * @param resource $captcha |
|
202 | + * |
|
203 | + * @return resource |
|
204 | + */ |
|
205 | + private static function fontsnoise($captcha) { |
|
206 | 206 | |
207 | - # get font |
|
208 | - $font = self::get_font(); |
|
207 | + # get font |
|
208 | + $font = self::get_font(); |
|
209 | 209 | |
210 | - $shift = 4; |
|
211 | - for($l=0;$l<=self::$code_length-1;$l++) { |
|
212 | - list($r,$g,$b) = self::get_random_rgb(); |
|
213 | - $color = imagecolorallocatealpha($captcha, $r, $g, $b, mt_rand(85,95)); |
|
210 | + $shift = 4; |
|
211 | + for($l=0;$l<=self::$code_length-1;$l++) { |
|
212 | + list($r,$g,$b) = self::get_random_rgb(); |
|
213 | + $color = imagecolorallocatealpha($captcha, $r, $g, $b, mt_rand(85,95)); |
|
214 | 214 | |
215 | - $angle = mt_rand(-5,5); |
|
215 | + $angle = mt_rand(-5,5); |
|
216 | 216 | |
217 | - $y = mt_rand(round(self::$height/1.5), ceil(self::$height*2)); |
|
218 | - $size = mt_rand(floor(self::$height/1.1), ceil(self::$height*1.5)); |
|
217 | + $y = mt_rand(round(self::$height/1.5), ceil(self::$height*2)); |
|
218 | + $size = mt_rand(floor(self::$height/1.1), ceil(self::$height*1.5)); |
|
219 | 219 | |
220 | - $letter = mb_substr(self::$code, mt_rand(0,self::$code_length-1), 1); |
|
220 | + $letter = mb_substr(self::$code, mt_rand(0,self::$code_length-1), 1); |
|
221 | 221 | |
222 | - $position = mt_rand($shift - round(self::$letter_width * .5), $shift + round(self::$letter_width * .5)); |
|
222 | + $position = mt_rand($shift - round(self::$letter_width * .5), $shift + round(self::$letter_width * .5)); |
|
223 | 223 | |
224 | - imagettftext($captcha, $size, $angle, $position, $y, $color, $font['file'], $letter); |
|
224 | + imagettftext($captcha, $size, $angle, $position, $y, $color, $font['file'], $letter); |
|
225 | 225 | |
226 | - if(self::$shuffle_font) { |
|
227 | - $font = self::get_font(); |
|
228 | - } |
|
226 | + if(self::$shuffle_font) { |
|
227 | + $font = self::get_font(); |
|
228 | + } |
|
229 | 229 | |
230 | - $shift += self::$letter_width; |
|
231 | - } |
|
230 | + $shift += self::$letter_width; |
|
231 | + } |
|
232 | 232 | |
233 | - return $captcha; |
|
234 | - } |
|
233 | + return $captcha; |
|
234 | + } |
|
235 | 235 | |
236 | 236 | |
237 | - /** |
|
238 | - * Valid and set code string |
|
239 | - * |
|
240 | - * @param string $code |
|
241 | - */ |
|
242 | - private static function set_code($code) { |
|
237 | + /** |
|
238 | + * Valid and set code string |
|
239 | + * |
|
240 | + * @param string $code |
|
241 | + */ |
|
242 | + private static function set_code($code) { |
|
243 | 243 | |
244 | - $condition = self::get_condition(); |
|
244 | + $condition = self::get_condition(); |
|
245 | 245 | |
246 | - $code = preg_replace(array('(\W+)','([^'.$condition.'])'), array('',''), $code); |
|
246 | + $code = preg_replace(array('(\W+)','([^'.$condition.'])'), array('',''), $code); |
|
247 | 247 | |
248 | - self::$code = $code; |
|
249 | - self::$code_length = mb_strlen(self::$code); |
|
250 | - self::$letter_width = (self::$width / self::$code_length >= self::$height) ? self::$height : (self::$width / self::$code_length) - 4 ; |
|
251 | - } |
|
248 | + self::$code = $code; |
|
249 | + self::$code_length = mb_strlen(self::$code); |
|
250 | + self::$letter_width = (self::$width / self::$code_length >= self::$height) ? self::$height : (self::$width / self::$code_length) - 4 ; |
|
251 | + } |
|
252 | 252 | |
253 | 253 | |
254 | - /** |
|
255 | - * Get random ttf font |
|
256 | - * |
|
257 | - * @return array |
|
258 | - */ |
|
259 | - private static function get_font() { |
|
254 | + /** |
|
255 | + * Get random ttf font |
|
256 | + * |
|
257 | + * @return array |
|
258 | + */ |
|
259 | + private static function get_font() { |
|
260 | 260 | |
261 | - # Select random fonts |
|
262 | - $fonts = glob(dirname(__FILE__)."/".self::$font_path."/*.ttf", GLOB_BRACE); |
|
261 | + # Select random fonts |
|
262 | + $fonts = glob(dirname(__FILE__)."/".self::$font_path."/*.ttf", GLOB_BRACE); |
|
263 | 263 | |
264 | - # choice font |
|
265 | - $font = array(); |
|
266 | - $font['file'] = $fonts[mt_rand(0,count($fonts)-1)]; |
|
264 | + # choice font |
|
265 | + $font = array(); |
|
266 | + $font['file'] = $fonts[mt_rand(0,count($fonts)-1)]; |
|
267 | 267 | |
268 | - return $font; |
|
269 | - } |
|
268 | + return $font; |
|
269 | + } |
|
270 | 270 | |
271 | 271 | |
272 | - /** |
|
273 | - * Get random HEX RGB color |
|
274 | - * |
|
275 | - * @return array |
|
276 | - */ |
|
277 | - private static function get_random_rgb() { |
|
272 | + /** |
|
273 | + * Get random HEX RGB color |
|
274 | + * |
|
275 | + * @return array |
|
276 | + */ |
|
277 | + private static function get_random_rgb() { |
|
278 | 278 | |
279 | - mt_srand(); |
|
280 | - $colorvariator = md5(self::$palette . mt_rand(self::$randoms[0], self::$randoms[1])); |
|
279 | + mt_srand(); |
|
280 | + $colorvariator = md5(self::$palette . mt_rand(self::$randoms[0], self::$randoms[1])); |
|
281 | 281 | |
282 | - return array( |
|
283 | - hexdec(substr($colorvariator, 0, 2)), |
|
284 | - hexdec(substr($colorvariator, 2, 2)), |
|
285 | - hexdec(substr($colorvariator, 4, 2)) |
|
286 | - ); |
|
287 | - } |
|
282 | + return array( |
|
283 | + hexdec(substr($colorvariator, 0, 2)), |
|
284 | + hexdec(substr($colorvariator, 2, 2)), |
|
285 | + hexdec(substr($colorvariator, 4, 2)) |
|
286 | + ); |
|
287 | + } |
|
288 | 288 | |
289 | 289 | |
290 | - /** |
|
291 | - * Get pcre condition for code string |
|
292 | - * |
|
293 | - * @return string |
|
294 | - */ |
|
295 | - private static function get_condition() { |
|
290 | + /** |
|
291 | + * Get pcre condition for code string |
|
292 | + * |
|
293 | + * @return string |
|
294 | + */ |
|
295 | + private static function get_condition() { |
|
296 | 296 | |
297 | - $condition = ""; |
|
297 | + $condition = ""; |
|
298 | 298 | |
299 | - if(self::$use_lower_letter) { |
|
300 | - $condition .= "a-z"; |
|
301 | - } |
|
302 | - if(self::$use_upper_letter) { |
|
303 | - $condition .= "A-Z"; |
|
304 | - } |
|
305 | - if(self::$use_number) { |
|
306 | - $condition .= "0-9"; |
|
307 | - } |
|
299 | + if(self::$use_lower_letter) { |
|
300 | + $condition .= "a-z"; |
|
301 | + } |
|
302 | + if(self::$use_upper_letter) { |
|
303 | + $condition .= "A-Z"; |
|
304 | + } |
|
305 | + if(self::$use_number) { |
|
306 | + $condition .= "0-9"; |
|
307 | + } |
|
308 | 308 | |
309 | - return $condition; |
|
310 | - } |
|
309 | + return $condition; |
|
310 | + } |
|
311 | 311 | |
312 | 312 | |
313 | - /** |
|
314 | - * Debug function for view palette |
|
315 | - */ |
|
316 | - public static function palette() { |
|
313 | + /** |
|
314 | + * Debug function for view palette |
|
315 | + */ |
|
316 | + public static function palette() { |
|
317 | 317 | |
318 | - $nums = range(self::$randoms[0], self::$randoms[1]); |
|
318 | + $nums = range(self::$randoms[0], self::$randoms[1]); |
|
319 | 319 | |
320 | - $scale = 30; |
|
320 | + $scale = 30; |
|
321 | 321 | |
322 | - $im = imagecreatetruecolor($scale * count($nums), $scale); |
|
322 | + $im = imagecreatetruecolor($scale * count($nums), $scale); |
|
323 | 323 | |
324 | - $shift = 0; |
|
325 | - foreach ($nums as $num) { |
|
324 | + $shift = 0; |
|
325 | + foreach ($nums as $num) { |
|
326 | 326 | |
327 | - $color = md5(self::$palette . $num); |
|
327 | + $color = md5(self::$palette . $num); |
|
328 | 328 | |
329 | - $r = hexdec(substr($color, 0, 2)); |
|
330 | - $g = hexdec(substr($color, 2, 2)); |
|
331 | - $b = hexdec(substr($color, 4, 2)); |
|
329 | + $r = hexdec(substr($color, 0, 2)); |
|
330 | + $g = hexdec(substr($color, 2, 2)); |
|
331 | + $b = hexdec(substr($color, 4, 2)); |
|
332 | 332 | |
333 | - $c = imagecolorallocate($im, $r, $g, $b); |
|
334 | - imagefilledrectangle($im, $scale * $shift, 0, $scale * ($shift + 1), $scale, $c); |
|
335 | - $shift++; |
|
336 | - } |
|
333 | + $c = imagecolorallocate($im, $r, $g, $b); |
|
334 | + imagefilledrectangle($im, $scale * $shift, 0, $scale * ($shift + 1), $scale, $c); |
|
335 | + $shift++; |
|
336 | + } |
|
337 | 337 | |
338 | - header('Content-Type: image/png'); |
|
339 | - imagepng($im); |
|
340 | - imagedestroy($im); |
|
341 | - } |
|
338 | + header('Content-Type: image/png'); |
|
339 | + imagepng($im); |
|
340 | + imagedestroy($im); |
|
341 | + } |
|
342 | 342 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | # palette |
45 | 45 | private static $palette = "aR-Captcha"; |
46 | - private static $randoms = array(0,20); |
|
46 | + private static $randoms = array(0, 20); |
|
47 | 47 | |
48 | 48 | # fonts path |
49 | 49 | private static $font_path = "fonts"; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @param string $code |
56 | 56 | */ |
57 | - public static function show($code="000000") { |
|
57 | + public static function show($code = "000000") { |
|
58 | 58 | |
59 | 59 | self::set_code($code); |
60 | 60 | |
@@ -110,24 +110,24 @@ discard block |
||
110 | 110 | $font = self::get_font(); |
111 | 111 | |
112 | 112 | $shift = 4; |
113 | - for($l=0;$l<=self::$code_length-1;$l++) { |
|
114 | - list($r,$g,$b) = self::get_random_rgb(); |
|
115 | - $color = imagecolorallocatealpha($captcha, $r, $g, $b, mt_rand(0,25)); |
|
113 | + for($l = 0; $l <= self::$code_length - 1; $l++) { |
|
114 | + list($r, $g, $b) = self::get_random_rgb(); |
|
115 | + $color = imagecolorallocatealpha($captcha, $r, $g, $b, mt_rand(0, 25)); |
|
116 | 116 | //$colorsh = imagecolorallocatealpha($captcha, $r/2, $g/2, $b/2, mt_rand(25,50)); |
117 | 117 | |
118 | - $angle = mt_rand(-15,15); |
|
118 | + $angle = mt_rand(-15, 15); |
|
119 | 119 | |
120 | - $y = mt_rand(round(self::$height/1.4), self::$height); |
|
121 | - $size = mt_rand(floor(self::$height/2.25), ceil(self::$height/1.20)); |
|
120 | + $y = mt_rand(round(self::$height / 1.4), self::$height); |
|
121 | + $size = mt_rand(floor(self::$height / 2.25), ceil(self::$height / 1.20)); |
|
122 | 122 | |
123 | 123 | $letter = mb_substr(self::$code, $l, 1); |
124 | 124 | |
125 | - switch($l) { |
|
125 | + switch ($l) { |
|
126 | 126 | case 0: |
127 | 127 | $position = mt_rand($shift - round(self::$letter_width * .05), $shift + round(self::$letter_width * .25)); |
128 | 128 | break; |
129 | 129 | |
130 | - case self::$code_length-1: |
|
130 | + case self::$code_length - 1: |
|
131 | 131 | $position = mt_rand($shift - round(self::$letter_width * .25), $shift + round(self::$letter_width * .05)); |
132 | 132 | break; |
133 | 133 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $min = min(self::$width, self::$height); |
163 | 163 | $max = max(self::$width, self::$height); |
164 | 164 | |
165 | - $scream = mt_rand(1,self::$code_length); |
|
165 | + $scream = mt_rand(1, self::$code_length); |
|
166 | 166 | |
167 | 167 | /*for($i=0;$i<=$scream;$i++) { |
168 | 168 | list($r,$g,$b) = self::get_random_rgb(); |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | imagepolygon($captcha, $points, $p, $color); |
179 | 179 | }*/ |
180 | 180 | |
181 | - for($i=0;$i<=$scream;$i++) { |
|
182 | - list($r,$g,$b) = self::get_random_rgb(); |
|
181 | + for($i = 0; $i <= $scream; $i++) { |
|
182 | + list($r, $g, $b) = self::get_random_rgb(); |
|
183 | 183 | $color = imagecolorallocatealpha($captcha, $r, $g, $b, 10); |
184 | 184 | |
185 | 185 | $points = array(); |
186 | - for($s=0;$s<=2;$s++) { |
|
187 | - $points[] = mt_rand(0,self::$width); mt_srand(); |
|
188 | - $points[] = mt_rand(0,self::$height); mt_srand(); |
|
186 | + for($s = 0; $s <= 2; $s++) { |
|
187 | + $points[] = mt_rand(0, self::$width); mt_srand(); |
|
188 | + $points[] = mt_rand(0, self::$height); mt_srand(); |
|
189 | 189 | } |
190 | - imagesetthickness($captcha, mt_rand(3,5)); |
|
190 | + imagesetthickness($captcha, mt_rand(3, 5)); |
|
191 | 191 | imagepolygon($captcha, $points, 2, $color); |
192 | 192 | } |
193 | 193 | |
@@ -208,16 +208,16 @@ discard block |
||
208 | 208 | $font = self::get_font(); |
209 | 209 | |
210 | 210 | $shift = 4; |
211 | - for($l=0;$l<=self::$code_length-1;$l++) { |
|
212 | - list($r,$g,$b) = self::get_random_rgb(); |
|
213 | - $color = imagecolorallocatealpha($captcha, $r, $g, $b, mt_rand(85,95)); |
|
211 | + for($l = 0; $l <= self::$code_length - 1; $l++) { |
|
212 | + list($r, $g, $b) = self::get_random_rgb(); |
|
213 | + $color = imagecolorallocatealpha($captcha, $r, $g, $b, mt_rand(85, 95)); |
|
214 | 214 | |
215 | - $angle = mt_rand(-5,5); |
|
215 | + $angle = mt_rand(-5, 5); |
|
216 | 216 | |
217 | - $y = mt_rand(round(self::$height/1.5), ceil(self::$height*2)); |
|
218 | - $size = mt_rand(floor(self::$height/1.1), ceil(self::$height*1.5)); |
|
217 | + $y = mt_rand(round(self::$height / 1.5), ceil(self::$height * 2)); |
|
218 | + $size = mt_rand(floor(self::$height / 1.1), ceil(self::$height * 1.5)); |
|
219 | 219 | |
220 | - $letter = mb_substr(self::$code, mt_rand(0,self::$code_length-1), 1); |
|
220 | + $letter = mb_substr(self::$code, mt_rand(0, self::$code_length - 1), 1); |
|
221 | 221 | |
222 | 222 | $position = mt_rand($shift - round(self::$letter_width * .5), $shift + round(self::$letter_width * .5)); |
223 | 223 | |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | |
244 | 244 | $condition = self::get_condition(); |
245 | 245 | |
246 | - $code = preg_replace(array('(\W+)','([^'.$condition.'])'), array('',''), $code); |
|
246 | + $code = preg_replace(array('(\W+)', '([^'.$condition.'])'), array('', ''), $code); |
|
247 | 247 | |
248 | 248 | self::$code = $code; |
249 | 249 | self::$code_length = mb_strlen(self::$code); |
250 | - self::$letter_width = (self::$width / self::$code_length >= self::$height) ? self::$height : (self::$width / self::$code_length) - 4 ; |
|
250 | + self::$letter_width = (self::$width / self::$code_length >= self::$height) ? self::$height : (self::$width / self::$code_length) - 4; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | |
264 | 264 | # choice font |
265 | 265 | $font = array(); |
266 | - $font['file'] = $fonts[mt_rand(0,count($fonts)-1)]; |
|
266 | + $font['file'] = $fonts[mt_rand(0, count($fonts) - 1)]; |
|
267 | 267 | |
268 | 268 | return $font; |
269 | 269 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | private static function get_random_rgb() { |
278 | 278 | |
279 | 279 | mt_srand(); |
280 | - $colorvariator = md5(self::$palette . mt_rand(self::$randoms[0], self::$randoms[1])); |
|
280 | + $colorvariator = md5(self::$palette.mt_rand(self::$randoms[0], self::$randoms[1])); |
|
281 | 281 | |
282 | 282 | return array( |
283 | 283 | hexdec(substr($colorvariator, 0, 2)), |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | $im = imagecreatetruecolor($scale * count($nums), $scale); |
323 | 323 | |
324 | 324 | $shift = 0; |
325 | - foreach ($nums as $num) { |
|
325 | + foreach($nums as $num) { |
|
326 | 326 | |
327 | - $color = md5(self::$palette . $num); |
|
327 | + $color = md5(self::$palette.$num); |
|
328 | 328 | |
329 | 329 | $r = hexdec(substr($color, 0, 2)); |
330 | 330 | $g = hexdec(substr($color, 2, 2)); |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | private static $letter_width = 0; |
24 | 24 | |
25 | 25 | # options for string |
26 | - private static $use_number = true; |
|
27 | - private static $use_upper_letter = true; |
|
28 | - private static $use_lower_letter = false; |
|
26 | + private static $use_number = TRUE; |
|
27 | + private static $use_upper_letter = TRUE; |
|
28 | + private static $use_lower_letter = FALSE; |
|
29 | 29 | |
30 | 30 | # options for images |
31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | private static $height = 85; |
38 | 38 | |
39 | 39 | # user settings |
40 | - private static $use_polygons = false; |
|
41 | - private static $use_fontsnoise = true; |
|
42 | - private static $shuffle_font = false; |
|
40 | + private static $use_polygons = FALSE; |
|
41 | + private static $use_fontsnoise = TRUE; |
|
42 | + private static $shuffle_font = FALSE; |
|
43 | 43 | |
44 | 44 | # palette |
45 | 45 | private static $palette = "aR-Captcha"; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | // Anti Hack |
16 | 16 | //--------------------------------------------------------- |
17 | 17 | if(!defined('RooCMS')) { |
18 | - die('Access Denied'); |
|
18 | + die('Access Denied'); |
|
19 | 19 | } |
20 | 20 | //######################################################### |
21 | 21 | |
@@ -25,436 +25,436 @@ discard block |
||
25 | 25 | */ |
26 | 26 | class Users extends Security { |
27 | 27 | |
28 | - use UserGroups; |
|
29 | - use UserAvatar; |
|
28 | + use UserGroups; |
|
29 | + use UserAvatar; |
|
30 | 30 | |
31 | - # user uniq data |
|
32 | - public $uid = 0; # user id |
|
33 | - public $login = ""; # user login |
|
34 | - public $nickname = ""; # user nickname |
|
35 | - public $avatar = ""; # user avatar |
|
36 | - public $email = ""; # user nickname |
|
37 | - public $title = "u"; # user title |
|
38 | - public $gid = 0; # user group id |
|
39 | - public $gtitle = ""; # user group title |
|
40 | - public $token = ""; # user security token |
|
31 | + # user uniq data |
|
32 | + public $uid = 0; # user id |
|
33 | + public $login = ""; # user login |
|
34 | + public $nickname = ""; # user nickname |
|
35 | + public $avatar = ""; # user avatar |
|
36 | + public $email = ""; # user nickname |
|
37 | + public $title = "u"; # user title |
|
38 | + public $gid = 0; # user group id |
|
39 | + public $gtitle = ""; # user group title |
|
40 | + public $token = ""; # user security token |
|
41 | 41 | |
42 | - # user ban status |
|
43 | - public $ban = 0; # ban status |
|
44 | - public $ban_reason = ""; # ban reason |
|
45 | - public $ban_expiried = 0; # ban date expiried (unixtimestamp) |
|
42 | + # user ban status |
|
43 | + public $ban = 0; # ban status |
|
44 | + public $ban_reason = ""; # ban reason |
|
45 | + public $ban_expiried = 0; # ban date expiried (unixtimestamp) |
|
46 | 46 | |
47 | - # user data array |
|
48 | - public $userdata = array('uid'=>0, 'gid'=>0, 'title'=>'u'); |
|
47 | + # user data array |
|
48 | + public $userdata = array('uid'=>0, 'gid'=>0, 'title'=>'u'); |
|
49 | 49 | |
50 | - # user global data |
|
51 | - private $usersession = ""; # user session |
|
52 | - private $userip = ""; # user ip address |
|
53 | - private $useragent = ""; # user agent string |
|
54 | - private $referer = ""; # user referer |
|
50 | + # user global data |
|
51 | + private $usersession = ""; # user session |
|
52 | + private $userip = ""; # user ip address |
|
53 | + private $useragent = ""; # user agent string |
|
54 | + private $referer = ""; # user referer |
|
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Work your magic |
|
60 | - */ |
|
61 | - public function __construct() { |
|
58 | + /** |
|
59 | + * Work your magic |
|
60 | + */ |
|
61 | + public function __construct() { |
|
62 | 62 | |
63 | - global $roocms; |
|
63 | + global $roocms; |
|
64 | 64 | |
65 | - # get user data |
|
66 | - $this->usersession &= $roocms->usersession; |
|
67 | - $this->userip &= $roocms->userip; |
|
68 | - $this->referer &= $roocms->referer; |
|
65 | + # get user data |
|
66 | + $this->usersession &= $roocms->usersession; |
|
67 | + $this->userip &= $roocms->userip; |
|
68 | + $this->referer &= $roocms->referer; |
|
69 | 69 | |
70 | - # init useragent |
|
71 | - $this->get_useragent(); |
|
70 | + # init useragent |
|
71 | + $this->get_useragent(); |
|
72 | 72 | |
73 | - # check useragent for detect spider bot |
|
74 | - $roocms->check_spider_bot($this->useragent); |
|
73 | + # check useragent for detect spider bot |
|
74 | + $roocms->check_spider_bot($this->useragent); |
|
75 | 75 | |
76 | - # init user |
|
77 | - $this->init_user(); |
|
76 | + # init user |
|
77 | + $this->init_user(); |
|
78 | 78 | |
79 | - if($this->uid != 0) { |
|
80 | - # control user data for security |
|
81 | - $this->control_userdata(); |
|
79 | + if($this->uid != 0) { |
|
80 | + # control user data for security |
|
81 | + $this->control_userdata(); |
|
82 | 82 | |
83 | - # update users info |
|
84 | - $this->update_user_time_last_visit($this->uid); |
|
85 | - } |
|
86 | - } |
|
83 | + # update users info |
|
84 | + $this->update_user_time_last_visit($this->uid); |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * Получаем персональные данные пользователя |
|
91 | - */ |
|
92 | - private function init_user() { |
|
89 | + /** |
|
90 | + * Получаем персональные данные пользователя |
|
91 | + */ |
|
92 | + private function init_user() { |
|
93 | 93 | |
94 | - global $db, $roocms, $parse; |
|
94 | + global $db, $roocms, $parse; |
|
95 | 95 | |
96 | - if(isset($roocms->sess['login']) && $db->check_id($roocms->sess['login'], USERS_TABLE, "login", "status='1'") && isset($roocms->sess['token']) && mb_strlen($roocms->sess['token']) == 32) { |
|
96 | + if(isset($roocms->sess['login']) && $db->check_id($roocms->sess['login'], USERS_TABLE, "login", "status='1'") && isset($roocms->sess['token']) && mb_strlen($roocms->sess['token']) == 32) { |
|
97 | 97 | |
98 | - # get data |
|
99 | - $q = $db->query("SELECT u.uid, u.gid, u.login, u.nickname, u.avatar, u.email, u.mailing, |
|
98 | + # get data |
|
99 | + $q = $db->query("SELECT u.uid, u.gid, u.login, u.nickname, u.avatar, u.email, u.mailing, |
|
100 | 100 | u.user_name, u.user_surname, u.user_last_name, u.user_birthdate, u.user_sex, u.user_slogan, |
101 | 101 | u.title, u.password, u.salt, u.ban, u.ban_reason, u.ban_expiried, u.date_create, u.secret_key, |
102 | 102 | g.title as gtitle |
103 | 103 | FROM ".USERS_TABLE." AS u |
104 | 104 | LEFT JOIN ".USERS_GROUP_TABLE." AS g ON (g.gid = u.gid) |
105 | 105 | WHERE u.login='".$roocms->sess['login']."' AND u.status='1'"); |
106 | - $data = $db->fetch_assoc($q); |
|
107 | - |
|
108 | - # uid |
|
109 | - $this->uid = (int) $data['uid']; |
|
110 | - # gid |
|
111 | - $this->gid = (int) $data['gid']; |
|
112 | - # gtitle |
|
113 | - $this->gtitle = $data['gtitle']; |
|
114 | - # login |
|
115 | - $this->login = $data['login']; |
|
116 | - # title |
|
117 | - $this->title = $data['title']; |
|
118 | - # nickname |
|
119 | - $this->nickname = $data['nickname']; |
|
120 | - # avatar |
|
121 | - $this->avatar = $data['avatar']; |
|
122 | ||
123 | - $this->email = $data['email']; |
|
124 | - # ban |
|
125 | - $this->ban = $data['ban']; |
|
126 | - $this->ban_reason = $data['ban_reason']; |
|
127 | - $this->ban_expiried = $data['ban_expiried']; |
|
128 | - |
|
129 | - # array userdata |
|
130 | - $this->userdata = array( |
|
131 | - 'uid' => (int) $data['uid'], |
|
132 | - 'gid' => (int) $data['gid'], |
|
133 | - 'gtitle' => $data['gtitle'], |
|
134 | - 'login' => $data['login'], |
|
135 | - 'nickname' => $data['nickname'], |
|
136 | - 'avatar' => $data['avatar'], |
|
137 | - 'email' => $data['email'], |
|
138 | - 'mailing' => $data['mailing'], |
|
139 | - 'title' => $data['title'], |
|
140 | - 'user_name' => $data['user_name'], |
|
141 | - 'user_surname' => $data['user_surname'], |
|
142 | - 'user_last_name' => $data['user_last_name'], |
|
143 | - 'user_birthdate' => $parse->date->jd_to_rus($data['user_birthdate']), |
|
144 | - 'user_birthdaten' => $parse->date->jd_to_rusint($data['user_birthdate']), |
|
145 | - 'user_sex' => $data['user_sex'], |
|
146 | - 'user_slogan' => $parse->text->br($data['user_slogan']), |
|
147 | - 'ban' => $data['ban'], |
|
148 | - 'ban_reason' => $data['ban_reason'], |
|
149 | - 'ban_expiried' => $parse->date->unix_to_rus($data['ban_expiried']), |
|
150 | - 'secret_key' => $data['secret_key'], |
|
151 | - 'date_create' => $parse->date->unix_to_rus($data['date_create']) |
|
152 | - ); |
|
153 | - |
|
154 | - |
|
155 | - # security token |
|
156 | - $this->token = $this->get_token($roocms->sess['login'], $data['password'], $data['salt']); |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Обновляем простую информацию пользователя, вроде времени последнего визита на сайт. |
|
163 | - * |
|
164 | - * @param int $uid - уникальные идентификатор пользователя |
|
165 | - */ |
|
166 | - private function update_user_time_last_visit($uid) { |
|
167 | - |
|
168 | - global $db, $roocms; |
|
169 | - |
|
170 | - # update time last visited |
|
171 | - $db->query("UPDATE ".USERS_TABLE." SET last_visit='".time()."', user_ip='".$roocms->userip."' WHERE uid='".$uid."' AND status='1'"); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * Get user data |
|
177 | - * |
|
178 | - * @param int $uid - user id |
|
179 | - * |
|
180 | - * @return array user data |
|
181 | - */ |
|
182 | - public function get_user_data($uid) { |
|
183 | - |
|
184 | - global $db, $parse; |
|
185 | - |
|
186 | - # default |
|
187 | - $row = array( |
|
188 | - 'uid' => 0, |
|
189 | - ); |
|
190 | - |
|
191 | - # check and get data |
|
192 | - if($db->check_id($uid, USERS_TABLE, "uid")) { |
|
193 | - $q = $db->query("SELECT uid, nickname, email, user_sex, user_slogan, avatar, user_birthdate, status, ban, ban_expiried, ban_reason, secret_key FROM ".USERS_TABLE." WHERE uid='".$uid."'"); |
|
194 | - $row = $db->fetch_assoc($q); |
|
195 | - |
|
196 | - $row['slogan'] = $parse->text->br($row['user_slogan']); |
|
197 | - $row['user_birthdate'] = $parse->date->jd_to_rus($row['user_birthdate']); |
|
198 | - } |
|
199 | - |
|
200 | - return $row; |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * Get users list |
|
206 | - * |
|
207 | - * @param int $status - current user status: 1 active user, 0 unactive user, -1 all user |
|
208 | - * @param int $ban - ban status: 0 without ban, 1 with ban, -1 all |
|
209 | - * @param int $mailing - subscrib status: 0 no, 1 yes, -1 all |
|
210 | - * @param array $users - array id's users |
|
211 | - * |
|
212 | - * @return array |
|
213 | - */ |
|
214 | - public function get_userlist($status=-1, $ban=-1, $mailing=-1, $users=[]) { |
|
215 | - |
|
216 | - global $db, $parse; |
|
217 | - |
|
218 | - # condition |
|
219 | - $cond = ""; |
|
220 | - |
|
221 | - $arcond = array("status"=>$status, "ban"=>$ban, "mailing"=>$mailing); |
|
222 | - |
|
223 | - foreach($arcond AS $k=>$v) { |
|
224 | - |
|
225 | - if($v == 0 || $v == 1) { |
|
226 | - $cond = $db->qcond_and($cond); |
|
227 | - $cond .= " ".$k."='".$v."' "; |
|
228 | - } |
|
229 | - } |
|
230 | - |
|
231 | - if(!empty($users)) { |
|
232 | - |
|
233 | - $cond = $db->qcond_and($cond); |
|
234 | - |
|
235 | - $uids = []; |
|
236 | - foreach($users AS $k=>$v) { |
|
237 | - $uids[] = " uid='".$v."' "; |
|
238 | - } |
|
239 | - |
|
240 | - $cond .= " ( ".implode(" OR ", $uids)." ) "; |
|
241 | - } |
|
242 | - |
|
243 | - # condition formating |
|
244 | - if($cond != "") { |
|
245 | - $cond = "WHERE".$cond; |
|
246 | - } |
|
247 | - |
|
248 | - # Get user list |
|
249 | - $userlist = []; |
|
250 | - $q = $db->query("SELECT uid, nickname, email, user_sex, user_slogan, avatar, user_birthdate, status, ban, ban_expiried, ban_reason, secret_key FROM ".USERS_TABLE." ".$cond." ORDER BY nickname ASC"); |
|
251 | - while($row = $db->fetch_assoc($q)) { |
|
252 | - $row['slogan'] = $parse->text->br($row['user_slogan']); |
|
106 | + $data = $db->fetch_assoc($q); |
|
107 | + |
|
108 | + # uid |
|
109 | + $this->uid = (int) $data['uid']; |
|
110 | + # gid |
|
111 | + $this->gid = (int) $data['gid']; |
|
112 | + # gtitle |
|
113 | + $this->gtitle = $data['gtitle']; |
|
114 | + # login |
|
115 | + $this->login = $data['login']; |
|
116 | + # title |
|
117 | + $this->title = $data['title']; |
|
118 | + # nickname |
|
119 | + $this->nickname = $data['nickname']; |
|
120 | + # avatar |
|
121 | + $this->avatar = $data['avatar']; |
|
122 | ||
123 | + $this->email = $data['email']; |
|
124 | + # ban |
|
125 | + $this->ban = $data['ban']; |
|
126 | + $this->ban_reason = $data['ban_reason']; |
|
127 | + $this->ban_expiried = $data['ban_expiried']; |
|
128 | + |
|
129 | + # array userdata |
|
130 | + $this->userdata = array( |
|
131 | + 'uid' => (int) $data['uid'], |
|
132 | + 'gid' => (int) $data['gid'], |
|
133 | + 'gtitle' => $data['gtitle'], |
|
134 | + 'login' => $data['login'], |
|
135 | + 'nickname' => $data['nickname'], |
|
136 | + 'avatar' => $data['avatar'], |
|
137 | + 'email' => $data['email'], |
|
138 | + 'mailing' => $data['mailing'], |
|
139 | + 'title' => $data['title'], |
|
140 | + 'user_name' => $data['user_name'], |
|
141 | + 'user_surname' => $data['user_surname'], |
|
142 | + 'user_last_name' => $data['user_last_name'], |
|
143 | + 'user_birthdate' => $parse->date->jd_to_rus($data['user_birthdate']), |
|
144 | + 'user_birthdaten' => $parse->date->jd_to_rusint($data['user_birthdate']), |
|
145 | + 'user_sex' => $data['user_sex'], |
|
146 | + 'user_slogan' => $parse->text->br($data['user_slogan']), |
|
147 | + 'ban' => $data['ban'], |
|
148 | + 'ban_reason' => $data['ban_reason'], |
|
149 | + 'ban_expiried' => $parse->date->unix_to_rus($data['ban_expiried']), |
|
150 | + 'secret_key' => $data['secret_key'], |
|
151 | + 'date_create' => $parse->date->unix_to_rus($data['date_create']) |
|
152 | + ); |
|
153 | + |
|
154 | + |
|
155 | + # security token |
|
156 | + $this->token = $this->get_token($roocms->sess['login'], $data['password'], $data['salt']); |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Обновляем простую информацию пользователя, вроде времени последнего визита на сайт. |
|
163 | + * |
|
164 | + * @param int $uid - уникальные идентификатор пользователя |
|
165 | + */ |
|
166 | + private function update_user_time_last_visit($uid) { |
|
167 | + |
|
168 | + global $db, $roocms; |
|
169 | + |
|
170 | + # update time last visited |
|
171 | + $db->query("UPDATE ".USERS_TABLE." SET last_visit='".time()."', user_ip='".$roocms->userip."' WHERE uid='".$uid."' AND status='1'"); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * Get user data |
|
177 | + * |
|
178 | + * @param int $uid - user id |
|
179 | + * |
|
180 | + * @return array user data |
|
181 | + */ |
|
182 | + public function get_user_data($uid) { |
|
183 | + |
|
184 | + global $db, $parse; |
|
185 | + |
|
186 | + # default |
|
187 | + $row = array( |
|
188 | + 'uid' => 0, |
|
189 | + ); |
|
190 | + |
|
191 | + # check and get data |
|
192 | + if($db->check_id($uid, USERS_TABLE, "uid")) { |
|
193 | + $q = $db->query("SELECT uid, nickname, email, user_sex, user_slogan, avatar, user_birthdate, status, ban, ban_expiried, ban_reason, secret_key FROM ".USERS_TABLE." WHERE uid='".$uid."'"); |
|
194 | + $row = $db->fetch_assoc($q); |
|
195 | + |
|
196 | + $row['slogan'] = $parse->text->br($row['user_slogan']); |
|
197 | + $row['user_birthdate'] = $parse->date->jd_to_rus($row['user_birthdate']); |
|
198 | + } |
|
199 | + |
|
200 | + return $row; |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * Get users list |
|
206 | + * |
|
207 | + * @param int $status - current user status: 1 active user, 0 unactive user, -1 all user |
|
208 | + * @param int $ban - ban status: 0 without ban, 1 with ban, -1 all |
|
209 | + * @param int $mailing - subscrib status: 0 no, 1 yes, -1 all |
|
210 | + * @param array $users - array id's users |
|
211 | + * |
|
212 | + * @return array |
|
213 | + */ |
|
214 | + public function get_userlist($status=-1, $ban=-1, $mailing=-1, $users=[]) { |
|
215 | + |
|
216 | + global $db, $parse; |
|
217 | + |
|
218 | + # condition |
|
219 | + $cond = ""; |
|
220 | + |
|
221 | + $arcond = array("status"=>$status, "ban"=>$ban, "mailing"=>$mailing); |
|
222 | + |
|
223 | + foreach($arcond AS $k=>$v) { |
|
224 | + |
|
225 | + if($v == 0 || $v == 1) { |
|
226 | + $cond = $db->qcond_and($cond); |
|
227 | + $cond .= " ".$k."='".$v."' "; |
|
228 | + } |
|
229 | + } |
|
230 | + |
|
231 | + if(!empty($users)) { |
|
232 | + |
|
233 | + $cond = $db->qcond_and($cond); |
|
234 | + |
|
235 | + $uids = []; |
|
236 | + foreach($users AS $k=>$v) { |
|
237 | + $uids[] = " uid='".$v."' "; |
|
238 | + } |
|
239 | + |
|
240 | + $cond .= " ( ".implode(" OR ", $uids)." ) "; |
|
241 | + } |
|
242 | + |
|
243 | + # condition formating |
|
244 | + if($cond != "") { |
|
245 | + $cond = "WHERE".$cond; |
|
246 | + } |
|
247 | + |
|
248 | + # Get user list |
|
249 | + $userlist = []; |
|
250 | + $q = $db->query("SELECT uid, nickname, email, user_sex, user_slogan, avatar, user_birthdate, status, ban, ban_expiried, ban_reason, secret_key FROM ".USERS_TABLE." ".$cond." ORDER BY nickname ASC"); |
|
251 | + while($row = $db->fetch_assoc($q)) { |
|
252 | + $row['slogan'] = $parse->text->br($row['user_slogan']); |
|
253 | 253 | |
254 | - $userlist[$row['uid']] = $row; |
|
255 | - } |
|
256 | - |
|
257 | - return $userlist; |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * Проверяем поля на уникальность |
|
263 | - * |
|
264 | - * ВНИМАНИЕ! Не расчитывайте на эту функцию, она временная. |
|
265 | - * |
|
266 | - * @param string $field - поле |
|
267 | - * @param string $name - значение поля |
|
268 | - * @param string $without - Выражение исключения для mysql запроса |
|
269 | - * @param string $table - Таблица для проверки |
|
270 | - * |
|
271 | - * @return bool $res - true - если значение не уникально, false - если значение уникально |
|
272 | - */ |
|
273 | - public function check_field($field, $name, $without="", $table=USERS_TABLE) { |
|
274 | - |
|
275 | - global $db; |
|
276 | - |
|
277 | - $res = false; |
|
278 | - |
|
279 | - if(trim($without) != trim($name)) { |
|
280 | - $w = $field."!='".trim($without)."'"; |
|
281 | - |
|
282 | - if(!$db->check_id($name, $table, $field, $w)) { |
|
283 | - $res = true; |
|
284 | - } |
|
285 | - } |
|
286 | - else { |
|
287 | - $res = true; |
|
288 | - } |
|
289 | - |
|
290 | - return $res; |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * Функция проверки почты пользователя. |
|
296 | - * Проверяем на дубли и корректность. |
|
297 | - * |
|
298 | - * @param string $email - адрес электронной почты пользователя. |
|
299 | - */ |
|
300 | - public function valid_user_email($email) { |
|
301 | - |
|
302 | - global $db, $logger, $parse; |
|
303 | - |
|
304 | - if(trim($email) != "") { |
|
305 | - if(!$parse->valid_email($email)) { |
|
306 | - $logger->error("Некорректный адрес электронной почты", false); |
|
307 | - } |
|
308 | - |
|
309 | - if($db->check_id($email, USERS_TABLE, "email")) { |
|
310 | - $logger->error("Пользователь с таким адресом почты уже есть в нашей базе данных", false); |
|
311 | - } |
|
312 | - } |
|
313 | - else { |
|
314 | - $logger->error("Электронная почта обязательная для каждого пользователя", false); |
|
315 | - } |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - /** |
|
320 | - * Функция проверяет Никнейм на уникальность. |
|
321 | - * В случае повторения добавляет к никнейму несколько цифр. |
|
322 | - * |
|
323 | - * ВНИМАНИЕ! Не расчитывайте на эту функцию. Она временная. |
|
324 | - * |
|
325 | - * @param string $nickname - Никнейм |
|
326 | - * |
|
327 | - * @return string |
|
328 | - */ |
|
329 | - public function uniq_nickname($nickname) { |
|
330 | - |
|
331 | - global $db, $logger; |
|
332 | - |
|
333 | - static $nick = NULL; |
|
334 | - |
|
335 | - if(!isset($nick)) { |
|
336 | - $nick = $nickname; |
|
337 | - } |
|
338 | - |
|
339 | - # Проверяем на уникальность |
|
340 | - if($db->check_id($nickname, USERS_TABLE, "nickname")) { |
|
341 | - $nickname = $this->uniq_nickname($nickname.randcode(2,"0123456789")); |
|
342 | - $notice = "Псевдоним ".$nick." недоступен. Был присвоен псевдоним ".$nickname; |
|
343 | - } |
|
344 | - |
|
345 | - # уведомление если оно есть |
|
346 | - if(isset($notice)) { |
|
347 | - $logger->info($notice, false); |
|
348 | - } |
|
349 | - |
|
350 | - return $nickname; |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * Проверяем персональные данные пользователя при попытки их создания и обновления |
|
356 | - */ |
|
357 | - public function correct_personal_data() { |
|
358 | - |
|
359 | - global $post, $parse; |
|
360 | - |
|
361 | - # user name/surname/last_name |
|
362 | - if(!isset($post->user_name)) { |
|
363 | - $post->user_name = ""; |
|
364 | - } |
|
365 | - if(!isset($post->user_surname)) { |
|
366 | - $post->user_surname = ""; |
|
367 | - } |
|
368 | - if(!isset($post->user_last_name)) { |
|
369 | - $post->user_last_name = ""; |
|
370 | - } |
|
371 | - |
|
372 | - # user birthdate |
|
373 | - if(isset($post->user_birthdate) && $post->user_birthdate != "") { |
|
374 | - $post->user_birthdate = $parse->date->rusint_to_jd($post->user_birthdate); |
|
375 | - } |
|
376 | - else { |
|
377 | - $post->user_birthdate = 0; |
|
378 | - } |
|
379 | - |
|
380 | - #check user sex |
|
381 | - switch($post->user_sex) { |
|
382 | - case 'm': |
|
383 | - $post->user_sex = "m"; |
|
384 | - break; |
|
385 | - case 'f': |
|
386 | - $post->user_sex = "f"; |
|
387 | - break; |
|
388 | - default: |
|
389 | - $post->user_sex = "n"; |
|
390 | - break; |
|
391 | - } |
|
392 | - |
|
393 | - # mailing |
|
394 | - if(!isset($post->mailing) || round($post->mailing) != 1) { |
|
395 | - $post->mailing = 0; |
|
396 | - } |
|
397 | - |
|
398 | - # check slogan |
|
399 | - if(!isset($post->user_slogan)) { |
|
400 | - $post->user_slogan = ""; |
|
401 | - } |
|
402 | - |
|
403 | - $post->user_slogan = $parse->text->clearhtml($post->user_slogan); |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * Функция проверяет никнейм пользователя указанный во время создания учетной записи |
|
409 | - */ |
|
410 | - public function check_create_nickname() { |
|
411 | - |
|
412 | - global $post; |
|
413 | - |
|
414 | - # Если никнейм не ввведен, делаем никнем из логина |
|
415 | - if(!isset($post->nickname) && isset($post->login)) { |
|
416 | - $post->nickname = mb_ucfirst($post->nickname); |
|
417 | - } |
|
418 | - |
|
419 | - # теперь проверяем на никальность |
|
420 | - if(isset($post->nickname)) { |
|
421 | - $post->nickname = $this->uniq_nickname($post->nickname); |
|
422 | - } |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * Функция проверяет логин пользователя указанный во время создания учетной записи |
|
428 | - */ |
|
429 | - public function check_create_login() { |
|
430 | - |
|
431 | - global $db, $post, $parse, $logger; |
|
432 | - |
|
433 | - if(!isset($post->login)) { |
|
434 | - if(isset($post->nickname)) { |
|
435 | - $post->login = mb_strtolower($parse->text->transliterate($post->nickname)); |
|
436 | - } |
|
437 | - else { |
|
438 | - $logger->error("У пользователя должен быть логин!", false); |
|
439 | - } |
|
440 | - } |
|
441 | - else { |
|
442 | - $post->login = mb_strtolower($parse->text->transliterate($post->login)); |
|
443 | - } |
|
444 | - |
|
445 | - if(isset($post->login) && $db->check_id($post->login, USERS_TABLE, "login")) { |
|
446 | - $logger->error("Логин ".$post->login." недоступен.", false); |
|
447 | - } |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - /** |
|
452 | - * Get useragent string from user |
|
453 | - */ |
|
454 | - public function get_useragent() { |
|
455 | - |
|
456 | - if(!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
457 | - $this->useragent = mb_strtolower($_SERVER['HTTP_USER_AGENT']); |
|
458 | - } |
|
459 | - } |
|
254 | + $userlist[$row['uid']] = $row; |
|
255 | + } |
|
256 | + |
|
257 | + return $userlist; |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * Проверяем поля на уникальность |
|
263 | + * |
|
264 | + * ВНИМАНИЕ! Не расчитывайте на эту функцию, она временная. |
|
265 | + * |
|
266 | + * @param string $field - поле |
|
267 | + * @param string $name - значение поля |
|
268 | + * @param string $without - Выражение исключения для mysql запроса |
|
269 | + * @param string $table - Таблица для проверки |
|
270 | + * |
|
271 | + * @return bool $res - true - если значение не уникально, false - если значение уникально |
|
272 | + */ |
|
273 | + public function check_field($field, $name, $without="", $table=USERS_TABLE) { |
|
274 | + |
|
275 | + global $db; |
|
276 | + |
|
277 | + $res = false; |
|
278 | + |
|
279 | + if(trim($without) != trim($name)) { |
|
280 | + $w = $field."!='".trim($without)."'"; |
|
281 | + |
|
282 | + if(!$db->check_id($name, $table, $field, $w)) { |
|
283 | + $res = true; |
|
284 | + } |
|
285 | + } |
|
286 | + else { |
|
287 | + $res = true; |
|
288 | + } |
|
289 | + |
|
290 | + return $res; |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * Функция проверки почты пользователя. |
|
296 | + * Проверяем на дубли и корректность. |
|
297 | + * |
|
298 | + * @param string $email - адрес электронной почты пользователя. |
|
299 | + */ |
|
300 | + public function valid_user_email($email) { |
|
301 | + |
|
302 | + global $db, $logger, $parse; |
|
303 | + |
|
304 | + if(trim($email) != "") { |
|
305 | + if(!$parse->valid_email($email)) { |
|
306 | + $logger->error("Некорректный адрес электронной почты", false); |
|
307 | + } |
|
308 | + |
|
309 | + if($db->check_id($email, USERS_TABLE, "email")) { |
|
310 | + $logger->error("Пользователь с таким адресом почты уже есть в нашей базе данных", false); |
|
311 | + } |
|
312 | + } |
|
313 | + else { |
|
314 | + $logger->error("Электронная почта обязательная для каждого пользователя", false); |
|
315 | + } |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + /** |
|
320 | + * Функция проверяет Никнейм на уникальность. |
|
321 | + * В случае повторения добавляет к никнейму несколько цифр. |
|
322 | + * |
|
323 | + * ВНИМАНИЕ! Не расчитывайте на эту функцию. Она временная. |
|
324 | + * |
|
325 | + * @param string $nickname - Никнейм |
|
326 | + * |
|
327 | + * @return string |
|
328 | + */ |
|
329 | + public function uniq_nickname($nickname) { |
|
330 | + |
|
331 | + global $db, $logger; |
|
332 | + |
|
333 | + static $nick = NULL; |
|
334 | + |
|
335 | + if(!isset($nick)) { |
|
336 | + $nick = $nickname; |
|
337 | + } |
|
338 | + |
|
339 | + # Проверяем на уникальность |
|
340 | + if($db->check_id($nickname, USERS_TABLE, "nickname")) { |
|
341 | + $nickname = $this->uniq_nickname($nickname.randcode(2,"0123456789")); |
|
342 | + $notice = "Псевдоним ".$nick." недоступен. Был присвоен псевдоним ".$nickname; |
|
343 | + } |
|
344 | + |
|
345 | + # уведомление если оно есть |
|
346 | + if(isset($notice)) { |
|
347 | + $logger->info($notice, false); |
|
348 | + } |
|
349 | + |
|
350 | + return $nickname; |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * Проверяем персональные данные пользователя при попытки их создания и обновления |
|
356 | + */ |
|
357 | + public function correct_personal_data() { |
|
358 | + |
|
359 | + global $post, $parse; |
|
360 | + |
|
361 | + # user name/surname/last_name |
|
362 | + if(!isset($post->user_name)) { |
|
363 | + $post->user_name = ""; |
|
364 | + } |
|
365 | + if(!isset($post->user_surname)) { |
|
366 | + $post->user_surname = ""; |
|
367 | + } |
|
368 | + if(!isset($post->user_last_name)) { |
|
369 | + $post->user_last_name = ""; |
|
370 | + } |
|
371 | + |
|
372 | + # user birthdate |
|
373 | + if(isset($post->user_birthdate) && $post->user_birthdate != "") { |
|
374 | + $post->user_birthdate = $parse->date->rusint_to_jd($post->user_birthdate); |
|
375 | + } |
|
376 | + else { |
|
377 | + $post->user_birthdate = 0; |
|
378 | + } |
|
379 | + |
|
380 | + #check user sex |
|
381 | + switch($post->user_sex) { |
|
382 | + case 'm': |
|
383 | + $post->user_sex = "m"; |
|
384 | + break; |
|
385 | + case 'f': |
|
386 | + $post->user_sex = "f"; |
|
387 | + break; |
|
388 | + default: |
|
389 | + $post->user_sex = "n"; |
|
390 | + break; |
|
391 | + } |
|
392 | + |
|
393 | + # mailing |
|
394 | + if(!isset($post->mailing) || round($post->mailing) != 1) { |
|
395 | + $post->mailing = 0; |
|
396 | + } |
|
397 | + |
|
398 | + # check slogan |
|
399 | + if(!isset($post->user_slogan)) { |
|
400 | + $post->user_slogan = ""; |
|
401 | + } |
|
402 | + |
|
403 | + $post->user_slogan = $parse->text->clearhtml($post->user_slogan); |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * Функция проверяет никнейм пользователя указанный во время создания учетной записи |
|
409 | + */ |
|
410 | + public function check_create_nickname() { |
|
411 | + |
|
412 | + global $post; |
|
413 | + |
|
414 | + # Если никнейм не ввведен, делаем никнем из логина |
|
415 | + if(!isset($post->nickname) && isset($post->login)) { |
|
416 | + $post->nickname = mb_ucfirst($post->nickname); |
|
417 | + } |
|
418 | + |
|
419 | + # теперь проверяем на никальность |
|
420 | + if(isset($post->nickname)) { |
|
421 | + $post->nickname = $this->uniq_nickname($post->nickname); |
|
422 | + } |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * Функция проверяет логин пользователя указанный во время создания учетной записи |
|
428 | + */ |
|
429 | + public function check_create_login() { |
|
430 | + |
|
431 | + global $db, $post, $parse, $logger; |
|
432 | + |
|
433 | + if(!isset($post->login)) { |
|
434 | + if(isset($post->nickname)) { |
|
435 | + $post->login = mb_strtolower($parse->text->transliterate($post->nickname)); |
|
436 | + } |
|
437 | + else { |
|
438 | + $logger->error("У пользователя должен быть логин!", false); |
|
439 | + } |
|
440 | + } |
|
441 | + else { |
|
442 | + $post->login = mb_strtolower($parse->text->transliterate($post->login)); |
|
443 | + } |
|
444 | + |
|
445 | + if(isset($post->login) && $db->check_id($post->login, USERS_TABLE, "login")) { |
|
446 | + $logger->error("Логин ".$post->login." недоступен.", false); |
|
447 | + } |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + /** |
|
452 | + * Get useragent string from user |
|
453 | + */ |
|
454 | + public function get_useragent() { |
|
455 | + |
|
456 | + if(!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
457 | + $this->useragent = mb_strtolower($_SERVER['HTTP_USER_AGENT']); |
|
458 | + } |
|
459 | + } |
|
460 | 460 | } |
@@ -29,29 +29,29 @@ discard block |
||
29 | 29 | use UserAvatar; |
30 | 30 | |
31 | 31 | # user uniq data |
32 | - public $uid = 0; # user id |
|
33 | - public $login = ""; # user login |
|
34 | - public $nickname = ""; # user nickname |
|
35 | - public $avatar = ""; # user avatar |
|
36 | - public $email = ""; # user nickname |
|
37 | - public $title = "u"; # user title |
|
38 | - public $gid = 0; # user group id |
|
39 | - public $gtitle = ""; # user group title |
|
40 | - public $token = ""; # user security token |
|
32 | + public $uid = 0; # user id |
|
33 | + public $login = ""; # user login |
|
34 | + public $nickname = ""; # user nickname |
|
35 | + public $avatar = ""; # user avatar |
|
36 | + public $email = ""; # user nickname |
|
37 | + public $title = "u"; # user title |
|
38 | + public $gid = 0; # user group id |
|
39 | + public $gtitle = ""; # user group title |
|
40 | + public $token = ""; # user security token |
|
41 | 41 | |
42 | 42 | # user ban status |
43 | - public $ban = 0; # ban status |
|
44 | - public $ban_reason = ""; # ban reason |
|
45 | - public $ban_expiried = 0; # ban date expiried (unixtimestamp) |
|
43 | + public $ban = 0; # ban status |
|
44 | + public $ban_reason = ""; # ban reason |
|
45 | + public $ban_expiried = 0; # ban date expiried (unixtimestamp) |
|
46 | 46 | |
47 | 47 | # user data array |
48 | - public $userdata = array('uid'=>0, 'gid'=>0, 'title'=>'u'); |
|
48 | + public $userdata = array('uid'=>0, 'gid'=>0, 'title'=>'u'); |
|
49 | 49 | |
50 | 50 | # user global data |
51 | - private $usersession = ""; # user session |
|
52 | - private $userip = ""; # user ip address |
|
53 | - private $useragent = ""; # user agent string |
|
54 | - private $referer = ""; # user referer |
|
51 | + private $usersession = ""; # user session |
|
52 | + private $userip = ""; # user ip address |
|
53 | + private $useragent = ""; # user agent string |
|
54 | + private $referer = ""; # user referer |
|
55 | 55 | |
56 | 56 | |
57 | 57 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | if(isset($roocms->sess['login']) && $db->check_id($roocms->sess['login'], USERS_TABLE, "login", "status='1'") && isset($roocms->sess['token']) && mb_strlen($roocms->sess['token']) == 32) { |
97 | 97 | |
98 | 98 | # get data |
99 | - $q = $db->query("SELECT u.uid, u.gid, u.login, u.nickname, u.avatar, u.email, u.mailing, |
|
99 | + $q = $db->query("SELECT u.uid, u.gid, u.login, u.nickname, u.avatar, u.email, u.mailing, |
|
100 | 100 | u.user_name, u.user_surname, u.user_last_name, u.user_birthdate, u.user_sex, u.user_slogan, |
101 | 101 | u.title, u.password, u.salt, u.ban, u.ban_reason, u.ban_expiried, u.date_create, u.secret_key, |
102 | 102 | g.title as gtitle |
@@ -110,21 +110,21 @@ discard block |
||
110 | 110 | # gid |
111 | 111 | $this->gid = (int) $data['gid']; |
112 | 112 | # gtitle |
113 | - $this->gtitle = $data['gtitle']; |
|
113 | + $this->gtitle = $data['gtitle']; |
|
114 | 114 | # login |
115 | 115 | $this->login = $data['login']; |
116 | 116 | # title |
117 | 117 | $this->title = $data['title']; |
118 | 118 | # nickname |
119 | - $this->nickname = $data['nickname']; |
|
119 | + $this->nickname = $data['nickname']; |
|
120 | 120 | # avatar |
121 | - $this->avatar = $data['avatar']; |
|
121 | + $this->avatar = $data['avatar']; |
|
122 | 122 | |
123 | - $this->email = $data['email']; |
|
123 | + $this->email = $data['email']; |
|
124 | 124 | # ban |
125 | - $this->ban = $data['ban']; |
|
126 | - $this->ban_reason = $data['ban_reason']; |
|
127 | - $this->ban_expiried = $data['ban_expiried']; |
|
125 | + $this->ban = $data['ban']; |
|
126 | + $this->ban_reason = $data['ban_reason']; |
|
127 | + $this->ban_expiried = $data['ban_expiried']; |
|
128 | 128 | |
129 | 129 | # array userdata |
130 | 130 | $this->userdata = array( |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return array |
213 | 213 | */ |
214 | - public function get_userlist($status=-1, $ban=-1, $mailing=-1, $users=[]) { |
|
214 | + public function get_userlist($status = -1, $ban = -1, $mailing = -1, $users = []) { |
|
215 | 215 | |
216 | 216 | global $db, $parse; |
217 | 217 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return bool $res - true - если значение не уникально, false - если значение уникально |
272 | 272 | */ |
273 | - public function check_field($field, $name, $without="", $table=USERS_TABLE) { |
|
273 | + public function check_field($field, $name, $without = "", $table = USERS_TABLE) { |
|
274 | 274 | |
275 | 275 | global $db; |
276 | 276 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | # Проверяем на уникальность |
340 | 340 | if($db->check_id($nickname, USERS_TABLE, "nickname")) { |
341 | - $nickname = $this->uniq_nickname($nickname.randcode(2,"0123456789")); |
|
341 | + $nickname = $this->uniq_nickname($nickname.randcode(2, "0123456789")); |
|
342 | 342 | $notice = "Псевдоним ".$nick." недоступен. Был присвоен псевдоним ".$nickname; |
343 | 343 | } |
344 | 344 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | } |
379 | 379 | |
380 | 380 | #check user sex |
381 | - switch($post->user_sex) { |
|
381 | + switch ($post->user_sex) { |
|
382 | 382 | case 'm': |
383 | 383 | $post->user_sex = "m"; |
384 | 384 | break; |
@@ -15,109 +15,109 @@ discard block |
||
15 | 15 | // Anti Hack |
16 | 16 | //--------------------------------------------------------- |
17 | 17 | if(!defined('RooCMS') || !defined('ACP')) { |
18 | - die('Access Denied'); |
|
18 | + die('Access Denied'); |
|
19 | 19 | } |
20 | 20 | //######################################################### |
21 | 21 | |
22 | 22 | |
23 | 23 | class ACP_Feeds_Feed { |
24 | 24 | |
25 | - use FeedExtends; |
|
25 | + use FeedExtends; |
|
26 | 26 | |
27 | - # vars |
|
28 | - private $feed = []; # structure parametrs |
|
29 | - private $userlist = []; |
|
27 | + # vars |
|
28 | + private $feed = []; # structure parametrs |
|
29 | + private $userlist = []; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * Key on "start" (c) |
|
35 | - * |
|
36 | - * @param $structure_data |
|
37 | - */ |
|
38 | - public function __construct($structure_data=[]) { |
|
39 | - $this->feed =& $structure_data; |
|
40 | - } |
|
33 | + /** |
|
34 | + * Key on "start" (c) |
|
35 | + * |
|
36 | + * @param $structure_data |
|
37 | + */ |
|
38 | + public function __construct($structure_data=[]) { |
|
39 | + $this->feed =& $structure_data; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * feed view |
|
45 | - */ |
|
46 | - public function control() { |
|
43 | + /** |
|
44 | + * feed view |
|
45 | + */ |
|
46 | + public function control() { |
|
47 | 47 | |
48 | - global $db, $parse, $tags, $tpl, $smarty; |
|
48 | + global $db, $parse, $tags, $tpl, $smarty; |
|
49 | 49 | |
50 | - # order request |
|
51 | - $order = $this->feed_order($this->feed['items_sorting']); |
|
50 | + # order request |
|
51 | + $order = $this->feed_order($this->feed['items_sorting']); |
|
52 | 52 | |
53 | - $smarty->assign("feed", $this->feed); |
|
53 | + $smarty->assign("feed", $this->feed); |
|
54 | 54 | |
55 | 55 | |
56 | - # feed items |
|
57 | - $taglinks = []; |
|
58 | - $feedlist = []; |
|
59 | - $q = $db->query("SELECT id, status, group_access, title, date_publications, date_end_publications, date_update, views FROM ".PAGES_FEED_TABLE." WHERE sid='".$this->feed['id']."' ORDER BY ".$order); |
|
60 | - while($row = $db->fetch_assoc($q)) { |
|
56 | + # feed items |
|
57 | + $taglinks = []; |
|
58 | + $feedlist = []; |
|
59 | + $q = $db->query("SELECT id, status, group_access, title, date_publications, date_end_publications, date_update, views FROM ".PAGES_FEED_TABLE." WHERE sid='".$this->feed['id']."' ORDER BY ".$order); |
|
60 | + while($row = $db->fetch_assoc($q)) { |
|
61 | 61 | |
62 | - # flag future publications |
|
63 | - $row['publication_future'] = ($row['date_publications'] > time()) ? true : false ; |
|
62 | + # flag future publications |
|
63 | + $row['publication_future'] = ($row['date_publications'] > time()) ? true : false ; |
|
64 | 64 | |
65 | - # flag show/hide |
|
66 | - $row['publication_status'] = "show"; |
|
65 | + # flag show/hide |
|
66 | + $row['publication_status'] = "show"; |
|
67 | 67 | |
68 | - if($row['date_end_publications'] != 0) { |
|
68 | + if($row['date_end_publications'] != 0) { |
|
69 | 69 | |
70 | - # hide publications if ending period |
|
71 | - if($row['date_end_publications'] < time()) { |
|
72 | - $row['publication_status'] = "hide"; |
|
73 | - } |
|
70 | + # hide publications if ending period |
|
71 | + if($row['date_end_publications'] < time()) { |
|
72 | + $row['publication_status'] = "hide"; |
|
73 | + } |
|
74 | 74 | |
75 | - # formated date |
|
76 | - $row['date_end_publications'] = $parse->date->unix_to_rus($row['date_end_publications']); |
|
77 | - } |
|
75 | + # formated date |
|
76 | + $row['date_end_publications'] = $parse->date->unix_to_rus($row['date_end_publications']); |
|
77 | + } |
|
78 | 78 | |
79 | - # formated date |
|
80 | - $row['date_publications'] = $parse->date->unix_to_rus($row['date_publications']); |
|
81 | - $row['date_update'] = $parse->date->unix_to_rus($row['date_update'], false, true, true); |
|
79 | + # formated date |
|
80 | + $row['date_publications'] = $parse->date->unix_to_rus($row['date_publications']); |
|
81 | + $row['date_update'] = $parse->date->unix_to_rus($row['date_update'], false, true, true); |
|
82 | 82 | |
83 | - $taglinks[$row['id']] = "feeditemid=".$row['id']; |
|
84 | - $feedlist[$row['id']] = $row; |
|
85 | - } |
|
83 | + $taglinks[$row['id']] = "feeditemid=".$row['id']; |
|
84 | + $feedlist[$row['id']] = $row; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | - # tags collect |
|
89 | - $feedlist = $tags->collect_tags($feedlist, $taglinks); |
|
88 | + # tags collect |
|
89 | + $feedlist = $tags->collect_tags($feedlist, $taglinks); |
|
90 | 90 | |
91 | - # smarty |
|
92 | - $smarty->assign("subfeeds", $this->feed['subfeeds']); |
|
93 | - $smarty->assign("feedlist", $feedlist); |
|
91 | + # smarty |
|
92 | + $smarty->assign("subfeeds", $this->feed['subfeeds']); |
|
93 | + $smarty->assign("feedlist", $feedlist); |
|
94 | 94 | |
95 | - $content = $tpl->load_template("feeds_control_feed", true); |
|
96 | - $smarty->assign("content", $content); |
|
97 | - } |
|
95 | + $content = $tpl->load_template("feeds_control_feed", true); |
|
96 | + $smarty->assign("content", $content); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * Create new record to feed |
|
102 | - */ |
|
103 | - public function create_item() { |
|
100 | + /** |
|
101 | + * Create new record to feed |
|
102 | + */ |
|
103 | + public function create_item() { |
|
104 | 104 | |
105 | - global $db, $users, $logger, $tags, $files, $img, $post, $tpl, $smarty; |
|
105 | + global $db, $users, $logger, $tags, $files, $img, $post, $tpl, $smarty; |
|
106 | 106 | |
107 | - # insert db |
|
108 | - if(isset($post->create_item)) { |
|
107 | + # insert db |
|
108 | + if(isset($post->create_item)) { |
|
109 | 109 | |
110 | - # Check post data |
|
111 | - $this->check_post_data_fields(); |
|
112 | - $this->control_post_data_date(); |
|
110 | + # Check post data |
|
111 | + $this->check_post_data_fields(); |
|
112 | + $this->control_post_data_date(); |
|
113 | 113 | |
114 | - if(!isset($_SESSION['error'])) { |
|
114 | + if(!isset($_SESSION['error'])) { |
|
115 | 115 | |
116 | - # Check secondary fields |
|
117 | - $this->correct_post_fields(); |
|
116 | + # Check secondary fields |
|
117 | + $this->correct_post_fields(); |
|
118 | 118 | |
119 | - # insert |
|
120 | - $db->query("INSERT INTO ".PAGES_FEED_TABLE." (title, meta_title, meta_description, meta_keywords, |
|
119 | + # insert |
|
120 | + $db->query("INSERT INTO ".PAGES_FEED_TABLE." (title, meta_title, meta_description, meta_keywords, |
|
121 | 121 | brief_item, full_item, author_id, |
122 | 122 | date_create, date_update, date_publications, date_end_publications, |
123 | 123 | group_access, |
@@ -128,159 +128,159 @@ discard block |
||
128 | 128 | '".$post->gids."', |
129 | 129 | '".$post->itemsort."', '".$this->feed['id']."')"); |
130 | 130 | |
131 | - # get feed item id |
|
132 | - $fiid = $db->insert_id(); |
|
131 | + # get feed item id |
|
132 | + $fiid = $db->insert_id(); |
|
133 | 133 | |
134 | - # save tags |
|
135 | - $tags->save_tags($post->tags, "feeditemid=".$fiid); |
|
134 | + # save tags |
|
135 | + $tags->save_tags($post->tags, "feeditemid=".$fiid); |
|
136 | 136 | |
137 | 137 | |
138 | - # attachment images |
|
139 | - $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
|
140 | - if($images) { |
|
141 | - foreach($images AS $image) { |
|
142 | - $img->insert_images($image, "feeditemid=".$fiid, $post->title); |
|
143 | - } |
|
144 | - } |
|
138 | + # attachment images |
|
139 | + $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
|
140 | + if($images) { |
|
141 | + foreach($images AS $image) { |
|
142 | + $img->insert_images($image, "feeditemid=".$fiid, $post->title); |
|
143 | + } |
|
144 | + } |
|
145 | 145 | |
146 | - # attachment files |
|
147 | - $files->upload("files", "feeditemid=".$fiid); |
|
146 | + # attachment files |
|
147 | + $files->upload("files", "feeditemid=".$fiid); |
|
148 | 148 | |
149 | - # recount items |
|
150 | - $this->count_items($this->feed['id']); |
|
149 | + # recount items |
|
150 | + $this->count_items($this->feed['id']); |
|
151 | 151 | |
152 | - # notice |
|
153 | - $logger->info("Запись #".$fiid." <".$post->title."> успешно создана."); |
|
152 | + # notice |
|
153 | + $logger->info("Запись #".$fiid." <".$post->title."> успешно создана."); |
|
154 | 154 | |
155 | - // TODO: Переделать! |
|
156 | - # mailling |
|
157 | - if($post->date_publications <= time() && $post->mailing == 1) { |
|
158 | - $this->mailing($fiid, $post->title, $post->brief_item); |
|
159 | - } |
|
160 | - } |
|
155 | + // TODO: Переделать! |
|
156 | + # mailling |
|
157 | + if($post->date_publications <= time() && $post->mailing == 1) { |
|
158 | + $this->mailing($fiid, $post->title, $post->brief_item); |
|
159 | + } |
|
160 | + } |
|
161 | 161 | |
162 | - # go |
|
163 | - go(CP."?act=feeds&part=control&page=".$this->feed['id']); |
|
164 | - } |
|
162 | + # go |
|
163 | + go(CP."?act=feeds&part=control&page=".$this->feed['id']); |
|
164 | + } |
|
165 | 165 | |
166 | - # userlist |
|
167 | - $this->userlist = $users->get_userlist(); |
|
166 | + # userlist |
|
167 | + $this->userlist = $users->get_userlist(); |
|
168 | 168 | |
169 | - # grouplist |
|
170 | - $groups = $users->get_usergroups(); |
|
169 | + # grouplist |
|
170 | + $groups = $users->get_usergroups(); |
|
171 | 171 | |
172 | - # popular tags |
|
173 | - $poptags = $tags->list_tags(true); |
|
172 | + # popular tags |
|
173 | + $poptags = $tags->list_tags(true); |
|
174 | 174 | |
175 | - # show upload files & images form |
|
176 | - $tpl->load_image_upload_tpl("imagesupload"); |
|
177 | - $tpl->load_files_upload_tpl("filesupload"); |
|
175 | + # show upload files & images form |
|
176 | + $tpl->load_image_upload_tpl("imagesupload"); |
|
177 | + $tpl->load_files_upload_tpl("filesupload"); |
|
178 | 178 | |
179 | - # smarty vars |
|
180 | - $smarty->assign("feed", $this->feed); # feed data |
|
181 | - $smarty->assign("poptags", $poptags); # tags |
|
182 | - $smarty->assign("userlist", $this->userlist); # users |
|
183 | - $smarty->assign("groups", $groups); # groups |
|
179 | + # smarty vars |
|
180 | + $smarty->assign("feed", $this->feed); # feed data |
|
181 | + $smarty->assign("poptags", $poptags); # tags |
|
182 | + $smarty->assign("userlist", $this->userlist); # users |
|
183 | + $smarty->assign("groups", $groups); # groups |
|
184 | 184 | |
185 | - # tpl |
|
186 | - $content = $tpl->load_template("feeds_create_item_feed", true); |
|
187 | - $smarty->assign("content", $content); |
|
188 | - } |
|
185 | + # tpl |
|
186 | + $content = $tpl->load_template("feeds_create_item_feed", true); |
|
187 | + $smarty->assign("content", $content); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | |
191 | - /** |
|
192 | - * Edit record from feed |
|
193 | - * |
|
194 | - * @param int $id - record identificator from feed |
|
195 | - */ |
|
196 | - public function edit_item($id) { |
|
191 | + /** |
|
192 | + * Edit record from feed |
|
193 | + * |
|
194 | + * @param int $id - record identificator from feed |
|
195 | + */ |
|
196 | + public function edit_item($id) { |
|
197 | 197 | |
198 | - global $db, $users, $tags, $files, $img, $tpl, $smarty, $parse; |
|
198 | + global $db, $users, $tags, $files, $img, $tpl, $smarty, $parse; |
|
199 | 199 | |
200 | - # userlist |
|
201 | - $this->userlist = $users->get_userlist(); |
|
200 | + # userlist |
|
201 | + $this->userlist = $users->get_userlist(); |
|
202 | 202 | |
203 | - # grouplist |
|
204 | - $groups = $users->get_usergroups(); |
|
203 | + # grouplist |
|
204 | + $groups = $users->get_usergroups(); |
|
205 | 205 | |
206 | - # get data |
|
207 | - $q = $db->query("SELECT id, sid, status, group_access, sort, title, meta_title, meta_description, meta_keywords, brief_item, full_item, author_id, date_publications, date_end_publications FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
208 | - $item = $db->fetch_assoc($q); |
|
206 | + # get data |
|
207 | + $q = $db->query("SELECT id, sid, status, group_access, sort, title, meta_title, meta_description, meta_keywords, brief_item, full_item, author_id, date_publications, date_end_publications FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
208 | + $item = $db->fetch_assoc($q); |
|
209 | 209 | |
210 | - $item['date_publications'] = $parse->date->unix_to_rusint($item['date_publications']); |
|
210 | + $item['date_publications'] = $parse->date->unix_to_rusint($item['date_publications']); |
|
211 | 211 | |
212 | - if($item['date_end_publications'] != 0) { |
|
213 | - $item['date_end_publications'] = $parse->date->unix_to_rusint($item['date_end_publications']); |
|
214 | - } |
|
212 | + if($item['date_end_publications'] != 0) { |
|
213 | + $item['date_end_publications'] = $parse->date->unix_to_rusint($item['date_end_publications']); |
|
214 | + } |
|
215 | 215 | |
216 | - # check access granted for groups |
|
217 | - $gids = $users->get_gid_access_granted($item['group_access']); |
|
216 | + # check access granted for groups |
|
217 | + $gids = $users->get_gid_access_granted($item['group_access']); |
|
218 | 218 | |
219 | - # item tags |
|
220 | - $item['tags'] = implode(", ", array_map(array("Tags", "get_tag_title"), $tags->read_tags("feeditemid=".$id))); |
|
219 | + # item tags |
|
220 | + $item['tags'] = implode(", ", array_map(array("Tags", "get_tag_title"), $tags->read_tags("feeditemid=".$id))); |
|
221 | 221 | |
222 | - # popular tags |
|
223 | - $poptags = $tags->list_tags(true); |
|
222 | + # popular tags |
|
223 | + $poptags = $tags->list_tags(true); |
|
224 | 224 | |
225 | 225 | |
226 | - # download attached images |
|
227 | - $attachimg = $img->load_images("feeditemid=".$id); |
|
228 | - $smarty->assign("attachimg", $attachimg); |
|
226 | + # download attached images |
|
227 | + $attachimg = $img->load_images("feeditemid=".$id); |
|
228 | + $smarty->assign("attachimg", $attachimg); |
|
229 | 229 | |
230 | - # show attached images |
|
231 | - $attachedimages = $tpl->load_template("attached_images", true); |
|
232 | - $smarty->assign("attachedimages", $attachedimages); |
|
230 | + # show attached images |
|
231 | + $attachedimages = $tpl->load_template("attached_images", true); |
|
232 | + $smarty->assign("attachedimages", $attachedimages); |
|
233 | 233 | |
234 | 234 | |
235 | - # download attached files |
|
236 | - $attachfile = $files->load_files("feeditemid=".$id); |
|
237 | - $smarty->assign("attachfile", $attachfile); |
|
235 | + # download attached files |
|
236 | + $attachfile = $files->load_files("feeditemid=".$id); |
|
237 | + $smarty->assign("attachfile", $attachfile); |
|
238 | 238 | |
239 | - # show attached files |
|
240 | - $attachedfiles = $tpl->load_template("attached_files", true); |
|
241 | - $smarty->assign("attachedfiles", $attachedfiles); |
|
239 | + # show attached files |
|
240 | + $attachedfiles = $tpl->load_template("attached_files", true); |
|
241 | + $smarty->assign("attachedfiles", $attachedfiles); |
|
242 | 242 | |
243 | 243 | |
244 | - # show upload files & images form |
|
245 | - $tpl->load_image_upload_tpl("imagesupload"); |
|
246 | - $tpl->load_files_upload_tpl("filesupload"); |
|
244 | + # show upload files & images form |
|
245 | + $tpl->load_image_upload_tpl("imagesupload"); |
|
246 | + $tpl->load_files_upload_tpl("filesupload"); |
|
247 | 247 | |
248 | 248 | |
249 | - # smarty vars |
|
250 | - $smarty->assign("item", $item); # item data |
|
251 | - $smarty->assign("feed", $this->feed); # feed data |
|
252 | - $smarty->assign("poptags", $poptags); # tags |
|
253 | - $smarty->assign("userlist", $this->userlist); # users list |
|
254 | - $smarty->assign("gids", $gids); # group id access granted |
|
255 | - $smarty->assign("groups", $groups); # group list |
|
249 | + # smarty vars |
|
250 | + $smarty->assign("item", $item); # item data |
|
251 | + $smarty->assign("feed", $this->feed); # feed data |
|
252 | + $smarty->assign("poptags", $poptags); # tags |
|
253 | + $smarty->assign("userlist", $this->userlist); # users list |
|
254 | + $smarty->assign("gids", $gids); # group id access granted |
|
255 | + $smarty->assign("groups", $groups); # group list |
|
256 | 256 | |
257 | - # tpl |
|
258 | - $content = $tpl->load_template("feeds_edit_item_feed", true); |
|
259 | - $smarty->assign("content", $content); |
|
260 | - } |
|
257 | + # tpl |
|
258 | + $content = $tpl->load_template("feeds_edit_item_feed", true); |
|
259 | + $smarty->assign("content", $content); |
|
260 | + } |
|
261 | 261 | |
262 | 262 | |
263 | - /** |
|
264 | - * Update record |
|
265 | - * |
|
266 | - * @param int $id - record identificator from feed |
|
267 | - */ |
|
268 | - public function update_item($id) { |
|
263 | + /** |
|
264 | + * Update record |
|
265 | + * |
|
266 | + * @param int $id - record identificator from feed |
|
267 | + */ |
|
268 | + public function update_item($id) { |
|
269 | 269 | |
270 | - global $db, $logger, $tags, $files, $img, $post, $get; |
|
270 | + global $db, $logger, $tags, $files, $img, $post, $get; |
|
271 | 271 | |
272 | - # Проверяем вводимые поля на ошибки |
|
273 | - $this->check_post_data_fields(); |
|
274 | - $this->control_post_data_date(); |
|
272 | + # Проверяем вводимые поля на ошибки |
|
273 | + $this->check_post_data_fields(); |
|
274 | + $this->control_post_data_date(); |
|
275 | 275 | |
276 | - # update |
|
277 | - if(!isset($_SESSION['error'])) { |
|
276 | + # update |
|
277 | + if(!isset($_SESSION['error'])) { |
|
278 | 278 | |
279 | 279 | # Check secondary fields |
280 | - $this->correct_post_fields(); |
|
280 | + $this->correct_post_fields(); |
|
281 | 281 | |
282 | - # update |
|
283 | - $db->query("UPDATE ".PAGES_FEED_TABLE." |
|
282 | + # update |
|
283 | + $db->query("UPDATE ".PAGES_FEED_TABLE." |
|
284 | 284 | SET |
285 | 285 | status = '".$post->status."', |
286 | 286 | group_access = '".$post->gids."', |
@@ -298,269 +298,269 @@ discard block |
||
298 | 298 | WHERE |
299 | 299 | id = '".$id."'"); |
300 | 300 | |
301 | - # save tags |
|
302 | - $tags->save_tags($post->tags, "feeditemid=".$id); |
|
301 | + # save tags |
|
302 | + $tags->save_tags($post->tags, "feeditemid=".$id); |
|
303 | 303 | |
304 | - # notice |
|
305 | - $logger->info("Запись #".$id." <".$post->title."> успешно отредактирована."); |
|
304 | + # notice |
|
305 | + $logger->info("Запись #".$id." <".$post->title."> успешно отредактирована."); |
|
306 | 306 | |
307 | - # update images |
|
308 | - $img->update_images_info("feeditemid", $id); |
|
307 | + # update images |
|
308 | + $img->update_images_info("feeditemid", $id); |
|
309 | 309 | |
310 | - # attachment images |
|
311 | - $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
|
312 | - if($images) { |
|
313 | - foreach($images AS $image) { |
|
314 | - $img->insert_images($image, "feeditemid=".$id, $post->title); |
|
315 | - } |
|
316 | - } |
|
310 | + # attachment images |
|
311 | + $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
|
312 | + if($images) { |
|
313 | + foreach($images AS $image) { |
|
314 | + $img->insert_images($image, "feeditemid=".$id, $post->title); |
|
315 | + } |
|
316 | + } |
|
317 | 317 | |
318 | - # attachment files |
|
319 | - $files->upload("files", "feeditemid=".$id); |
|
318 | + # attachment files |
|
319 | + $files->upload("files", "feeditemid=".$id); |
|
320 | 320 | |
321 | - # go |
|
322 | - go(CP."?act=feeds&part=control&page=".$get->_page); |
|
323 | - } |
|
321 | + # go |
|
322 | + go(CP."?act=feeds&part=control&page=".$get->_page); |
|
323 | + } |
|
324 | 324 | |
325 | - # back |
|
326 | - goback(); |
|
327 | - } |
|
325 | + # back |
|
326 | + goback(); |
|
327 | + } |
|
328 | 328 | |
329 | 329 | |
330 | - /** |
|
331 | - * Migrate record to another feed |
|
332 | - * |
|
333 | - * @param int $id - record identificator from feed |
|
334 | - */ |
|
335 | - public function migrate_item($id) { |
|
330 | + /** |
|
331 | + * Migrate record to another feed |
|
332 | + * |
|
333 | + * @param int $id - record identificator from feed |
|
334 | + */ |
|
335 | + public function migrate_item($id) { |
|
336 | 336 | |
337 | - global $db, $logger, $tpl, $smarty, $post; |
|
337 | + global $db, $logger, $tpl, $smarty, $post; |
|
338 | 338 | |
339 | - # Migrate |
|
340 | - if(isset($post->from) && isset($post->to) && $db->check_id($post->from, STRUCTURE_TABLE, "id", "page_type='feed'") && $db->check_id($post->to, STRUCTURE_TABLE, "id", "page_type='feed'")) { |
|
339 | + # Migrate |
|
340 | + if(isset($post->from) && isset($post->to) && $db->check_id($post->from, STRUCTURE_TABLE, "id", "page_type='feed'") && $db->check_id($post->to, STRUCTURE_TABLE, "id", "page_type='feed'")) { |
|
341 | 341 | |
342 | - $db->query("UPDATE ".PAGES_FEED_TABLE." |
|
342 | + $db->query("UPDATE ".PAGES_FEED_TABLE." |
|
343 | 343 | SET sid = '".$post->to."', |
344 | 344 | date_update = '".time()."' |
345 | 345 | WHERE id = '".$id."'"); |
346 | 346 | |
347 | - # recount items |
|
348 | - $this->count_items($post->from); |
|
349 | - $this->count_items($post->to); |
|
347 | + # recount items |
|
348 | + $this->count_items($post->from); |
|
349 | + $this->count_items($post->to); |
|
350 | 350 | |
351 | 351 | |
352 | - # notice |
|
353 | - $logger->info("Элемент #".$id." успешно перемещен."); |
|
352 | + # notice |
|
353 | + $logger->info("Элемент #".$id." успешно перемещен."); |
|
354 | 354 | |
355 | - #go |
|
356 | - go(CP."?act=feeds&part=control&page=".$post->to); |
|
357 | - } |
|
355 | + #go |
|
356 | + go(CP."?act=feeds&part=control&page=".$post->to); |
|
357 | + } |
|
358 | 358 | |
359 | 359 | |
360 | - # get data item from db |
|
361 | - $q = $db->query("SELECT id, sid, title FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
362 | - $data = $db->fetch_assoc($q); |
|
360 | + # get data item from db |
|
361 | + $q = $db->query("SELECT id, sid, title FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
362 | + $data = $db->fetch_assoc($q); |
|
363 | 363 | |
364 | - # smarty vars |
|
365 | - $smarty->assign("item", $data); |
|
364 | + # smarty vars |
|
365 | + $smarty->assign("item", $data); |
|
366 | 366 | |
367 | 367 | |
368 | - # get data feeds from db |
|
369 | - $feeds = []; |
|
370 | - $q = $db->query("SELECT id, title, alias FROM ".STRUCTURE_TABLE." WHERE page_type='feed' ORDER BY id ASC"); |
|
371 | - while($row = $db->fetch_assoc($q)) { |
|
372 | - $feeds[$row['id']] = $row; |
|
373 | - } |
|
368 | + # get data feeds from db |
|
369 | + $feeds = []; |
|
370 | + $q = $db->query("SELECT id, title, alias FROM ".STRUCTURE_TABLE." WHERE page_type='feed' ORDER BY id ASC"); |
|
371 | + while($row = $db->fetch_assoc($q)) { |
|
372 | + $feeds[$row['id']] = $row; |
|
373 | + } |
|
374 | 374 | |
375 | - # smarty vars |
|
376 | - $smarty->assign("feeds", $feeds); |
|
375 | + # smarty vars |
|
376 | + $smarty->assign("feeds", $feeds); |
|
377 | 377 | |
378 | - # tpl |
|
379 | - $content = $tpl->load_template("feeds_migrate_item_feed", true); |
|
380 | - $smarty->assign("content", $content); |
|
381 | - } |
|
378 | + # tpl |
|
379 | + $content = $tpl->load_template("feeds_migrate_item_feed", true); |
|
380 | + $smarty->assign("content", $content); |
|
381 | + } |
|
382 | 382 | |
383 | 383 | |
384 | - /** |
|
385 | - * Change status to record feed |
|
386 | - * |
|
387 | - * @param int $id - record id |
|
388 | - * @param int $status - 1=show , 0=hide |
|
389 | - */ |
|
390 | - public function change_item_status($id, $status = 1) { |
|
384 | + /** |
|
385 | + * Change status to record feed |
|
386 | + * |
|
387 | + * @param int $id - record id |
|
388 | + * @param int $status - 1=show , 0=hide |
|
389 | + */ |
|
390 | + public function change_item_status($id, $status = 1) { |
|
391 | 391 | |
392 | - global $db, $logger; |
|
392 | + global $db, $logger; |
|
393 | 393 | |
394 | - $status = (int) filter_var($status, FILTER_VALIDATE_BOOLEAN); |
|
394 | + $status = (int) filter_var($status, FILTER_VALIDATE_BOOLEAN); |
|
395 | 395 | |
396 | - # update data in db |
|
397 | - $db->query("UPDATE ".PAGES_FEED_TABLE." SET status='".$status."' WHERE id='".$id."'"); |
|
396 | + # update data in db |
|
397 | + $db->query("UPDATE ".PAGES_FEED_TABLE." SET status='".$status."' WHERE id='".$id."'"); |
|
398 | 398 | |
399 | - # notice |
|
400 | - $mstatus = ($status) ? "Видимый" : "Скрытый" ; |
|
401 | - $logger->info("Запись #".$id." успешно изменила свой статус на <".$mstatus.">."); |
|
399 | + # notice |
|
400 | + $mstatus = ($status) ? "Видимый" : "Скрытый" ; |
|
401 | + $logger->info("Запись #".$id." успешно изменила свой статус на <".$mstatus.">."); |
|
402 | 402 | |
403 | - # go |
|
404 | - goback(); |
|
405 | - } |
|
403 | + # go |
|
404 | + goback(); |
|
405 | + } |
|
406 | 406 | |
407 | 407 | |
408 | - /** |
|
409 | - * Remove record from feed |
|
410 | - * |
|
411 | - * @param int $id - record id |
|
412 | - */ |
|
413 | - public function delete_item($id) { |
|
408 | + /** |
|
409 | + * Remove record from feed |
|
410 | + * |
|
411 | + * @param int $id - record id |
|
412 | + */ |
|
413 | + public function delete_item($id) { |
|
414 | 414 | |
415 | - global $db, $logger, $img, $files, $tags; |
|
415 | + global $db, $logger, $img, $files, $tags; |
|
416 | 416 | |
417 | - # get sid |
|
418 | - $q = $db->query("SELECT sid FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
419 | - $row = $db->fetch_assoc($q); |
|
417 | + # get sid |
|
418 | + $q = $db->query("SELECT sid FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
419 | + $row = $db->fetch_assoc($q); |
|
420 | 420 | |
421 | - # del attached images |
|
422 | - $img->remove_images("feeditemid=".$id); |
|
421 | + # del attached images |
|
422 | + $img->remove_images("feeditemid=".$id); |
|
423 | 423 | |
424 | - # del attached files |
|
425 | - $files->remove_files("feeditemid=".$id); |
|
424 | + # del attached files |
|
425 | + $files->remove_files("feeditemid=".$id); |
|
426 | 426 | |
427 | - # del tags |
|
428 | - $tags->save_tags("", "feeditemid=".$id); |
|
427 | + # del tags |
|
428 | + $tags->save_tags("", "feeditemid=".$id); |
|
429 | 429 | |
430 | - # delete item |
|
431 | - $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
430 | + # delete item |
|
431 | + $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
432 | 432 | |
433 | - # recount items |
|
434 | - $this->count_items($row['sid']); |
|
433 | + # recount items |
|
434 | + $this->count_items($row['sid']); |
|
435 | 435 | |
436 | - # notice |
|
437 | - $logger->info("Элемент #".$id." успешно удален."); |
|
436 | + # notice |
|
437 | + $logger->info("Элемент #".$id." успешно удален."); |
|
438 | 438 | |
439 | - # go |
|
440 | - goback(); |
|
441 | - } |
|
439 | + # go |
|
440 | + goback(); |
|
441 | + } |
|
442 | 442 | |
443 | 443 | |
444 | - /** |
|
445 | - * Remove feed |
|
446 | - * |
|
447 | - * @param int $sid - structure element id |
|
448 | - */ |
|
449 | - public function delete_feed($sid) { |
|
444 | + /** |
|
445 | + * Remove feed |
|
446 | + * |
|
447 | + * @param int $sid - structure element id |
|
448 | + */ |
|
449 | + public function delete_feed($sid) { |
|
450 | 450 | |
451 | - global $db, $img, $files, $tags; |
|
451 | + global $db, $img, $files, $tags; |
|
452 | 452 | |
453 | - $cond = ""; |
|
454 | - $f = $db->query("SELECT id FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
|
455 | - while($fid = $db->fetch_assoc($f)) { |
|
456 | - # del tags |
|
457 | - $tags->save_tags("", "feeditemid=".$fid['id']); |
|
458 | - # cond |
|
459 | - $cond = $db->qcond_or($cond); |
|
460 | - $cond .= " attachedto='feeditemid=".$fid['id']."' " ; |
|
461 | - } |
|
453 | + $cond = ""; |
|
454 | + $f = $db->query("SELECT id FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
|
455 | + while($fid = $db->fetch_assoc($f)) { |
|
456 | + # del tags |
|
457 | + $tags->save_tags("", "feeditemid=".$fid['id']); |
|
458 | + # cond |
|
459 | + $cond = $db->qcond_or($cond); |
|
460 | + $cond .= " attachedto='feeditemid=".$fid['id']."' " ; |
|
461 | + } |
|
462 | 462 | |
463 | - # del attached images |
|
464 | - if(trim($cond) != "") { |
|
465 | - $img->remove_images($cond, true); |
|
466 | - $files->remove_files($cond, true); |
|
467 | - } |
|
468 | - |
|
469 | - $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
|
470 | - } |
|
463 | + # del attached images |
|
464 | + if(trim($cond) != "") { |
|
465 | + $img->remove_images($cond, true); |
|
466 | + $files->remove_files($cond, true); |
|
467 | + } |
|
468 | + |
|
469 | + $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
|
470 | + } |
|
471 | 471 | |
472 | 472 | |
473 | - /** |
|
474 | - * Settings feed |
|
475 | - */ |
|
476 | - public function settings() { |
|
473 | + /** |
|
474 | + * Settings feed |
|
475 | + */ |
|
476 | + public function settings() { |
|
477 | 477 | |
478 | - global $config, $tpl, $smarty; |
|
478 | + global $config, $tpl, $smarty; |
|
479 | 479 | |
480 | - # Уведомление о глобальном отключении RSS лент |
|
481 | - $this->feed['rss_warn'] = (!$config->rss_power) ? true : false ; |
|
480 | + # Уведомление о глобальном отключении RSS лент |
|
481 | + $this->feed['rss_warn'] = (!$config->rss_power) ? true : false ; |
|
482 | 482 | |
483 | - # глобальное значение количества элементов на страницу |
|
484 | - $this->feed['global_items_per_page'] =& $config->feed_items_per_page; |
|
483 | + # глобальное значение количества элементов на страницу |
|
484 | + $this->feed['global_items_per_page'] =& $config->feed_items_per_page; |
|
485 | 485 | |
486 | - # default thumb size |
|
487 | - $default_thumb_size = array('width' => $config->gd_thumb_image_width, |
|
488 | - 'height' => $config->gd_thumb_image_height); |
|
486 | + # default thumb size |
|
487 | + $default_thumb_size = array('width' => $config->gd_thumb_image_width, |
|
488 | + 'height' => $config->gd_thumb_image_height); |
|
489 | 489 | |
490 | - # smarty vars |
|
491 | - $smarty->assign("feed",$this->feed); |
|
492 | - $smarty->assign("default_thumb_size", $default_thumb_size); |
|
490 | + # smarty vars |
|
491 | + $smarty->assign("feed",$this->feed); |
|
492 | + $smarty->assign("default_thumb_size", $default_thumb_size); |
|
493 | 493 | |
494 | - # tpl |
|
495 | - $content = $tpl->load_template("feeds_settings_feed", true); |
|
496 | - $smarty->assign("content", $content); |
|
497 | - } |
|
494 | + # tpl |
|
495 | + $content = $tpl->load_template("feeds_settings_feed", true); |
|
496 | + $smarty->assign("content", $content); |
|
497 | + } |
|
498 | 498 | |
499 | 499 | |
500 | - /** |
|
501 | - * Settings update to feed |
|
502 | - */ |
|
503 | - public function update_settings() { |
|
504 | - |
|
505 | - global $db, $img, $post, $logger; |
|
506 | - |
|
507 | - if(isset($post->update_settings)) { |
|
508 | - # update buffer |
|
509 | - $update = ""; |
|
510 | - |
|
511 | - # RSS flag |
|
512 | - $rss = 0; |
|
513 | - if($post->rss == "1") { |
|
514 | - $rss = 1; |
|
515 | - } |
|
516 | - $update .= " rss='".$rss."', "; |
|
517 | - |
|
518 | - # items per page |
|
519 | - $items_per_page = 0; |
|
520 | - if(round($post->items_per_page) >= 0) { |
|
521 | - $items_per_page = round($post->items_per_page); |
|
522 | - } |
|
523 | - $update .= " items_per_page='".$items_per_page."', " ; |
|
524 | - |
|
525 | - # thumbnail check |
|
526 | - $img->check_post_thumb_parametrs(); |
|
527 | - |
|
528 | - # items sorting in feed |
|
529 | - $items_sorting = "datepublication"; |
|
530 | - if(isset($post->items_sorting)) { |
|
531 | - switch($post->items_sorting) { |
|
532 | - case 'title_asc': |
|
533 | - $items_sorting = "title_asc"; |
|
534 | - break; |
|
535 | - |
|
536 | - case 'title_desc': |
|
537 | - $items_sorting = "title_desc"; |
|
538 | - break; |
|
539 | - |
|
540 | - case 'manual_sorting': |
|
541 | - $items_sorting = "manual_sorting"; |
|
542 | - break; |
|
543 | - } |
|
544 | - } |
|
545 | - $update .= " items_sorting = '".$items_sorting."', "; |
|
546 | - |
|
547 | - # show_child_feeds |
|
548 | - $show_child_feeds = "none"; |
|
549 | - if(isset($post->show_child_feeds)) { |
|
550 | - switch($post->show_child_feeds) { |
|
551 | - case 'default': |
|
552 | - $show_child_feeds = "default"; |
|
553 | - break; |
|
554 | - |
|
555 | - case 'forced': |
|
556 | - $show_child_feeds = "forced"; |
|
557 | - break; |
|
558 | - } |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - # up data to db |
|
563 | - $db->query("UPDATE ".STRUCTURE_TABLE." |
|
500 | + /** |
|
501 | + * Settings update to feed |
|
502 | + */ |
|
503 | + public function update_settings() { |
|
504 | + |
|
505 | + global $db, $img, $post, $logger; |
|
506 | + |
|
507 | + if(isset($post->update_settings)) { |
|
508 | + # update buffer |
|
509 | + $update = ""; |
|
510 | + |
|
511 | + # RSS flag |
|
512 | + $rss = 0; |
|
513 | + if($post->rss == "1") { |
|
514 | + $rss = 1; |
|
515 | + } |
|
516 | + $update .= " rss='".$rss."', "; |
|
517 | + |
|
518 | + # items per page |
|
519 | + $items_per_page = 0; |
|
520 | + if(round($post->items_per_page) >= 0) { |
|
521 | + $items_per_page = round($post->items_per_page); |
|
522 | + } |
|
523 | + $update .= " items_per_page='".$items_per_page."', " ; |
|
524 | + |
|
525 | + # thumbnail check |
|
526 | + $img->check_post_thumb_parametrs(); |
|
527 | + |
|
528 | + # items sorting in feed |
|
529 | + $items_sorting = "datepublication"; |
|
530 | + if(isset($post->items_sorting)) { |
|
531 | + switch($post->items_sorting) { |
|
532 | + case 'title_asc': |
|
533 | + $items_sorting = "title_asc"; |
|
534 | + break; |
|
535 | + |
|
536 | + case 'title_desc': |
|
537 | + $items_sorting = "title_desc"; |
|
538 | + break; |
|
539 | + |
|
540 | + case 'manual_sorting': |
|
541 | + $items_sorting = "manual_sorting"; |
|
542 | + break; |
|
543 | + } |
|
544 | + } |
|
545 | + $update .= " items_sorting = '".$items_sorting."', "; |
|
546 | + |
|
547 | + # show_child_feeds |
|
548 | + $show_child_feeds = "none"; |
|
549 | + if(isset($post->show_child_feeds)) { |
|
550 | + switch($post->show_child_feeds) { |
|
551 | + case 'default': |
|
552 | + $show_child_feeds = "default"; |
|
553 | + break; |
|
554 | + |
|
555 | + case 'forced': |
|
556 | + $show_child_feeds = "forced"; |
|
557 | + break; |
|
558 | + } |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + # up data to db |
|
563 | + $db->query("UPDATE ".STRUCTURE_TABLE." |
|
564 | 564 | SET |
565 | 565 | ".$update." |
566 | 566 | show_child_feeds='".$show_child_feeds."', |
@@ -572,148 +572,148 @@ discard block |
||
572 | 572 | WHERE |
573 | 573 | id='".$this->feed['id']."'"); |
574 | 574 | |
575 | - $logger->info("Настройки ленты #".$this->feed['id']." успешно обновлены."); |
|
576 | - } |
|
575 | + $logger->info("Настройки ленты #".$this->feed['id']." успешно обновлены."); |
|
576 | + } |
|
577 | 577 | |
578 | - # go |
|
579 | - goback(); |
|
580 | - } |
|
578 | + # go |
|
579 | + goback(); |
|
580 | + } |
|
581 | 581 | |
582 | 582 | |
583 | - /** |
|
584 | - * Recount records in feed |
|
585 | - * |
|
586 | - * @param int $sid - feed id |
|
587 | - */ |
|
588 | - public function count_items($sid) { |
|
583 | + /** |
|
584 | + * Recount records in feed |
|
585 | + * |
|
586 | + * @param int $sid - feed id |
|
587 | + */ |
|
588 | + public function count_items($sid) { |
|
589 | 589 | |
590 | - global $db; |
|
590 | + global $db; |
|
591 | 591 | |
592 | - # count |
|
593 | - $items = $db->count(PAGES_FEED_TABLE, "sid='".$sid."'"); |
|
592 | + # count |
|
593 | + $items = $db->count(PAGES_FEED_TABLE, "sid='".$sid."'"); |
|
594 | 594 | |
595 | - # save |
|
596 | - $db->query("UPDATE ".STRUCTURE_TABLE." SET items='".$items."' WHERE id='".$sid."'"); |
|
597 | - } |
|
595 | + # save |
|
596 | + $db->query("UPDATE ".STRUCTURE_TABLE." SET items='".$items."' WHERE id='".$sid."'"); |
|
597 | + } |
|
598 | 598 | |
599 | 599 | |
600 | - /** |
|
601 | - * Check data post |
|
602 | - */ |
|
603 | - private function check_post_data_fields() { |
|
600 | + /** |
|
601 | + * Check data post |
|
602 | + */ |
|
603 | + private function check_post_data_fields() { |
|
604 | 604 | |
605 | - global $post, $logger; |
|
605 | + global $post, $logger; |
|
606 | 606 | |
607 | - # title |
|
608 | - if(!isset($post->title)) { |
|
609 | - $logger->error("Не заполнен заголовок элемента", false); |
|
610 | - } |
|
607 | + # title |
|
608 | + if(!isset($post->title)) { |
|
609 | + $logger->error("Не заполнен заголовок элемента", false); |
|
610 | + } |
|
611 | 611 | |
612 | - # full desc item |
|
613 | - if(!isset($post->full_item)) { |
|
614 | - $logger->error("Не заполнен подробный текст элемента", false); |
|
615 | - } |
|
612 | + # full desc item |
|
613 | + if(!isset($post->full_item)) { |
|
614 | + $logger->error("Не заполнен подробный текст элемента", false); |
|
615 | + } |
|
616 | 616 | |
617 | - # status |
|
618 | - $post->status = (int) filter_var($post->status, FILTER_VALIDATE_BOOLEAN); |
|
619 | - } |
|
617 | + # status |
|
618 | + $post->status = (int) filter_var($post->status, FILTER_VALIDATE_BOOLEAN); |
|
619 | + } |
|
620 | 620 | |
621 | 621 | |
622 | - /** |
|
623 | - * Check dates from data post |
|
624 | - */ |
|
625 | - private function control_post_data_date() { |
|
622 | + /** |
|
623 | + * Check dates from data post |
|
624 | + */ |
|
625 | + private function control_post_data_date() { |
|
626 | 626 | |
627 | - global $post, $parse; |
|
627 | + global $post, $parse; |
|
628 | 628 | |
629 | - # check isset date publication |
|
630 | - if(!isset($post->date_publications)) { |
|
631 | - $post->date_publications = date("d.m.Y",time()); |
|
632 | - } |
|
629 | + # check isset date publication |
|
630 | + if(!isset($post->date_publications)) { |
|
631 | + $post->date_publications = date("d.m.Y",time()); |
|
632 | + } |
|
633 | 633 | |
634 | - # check isset date end publication |
|
635 | - if(!isset($post->date_end_publications)) { |
|
636 | - $post->date_end_publications = 0; |
|
637 | - } |
|
634 | + # check isset date end publication |
|
635 | + if(!isset($post->date_end_publications)) { |
|
636 | + $post->date_end_publications = 0; |
|
637 | + } |
|
638 | 638 | |
639 | - # date publications |
|
640 | - $post->date_publications = $parse->date->rusint_to_unix($post->date_publications); |
|
639 | + # date publications |
|
640 | + $post->date_publications = $parse->date->rusint_to_unix($post->date_publications); |
|
641 | 641 | |
642 | - # date end publications |
|
643 | - if($post->date_end_publications != 0) { |
|
644 | - $post->date_end_publications = $parse->date->rusint_to_unix($post->date_end_publications); |
|
645 | - } |
|
642 | + # date end publications |
|
643 | + if($post->date_end_publications != 0) { |
|
644 | + $post->date_end_publications = $parse->date->rusint_to_unix($post->date_end_publications); |
|
645 | + } |
|
646 | 646 | |
647 | - if($post->date_end_publications <= $post->date_publications) { |
|
648 | - $post->date_end_publications = 0; |
|
649 | - } |
|
650 | - } |
|
647 | + if($post->date_end_publications <= $post->date_publications) { |
|
648 | + $post->date_end_publications = 0; |
|
649 | + } |
|
650 | + } |
|
651 | 651 | |
652 | 652 | |
653 | - /** |
|
654 | - * Check and correct secondary fields |
|
655 | - */ |
|
656 | - private function correct_post_fields() { |
|
653 | + /** |
|
654 | + * Check and correct secondary fields |
|
655 | + */ |
|
656 | + private function correct_post_fields() { |
|
657 | 657 | |
658 | - global $users, $post; |
|
658 | + global $users, $post; |
|
659 | 659 | |
660 | - # tags |
|
661 | - if(!isset($post->tags)) { |
|
662 | - $post->tags = NULL; |
|
663 | - } |
|
660 | + # tags |
|
661 | + if(!isset($post->tags)) { |
|
662 | + $post->tags = NULL; |
|
663 | + } |
|
664 | 664 | |
665 | - # sort |
|
666 | - if(!isset($post->itemsort) || round($post->itemsort) < 0) { |
|
667 | - $post->itemsort = 0; |
|
668 | - } |
|
669 | - else { |
|
670 | - $post->itemsort = round($post->itemsort); |
|
671 | - } |
|
665 | + # sort |
|
666 | + if(!isset($post->itemsort) || round($post->itemsort) < 0) { |
|
667 | + $post->itemsort = 0; |
|
668 | + } |
|
669 | + else { |
|
670 | + $post->itemsort = round($post->itemsort); |
|
671 | + } |
|
672 | 672 | |
673 | - # group ids with access |
|
674 | - if(isset($post->gids) && is_array($post->gids)) { |
|
675 | - $post->gids = implode(",", $post->gids); |
|
676 | - } |
|
677 | - else { |
|
678 | - $post->gids = 0; |
|
679 | - } |
|
673 | + # group ids with access |
|
674 | + if(isset($post->gids) && is_array($post->gids)) { |
|
675 | + $post->gids = implode(",", $post->gids); |
|
676 | + } |
|
677 | + else { |
|
678 | + $post->gids = 0; |
|
679 | + } |
|
680 | 680 | |
681 | - # userlist |
|
682 | - $this->userlist = $users->get_userlist(); |
|
683 | - |
|
684 | - # author |
|
685 | - if(!isset($post->author_id) || !array_key_exists($post->author_id, $this->userlist)) { |
|
686 | - $post->author_id = 0; |
|
687 | - } |
|
688 | - } |
|
681 | + # userlist |
|
682 | + $this->userlist = $users->get_userlist(); |
|
683 | + |
|
684 | + # author |
|
685 | + if(!isset($post->author_id) || !array_key_exists($post->author_id, $this->userlist)) { |
|
686 | + $post->author_id = 0; |
|
687 | + } |
|
688 | + } |
|
689 | 689 | |
690 | 690 | |
691 | - /** |
|
692 | - * Это временная функция |
|
693 | - * |
|
694 | - * @param int $id |
|
695 | - * @param string $title |
|
696 | - * @param string $subject |
|
697 | - */ |
|
698 | - private function mailing($id, $title, $subject) { |
|
699 | - |
|
700 | - global $parse, $mailer, $logger, $users, $mailer, $site; |
|
701 | - |
|
702 | - # get userlist |
|
703 | - $userlist = $users->get_userlist(1, 0, 1); |
|
704 | - |
|
705 | - # html |
|
706 | - $subject = $parse->text->html($subject); |
|
707 | - $subject = "<h1>".$title."</h1> |
|
691 | + /** |
|
692 | + * Это временная функция |
|
693 | + * |
|
694 | + * @param int $id |
|
695 | + * @param string $title |
|
696 | + * @param string $subject |
|
697 | + */ |
|
698 | + private function mailing($id, $title, $subject) { |
|
699 | + |
|
700 | + global $parse, $mailer, $logger, $users, $mailer, $site; |
|
701 | + |
|
702 | + # get userlist |
|
703 | + $userlist = $users->get_userlist(1, 0, 1); |
|
704 | + |
|
705 | + # html |
|
706 | + $subject = $parse->text->html($subject); |
|
707 | + $subject = "<h1>".$title."</h1> |
|
708 | 708 | ".$subject." |
709 | 709 | <br /><br /><a href=\"http://".$site['domain']."/index.php?page=".$this->feed['alias']."&id=".$id."\">Читать полностью</a>"; |
710 | 710 | |
711 | - # send to email |
|
712 | - if(count($userlist) != 0) { |
|
713 | - $mailer->spread($userlist, $title, $subject); |
|
714 | - } |
|
715 | - else { |
|
716 | - $logger->error("Сообщение не отправлено! Не обнаружены подписчики подходящие под заданные критерии.", false); |
|
717 | - } |
|
718 | - } |
|
711 | + # send to email |
|
712 | + if(count($userlist) != 0) { |
|
713 | + $mailer->spread($userlist, $title, $subject); |
|
714 | + } |
|
715 | + else { |
|
716 | + $logger->error("Сообщение не отправлено! Не обнаружены подписчики подходящие под заданные критерии.", false); |
|
717 | + } |
|
718 | + } |
|
719 | 719 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | while($row = $db->fetch_assoc($q)) { |
61 | 61 | |
62 | 62 | # flag future publications |
63 | - $row['publication_future'] = ($row['date_publications'] > time()) ? true : false ; |
|
63 | + $row['publication_future'] = ($row['date_publications'] > time()) ? TRUE : FALSE ; |
|
64 | 64 | |
65 | 65 | # flag show/hide |
66 | 66 | $row['publication_status'] = "show"; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | # formated date |
80 | 80 | $row['date_publications'] = $parse->date->unix_to_rus($row['date_publications']); |
81 | - $row['date_update'] = $parse->date->unix_to_rus($row['date_update'], false, true, true); |
|
81 | + $row['date_update'] = $parse->date->unix_to_rus($row['date_update'], FALSE, TRUE, TRUE); |
|
82 | 82 | |
83 | 83 | $taglinks[$row['id']] = "feeditemid=".$row['id']; |
84 | 84 | $feedlist[$row['id']] = $row; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $smarty->assign("subfeeds", $this->feed['subfeeds']); |
93 | 93 | $smarty->assign("feedlist", $feedlist); |
94 | 94 | |
95 | - $content = $tpl->load_template("feeds_control_feed", true); |
|
95 | + $content = $tpl->load_template("feeds_control_feed", TRUE); |
|
96 | 96 | $smarty->assign("content", $content); |
97 | 97 | } |
98 | 98 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | # attachment images |
139 | 139 | $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
140 | 140 | if($images) { |
141 | - foreach($images AS $image) { |
|
141 | + foreach($images as $image) { |
|
142 | 142 | $img->insert_images($image, "feeditemid=".$fiid, $post->title); |
143 | 143 | } |
144 | 144 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $groups = $users->get_usergroups(); |
171 | 171 | |
172 | 172 | # popular tags |
173 | - $poptags = $tags->list_tags(true); |
|
173 | + $poptags = $tags->list_tags(TRUE); |
|
174 | 174 | |
175 | 175 | # show upload files & images form |
176 | 176 | $tpl->load_image_upload_tpl("imagesupload"); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $smarty->assign("groups", $groups); # groups |
184 | 184 | |
185 | 185 | # tpl |
186 | - $content = $tpl->load_template("feeds_create_item_feed", true); |
|
186 | + $content = $tpl->load_template("feeds_create_item_feed", TRUE); |
|
187 | 187 | $smarty->assign("content", $content); |
188 | 188 | } |
189 | 189 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $item['tags'] = implode(", ", array_map(array("Tags", "get_tag_title"), $tags->read_tags("feeditemid=".$id))); |
221 | 221 | |
222 | 222 | # popular tags |
223 | - $poptags = $tags->list_tags(true); |
|
223 | + $poptags = $tags->list_tags(TRUE); |
|
224 | 224 | |
225 | 225 | |
226 | 226 | # download attached images |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $smarty->assign("attachimg", $attachimg); |
229 | 229 | |
230 | 230 | # show attached images |
231 | - $attachedimages = $tpl->load_template("attached_images", true); |
|
231 | + $attachedimages = $tpl->load_template("attached_images", TRUE); |
|
232 | 232 | $smarty->assign("attachedimages", $attachedimages); |
233 | 233 | |
234 | 234 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $smarty->assign("attachfile", $attachfile); |
238 | 238 | |
239 | 239 | # show attached files |
240 | - $attachedfiles = $tpl->load_template("attached_files", true); |
|
240 | + $attachedfiles = $tpl->load_template("attached_files", TRUE); |
|
241 | 241 | $smarty->assign("attachedfiles", $attachedfiles); |
242 | 242 | |
243 | 243 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $smarty->assign("groups", $groups); # group list |
256 | 256 | |
257 | 257 | # tpl |
258 | - $content = $tpl->load_template("feeds_edit_item_feed", true); |
|
258 | + $content = $tpl->load_template("feeds_edit_item_feed", TRUE); |
|
259 | 259 | $smarty->assign("content", $content); |
260 | 260 | } |
261 | 261 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | # attachment images |
311 | 311 | $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
312 | 312 | if($images) { |
313 | - foreach($images AS $image) { |
|
313 | + foreach($images as $image) { |
|
314 | 314 | $img->insert_images($image, "feeditemid=".$id, $post->title); |
315 | 315 | } |
316 | 316 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | $smarty->assign("feeds", $feeds); |
377 | 377 | |
378 | 378 | # tpl |
379 | - $content = $tpl->load_template("feeds_migrate_item_feed", true); |
|
379 | + $content = $tpl->load_template("feeds_migrate_item_feed", TRUE); |
|
380 | 380 | $smarty->assign("content", $content); |
381 | 381 | } |
382 | 382 | |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | |
463 | 463 | # del attached images |
464 | 464 | if(trim($cond) != "") { |
465 | - $img->remove_images($cond, true); |
|
466 | - $files->remove_files($cond, true); |
|
465 | + $img->remove_images($cond, TRUE); |
|
466 | + $files->remove_files($cond, TRUE); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | global $config, $tpl, $smarty; |
479 | 479 | |
480 | 480 | # Уведомление о глобальном отключении RSS лент |
481 | - $this->feed['rss_warn'] = (!$config->rss_power) ? true : false ; |
|
481 | + $this->feed['rss_warn'] = (!$config->rss_power) ? TRUE : FALSE ; |
|
482 | 482 | |
483 | 483 | # глобальное значение количества элементов на страницу |
484 | 484 | $this->feed['global_items_per_page'] =& $config->feed_items_per_page; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | $smarty->assign("default_thumb_size", $default_thumb_size); |
493 | 493 | |
494 | 494 | # tpl |
495 | - $content = $tpl->load_template("feeds_settings_feed", true); |
|
495 | + $content = $tpl->load_template("feeds_settings_feed", TRUE); |
|
496 | 496 | $smarty->assign("content", $content); |
497 | 497 | } |
498 | 498 | |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | |
607 | 607 | # title |
608 | 608 | if(!isset($post->title)) { |
609 | - $logger->error("Не заполнен заголовок элемента", false); |
|
609 | + $logger->error("Не заполнен заголовок элемента", FALSE); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | # full desc item |
613 | 613 | if(!isset($post->full_item)) { |
614 | - $logger->error("Не заполнен подробный текст элемента", false); |
|
614 | + $logger->error("Не заполнен подробный текст элемента", FALSE); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | # status |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | $mailer->spread($userlist, $title, $subject); |
714 | 714 | } |
715 | 715 | else { |
716 | - $logger->error("Сообщение не отправлено! Не обнаружены подписчики подходящие под заданные критерии.", false); |
|
716 | + $logger->error("Сообщение не отправлено! Не обнаружены подписчики подходящие под заданные критерии.", FALSE); |
|
717 | 717 | } |
718 | 718 | } |
719 | 719 | } |