Completed
Push — master ( 0669d1...20d753 )
by Dimas
09:15 queued 01:26
created
src/MVC/function.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  */
8 8
 function maintenance()
9 9
 {
10
-	include __DIR__ . '/maintenance.php';
11
-	exit;
10
+  include __DIR__ . '/maintenance.php';
11
+  exit;
12 12
 }
13 13
 /**
14 14
  * Debug Error
@@ -17,6 +17,6 @@  discard block
 block discarded – undo
17 17
  */
18 18
 function show_error()
19 19
 {
20
-	error_reporting(E_ALL);
21
-	ini_set('display_errors', 'On');
20
+  error_reporting(E_ALL);
21
+  ini_set('display_errors', 'On');
22 22
 }
Please login to merge, or discard this patch.
src/shim/JSLikeHTMLElement.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -37,83 +37,83 @@
 block discarded – undo
37 37
  */
38 38
 class JSLikeHTMLElement extends DOMElement
39 39
 {
40
-	/**
41
-	 * Used for setting innerHTML like it's done in JavaScript:.
42
-	 *
43
-	 * @code
44
-	 * $div->innerHTML = '<h2>Chapter 2</h2><p>The story begins...</p>';
45
-	 * @endcode
46
-	 */
47
-	public function __set($name, $value)
48
-	{
49
-		if ('innerHTML' == $name) {
50
-			// first, empty the element
51
-			for ($x = $this->childNodes->length - 1; $x >= 0; --$x) {
52
-				$this->removeChild($this->childNodes->item($x));
53
-			}
54
-			// $value holds our new inner HTML
55
-			if ('' != $value) {
56
-				$f = $this->ownerDocument->createDocumentFragment();
57
-				// appendXML() expects well-formed markup (XHTML)
58
-				$result = @$f->appendXML($value); // @ to suppress PHP warnings
59
-				if ($result) {
60
-					if ($f->hasChildNodes()) {
61
-						$this->appendChild($f);
62
-					}
63
-				} else {
64
-					// $value is probably ill-formed
65
-					$f = new DOMDocument();
66
-					$value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
67
-					// Using <htmlfragment> will generate a warning, but so will bad HTML
68
-					// (and by this point, bad HTML is what we've got).
69
-					// We use it (and suppress the warning) because an HTML fragment will
70
-					// be wrapped around <html><body> tags which we don't really want to keep.
71
-					// Note: despite the warning, if loadHTML succeeds it will return true.
72
-					$result = @$f->loadHTML('<htmlfragment>' . $value . '</htmlfragment>');
73
-					if ($result) {
74
-						$import = $f->getElementsByTagName('htmlfragment')->item(0);
75
-						foreach ($import->childNodes as $child) {
76
-							$importedNode = $this->ownerDocument->importNode($child, true);
77
-							$this->appendChild($importedNode);
78
-						}
79
-					} else {
80
-						// oh well, we tried, we really did. :(
81
-						// this element is now empty
82
-					}
83
-				}
84
-			}
85
-		} else {
86
-			$trace = debug_backtrace();
87
-			trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
88
-		}
89
-	}
40
+  /**
41
+   * Used for setting innerHTML like it's done in JavaScript:.
42
+   *
43
+   * @code
44
+   * $div->innerHTML = '<h2>Chapter 2</h2><p>The story begins...</p>';
45
+   * @endcode
46
+   */
47
+  public function __set($name, $value)
48
+  {
49
+    if ('innerHTML' == $name) {
50
+      // first, empty the element
51
+      for ($x = $this->childNodes->length - 1; $x >= 0; --$x) {
52
+        $this->removeChild($this->childNodes->item($x));
53
+      }
54
+      // $value holds our new inner HTML
55
+      if ('' != $value) {
56
+        $f = $this->ownerDocument->createDocumentFragment();
57
+        // appendXML() expects well-formed markup (XHTML)
58
+        $result = @$f->appendXML($value); // @ to suppress PHP warnings
59
+        if ($result) {
60
+          if ($f->hasChildNodes()) {
61
+            $this->appendChild($f);
62
+          }
63
+        } else {
64
+          // $value is probably ill-formed
65
+          $f = new DOMDocument();
66
+          $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
67
+          // Using <htmlfragment> will generate a warning, but so will bad HTML
68
+          // (and by this point, bad HTML is what we've got).
69
+          // We use it (and suppress the warning) because an HTML fragment will
70
+          // be wrapped around <html><body> tags which we don't really want to keep.
71
+          // Note: despite the warning, if loadHTML succeeds it will return true.
72
+          $result = @$f->loadHTML('<htmlfragment>' . $value . '</htmlfragment>');
73
+          if ($result) {
74
+            $import = $f->getElementsByTagName('htmlfragment')->item(0);
75
+            foreach ($import->childNodes as $child) {
76
+              $importedNode = $this->ownerDocument->importNode($child, true);
77
+              $this->appendChild($importedNode);
78
+            }
79
+          } else {
80
+            // oh well, we tried, we really did. :(
81
+            // this element is now empty
82
+          }
83
+        }
84
+      }
85
+    } else {
86
+      $trace = debug_backtrace();
87
+      trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
88
+    }
89
+  }
90 90
 
91
-	/**
92
-	 * Used for getting innerHTML like it's done in JavaScript:.
93
-	 *
94
-	 * @code
95
-	 * $string = $div->innerHTML;
96
-	 * @endcode
97
-	 */
98
-	public function __get($name)
99
-	{
100
-		if ('innerHTML' == $name) {
101
-			$inner = '';
102
-			foreach ($this->childNodes as $child) {
103
-				$inner .= $this->ownerDocument->saveXML($child);
104
-			}
91
+  /**
92
+   * Used for getting innerHTML like it's done in JavaScript:.
93
+   *
94
+   * @code
95
+   * $string = $div->innerHTML;
96
+   * @endcode
97
+   */
98
+  public function __get($name)
99
+  {
100
+    if ('innerHTML' == $name) {
101
+      $inner = '';
102
+      foreach ($this->childNodes as $child) {
103
+        $inner .= $this->ownerDocument->saveXML($child);
104
+      }
105 105
 
106
-			return $inner;
107
-		}
106
+      return $inner;
107
+    }
108 108
 
109
-		$trace = debug_backtrace();
110
-		trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
109
+    $trace = debug_backtrace();
110
+    trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
111 111
 
112
-		return null;
113
-	}
112
+    return null;
113
+  }
114 114
 
115
-	public function __toString()
116
-	{
117
-		return '[' . $this->tagName . ']';
118
-	}
115
+  public function __toString()
116
+  {
117
+    return '[' . $this->tagName . ']';
118
+  }
119 119
 }
Please login to merge, or discard this patch.
etc/server/websocket/websockets.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
etc/server/dummyimage/index.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
-	// &#215; is the multiplication sign, it is not an 'x'
167
-	$text = $width . " &#215; " . $height;
164
+  $lines = 1;
165
+  // This is the default text string that will go right in the middle of the rectangle
166
+  // &#215; is the multiplication sign, it is not an 'x'
167
+  $text = $width . " &#215; " . $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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
etc/server/dummyimage/color.class.php 1 patch
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -17,275 +17,275 @@
 block discarded – undo
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
Please login to merge, or discard this patch.