@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | if (isset($package['devDependencies'])) { |
23 | 23 | $packages = array_merge($package['devDependencies'], $packages); |
24 | 24 | } |
25 | -$packages = array_map(function ($pkg) { |
|
25 | +$packages = array_map(function($pkg) { |
|
26 | 26 | //var_dump($pkg); |
27 | 27 | if (false === strpos($pkg, '@types/')) { |
28 | 28 | return $pkg; |
@@ -31,19 +31,19 @@ discard block |
||
31 | 31 | } |
32 | 32 | }, array_keys($packages)); |
33 | 33 | $packages = array_values(array_filter($packages)); |
34 | -$packages = array_map(function ($pkg) { |
|
34 | +$packages = array_map(function($pkg) { |
|
35 | 35 | return "@types/$pkg"; |
36 | 36 | }, $packages); |
37 | 37 | |
38 | 38 | if (isset($package['devDependencies'])) { |
39 | - array_map(function ($types) { |
|
39 | + array_map(function($types) { |
|
40 | 40 | $package['devDependencies'][$types] = '*'; |
41 | 41 | }, $packages); |
42 | 42 | } |
43 | 43 | |
44 | 44 | \Filemanager\file::file($location, $package, true); |
45 | 45 | |
46 | -$cmd = function ($pkg) { |
|
46 | +$cmd = function($pkg) { |
|
47 | 47 | return 'cd ' . ROOT . ' && echo "Installing ' . $pkg . ' On %cd%" && '; |
48 | 48 | }; |
49 | 49 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | $data = $p->fetchAll(); |
36 | 36 | $result['recordsTotal'] = count($data); |
37 | 37 | $result['recordsFiltered'] = (int) count($data); |
38 | -$data_filter = array_map(function ($map_data) { |
|
38 | +$data_filter = array_map(function($map_data) { |
|
39 | 39 | $i = 0; |
40 | 40 | foreach ($map_data as $key => $value) { |
41 | 41 | if (is_numeric($value)) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return $this |
141 | 141 | */ |
142 | - public function switch(string $dbname) |
|
142 | + public function switch (string $dbname) |
|
143 | 143 | { |
144 | 144 | $this->query('USE ' . $dbname)->exec(); |
145 | 145 | |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | $this->query = ''; |
725 | 725 | if ($filter) { |
726 | 726 | if (!empty($exec) && is_array($exec)) { |
727 | - $filtered = array_map(function ($data) use ($filter) { |
|
727 | + $filtered = array_map(function($data) use ($filter) { |
|
728 | 728 | if (isset($data[$filter])) { |
729 | 729 | return $data[$filter]; |
730 | 730 | } |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | protected function checkHost($hostName) |
264 | 264 | { |
265 | 265 | return true; // Override and return false if the host is not one that you would expect. |
266 | - // Ex: You only want to accept hosts from the my-domain.com domain, |
|
267 | - // but you receive a host from malicious-site.com instead. |
|
266 | + // Ex: You only want to accept hosts from the my-domain.com domain, |
|
267 | + // but you receive a host from malicious-site.com instead. |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | protected function checkOrigin($origin) |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | protected function processProtocol($protocol) |
286 | 286 | { |
287 | 287 | return ''; // return either "Sec-WebSocket-Protocol: SelectedProtocolFromClientList\r\n" or return an empty string. |
288 | - // The carriage return/newline combo must appear at the end of a non-empty string, and must not |
|
289 | - // appear at the beginning of the string nor in an otherwise empty string, or it will be considered part of |
|
290 | - // the response body, which will trigger an error in the client as it will not be formatted correctly. |
|
288 | + // The carriage return/newline combo must appear at the end of a non-empty string, and must not |
|
289 | + // appear at the beginning of the string nor in an otherwise empty string, or it will be considered part of |
|
290 | + // the response body, which will trigger an error in the client as it will not be formatted correctly. |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | protected function processExtensions($extensions) |
@@ -5,7 +5,7 @@ |
||
5 | 5 | $pdo->where(['simcard' => strtolower($_REQUEST['simcard'])]); |
6 | 6 | } |
7 | 7 | $row = $pdo->row_array(); |
8 | -$row = array_map(function ($db) { |
|
8 | +$row = array_map(function($db) { |
|
9 | 9 | if (isset($db['msisdn'])) { |
10 | 10 | if (strlen($db['msisdn']) <= 7) return; |
11 | 11 | return $db['msisdn']; |
@@ -7,7 +7,9 @@ |
||
7 | 7 | $row = $pdo->row_array(); |
8 | 8 | $row = array_map(function ($db) { |
9 | 9 | if (isset($db['msisdn'])) { |
10 | - if (strlen($db['msisdn']) <= 7) return; |
|
10 | + if (strlen($db['msisdn']) <= 7) { |
|
11 | + return; |
|
12 | + } |
|
11 | 13 | return $db['msisdn']; |
12 | 14 | } |
13 | 15 | }, $row); |
@@ -19,8 +19,9 @@ |
||
19 | 19 | $url .= "?s=$s&d=$d&r=$r"; |
20 | 20 | if ($img) { |
21 | 21 | $url = '<img src="' . $url . '"'; |
22 | - foreach ($atts as $key => $val) |
|
23 | - $url .= ' ' . $key . '="' . $val . '"'; |
|
22 | + foreach ($atts as $key => $val) { |
|
23 | + $url .= ' ' . $key . '="' . $val . '"'; |
|
24 | + } |
|
24 | 25 | $url .= ' />'; |
25 | 26 | } |
26 | 27 | return $url; |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | return $html; |
346 | 346 | } |
347 | 347 | |
348 | - function generateForm($location = '', $type = 0, $comment = false) |
|
348 | + function generateForm($location = '', $type = 0, $comment = false) |
|
349 | 349 | { |
350 | 350 | $this->setToken(); |
351 | 351 | if ($location == '') |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | $sql = "SELECT `id` FROM `" . $this->settings['comments_table'] . "` WHERE `parent` = 0 "; |
736 | 736 | |
737 | 737 | if ($pageid) |
738 | - $sql .= " AND `pageid`='" . (int) $pageid . "'"; |
|
738 | + $sql .= " AND `pageid`='" . (int) $pageid . "'"; |
|
739 | 739 | |
740 | 740 | |
741 | 741 | $total = mysqli_num_rows(mysqli_query($this->link, $sql)); |
@@ -47,13 +47,16 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function __construct($db_details, $settings = array()) |
49 | 49 | { |
50 | - if (session_id() == '') |
|
51 | - session_start(); |
|
50 | + if (session_id() == '') { |
|
51 | + session_start(); |
|
52 | + } |
|
52 | 53 | |
53 | 54 | // we first manage the mysql connection |
54 | 55 | $this->link = @mysqli_connect($db_details['db_host'], $db_details['db_user'], $db_details['db_pass']); |
55 | 56 | |
56 | - if (!$this->link) die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
|
57 | + if (!$this->link) { |
|
58 | + die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
|
59 | + } |
|
57 | 60 | |
58 | 61 | mysqli_select_db($this->link, $db_details['db_name']) or die(mysqli_error($this->link)); |
59 | 62 | |
@@ -63,8 +66,9 @@ discard block |
||
63 | 66 | $this->settings['comments_table'] = str_replace("`", "``", $this->settings['comments_table']); |
64 | 67 | |
65 | 68 | // auto install |
66 | - if ($this->settings['auto_install'] && !@mysqli_num_rows(mysqli_query($this->link, "SELECT `id` FROM `" . $this->settings['comments_table'] . "`"))) |
|
67 | - $this->install(); |
|
69 | + if ($this->settings['auto_install'] && !@mysqli_num_rows(mysqli_query($this->link, "SELECT `id` FROM `" . $this->settings['comments_table'] . "`"))) { |
|
70 | + $this->install(); |
|
71 | + } |
|
68 | 72 | |
69 | 73 | |
70 | 74 | // edit comment |
@@ -79,17 +83,21 @@ discard block |
||
79 | 83 | |
80 | 84 | |
81 | 85 | // delete comment |
82 | - if (isset($_POST['comm_del'])) |
|
83 | - if ($this->delComm($_POST['comm_del'])) |
|
86 | + if (isset($_POST['comm_del'])) { |
|
87 | + if ($this->delComm($_POST['comm_del'])) |
|
84 | 88 | $this->success = "Comment deleted !"; |
89 | + } |
|
85 | 90 | |
86 | 91 | // bann ip |
87 | - if (isset($_GET['comm_ban']) && $this->banIP($_GET['comm_ban'])) // we banned the ip |
|
92 | + if (isset($_GET['comm_ban']) && $this->banIP($_GET['comm_ban'])) { |
|
93 | + // we banned the ip |
|
88 | 94 | $this->success = "IP banned !"; |
95 | + } |
|
89 | 96 | |
90 | 97 | // UnBann ip |
91 | - if (isset($_GET['comm_unban']) && $this->unBanIP($_GET['comm_unban'])) |
|
92 | - $this->success = "IP UnBanned !"; |
|
98 | + if (isset($_GET['comm_unban']) && $this->unBanIP($_GET['comm_unban'])) { |
|
99 | + $this->success = "IP UnBanned !"; |
|
100 | + } |
|
93 | 101 | |
94 | 102 | return true; |
95 | 103 | } |
@@ -98,8 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | function grabComment($pageid, $update_id = false) |
100 | 108 | { |
101 | - if (session_id() == '') |
|
102 | - session_start(); |
|
109 | + if (session_id() == '') { |
|
110 | + session_start(); |
|
111 | + } |
|
103 | 112 | |
104 | 113 | $_SESSION['comm_pageid'] = $pageid; |
105 | 114 | |
@@ -144,20 +153,22 @@ discard block |
||
144 | 153 | |
145 | 154 | |
146 | 155 | // we check in case the email is not valid |
147 | - if (!$this->settings['optional_email']) |
|
148 | - if (!$this->isValidMail($email)) { |
|
156 | + if (!$this->settings['optional_email']) { |
|
157 | + if (!$this->isValidMail($email)) { |
|
149 | 158 | $this->error = "Invalid email !"; |
159 | + } |
|
150 | 160 | return false; |
151 | 161 | } |
152 | 162 | |
153 | 163 | |
154 | 164 | // we check if it's an update or a new message |
155 | 165 | if ($update_id) { |
156 | - if ($this->settings['public']) |
|
157 | - $upd_fields = ",`name` = '" . mysqli_real_escape_string($this->link, $name) . "', |
|
166 | + if ($this->settings['public']) { |
|
167 | + $upd_fields = ",`name` = '" . mysqli_real_escape_string($this->link, $name) . "', |
|
158 | 168 | `email` = '" . mysqli_real_escape_string($this->link, $email) . "'"; |
159 | - else |
|
160 | - $upd_fields = ''; |
|
169 | + } else { |
|
170 | + $upd_fields = ''; |
|
171 | + } |
|
161 | 172 | |
162 | 173 | |
163 | 174 | if (mysqli_query($this->link, "UPDATE `" . $this->settings['comments_table'] . "` SET |
@@ -176,10 +187,11 @@ discard block |
||
176 | 187 | isset($_POST['comm_reply']) && |
177 | 188 | mysqli_num_rows(mysqli_query($this->link, "SELECT `id` FROM `" . $this->settings['comments_table'] . "` |
178 | 189 | WHERE `id`= '" . (int) $_POST['comm_reply'] . "' AND `parent` = '0'")) |
179 | - ) |
|
180 | - $reply = ",`parent` = '" . (int) $_POST['comm_reply'] . "'"; |
|
181 | - else |
|
182 | - $reply = ''; |
|
190 | + ) { |
|
191 | + $reply = ",`parent` = '" . (int) $_POST['comm_reply'] . "'"; |
|
192 | + } else { |
|
193 | + $reply = ''; |
|
194 | + } |
|
183 | 195 | |
184 | 196 | |
185 | 197 | |
@@ -216,8 +228,9 @@ discard block |
||
216 | 228 | function generateComments($pageid = 0, $perpage = 10) |
217 | 229 | { |
218 | 230 | |
219 | - if (session_id() == '') |
|
220 | - session_start(); |
|
231 | + if (session_id() == '') { |
|
232 | + session_start(); |
|
233 | + } |
|
221 | 234 | |
222 | 235 | $_SESSION['comm_pageid'] = $pageid; |
223 | 236 | |
@@ -230,8 +243,9 @@ discard block |
||
230 | 243 | // we generate the output of the comments |
231 | 244 | if ($comments) { |
232 | 245 | foreach ($comments as $comment) { |
233 | - if (!($name = $this->getUsername($comment->name))) |
|
234 | - $name = $comment->name; |
|
246 | + if (!($name = $this->getUsername($comment->name))) { |
|
247 | + $name = $comment->name; |
|
248 | + } |
|
235 | 249 | |
236 | 250 | // show reply link or form |
237 | 251 | if (isset($_GET['comm_reply']) && ($comment->id == $_GET['comm_reply'])) { |
@@ -295,18 +309,20 @@ discard block |
||
295 | 309 | $html = ""; |
296 | 310 | $comments = $this->getReplies($comm_id, $limit); |
297 | 311 | // we generate the output of the comments |
298 | - if ($comments) |
|
299 | - foreach ($comments as $comment) { |
|
312 | + if ($comments) { |
|
313 | + foreach ($comments as $comment) { |
|
300 | 314 | if (!($name = $this->getUsername($comment->name))) |
301 | 315 | $name = $comment->name; |
316 | + } |
|
302 | 317 | |
303 | 318 | // show normal username or with adminStyles |
304 | 319 | $style = ""; |
305 | 320 | if ($comment->isadmin) { |
306 | 321 | $show_name = "<span style='" . $this->settings['adminStyle']['username'] . "'>" . $this->html($name) . "</span>"; |
307 | 322 | $style = $this->settings['adminStyle']['box']; |
308 | - } else |
|
309 | - $show_name = $this->html($name); |
|
323 | + } else { |
|
324 | + $show_name = $this->html($name); |
|
325 | + } |
|
310 | 326 | |
311 | 327 | // show extra info only to admin |
312 | 328 | $show_extra = ""; |
@@ -325,19 +341,21 @@ discard block |
||
325 | 341 | <div class='media-body'>"; |
326 | 342 | |
327 | 343 | |
328 | - if (isset($_GET['comm_edit']) && ($_GET['comm_edit'] === $comment->id) && $this->hasRights($comment)) |
|
329 | - // we generate the form in edit mode with precompleted data |
|
344 | + if (isset($_GET['comm_edit']) && ($_GET['comm_edit'] === $comment->id) && $this->hasRights($comment)) { |
|
345 | + // we generate the form in edit mode with precompleted data |
|
330 | 346 | $html .= $this->generateForm('', 2, $comment); |
331 | - else |
|
332 | - $html .= "<h4 class='media-heading'> |
|
347 | + } else { |
|
348 | + $html .= "<h4 class='media-heading'> |
|
333 | 349 | $show_name $show_extra |
334 | 350 | <small class='muted'>" . $this->tsince($comment->time) . " replied </small> |
335 | 351 | " . $this->admin_options($comment) . " |
336 | 352 | </h4> |
337 | 353 | <p>" . nl2br($this->html($comment->message)) . "</p>"; |
354 | + } |
|
338 | 355 | |
339 | - if ($is_del) |
|
340 | - $html .= $this->gennerateConfirm('', 'comm_del', $comment->id); |
|
356 | + if ($is_del) { |
|
357 | + $html .= $this->gennerateConfirm('', 'comm_del', $comment->id); |
|
358 | + } |
|
341 | 359 | |
342 | 360 | $html .= "</div></div>"; |
343 | 361 | } |
@@ -348,19 +366,22 @@ discard block |
||
348 | 366 | function generateForm($location = '', $type = 0, $comment = false) |
349 | 367 | { |
350 | 368 | $this->setToken(); |
351 | - if ($location == '') |
|
352 | - $location = "?" . $this->queryString('', $this->ignore); |
|
369 | + if ($location == '') { |
|
370 | + $location = "?" . $this->queryString('', $this->ignore); |
|
371 | + } |
|
353 | 372 | |
354 | 373 | |
355 | - if (!$comment) |
|
356 | - $comment = (object) array("name" => "", "email" => "", "message" => ""); |
|
374 | + if (!$comment) { |
|
375 | + $comment = (object) array("name" => "", "email" => "", "message" => ""); |
|
376 | + } |
|
357 | 377 | |
358 | - if ($type == 1) |
|
359 | - $title = "<input type='hidden' name='comm_reply' value='" . (int) $_GET['comm_reply'] . "'>Post a reply"; |
|
360 | - else if ($type == 2) |
|
361 | - $title = "<input type='hidden' name='comm_edit' value='" . (int) $_GET['comm_edit'] . "'>Edit comment"; |
|
362 | - else |
|
363 | - $title = "Post a comment"; |
|
378 | + if ($type == 1) { |
|
379 | + $title = "<input type='hidden' name='comm_reply' value='" . (int) $_GET['comm_reply'] . "'>Post a reply"; |
|
380 | + } else if ($type == 2) { |
|
381 | + $title = "<input type='hidden' name='comm_edit' value='" . (int) $_GET['comm_edit'] . "'>Edit comment"; |
|
382 | + } else { |
|
383 | + $title = "Post a comment"; |
|
384 | + } |
|
364 | 385 | |
365 | 386 | $show_name_email = ''; |
366 | 387 | |
@@ -440,8 +461,9 @@ discard block |
||
440 | 461 | UNIQUE KEY `ip` (`ip`) |
441 | 462 | );"; |
442 | 463 | |
443 | - if (mysqli_query($this->link, $sql) && mysqli_query($this->link, $sql2)) |
|
444 | - return true; |
|
464 | + if (mysqli_query($this->link, $sql) && mysqli_query($this->link, $sql2)) { |
|
465 | + return true; |
|
466 | + } |
|
445 | 467 | |
446 | 468 | return false; |
447 | 469 | } |
@@ -457,8 +479,9 @@ discard block |
||
457 | 479 | |
458 | 480 | $sql = "SELECT * FROM `" . $this->settings['comments_table'] . "` WHERE `parent` = 0 "; |
459 | 481 | |
460 | - if ($pageid) |
|
461 | - $sql .= "AND `pageid` = '" . mysqli_real_escape_string($this->link, $pageid) . "'"; |
|
482 | + if ($pageid) { |
|
483 | + $sql .= "AND `pageid` = '" . mysqli_real_escape_string($this->link, $pageid) . "'"; |
|
484 | + } |
|
462 | 485 | |
463 | 486 | // some sorting options |
464 | 487 | $sql .= " " . $this->settings['sort'] . " "; // this is pasted as is |
@@ -469,18 +492,20 @@ discard block |
||
469 | 492 | |
470 | 493 | $total_results = mysqli_num_rows(mysqli_query($this->link, $sql)); |
471 | 494 | |
472 | - if ($page_number > ceil($total_results / $perpage)) |
|
473 | - $page_number = ceil($total_results / $perpage); |
|
495 | + if ($page_number > ceil($total_results / $perpage)) { |
|
496 | + $page_number = ceil($total_results / $perpage); |
|
497 | + } |
|
474 | 498 | |
475 | 499 | $start = ($page_number - 1) * $perpage; |
476 | 500 | |
477 | 501 | $sql .= "LIMIT $start, $perpage"; |
478 | 502 | |
479 | - if ($result = mysqli_query($this->link, $sql)) |
|
480 | - while ($row = mysqli_fetch_object($result)) |
|
503 | + if ($result = mysqli_query($this->link, $sql)) { |
|
504 | + while ($row = mysqli_fetch_object($result)) |
|
481 | 505 | $comments[] = $row; |
482 | - else |
|
483 | - return false; |
|
506 | + } else { |
|
507 | + return false; |
|
508 | + } |
|
484 | 509 | |
485 | 510 | return $comments; |
486 | 511 | } |
@@ -500,11 +525,12 @@ discard block |
||
500 | 525 | // limitation |
501 | 526 | $sql .= "LIMIT 0, $limit"; |
502 | 527 | |
503 | - if ($result = mysqli_query($this->link, $sql)) |
|
504 | - while ($row = mysqli_fetch_object($result)) |
|
528 | + if ($result = mysqli_query($this->link, $sql)) { |
|
529 | + while ($row = mysqli_fetch_object($result)) |
|
505 | 530 | $comments[] = $row; |
506 | - else |
|
507 | - return false; |
|
531 | + } else { |
|
532 | + return false; |
|
533 | + } |
|
508 | 534 | |
509 | 535 | return $comments; |
510 | 536 | } |
@@ -547,8 +573,9 @@ discard block |
||
547 | 573 | |
548 | 574 | $time = abs(time() - $time); // to get the time since that moment |
549 | 575 | |
550 | - if ($time == 0) |
|
551 | - return "Just now"; |
|
576 | + if ($time == 0) { |
|
577 | + return "Just now"; |
|
578 | + } |
|
552 | 579 | |
553 | 580 | $tokens = array( |
554 | 581 | 31536000 => 'year', |
@@ -561,7 +588,9 @@ discard block |
||
561 | 588 | ); |
562 | 589 | |
563 | 590 | foreach ($tokens as $unit => $text) { |
564 | - if ($time < $unit) continue; |
|
591 | + if ($time < $unit) { |
|
592 | + continue; |
|
593 | + } |
|
565 | 594 | $numberOfUnits = floor($time / $unit); |
566 | 595 | return $numberOfUnits . ' ' . $text . (($numberOfUnits > 1) ? 's' : '') . ' ' . $end_msg; |
567 | 596 | } |
@@ -570,13 +599,15 @@ discard block |
||
570 | 599 | function isValidMail($mail) |
571 | 600 | { |
572 | 601 | |
573 | - if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) |
|
574 | - return FALSE; |
|
602 | + if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { |
|
603 | + return FALSE; |
|
604 | + } |
|
575 | 605 | |
576 | 606 | |
577 | 607 | list($username, $maildomain) = explode("@", $mail); |
578 | - if (checkdnsrr($maildomain, "MX")) |
|
579 | - return TRUE; |
|
608 | + if (checkdnsrr($maildomain, "MX")) { |
|
609 | + return TRUE; |
|
610 | + } |
|
580 | 611 | |
581 | 612 | return FALSE; |
582 | 613 | } |
@@ -633,8 +664,9 @@ discard block |
||
633 | 664 | */ |
634 | 665 | function setToken() |
635 | 666 | { |
636 | - if (session_id() == '') |
|
637 | - session_start(); |
|
667 | + if (session_id() == '') { |
|
668 | + session_start(); |
|
669 | + } |
|
638 | 670 | |
639 | 671 | $_SESSION['comm_token'] = md5(time() . rand()); |
640 | 672 | } |
@@ -652,8 +684,9 @@ discard block |
||
652 | 684 | foreach ($_GET as $k => $v) { |
653 | 685 | if ((is_array($ignore) && in_array($k, $ignore)) |
654 | 686 | || (is_string($ignore) && preg_match($ignore, $k)) |
655 | - ) |
|
656 | - continue; |
|
687 | + ) { |
|
688 | + continue; |
|
689 | + } |
|
657 | 690 | |
658 | 691 | if ($type == 'hidden') { |
659 | 692 | $result .= "<input type='hidden' name='" . urlencode($k) . "' value='" . urlencode($v) . "'>"; |
@@ -662,8 +695,9 @@ discard block |
||
662 | 695 | } |
663 | 696 | } |
664 | 697 | |
665 | - if (is_array($result)) |
|
666 | - return implode("&", $result); |
|
698 | + if (is_array($result)) { |
|
699 | + return implode("&", $result); |
|
700 | + } |
|
667 | 701 | |
668 | 702 | return $result; |
669 | 703 | } |
@@ -676,8 +710,9 @@ discard block |
||
676 | 710 | function gennerateConfirm($location = '', $info_name = 'comm_del', $info_value = 0, $submit = "I'm sure, Delete") |
677 | 711 | { |
678 | 712 | |
679 | - if ($location == '') |
|
680 | - $location = "?" . $this->queryString('', $this->ignore); |
|
713 | + if ($location == '') { |
|
714 | + $location = "?" . $this->queryString('', $this->ignore); |
|
715 | + } |
|
681 | 716 | |
682 | 717 | return "<form class='form-horizontal' action='$location' method='post'> |
683 | 718 | <div class='control-group'> |
@@ -696,11 +731,13 @@ discard block |
||
696 | 731 | */ |
697 | 732 | function hasRights($comment) |
698 | 733 | { |
699 | - if (session_id() == '') |
|
700 | - session_start(); |
|
734 | + if (session_id() == '') { |
|
735 | + session_start(); |
|
736 | + } |
|
701 | 737 | |
702 | - if ($this->settings['isAdmin'] || (isset($_SESSION['comm_last_id']) && $_SESSION['comm_last_id'] == $comment->id)) |
|
703 | - return true; |
|
738 | + if ($this->settings['isAdmin'] || (isset($_SESSION['comm_last_id']) && $_SESSION['comm_last_id'] == $comment->id)) { |
|
739 | + return true; |
|
740 | + } |
|
704 | 741 | return false; |
705 | 742 | } |
706 | 743 | /** |
@@ -711,13 +748,14 @@ discard block |
||
711 | 748 | function admin_options($comment) |
712 | 749 | { |
713 | 750 | // if is admin or the person who posted the message |
714 | - if ($this->hasRights($comment)) |
|
715 | - return "<a href='?" . $this->queryString('', $this->ignore) . "&comm_edit=$comment->id#$comment->id'>Edit</a> |
|
751 | + if ($this->hasRights($comment)) { |
|
752 | + return "<a href='?" . $this->queryString('', $this->ignore) . "&comm_edit=$comment->id#$comment->id'>Edit</a> |
|
716 | 753 | | <a href='?" . $this->queryString('', $this->ignore) . "&comm_del=$comment->id#$comment->id'>Delete</a>" . |
717 | 754 | ($this->settings['isAdmin'] ? //if is admin |
718 | 755 | " | <a href='?" . $this->queryString('', $this->ignore) . "&comm_" . |
719 | 756 | ($this->isBanned($comment->ip) ? "un" : "") . "ban=" . urlencode($comment->ip) . "'>" . |
720 | 757 | ($this->isBanned($comment->ip) ? "Un" : "") . "Ban</a>" : ""); |
758 | + } |
|
721 | 759 | } |
722 | 760 | |
723 | 761 | |
@@ -734,8 +772,9 @@ discard block |
||
734 | 772 | |
735 | 773 | $sql = "SELECT `id` FROM `" . $this->settings['comments_table'] . "` WHERE `parent` = 0 "; |
736 | 774 | |
737 | - if ($pageid) |
|
738 | - $sql .= " AND `pageid`='" . (int) $pageid . "'"; |
|
775 | + if ($pageid) { |
|
776 | + $sql .= " AND `pageid`='" . (int) $pageid . "'"; |
|
777 | + } |
|
739 | 778 | |
740 | 779 | |
741 | 780 | $total = mysqli_num_rows(mysqli_query($this->link, $sql)); |
@@ -748,20 +787,25 @@ discard block |
||
748 | 787 | |
749 | 788 | $html = "<div class='pagination'><ul>"; |
750 | 789 | |
751 | - if ($page > 4) |
|
752 | - $html .= "<li><a href='?$query'>First</a></li>"; |
|
790 | + if ($page > 4) { |
|
791 | + $html .= "<li><a href='?$query'>First</a></li>"; |
|
792 | + } |
|
753 | 793 | |
754 | - if ($page > 1) |
|
755 | - $html .= "<li><a href='?comm_page=" . ($page - 1) . "$query'>Prev</a> </li>"; |
|
794 | + if ($page > 1) { |
|
795 | + $html .= "<li><a href='?comm_page=" . ($page - 1) . "$query'>Prev</a> </li>"; |
|
796 | + } |
|
756 | 797 | |
757 | - for ($i = max(1, $page - 3); $i <= min($page + 3, $total_pages); $i++) |
|
758 | - $html .= ($i == $page ? "<li class='active'><a>" . $i . "</a></li>" : " <li><a href='?comm_page=$i$query'>$i</a></li> "); |
|
798 | + for ($i = max(1, $page - 3); $i <= min($page + 3, $total_pages); $i++) { |
|
799 | + $html .= ($i == $page ? "<li class='active'><a>" . $i . "</a></li>" : " <li><a href='?comm_page=$i$query'>$i</a></li> "); |
|
800 | + } |
|
759 | 801 | |
760 | - if ($page < $total_pages) |
|
761 | - $html .= "<li><a href='?comm_page=" . ($page + 1) . "$query'>Next</a></li>"; |
|
802 | + if ($page < $total_pages) { |
|
803 | + $html .= "<li><a href='?comm_page=" . ($page + 1) . "$query'>Next</a></li>"; |
|
804 | + } |
|
762 | 805 | |
763 | - if ($page < $total_pages - 3) |
|
764 | - $html .= "<li><a href='?comm_page=$total_pages$query'> Last </a></li>"; |
|
806 | + if ($page < $total_pages - 3) { |
|
807 | + $html .= "<li><a href='?comm_page=$total_pages$query'> Last </a></li>"; |
|
808 | + } |
|
765 | 809 | |
766 | 810 | $html .= "</ul></div>"; |
767 | 811 | |
@@ -791,10 +835,11 @@ discard block |
||
791 | 835 | */ |
792 | 836 | function banIP($ip) |
793 | 837 | { |
794 | - if ($this->settings['isAdmin']) |
|
795 | - if (mysqli_query($this->link, "INSERT INTO `" . $this->settings['banned_table'] . "` |
|
838 | + if ($this->settings['isAdmin']) { |
|
839 | + if (mysqli_query($this->link, "INSERT INTO `" . $this->settings['banned_table'] . "` |
|
796 | 840 | SET `ip` = '" . mysqli_real_escape_string($this->link, $ip) . "'")) |
797 | 841 | return true; |
842 | + } |
|
798 | 843 | return false; |
799 | 844 | } |
800 | 845 | |
@@ -820,8 +865,9 @@ discard block |
||
820 | 865 | function isBanned($ip) |
821 | 866 | { |
822 | 867 | // no need to check the same ip 2 times in a row |
823 | - if (count($this->checked_ips) && in_array($ip, array_keys($this->checked_ips))) |
|
824 | - return $this->checked_ips[$ip]; |
|
868 | + if (count($this->checked_ips) && in_array($ip, array_keys($this->checked_ips))) { |
|
869 | + return $this->checked_ips[$ip]; |
|
870 | + } |
|
825 | 871 | |
826 | 872 | $this->checked_ips[$ip] = $ip; |
827 | 873 |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { |
27 | - // If the browser has a cached version of this image, send 304 |
|
28 | - header('Last-Modified: ' . $_SERVER['HTTP_IF_MODIFIED_SINCE'], true, 304); |
|
29 | - exit; |
|
27 | + // If the browser has a cached version of this image, send 304 |
|
28 | + header('Last-Modified: ' . $_SERVER['HTTP_IF_MODIFIED_SINCE'], true, 304); |
|
29 | + exit; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | // if not exist query GET x |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $x = strtolower(isset($_GET['x']) ? $_GET['x'] : $queryurl); |
36 | 36 | // If the first character of $x is a / then get rid of it |
37 | 37 | if ($x[0] == '/') { |
38 | - $x = ltrim($x, '/'); |
|
38 | + $x = ltrim($x, '/'); |
|
39 | 39 | } |
40 | 40 | $x_pieces = explode('/', $x); |
41 | 41 | |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | // Find the background color which is always after the 2nd slash in the url |
46 | 46 | $bg_color = 'ccc'; |
47 | 47 | if (isset($x_pieces[1])) { |
48 | - $bg_color_parts = explode('.', $x_pieces[1]); |
|
49 | - if (isset($bg_color_parts[0]) && !empty($bg_color_parts[0])) { |
|
50 | - $bg_color = $bg_color_parts[0]; |
|
51 | - } |
|
48 | + $bg_color_parts = explode('.', $x_pieces[1]); |
|
49 | + if (isset($bg_color_parts[0]) && !empty($bg_color_parts[0])) { |
|
50 | + $bg_color = $bg_color_parts[0]; |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | $background = new color(); |
54 | 54 | $background->set_hex($bg_color); |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | // Find the foreground color which is always after the 3rd slash in the url |
57 | 57 | $fg_color = '000'; |
58 | 58 | if (isset($x_pieces[2])) { |
59 | - $fg_color_parts = explode('.', $x_pieces[2]); |
|
60 | - if (isset($fg_color_parts[0]) && !empty($fg_color_parts[0])) { |
|
61 | - $fg_color = $fg_color_parts[0]; |
|
62 | - } |
|
59 | + $fg_color_parts = explode('.', $x_pieces[2]); |
|
60 | + if (isset($fg_color_parts[0]) && !empty($fg_color_parts[0])) { |
|
61 | + $fg_color = $fg_color_parts[0]; |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | $foreground = new color(); |
65 | 65 | $foreground->set_hex($fg_color); |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | $file_format = 'png'; |
69 | 69 | preg_match_all('/(gif|jpg|jpeg)/', $x, $result); |
70 | 70 | if (isset($result[0]) && isset($result[0][0]) && $result[0][0]) { |
71 | - $file_format = $result[0][0]; |
|
71 | + $file_format = $result[0][0]; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // Find the image dimensions |
75 | 75 | if (substr_count($x_pieces[0], ':') > 1) { |
76 | - die('Too many colons in the dimension paramter! There should be 1 at most.'); |
|
76 | + die('Too many colons in the dimension paramter! There should be 1 at most.'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | if (strstr($x_pieces[0], ':') && !strstr($x_pieces[0], 'x')) { |
80 | - die('To calculate a ratio you need to provide a height!'); |
|
80 | + die('To calculate a ratio you need to provide a height!'); |
|
81 | 81 | } |
82 | 82 | // Dimensions are always the first paramter in the URL |
83 | 83 | $dimensions = explode('x', $x_pieces[0]); |
@@ -86,46 +86,46 @@ discard block |
||
86 | 86 | $width = preg_replace('/[^\d:\.]/i', '', $dimensions[0]); |
87 | 87 | $height = $width; |
88 | 88 | if ($dimensions[1]) { |
89 | - $height = preg_replace('/[^\d:\.]/i', '', $dimensions[1]); |
|
89 | + $height = preg_replace('/[^\d:\.]/i', '', $dimensions[1]); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // If the dimensions are too small then kill the script |
93 | 93 | if ($width < 1 || $height < 1) { |
94 | - die("Too small of an image!"); |
|
94 | + die("Too small of an image!"); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | // If one of the dimensions has a colon in it, we can calculate the aspect ratio. Chances are the height will contain a ratio, so we'll check that first. |
98 | 98 | if (preg_match('/:/', $height)) { |
99 | - $ratio = explode(':', $height); |
|
99 | + $ratio = explode(':', $height); |
|
100 | 100 | |
101 | - // If we only have one ratio value, set the other value to the same value of the first making it a ratio of 1 |
|
102 | - if (!$ratio[1]) { |
|
103 | - $ratio[1] = $ratio[0]; |
|
104 | - } |
|
101 | + // If we only have one ratio value, set the other value to the same value of the first making it a ratio of 1 |
|
102 | + if (!$ratio[1]) { |
|
103 | + $ratio[1] = $ratio[0]; |
|
104 | + } |
|
105 | 105 | |
106 | - if (!$ratio[0]) { |
|
107 | - $ratio[0] = $ratio[1]; |
|
108 | - } |
|
106 | + if (!$ratio[0]) { |
|
107 | + $ratio[0] = $ratio[1]; |
|
108 | + } |
|
109 | 109 | |
110 | - $height = ($width * $ratio[1]) / $ratio[0]; |
|
110 | + $height = ($width * $ratio[1]) / $ratio[0]; |
|
111 | 111 | } else if (preg_match('/:/', $width)) { |
112 | - $ratio = explode(':', $width); |
|
113 | - //If we only have one ratio value, set the other value to the same value of the first making it a ratio of 1 |
|
114 | - if (!$ratio[1]) { |
|
115 | - $ratio[1] = $ratio[0]; |
|
116 | - } |
|
112 | + $ratio = explode(':', $width); |
|
113 | + //If we only have one ratio value, set the other value to the same value of the first making it a ratio of 1 |
|
114 | + if (!$ratio[1]) { |
|
115 | + $ratio[1] = $ratio[0]; |
|
116 | + } |
|
117 | 117 | |
118 | - if (!$ratio[0]) { |
|
119 | - $ratio[0] = $ratio[1]; |
|
120 | - } |
|
118 | + if (!$ratio[0]) { |
|
119 | + $ratio[0] = $ratio[1]; |
|
120 | + } |
|
121 | 121 | |
122 | - $width = ($height * $ratio[0]) / $ratio[1]; |
|
122 | + $width = ($height * $ratio[0]) / $ratio[1]; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | //Limit the size of the image to no more than an area of 16,000,000 |
126 | 126 | $area = $width * $height; |
127 | 127 | if ($area >= 16000000 || $width > 9999 || $height > 9999) { |
128 | - die("Too big of an image!"); |
|
128 | + die("Too big of an image!"); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | //Let's round the dimensions to 3 decimal places for aesthetics |
@@ -144,27 +144,27 @@ discard block |
||
144 | 144 | $fg_color = imageColorAllocate($img, $foreground->get_rgb('r'), $foreground->get_rgb('g'), $foreground->get_rgb('b')); |
145 | 145 | |
146 | 146 | if (empty($_GET['text']) || !isset($_GET['text'])) { |
147 | - preg_match('/&text=(.+)/i', $_GET['x'], $matches); |
|
148 | - if (isset($matches[1])) { |
|
149 | - $_GET['text'] = urldecode($matches[1]); |
|
150 | - } |
|
147 | + preg_match('/&text=(.+)/i', $_GET['x'], $matches); |
|
148 | + if (isset($matches[1])) { |
|
149 | + $_GET['text'] = urldecode($matches[1]); |
|
150 | + } |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | if (isset($_GET['text']) && $_GET['text']) { |
154 | - $_GET['text'] = preg_replace_callback( |
|
155 | - "/(0x[0-9A-F]{,3})/ui", |
|
156 | - function ($matches) { |
|
157 | - return chr(hexdec($matches[0])); |
|
158 | - }, |
|
159 | - $_GET['text'] |
|
160 | - ); |
|
161 | - $lines = substr_count($_GET['text'], '|'); |
|
162 | - $text = preg_replace('/\|/i', "\n", $_GET['text']); |
|
154 | + $_GET['text'] = preg_replace_callback( |
|
155 | + "/(0x[0-9A-F]{,3})/ui", |
|
156 | + function ($matches) { |
|
157 | + return chr(hexdec($matches[0])); |
|
158 | + }, |
|
159 | + $_GET['text'] |
|
160 | + ); |
|
161 | + $lines = substr_count($_GET['text'], '|'); |
|
162 | + $text = preg_replace('/\|/i', "\n", $_GET['text']); |
|
163 | 163 | } else { |
164 | - $lines = 1; |
|
165 | - // This is the default text string that will go right in the middle of the rectangle |
|
166 | - // × is the multiplication sign, it is not an 'x' |
|
167 | - $text = $width . " × " . $height; |
|
164 | + $lines = 1; |
|
165 | + // This is the default text string that will go right in the middle of the rectangle |
|
166 | + // × is the multiplication sign, it is not an 'x' |
|
167 | + $text = $width . " × " . $height; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // Ric Ewing: I modified this to behave better with long or narrow images and condensed the resize code to a single line |
@@ -189,27 +189,27 @@ discard block |
||
189 | 189 | |
190 | 190 | function process_output_buffer($buffer = '') |
191 | 191 | { |
192 | - $buffer = trim($buffer); |
|
193 | - if (strlen($buffer) == 0) { |
|
194 | - return ''; |
|
195 | - } |
|
196 | - return $buffer; |
|
192 | + $buffer = trim($buffer); |
|
193 | + if (strlen($buffer) == 0) { |
|
194 | + return ''; |
|
195 | + } |
|
196 | + return $buffer; |
|
197 | 197 | } |
198 | 198 | // Start output buffering so we can determine the Content-Length of the file |
199 | 199 | ob_start('process_output_buffer'); |
200 | 200 | |
201 | 201 | // Create the final image based on the provided file format. |
202 | 202 | switch ($file_format) { |
203 | - case 'gif': |
|
204 | - imagegif($img); |
|
205 | - break; |
|
206 | - case 'png': |
|
207 | - imagepng($img); |
|
208 | - break; |
|
209 | - case 'jpg': |
|
210 | - case 'jpeg': |
|
211 | - imagejpeg($img); |
|
212 | - break; |
|
203 | + case 'gif': |
|
204 | + imagegif($img); |
|
205 | + break; |
|
206 | + case 'png': |
|
207 | + imagepng($img); |
|
208 | + break; |
|
209 | + case 'jpg': |
|
210 | + case 'jpeg': |
|
211 | + imagejpeg($img); |
|
212 | + break; |
|
213 | 213 | } |
214 | 214 | $output = ob_get_contents(); |
215 | 215 | |
@@ -230,21 +230,21 @@ discard block |
||
230 | 230 | //Ruquay K Calloway http://ruquay.com/sandbox/imagettf/ made a better function to find the coordinates of the text bounding box so I used it. |
231 | 231 | function imagettfbbox_t($size, $text_angle, $fontfile, $text) |
232 | 232 | { |
233 | - // Compute size with a zero angle |
|
234 | - $coords = imagettfbbox($size, 0, $fontfile, $text); |
|
235 | - |
|
236 | - // Convert angle to radians |
|
237 | - $a = deg2rad($text_angle); |
|
238 | - |
|
239 | - // Compute some usefull values |
|
240 | - $ca = cos($a); |
|
241 | - $sa = sin($a); |
|
242 | - $ret = array(); |
|
243 | - |
|
244 | - // Perform transformations |
|
245 | - for ($i = 0; $i < 7; $i += 2) { |
|
246 | - $ret[$i] = round($coords[$i] * $ca + $coords[$i + 1] * $sa); |
|
247 | - $ret[$i + 1] = round($coords[$i + 1] * $ca - $coords[$i] * $sa); |
|
248 | - } |
|
249 | - return $ret; |
|
233 | + // Compute size with a zero angle |
|
234 | + $coords = imagettfbbox($size, 0, $fontfile, $text); |
|
235 | + |
|
236 | + // Convert angle to radians |
|
237 | + $a = deg2rad($text_angle); |
|
238 | + |
|
239 | + // Compute some usefull values |
|
240 | + $ca = cos($a); |
|
241 | + $sa = sin($a); |
|
242 | + $ret = array(); |
|
243 | + |
|
244 | + // Perform transformations |
|
245 | + for ($i = 0; $i < 7; $i += 2) { |
|
246 | + $ret[$i] = round($coords[$i] * $ca + $coords[$i + 1] * $sa); |
|
247 | + $ret[$i + 1] = round($coords[$i + 1] * $ca - $coords[$i] * $sa); |
|
248 | + } |
|
249 | + return $ret; |
|
250 | 250 | } |
@@ -153,7 +153,7 @@ |
||
153 | 153 | if (isset($_GET['text']) && $_GET['text']) { |
154 | 154 | $_GET['text'] = preg_replace_callback( |
155 | 155 | "/(0x[0-9A-F]{,3})/ui", |
156 | - function ($matches) { |
|
156 | + function($matches) { |
|
157 | 157 | return chr(hexdec($matches[0])); |
158 | 158 | }, |
159 | 159 | $_GET['text'] |
@@ -17,275 +17,275 @@ |
||
17 | 17 | class color { |
18 | 18 | |
19 | 19 | /** |
20 | - * @var array $rgb |
|
21 | - * @access private |
|
22 | - * @desc array for RGB colors |
|
23 | - */ |
|
24 | - var $rgb=array('r'=>0,'g'=>0,'b'=>0); |
|
20 | + * @var array $rgb |
|
21 | + * @access private |
|
22 | + * @desc array for RGB colors |
|
23 | + */ |
|
24 | + var $rgb=array('r'=>0,'g'=>0,'b'=>0); |
|
25 | 25 | |
26 | 26 | /** |
27 | - * @var string $hex |
|
28 | - * @access private |
|
29 | - * @desc variable for HTML HEX color |
|
30 | - */ |
|
31 | - var $hex=''; |
|
27 | + * @var string $hex |
|
28 | + * @access private |
|
29 | + * @desc variable for HTML HEX color |
|
30 | + */ |
|
31 | + var $hex=''; |
|
32 | 32 | |
33 | 33 | /** |
34 | - * @var array $cmyk |
|
35 | - * @access private |
|
36 | - * @desc array for cmyk colors |
|
37 | - */ |
|
38 | - var $cmyk=array('c'=>0,'m'=>0,'y'=>0,'b'=>0); |
|
34 | + * @var array $cmyk |
|
35 | + * @access private |
|
36 | + * @desc array for cmyk colors |
|
37 | + */ |
|
38 | + var $cmyk=array('c'=>0,'m'=>0,'y'=>0,'b'=>0); |
|
39 | 39 | |
40 | - /** |
|
41 | - * Sets the RGB values |
|
42 | - * @param int $red number from 0-255 for blue color value |
|
43 | - * @param int $green number from 0-255 for green color value |
|
44 | - * @param int $blue number from 0-255 for blue color value |
|
45 | - * @access public |
|
46 | - * @desc Sets the RGB values |
|
47 | - */ |
|
48 | - function set_rgb($red,$green,$blue){ |
|
40 | + /** |
|
41 | + * Sets the RGB values |
|
42 | + * @param int $red number from 0-255 for blue color value |
|
43 | + * @param int $green number from 0-255 for green color value |
|
44 | + * @param int $blue number from 0-255 for blue color value |
|
45 | + * @access public |
|
46 | + * @desc Sets the RGB values |
|
47 | + */ |
|
48 | + function set_rgb($red,$green,$blue){ |
|
49 | 49 | |
50 | - $this->rgb['r']=$red; |
|
51 | - $this->rgb['g']=$green; |
|
52 | - $this->rgb['b']=$blue; |
|
50 | + $this->rgb['r']=$red; |
|
51 | + $this->rgb['g']=$green; |
|
52 | + $this->rgb['b']=$blue; |
|
53 | 53 | |
54 | - $this->convert_rgb_to_cmyk(); |
|
55 | - $this->convert_rgb_to_hex(); |
|
56 | - } |
|
54 | + $this->convert_rgb_to_cmyk(); |
|
55 | + $this->convert_rgb_to_hex(); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Sets the HEX HTML color value |
|
60 | - * @param string $hex 6,3,2, or 1 characters long. |
|
61 | - * @access public |
|
62 | - * @desc Sets the HEX HTML color value like ffff00. It will convert shorthand to a 6 digit hex. |
|
63 | - */ |
|
64 | - function set_hex($hex){ |
|
65 | - //$hex = settype($hex, 'string'); |
|
66 | - $hex = strtolower($hex); |
|
67 | - $hex = preg_replace('/#/', '', $hex); //Strips out the # character |
|
68 | - $hexlength = strlen($hex); |
|
69 | - $input = $hex; |
|
70 | - switch($hexlength) { |
|
71 | - case 1: |
|
72 | - $hex = $input.$input.$input.$input.$input.$input; |
|
73 | - break; |
|
74 | - case 2: |
|
75 | - $hex = $input[0].$input[1].$input[0].$input[1].$input[0].$input[1]; |
|
76 | - break; |
|
77 | - case 3: |
|
78 | - $hex = $input[0].$input[0].$input[1].$input[1].$input[2].$input[2]; |
|
79 | - break; |
|
80 | - } |
|
81 | - $this->hex=$hex; |
|
58 | + /** |
|
59 | + * Sets the HEX HTML color value |
|
60 | + * @param string $hex 6,3,2, or 1 characters long. |
|
61 | + * @access public |
|
62 | + * @desc Sets the HEX HTML color value like ffff00. It will convert shorthand to a 6 digit hex. |
|
63 | + */ |
|
64 | + function set_hex($hex){ |
|
65 | + //$hex = settype($hex, 'string'); |
|
66 | + $hex = strtolower($hex); |
|
67 | + $hex = preg_replace('/#/', '', $hex); //Strips out the # character |
|
68 | + $hexlength = strlen($hex); |
|
69 | + $input = $hex; |
|
70 | + switch($hexlength) { |
|
71 | + case 1: |
|
72 | + $hex = $input.$input.$input.$input.$input.$input; |
|
73 | + break; |
|
74 | + case 2: |
|
75 | + $hex = $input[0].$input[1].$input[0].$input[1].$input[0].$input[1]; |
|
76 | + break; |
|
77 | + case 3: |
|
78 | + $hex = $input[0].$input[0].$input[1].$input[1].$input[2].$input[2]; |
|
79 | + break; |
|
80 | + } |
|
81 | + $this->hex=$hex; |
|
82 | 82 | |
83 | - $this->convert_hex_to_rgb(); |
|
84 | - $this->convert_rgb_to_cmyk(); |
|
85 | - } |
|
83 | + $this->convert_hex_to_rgb(); |
|
84 | + $this->convert_rgb_to_cmyk(); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Sets the HTML color name, converting it to a 6 digit hex code. |
|
89 | - * @param string $name The name of the color. |
|
90 | - * @access public |
|
91 | - * @desc Sets the HTML color name, converting it to a 6 digit hex code. |
|
92 | - */ |
|
93 | - function set_name($name){ |
|
94 | - $this->hex = $this->convert_name_to_hex($name); |
|
87 | + /** |
|
88 | + * Sets the HTML color name, converting it to a 6 digit hex code. |
|
89 | + * @param string $name The name of the color. |
|
90 | + * @access public |
|
91 | + * @desc Sets the HTML color name, converting it to a 6 digit hex code. |
|
92 | + */ |
|
93 | + function set_name($name){ |
|
94 | + $this->hex = $this->convert_name_to_hex($name); |
|
95 | 95 | |
96 | - $this->convert_hex_to_rgb(); |
|
97 | - $this->convert_rgb_to_cmyk(); |
|
98 | - } |
|
96 | + $this->convert_hex_to_rgb(); |
|
97 | + $this->convert_rgb_to_cmyk(); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * Sets the CMYK color values |
|
102 | - * @param int $c number from 0-100 for c color value |
|
103 | - * @param int $m number from 0-100 for m color value |
|
104 | - * @param int $y number from 0-100 for y color value |
|
105 | - * @param int $b number from 0-100 for b color value |
|
106 | - * @access public |
|
107 | - * @desc Sets the CMYK color values |
|
108 | - */ |
|
109 | - function set_cmyk($c,$m,$y,$b){ |
|
110 | - $this->cmyk['c']=$c; |
|
111 | - $this->cmyk['m']=$m; |
|
112 | - $this->cmyk['y']=$y; |
|
113 | - $this->cmyk['b']=$b; |
|
100 | + /** |
|
101 | + * Sets the CMYK color values |
|
102 | + * @param int $c number from 0-100 for c color value |
|
103 | + * @param int $m number from 0-100 for m color value |
|
104 | + * @param int $y number from 0-100 for y color value |
|
105 | + * @param int $b number from 0-100 for b color value |
|
106 | + * @access public |
|
107 | + * @desc Sets the CMYK color values |
|
108 | + */ |
|
109 | + function set_cmyk($c,$m,$y,$b){ |
|
110 | + $this->cmyk['c']=$c; |
|
111 | + $this->cmyk['m']=$m; |
|
112 | + $this->cmyk['y']=$y; |
|
113 | + $this->cmyk['b']=$b; |
|
114 | 114 | |
115 | - $this->convert_cmyk_to_rgb(); |
|
116 | - $this->convert_rgb_to_hex(); |
|
117 | - } |
|
115 | + $this->convert_cmyk_to_rgb(); |
|
116 | + $this->convert_rgb_to_hex(); |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Sets the pantone color value |
|
121 | - * @param string $pantone_name name of the pantone color |
|
122 | - * @access public |
|
123 | - * @desc Sets the pantone color value |
|
124 | - */ |
|
125 | - function set_pantone($pantone_name){ |
|
126 | - $this->pantone=$pantone_name; |
|
127 | - $this->cmyk['c']=$this->pantone_pallete[$pantone_name]['c']; |
|
128 | - $this->cmyk['m']=$this->pantone_pallete[$pantone_name]['m']; |
|
129 | - $this->cmyk['y']=$this->pantone_pallete[$pantone_name]['y']; |
|
130 | - $this->cmyk['b']=$this->pantone_pallete[$pantone_name]['b']; |
|
119 | + /** |
|
120 | + * Sets the pantone color value |
|
121 | + * @param string $pantone_name name of the pantone color |
|
122 | + * @access public |
|
123 | + * @desc Sets the pantone color value |
|
124 | + */ |
|
125 | + function set_pantone($pantone_name){ |
|
126 | + $this->pantone=$pantone_name; |
|
127 | + $this->cmyk['c']=$this->pantone_pallete[$pantone_name]['c']; |
|
128 | + $this->cmyk['m']=$this->pantone_pallete[$pantone_name]['m']; |
|
129 | + $this->cmyk['y']=$this->pantone_pallete[$pantone_name]['y']; |
|
130 | + $this->cmyk['b']=$this->pantone_pallete[$pantone_name]['b']; |
|
131 | 131 | |
132 | - $this->convert_cmyk_to_rgb(); |
|
133 | - $this->convert_rgb_to_hex(); |
|
134 | - } |
|
132 | + $this->convert_cmyk_to_rgb(); |
|
133 | + $this->convert_rgb_to_hex(); |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Sets the pantone pc color value |
|
138 | - * @param string $pantone_name_pc name of the pantone pc color |
|
139 | - * @access public |
|
140 | - * @desc Sets the pantone pc color value |
|
141 | - */ |
|
142 | - function set_pantone_pc($pantone_name){ |
|
143 | - $this->pantone_pc=$pantone_name; |
|
144 | - $this->cmyk['c']=$this->pantone_pallete_pc[$pantone_name]['c']; |
|
145 | - $this->cmyk['m']=$this->pantone_pallete_pc[$pantone_name]['m']; |
|
146 | - $this->cmyk['y']=$this->pantone_pallete_pc[$pantone_name]['y']; |
|
147 | - $this->cmyk['b']=$this->pantone_pallete_pc[$pantone_name]['b']; |
|
136 | + /** |
|
137 | + * Sets the pantone pc color value |
|
138 | + * @param string $pantone_name_pc name of the pantone pc color |
|
139 | + * @access public |
|
140 | + * @desc Sets the pantone pc color value |
|
141 | + */ |
|
142 | + function set_pantone_pc($pantone_name){ |
|
143 | + $this->pantone_pc=$pantone_name; |
|
144 | + $this->cmyk['c']=$this->pantone_pallete_pc[$pantone_name]['c']; |
|
145 | + $this->cmyk['m']=$this->pantone_pallete_pc[$pantone_name]['m']; |
|
146 | + $this->cmyk['y']=$this->pantone_pallete_pc[$pantone_name]['y']; |
|
147 | + $this->cmyk['b']=$this->pantone_pallete_pc[$pantone_name]['b']; |
|
148 | 148 | |
149 | - $this->convert_cmyk_to_rgb(); |
|
150 | - $this->convert_rgb_to_hex(); |
|
151 | - } |
|
149 | + $this->convert_cmyk_to_rgb(); |
|
150 | + $this->convert_rgb_to_hex(); |
|
151 | + } |
|
152 | 152 | |
153 | - //include("pantone.color.class.php"); |
|
153 | + //include("pantone.color.class.php"); |
|
154 | 154 | |
155 | - /** |
|
156 | - * Returns the RGB values of a set color |
|
157 | - * @return array $rgb color values of red ($rgb['r']), green ($rgb['green') and blue ($rgb['b']) |
|
158 | - * @access public |
|
159 | - * @desc Returns the RGB values of a set color |
|
160 | - */ |
|
161 | - function get_rgb($val){ |
|
162 | - if($val) { |
|
163 | - return $this->rgb[$val]; |
|
164 | - } else { |
|
165 | - return $this->rgb; |
|
166 | - } |
|
167 | - } |
|
155 | + /** |
|
156 | + * Returns the RGB values of a set color |
|
157 | + * @return array $rgb color values of red ($rgb['r']), green ($rgb['green') and blue ($rgb['b']) |
|
158 | + * @access public |
|
159 | + * @desc Returns the RGB values of a set color |
|
160 | + */ |
|
161 | + function get_rgb($val){ |
|
162 | + if($val) { |
|
163 | + return $this->rgb[$val]; |
|
164 | + } else { |
|
165 | + return $this->rgb; |
|
166 | + } |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Returns the HEX HTML color value of a set color |
|
171 | - * @return string $hex HEX HTML color value |
|
172 | - * @access public |
|
173 | - * @desc Returns the HEX HTML color value of a set color |
|
174 | - */ |
|
175 | - function get_hex(){ |
|
176 | - return $this->hex; |
|
177 | - } |
|
169 | + /** |
|
170 | + * Returns the HEX HTML color value of a set color |
|
171 | + * @return string $hex HEX HTML color value |
|
172 | + * @access public |
|
173 | + * @desc Returns the HEX HTML color value of a set color |
|
174 | + */ |
|
175 | + function get_hex(){ |
|
176 | + return $this->hex; |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Returns the CMYK values of a set color |
|
181 | - * @return array $cmyk color values of c ($cmyk['c']), m ($cmyk['m'), y ($cmyk['blue']) and b ($cmyk['b']) |
|
182 | - * @access public |
|
183 | - * @desc Returns the CMYK values of a set color |
|
184 | - */ |
|
185 | - function get_cmyk(){ |
|
186 | - return $this->cmyk; |
|
187 | - } |
|
179 | + /** |
|
180 | + * Returns the CMYK values of a set color |
|
181 | + * @return array $cmyk color values of c ($cmyk['c']), m ($cmyk['m'), y ($cmyk['blue']) and b ($cmyk['b']) |
|
182 | + * @access public |
|
183 | + * @desc Returns the CMYK values of a set color |
|
184 | + */ |
|
185 | + function get_cmyk(){ |
|
186 | + return $this->cmyk; |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
190 | - * Converts the RGB colors to HEX HTML colors |
|
191 | - * @access private |
|
192 | - * @desc Converts the RGB colors to HEX HTML colors |
|
193 | - */ |
|
194 | - function convert_rgb_to_hex(){ |
|
195 | - $this->hex=$this->hex_trip[$this->rgb['r']].$this->hex_trip[$this->rgb['g']].$this->hex_trip[$this->rgb['b']]; |
|
196 | - } |
|
189 | + /** |
|
190 | + * Converts the RGB colors to HEX HTML colors |
|
191 | + * @access private |
|
192 | + * @desc Converts the RGB colors to HEX HTML colors |
|
193 | + */ |
|
194 | + function convert_rgb_to_hex(){ |
|
195 | + $this->hex=$this->hex_trip[$this->rgb['r']].$this->hex_trip[$this->rgb['g']].$this->hex_trip[$this->rgb['b']]; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * Converts the RGB colors to CMYK colors |
|
200 | - * @access private |
|
201 | - * @desc Converts the RGB colors to CMYK colors |
|
202 | - */ |
|
203 | - function convert_rgb_to_cmyk(){ |
|
204 | - $c = (255-$this->rgb['r'] )/255.0*100; |
|
205 | - $m = (255-$this->rgb['g'] )/255.0*100; |
|
206 | - $y = (255-$this->rgb['b'] )/255.0*100; |
|
198 | + /** |
|
199 | + * Converts the RGB colors to CMYK colors |
|
200 | + * @access private |
|
201 | + * @desc Converts the RGB colors to CMYK colors |
|
202 | + */ |
|
203 | + function convert_rgb_to_cmyk(){ |
|
204 | + $c = (255-$this->rgb['r'] )/255.0*100; |
|
205 | + $m = (255-$this->rgb['g'] )/255.0*100; |
|
206 | + $y = (255-$this->rgb['b'] )/255.0*100; |
|
207 | 207 | |
208 | - $b = min(array($c,$m,$y)); |
|
209 | - $c=$c-$b; |
|
210 | - $m=$m-$b; |
|
211 | - $y=$y-$b; |
|
208 | + $b = min(array($c,$m,$y)); |
|
209 | + $c=$c-$b; |
|
210 | + $m=$m-$b; |
|
211 | + $y=$y-$b; |
|
212 | 212 | |
213 | - $this->cmyk = array( 'c' => $c, 'm' => $m, 'y' => $y, 'b' => $b); |
|
214 | - } |
|
213 | + $this->cmyk = array( 'c' => $c, 'm' => $m, 'y' => $y, 'b' => $b); |
|
214 | + } |
|
215 | 215 | |
216 | - /** |
|
217 | - * Converts the CMYK colors to RGB colors |
|
218 | - * @access private |
|
219 | - * @desc Converts the CMYK colors to RGB colors |
|
220 | - */ |
|
221 | - function convert_cmyk_to_rgb(){ |
|
222 | - $red=$this->cmyk['c']+$this->cmyk['b']; |
|
223 | - $green=$this->cmyk['m']+$this->cmyk['b']; |
|
224 | - $blue=$this->cmyk['y']+$this->cmyk['b']; |
|
216 | + /** |
|
217 | + * Converts the CMYK colors to RGB colors |
|
218 | + * @access private |
|
219 | + * @desc Converts the CMYK colors to RGB colors |
|
220 | + */ |
|
221 | + function convert_cmyk_to_rgb(){ |
|
222 | + $red=$this->cmyk['c']+$this->cmyk['b']; |
|
223 | + $green=$this->cmyk['m']+$this->cmyk['b']; |
|
224 | + $blue=$this->cmyk['y']+$this->cmyk['b']; |
|
225 | 225 | |
226 | - $red=($red-100)*(-1); |
|
227 | - $green=($green-100)*(-1); |
|
228 | - $blue=($blue-100)*(-1); |
|
226 | + $red=($red-100)*(-1); |
|
227 | + $green=($green-100)*(-1); |
|
228 | + $blue=($blue-100)*(-1); |
|
229 | 229 | |
230 | - $red=round($red/100*255,0); |
|
231 | - $green=round($green/100*255,0); |
|
232 | - $blue=round($blue/100*255,0); |
|
230 | + $red=round($red/100*255,0); |
|
231 | + $green=round($green/100*255,0); |
|
232 | + $blue=round($blue/100*255,0); |
|
233 | 233 | |
234 | - $this->rgb['r']=$red; |
|
235 | - $this->rgb['g']=$green; |
|
236 | - $this->rgb['b']=$blue; |
|
237 | - } |
|
234 | + $this->rgb['r']=$red; |
|
235 | + $this->rgb['g']=$green; |
|
236 | + $this->rgb['b']=$blue; |
|
237 | + } |
|
238 | 238 | |
239 | - /** |
|
240 | - * Converts the HTML HEX colors to RGB colors |
|
241 | - * @access private |
|
242 | - * @desc Converts the HTML HEX colors to RGB colors |
|
243 | - * @url http://css-tricks.com/snippets/php/convert-hex-to-rgb/ |
|
244 | - */ |
|
245 | - function convert_hex_to_rgb(){ |
|
246 | - $red = substr($this->hex,0,2); |
|
247 | - $green = substr($this->hex,2,2); |
|
248 | - $blue = substr($this->hex,4,2); |
|
239 | + /** |
|
240 | + * Converts the HTML HEX colors to RGB colors |
|
241 | + * @access private |
|
242 | + * @desc Converts the HTML HEX colors to RGB colors |
|
243 | + * @url http://css-tricks.com/snippets/php/convert-hex-to-rgb/ |
|
244 | + */ |
|
245 | + function convert_hex_to_rgb(){ |
|
246 | + $red = substr($this->hex,0,2); |
|
247 | + $green = substr($this->hex,2,2); |
|
248 | + $blue = substr($this->hex,4,2); |
|
249 | 249 | $this->rgb['r'] = hexdec( $red ); |
250 | 250 | $this->rgb['g'] = hexdec( $green ); |
251 | 251 | $this->rgb['b'] = hexdec( $blue ); |
252 | - } |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * Converts HTML color name to 6 digit HEX value. |
|
256 | - * @access private |
|
257 | - * @param string $name One of the offical HTML color names. |
|
258 | - * @desc Converts HTML color name to 6 digit HEX value. |
|
259 | - * @url http://en.wikipedia.org/wiki/HTML_color_names |
|
260 | - */ |
|
261 | - function convert_name_to_hex($name){ |
|
262 | - $color_names = array( |
|
263 | - 'aqua' => '00ffff', |
|
264 | - 'cyan' => '00ffff', |
|
265 | - 'gray' => '808080', |
|
266 | - 'grey' => '808080', |
|
267 | - 'navy' => '000080', |
|
268 | - 'silver' => 'C0C0C0', |
|
269 | - 'black' => '000000', |
|
270 | - 'green' => '008000', |
|
271 | - 'olive' => '808000', |
|
272 | - 'teal' => '008080', |
|
273 | - 'blue' => '0000FF', |
|
274 | - 'lime' => '00FF00', |
|
275 | - 'purple' => '800080', |
|
276 | - 'white' => 'ffffff', |
|
277 | - 'fuchsia' => 'FF00FF', |
|
278 | - 'magenta' => 'FF00FF', |
|
279 | - 'maroon' => '800000', |
|
280 | - 'red' => 'FF0000', |
|
281 | - 'yellow' => 'FFFF00' |
|
282 | - ); |
|
283 | - if (array_key_exists($name, $color_names)) { |
|
284 | - return $color_names[$name]; |
|
285 | - } |
|
286 | - else { |
|
287 | - //error |
|
288 | - } |
|
289 | - } |
|
254 | + /** |
|
255 | + * Converts HTML color name to 6 digit HEX value. |
|
256 | + * @access private |
|
257 | + * @param string $name One of the offical HTML color names. |
|
258 | + * @desc Converts HTML color name to 6 digit HEX value. |
|
259 | + * @url http://en.wikipedia.org/wiki/HTML_color_names |
|
260 | + */ |
|
261 | + function convert_name_to_hex($name){ |
|
262 | + $color_names = array( |
|
263 | + 'aqua' => '00ffff', |
|
264 | + 'cyan' => '00ffff', |
|
265 | + 'gray' => '808080', |
|
266 | + 'grey' => '808080', |
|
267 | + 'navy' => '000080', |
|
268 | + 'silver' => 'C0C0C0', |
|
269 | + 'black' => '000000', |
|
270 | + 'green' => '008000', |
|
271 | + 'olive' => '808000', |
|
272 | + 'teal' => '008080', |
|
273 | + 'blue' => '0000FF', |
|
274 | + 'lime' => '00FF00', |
|
275 | + 'purple' => '800080', |
|
276 | + 'white' => 'ffffff', |
|
277 | + 'fuchsia' => 'FF00FF', |
|
278 | + 'magenta' => 'FF00FF', |
|
279 | + 'maroon' => '800000', |
|
280 | + 'red' => 'FF0000', |
|
281 | + 'yellow' => 'FFFF00' |
|
282 | + ); |
|
283 | + if (array_key_exists($name, $color_names)) { |
|
284 | + return $color_names[$name]; |
|
285 | + } |
|
286 | + else { |
|
287 | + //error |
|
288 | + } |
|
289 | + } |
|
290 | 290 | } |
291 | 291 | ?> |
292 | 292 | \ No newline at end of file |
@@ -21,21 +21,21 @@ discard block |
||
21 | 21 | * @access private |
22 | 22 | * @desc array for RGB colors |
23 | 23 | */ |
24 | - var $rgb=array('r'=>0,'g'=>0,'b'=>0); |
|
24 | + var $rgb = array('r'=>0, 'g'=>0, 'b'=>0); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @var string $hex |
28 | 28 | * @access private |
29 | 29 | * @desc variable for HTML HEX color |
30 | 30 | */ |
31 | - var $hex=''; |
|
31 | + var $hex = ''; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @var array $cmyk |
35 | 35 | * @access private |
36 | 36 | * @desc array for cmyk colors |
37 | 37 | */ |
38 | - var $cmyk=array('c'=>0,'m'=>0,'y'=>0,'b'=>0); |
|
38 | + var $cmyk = array('c'=>0, 'm'=>0, 'y'=>0, 'b'=>0); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Sets the RGB values |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | * @access public |
46 | 46 | * @desc Sets the RGB values |
47 | 47 | */ |
48 | - function set_rgb($red,$green,$blue){ |
|
48 | + function set_rgb($red, $green, $blue) { |
|
49 | 49 | |
50 | - $this->rgb['r']=$red; |
|
51 | - $this->rgb['g']=$green; |
|
52 | - $this->rgb['b']=$blue; |
|
50 | + $this->rgb['r'] = $red; |
|
51 | + $this->rgb['g'] = $green; |
|
52 | + $this->rgb['b'] = $blue; |
|
53 | 53 | |
54 | 54 | $this->convert_rgb_to_cmyk(); |
55 | 55 | $this->convert_rgb_to_hex(); |
@@ -61,24 +61,24 @@ discard block |
||
61 | 61 | * @access public |
62 | 62 | * @desc Sets the HEX HTML color value like ffff00. It will convert shorthand to a 6 digit hex. |
63 | 63 | */ |
64 | - function set_hex($hex){ |
|
64 | + function set_hex($hex) { |
|
65 | 65 | //$hex = settype($hex, 'string'); |
66 | 66 | $hex = strtolower($hex); |
67 | 67 | $hex = preg_replace('/#/', '', $hex); //Strips out the # character |
68 | 68 | $hexlength = strlen($hex); |
69 | 69 | $input = $hex; |
70 | - switch($hexlength) { |
|
70 | + switch ($hexlength) { |
|
71 | 71 | case 1: |
72 | - $hex = $input.$input.$input.$input.$input.$input; |
|
72 | + $hex = $input . $input . $input . $input . $input . $input; |
|
73 | 73 | break; |
74 | 74 | case 2: |
75 | - $hex = $input[0].$input[1].$input[0].$input[1].$input[0].$input[1]; |
|
75 | + $hex = $input[0] . $input[1] . $input[0] . $input[1] . $input[0] . $input[1]; |
|
76 | 76 | break; |
77 | 77 | case 3: |
78 | - $hex = $input[0].$input[0].$input[1].$input[1].$input[2].$input[2]; |
|
78 | + $hex = $input[0] . $input[0] . $input[1] . $input[1] . $input[2] . $input[2]; |
|
79 | 79 | break; |
80 | 80 | } |
81 | - $this->hex=$hex; |
|
81 | + $this->hex = $hex; |
|
82 | 82 | |
83 | 83 | $this->convert_hex_to_rgb(); |
84 | 84 | $this->convert_rgb_to_cmyk(); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @access public |
91 | 91 | * @desc Sets the HTML color name, converting it to a 6 digit hex code. |
92 | 92 | */ |
93 | - function set_name($name){ |
|
93 | + function set_name($name) { |
|
94 | 94 | $this->hex = $this->convert_name_to_hex($name); |
95 | 95 | |
96 | 96 | $this->convert_hex_to_rgb(); |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | * @access public |
107 | 107 | * @desc Sets the CMYK color values |
108 | 108 | */ |
109 | - function set_cmyk($c,$m,$y,$b){ |
|
110 | - $this->cmyk['c']=$c; |
|
111 | - $this->cmyk['m']=$m; |
|
112 | - $this->cmyk['y']=$y; |
|
113 | - $this->cmyk['b']=$b; |
|
109 | + function set_cmyk($c, $m, $y, $b) { |
|
110 | + $this->cmyk['c'] = $c; |
|
111 | + $this->cmyk['m'] = $m; |
|
112 | + $this->cmyk['y'] = $y; |
|
113 | + $this->cmyk['b'] = $b; |
|
114 | 114 | |
115 | 115 | $this->convert_cmyk_to_rgb(); |
116 | 116 | $this->convert_rgb_to_hex(); |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | * @access public |
123 | 123 | * @desc Sets the pantone color value |
124 | 124 | */ |
125 | - function set_pantone($pantone_name){ |
|
126 | - $this->pantone=$pantone_name; |
|
127 | - $this->cmyk['c']=$this->pantone_pallete[$pantone_name]['c']; |
|
128 | - $this->cmyk['m']=$this->pantone_pallete[$pantone_name]['m']; |
|
129 | - $this->cmyk['y']=$this->pantone_pallete[$pantone_name]['y']; |
|
130 | - $this->cmyk['b']=$this->pantone_pallete[$pantone_name]['b']; |
|
125 | + function set_pantone($pantone_name) { |
|
126 | + $this->pantone = $pantone_name; |
|
127 | + $this->cmyk['c'] = $this->pantone_pallete[$pantone_name]['c']; |
|
128 | + $this->cmyk['m'] = $this->pantone_pallete[$pantone_name]['m']; |
|
129 | + $this->cmyk['y'] = $this->pantone_pallete[$pantone_name]['y']; |
|
130 | + $this->cmyk['b'] = $this->pantone_pallete[$pantone_name]['b']; |
|
131 | 131 | |
132 | 132 | $this->convert_cmyk_to_rgb(); |
133 | 133 | $this->convert_rgb_to_hex(); |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | * @access public |
140 | 140 | * @desc Sets the pantone pc color value |
141 | 141 | */ |
142 | - function set_pantone_pc($pantone_name){ |
|
143 | - $this->pantone_pc=$pantone_name; |
|
144 | - $this->cmyk['c']=$this->pantone_pallete_pc[$pantone_name]['c']; |
|
145 | - $this->cmyk['m']=$this->pantone_pallete_pc[$pantone_name]['m']; |
|
146 | - $this->cmyk['y']=$this->pantone_pallete_pc[$pantone_name]['y']; |
|
147 | - $this->cmyk['b']=$this->pantone_pallete_pc[$pantone_name]['b']; |
|
142 | + function set_pantone_pc($pantone_name) { |
|
143 | + $this->pantone_pc = $pantone_name; |
|
144 | + $this->cmyk['c'] = $this->pantone_pallete_pc[$pantone_name]['c']; |
|
145 | + $this->cmyk['m'] = $this->pantone_pallete_pc[$pantone_name]['m']; |
|
146 | + $this->cmyk['y'] = $this->pantone_pallete_pc[$pantone_name]['y']; |
|
147 | + $this->cmyk['b'] = $this->pantone_pallete_pc[$pantone_name]['b']; |
|
148 | 148 | |
149 | 149 | $this->convert_cmyk_to_rgb(); |
150 | 150 | $this->convert_rgb_to_hex(); |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @access public |
159 | 159 | * @desc Returns the RGB values of a set color |
160 | 160 | */ |
161 | - function get_rgb($val){ |
|
162 | - if($val) { |
|
161 | + function get_rgb($val) { |
|
162 | + if ($val) { |
|
163 | 163 | return $this->rgb[$val]; |
164 | 164 | } else { |
165 | 165 | return $this->rgb; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @access public |
173 | 173 | * @desc Returns the HEX HTML color value of a set color |
174 | 174 | */ |
175 | - function get_hex(){ |
|
175 | + function get_hex() { |
|
176 | 176 | return $this->hex; |
177 | 177 | } |
178 | 178 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @access public |
183 | 183 | * @desc Returns the CMYK values of a set color |
184 | 184 | */ |
185 | - function get_cmyk(){ |
|
185 | + function get_cmyk() { |
|
186 | 186 | return $this->cmyk; |
187 | 187 | } |
188 | 188 | |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | * @access private |
192 | 192 | * @desc Converts the RGB colors to HEX HTML colors |
193 | 193 | */ |
194 | - function convert_rgb_to_hex(){ |
|
195 | - $this->hex=$this->hex_trip[$this->rgb['r']].$this->hex_trip[$this->rgb['g']].$this->hex_trip[$this->rgb['b']]; |
|
194 | + function convert_rgb_to_hex() { |
|
195 | + $this->hex = $this->hex_trip[$this->rgb['r']] . $this->hex_trip[$this->rgb['g']] . $this->hex_trip[$this->rgb['b']]; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | * @access private |
201 | 201 | * @desc Converts the RGB colors to CMYK colors |
202 | 202 | */ |
203 | - function convert_rgb_to_cmyk(){ |
|
204 | - $c = (255-$this->rgb['r'] )/255.0*100; |
|
205 | - $m = (255-$this->rgb['g'] )/255.0*100; |
|
206 | - $y = (255-$this->rgb['b'] )/255.0*100; |
|
203 | + function convert_rgb_to_cmyk() { |
|
204 | + $c = (255 - $this->rgb['r']) / 255.0 * 100; |
|
205 | + $m = (255 - $this->rgb['g']) / 255.0 * 100; |
|
206 | + $y = (255 - $this->rgb['b']) / 255.0 * 100; |
|
207 | 207 | |
208 | - $b = min(array($c,$m,$y)); |
|
209 | - $c=$c-$b; |
|
210 | - $m=$m-$b; |
|
211 | - $y=$y-$b; |
|
208 | + $b = min(array($c, $m, $y)); |
|
209 | + $c = $c - $b; |
|
210 | + $m = $m - $b; |
|
211 | + $y = $y - $b; |
|
212 | 212 | |
213 | - $this->cmyk = array( 'c' => $c, 'm' => $m, 'y' => $y, 'b' => $b); |
|
213 | + $this->cmyk = array('c' => $c, 'm' => $m, 'y' => $y, 'b' => $b); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -218,22 +218,22 @@ discard block |
||
218 | 218 | * @access private |
219 | 219 | * @desc Converts the CMYK colors to RGB colors |
220 | 220 | */ |
221 | - function convert_cmyk_to_rgb(){ |
|
222 | - $red=$this->cmyk['c']+$this->cmyk['b']; |
|
223 | - $green=$this->cmyk['m']+$this->cmyk['b']; |
|
224 | - $blue=$this->cmyk['y']+$this->cmyk['b']; |
|
221 | + function convert_cmyk_to_rgb() { |
|
222 | + $red = $this->cmyk['c'] + $this->cmyk['b']; |
|
223 | + $green = $this->cmyk['m'] + $this->cmyk['b']; |
|
224 | + $blue = $this->cmyk['y'] + $this->cmyk['b']; |
|
225 | 225 | |
226 | - $red=($red-100)*(-1); |
|
227 | - $green=($green-100)*(-1); |
|
228 | - $blue=($blue-100)*(-1); |
|
226 | + $red = ($red - 100) * (-1); |
|
227 | + $green = ($green - 100) * (-1); |
|
228 | + $blue = ($blue - 100) * (-1); |
|
229 | 229 | |
230 | - $red=round($red/100*255,0); |
|
231 | - $green=round($green/100*255,0); |
|
232 | - $blue=round($blue/100*255,0); |
|
230 | + $red = round($red / 100 * 255, 0); |
|
231 | + $green = round($green / 100 * 255, 0); |
|
232 | + $blue = round($blue / 100 * 255, 0); |
|
233 | 233 | |
234 | - $this->rgb['r']=$red; |
|
235 | - $this->rgb['g']=$green; |
|
236 | - $this->rgb['b']=$blue; |
|
234 | + $this->rgb['r'] = $red; |
|
235 | + $this->rgb['g'] = $green; |
|
236 | + $this->rgb['b'] = $blue; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -242,13 +242,13 @@ discard block |
||
242 | 242 | * @desc Converts the HTML HEX colors to RGB colors |
243 | 243 | * @url http://css-tricks.com/snippets/php/convert-hex-to-rgb/ |
244 | 244 | */ |
245 | - function convert_hex_to_rgb(){ |
|
246 | - $red = substr($this->hex,0,2); |
|
247 | - $green = substr($this->hex,2,2); |
|
248 | - $blue = substr($this->hex,4,2); |
|
249 | - $this->rgb['r'] = hexdec( $red ); |
|
250 | - $this->rgb['g'] = hexdec( $green ); |
|
251 | - $this->rgb['b'] = hexdec( $blue ); |
|
245 | + function convert_hex_to_rgb() { |
|
246 | + $red = substr($this->hex, 0, 2); |
|
247 | + $green = substr($this->hex, 2, 2); |
|
248 | + $blue = substr($this->hex, 4, 2); |
|
249 | + $this->rgb['r'] = hexdec($red); |
|
250 | + $this->rgb['g'] = hexdec($green); |
|
251 | + $this->rgb['b'] = hexdec($blue); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @desc Converts HTML color name to 6 digit HEX value. |
259 | 259 | * @url http://en.wikipedia.org/wiki/HTML_color_names |
260 | 260 | */ |
261 | - function convert_name_to_hex($name){ |
|
261 | + function convert_name_to_hex($name) { |
|
262 | 262 | $color_names = array( |
263 | 263 | 'aqua' => '00ffff', |
264 | 264 | 'cyan' => '00ffff', |
@@ -282,8 +282,7 @@ |
||
282 | 282 | ); |
283 | 283 | if (array_key_exists($name, $color_names)) { |
284 | 284 | return $color_names[$name]; |
285 | - } |
|
286 | - else { |
|
285 | + } else { |
|
287 | 286 | //error |
288 | 287 | } |
289 | 288 | } |