$num fields in line $row:
100 | * // create a new instance of Services_JSON
101 | * $json = new Services_JSON();
102 | *
103 | * // convert a complexe value to JSON notation, and send it to the browser
104 | * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
105 | * $output = $json->encode($value);
106 | *
107 | * print($output);
108 | * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
109 | *
110 | * // accept incoming POST data, assumed to be in JSON notation
111 | * $input = file_get_contents('php://input', 1000000);
112 | * $value = $json->decode($input);
113 | *
114 | */
115 | class Services_JSON
116 | {
117 | /**
118 | * constructs a new JSON instance
119 | *
120 | * @param int $use object behavior flags; combine with boolean-OR
121 | *
122 | * possible values:
123 | * - SERVICES_JSON_LOOSE_TYPE: loose typing.
124 | * "{...}" syntax creates associative arrays
125 | * instead of objects in decode().
126 | * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
127 | * Values which can't be encoded (e.g. resources)
128 | * appear as NULL instead of throwing errors.
129 | * By default, a deeply-nested resource will
130 | * bubble up with an error, so all return values
131 | * from encode() should be checked with isError()
132 | */
133 | function Services_JSON($use = 0)
134 | {
135 | $this->use = $use;
136 | }
137 |
138 | /**
139 | * convert a string from one UTF-16 char to one UTF-8 char
140 | *
141 | * Normally should be handled by mb_convert_encoding, but
142 | * provides a slower PHP-only method for installations
143 | * that lack the multibye string extension.
144 | *
145 | * @param string $utf16 UTF-16 character
146 | * @return string UTF-8 character
147 | * @access private
148 | */
149 | function utf162utf8($utf16)
150 | {
151 | // oh please oh please oh please oh please oh please
152 | if(function_exists('mb_convert_encoding')) {
153 | return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
154 | }
155 |
156 | $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
157 |
158 | switch(true) {
159 | case ((0x7F & $bytes) == $bytes):
160 | // this case should never be reached, because we are in ASCII range
161 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
162 | return chr(0x7F & $bytes);
163 |
164 | case (0x07FF & $bytes) == $bytes:
165 | // return a 2-byte UTF-8 character
166 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
167 | return chr(0xC0 | (($bytes >> 6) & 0x1F))
168 | . chr(0x80 | ($bytes & 0x3F));
169 |
170 | case (0xFFFF & $bytes) == $bytes:
171 | // return a 3-byte UTF-8 character
172 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
173 | return chr(0xE0 | (($bytes >> 12) & 0x0F))
174 | . chr(0x80 | (($bytes >> 6) & 0x3F))
175 | . chr(0x80 | ($bytes & 0x3F));
176 | }
177 |
178 | // ignoring UTF-32 for now, sorry
179 | return '';
180 | }
181 |
182 | /**
183 | * convert a string from one UTF-8 char to one UTF-16 char
184 | *
185 | * Normally should be handled by mb_convert_encoding, but
186 | * provides a slower PHP-only method for installations
187 | * that lack the multibye string extension.
188 | *
189 | * @param string $utf8 UTF-8 character
190 | * @return string UTF-16 character
191 | * @access private
192 | */
193 | function utf82utf16($utf8)
194 | {
195 | // oh please oh please oh please oh please oh please
196 | if(function_exists('mb_convert_encoding')) {
197 | return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
198 | }
199 |
200 | switch(strlen($utf8)) {
201 | case 1:
202 | // this case should never be reached, because we are in ASCII range
203 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
204 | return $utf8;
205 |
206 | case 2:
207 | // return a UTF-16 character from a 2-byte UTF-8 char
208 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
209 | return chr(0x07 & (ord($utf8{0}) >> 2))
210 | . chr((0xC0 & (ord($utf8{0}) << 6))
211 | | (0x3F & ord($utf8{1})));
212 |
213 | case 3:
214 | // return a UTF-16 character from a 3-byte UTF-8 char
215 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
216 | return chr((0xF0 & (ord($utf8{0}) << 4))
217 | | (0x0F & (ord($utf8{1}) >> 2)))
218 | . chr((0xC0 & (ord($utf8{1}) << 6))
219 | | (0x7F & ord($utf8{2})));
220 | }
221 |
222 | // ignoring UTF-32 for now, sorry
223 | return '';
224 | }
225 |
226 | /**
227 | * encodes an arbitrary variable into JSON format
228 | *
229 | * @param mixed $var any number, boolean, string, array, or object to be encoded.
230 | * see argument 1 to Services_JSON() above for array-parsing behavior.
231 | * if var is a strng, note that encode() always expects it
232 | * to be in ASCII or UTF-8 format!
233 | *
234 | * @return mixed JSON string representation of input var or an error if a problem occurs
235 | * @access public
236 | */
237 | function encode($var)
238 | {
239 | switch (gettype($var)) {
240 | case 'boolean':
241 | return $var ? 'true' : 'false';
242 |
243 | case 'NULL':
244 | return 'null';
245 |
246 | case 'integer':
247 | return (int) $var;
248 |
249 | case 'double':
250 | case 'float':
251 | return (float) $var;
252 |
253 | case 'string':
254 | // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
255 | $ascii = '';
256 | $strlen_var = strlen($var);
257 |
258 | /*
259 | * Iterate over every character in the string,
260 | * escaping with a slash or encoding to UTF-8 where necessary
261 | */
262 | for ($c = 0; $c < $strlen_var; ++$c) {
263 |
264 | $ord_var_c = ord($var{$c});
265 |
266 | switch (true) {
267 | case $ord_var_c == 0x08:
268 | $ascii .= '\b';
269 | break;
270 | case $ord_var_c == 0x09:
271 | $ascii .= '\t';
272 | break;
273 | case $ord_var_c == 0x0A:
274 | $ascii .= '\n';
275 | break;
276 | case $ord_var_c == 0x0C:
277 | $ascii .= '\f';
278 | break;
279 | case $ord_var_c == 0x0D:
280 | $ascii .= '\r';
281 | break;
282 |
283 | case $ord_var_c == 0x22:
284 | case $ord_var_c == 0x2F:
285 | case $ord_var_c == 0x5C:
286 | // double quote, slash, slosh
287 | $ascii .= '\\'.$var{$c};
288 | break;
289 |
290 | case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
291 | // characters U-00000000 - U-0000007F (same as ASCII)
292 | $ascii .= $var{$c};
293 | break;
294 |
295 | case (($ord_var_c & 0xE0) == 0xC0):
296 | // characters U-00000080 - U-000007FF, mask 110XXXXX
297 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
298 | $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
299 | $c += 1;
300 | $utf16 = $this->utf82utf16($char);
301 | $ascii .= sprintf('\u%04s', bin2hex($utf16));
302 | break;
303 |
304 | case (($ord_var_c & 0xF0) == 0xE0):
305 | // characters U-00000800 - U-0000FFFF, mask 1110XXXX
306 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
307 | $char = pack('C*', $ord_var_c,
308 | ord($var{$c + 1}),
309 | ord($var{$c + 2}));
310 | $c += 2;
311 | $utf16 = $this->utf82utf16($char);
312 | $ascii .= sprintf('\u%04s', bin2hex($utf16));
313 | break;
314 |
315 | case (($ord_var_c & 0xF8) == 0xF0):
316 | // characters U-00010000 - U-001FFFFF, mask 11110XXX
317 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
318 | $char = pack('C*', $ord_var_c,
319 | ord($var{$c + 1}),
320 | ord($var{$c + 2}),
321 | ord($var{$c + 3}));
322 | $c += 3;
323 | $utf16 = $this->utf82utf16($char);
324 | $ascii .= sprintf('\u%04s', bin2hex($utf16));
325 | break;
326 |
327 | case (($ord_var_c & 0xFC) == 0xF8):
328 | // characters U-00200000 - U-03FFFFFF, mask 111110XX
329 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
330 | $char = pack('C*', $ord_var_c,
331 | ord($var{$c + 1}),
332 | ord($var{$c + 2}),
333 | ord($var{$c + 3}),
334 | ord($var{$c + 4}));
335 | $c += 4;
336 | $utf16 = $this->utf82utf16($char);
337 | $ascii .= sprintf('\u%04s', bin2hex($utf16));
338 | break;
339 |
340 | case (($ord_var_c & 0xFE) == 0xFC):
341 | // characters U-04000000 - U-7FFFFFFF, mask 1111110X
342 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
343 | $char = pack('C*', $ord_var_c,
344 | ord($var{$c + 1}),
345 | ord($var{$c + 2}),
346 | ord($var{$c + 3}),
347 | ord($var{$c + 4}),
348 | ord($var{$c + 5}));
349 | $c += 5;
350 | $utf16 = $this->utf82utf16($char);
351 | $ascii .= sprintf('\u%04s', bin2hex($utf16));
352 | break;
353 | }
354 | }
355 |
356 | return '"'.$ascii.'"';
357 |
358 | case 'array':
359 | /*
360 | * As per JSON spec if any array key is not an integer
361 | * we must treat the the whole array as an object. We
362 | * also try to catch a sparsely populated associative
363 | * array with numeric keys here because some JS engines
364 | * will create an array with empty indexes up to
365 | * max_index which can cause memory issues and because
366 | * the keys, which may be relevant, will be remapped
367 | * otherwise.
368 | *
369 | * As per the ECMA and JSON specification an object may
370 | * have any string as a property. Unfortunately due to
371 | * a hole in the ECMA specification if the key is a
372 | * ECMA reserved word or starts with a digit the
373 | * parameter is only accessible using ECMAScript's
374 | * bracket notation.
375 | */
376 |
377 | // treat as a JSON object
378 | if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
379 | $properties = array_map(array($this, 'name_value'),
380 | array_keys($var),
381 | array_values($var));
382 |
383 | foreach($properties as $property) {
384 | if(Services_JSON::isError($property)) {
385 | return $property;
386 | }
387 | }
388 |
389 | return '{' . join(',', $properties) . '}';
390 | }
391 |
392 | // treat it like a regular array
393 | $elements = array_map(array($this, 'encode'), $var);
394 |
395 | foreach($elements as $element) {
396 | if(Services_JSON::isError($element)) {
397 | return $element;
398 | }
399 | }
400 |
401 | return '[' . join(',', $elements) . ']';
402 |
403 | case 'object':
404 | $vars = get_object_vars($var);
405 |
406 | $properties = array_map(array($this, 'name_value'),
407 | array_keys($vars),
408 | array_values($vars));
409 |
410 | foreach($properties as $property) {
411 | if(Services_JSON::isError($property)) {
412 | return $property;
413 | }
414 | }
415 |
416 | return '{' . join(',', $properties) . '}';
417 |
418 | default:
419 | return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
420 | ? 'null'
421 | : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
422 | }
423 | }
424 |
425 | /**
426 | * array-walking function for use in generating JSON-formatted name-value pairs
427 | *
428 | * @param string $name name of key to use
429 | * @param mixed $value reference to an array element to be encoded
430 | *
431 | * @return string JSON-formatted name-value pair, like '"name":value'
432 | * @access private
433 | */
434 | function name_value($name, $value)
435 | {
436 | $encoded_value = $this->encode($value);
437 |
438 | if(Services_JSON::isError($encoded_value)) {
439 | return $encoded_value;
440 | }
441 |
442 | return $this->encode(strval($name)) . ':' . $encoded_value;
443 | }
444 |
445 | /**
446 | * reduce a string by removing leading and trailing comments and whitespace
447 | *
448 | * @param $str string string value to strip of comments and whitespace
449 | *
450 | * @return string string value stripped of comments and whitespace
451 | * @access private
452 | */
453 | function reduce_string($str)
454 | {
455 | $str = preg_replace(array(
456 |
457 | // eliminate single line comments in '// ...' form
458 | '#^\s*//(.+)$#m',
459 |
460 | // eliminate multi-line comments in '/* ... */' form, at start of string
461 | '#^\s*/\*(.+)\*/#Us',
462 |
463 | // eliminate multi-line comments in '/* ... */' form, at end of string
464 | '#/\*(.+)\*/\s*$#Us'
465 |
466 | ), '', $str);
467 |
468 | // eliminate extraneous space
469 | return trim($str);
470 | }
471 |
472 | /**
473 | * decodes a JSON string into appropriate variable
474 | *
475 | * @param string $str JSON-formatted string
476 | *
477 | * @return mixed number, boolean, string, array, or object
478 | * corresponding to given JSON input string.
479 | * See argument 1 to Services_JSON() above for object-output behavior.
480 | * Note that decode() always returns strings
481 | * in ASCII or UTF-8 format!
482 | * @access public
483 | */
484 | function decode($str)
485 | {
486 | $str = $this->reduce_string($str);
487 |
488 | switch (strtolower($str)) {
489 | case 'true':
490 | return true;
491 |
492 | case 'false':
493 | return false;
494 |
495 | case 'null':
496 | return null;
497 |
498 | default:
499 | $m = array();
500 |
501 | if (is_numeric($str)) {
502 | // Lookie-loo, it's a number
503 |
504 | // This would work on its own, but I'm trying to be
505 | // good about returning integers where appropriate:
506 | // return (float)$str;
507 |
508 | // Return float or int, as appropriate
509 | return ((float)$str == (integer)$str)
510 | ? (integer)$str
511 | : (float)$str;
512 |
513 | } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
514 | // STRINGS RETURNED IN UTF-8 FORMAT
515 | $delim = substr($str, 0, 1);
516 | $chrs = substr($str, 1, -1);
517 | $utf8 = '';
518 | $strlen_chrs = strlen($chrs);
519 |
520 | for ($c = 0; $c < $strlen_chrs; ++$c) {
521 |
522 | $substr_chrs_c_2 = substr($chrs, $c, 2);
523 | $ord_chrs_c = ord($chrs{$c});
524 |
525 | switch (true) {
526 | case $substr_chrs_c_2 == '\b':
527 | $utf8 .= chr(0x08);
528 | ++$c;
529 | break;
530 | case $substr_chrs_c_2 == '\t':
531 | $utf8 .= chr(0x09);
532 | ++$c;
533 | break;
534 | case $substr_chrs_c_2 == '\n':
535 | $utf8 .= chr(0x0A);
536 | ++$c;
537 | break;
538 | case $substr_chrs_c_2 == '\f':
539 | $utf8 .= chr(0x0C);
540 | ++$c;
541 | break;
542 | case $substr_chrs_c_2 == '\r':
543 | $utf8 .= chr(0x0D);
544 | ++$c;
545 | break;
546 |
547 | case $substr_chrs_c_2 == '\\"':
548 | case $substr_chrs_c_2 == '\\\'':
549 | case $substr_chrs_c_2 == '\\\\':
550 | case $substr_chrs_c_2 == '\\/':
551 | if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
552 | ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
553 | $utf8 .= $chrs{++$c};
554 | }
555 | break;
556 |
557 | case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
558 | // single, escaped unicode character
559 | $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
560 | . chr(hexdec(substr($chrs, ($c + 4), 2)));
561 | $utf8 .= $this->utf162utf8($utf16);
562 | $c += 5;
563 | break;
564 |
565 | case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
566 | $utf8 .= $chrs{$c};
567 | break;
568 |
569 | case ($ord_chrs_c & 0xE0) == 0xC0:
570 | // characters U-00000080 - U-000007FF, mask 110XXXXX
571 | //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
572 | $utf8 .= substr($chrs, $c, 2);
573 | ++$c;
574 | break;
575 |
576 | case ($ord_chrs_c & 0xF0) == 0xE0:
577 | // characters U-00000800 - U-0000FFFF, mask 1110XXXX
578 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
579 | $utf8 .= substr($chrs, $c, 3);
580 | $c += 2;
581 | break;
582 |
583 | case ($ord_chrs_c & 0xF8) == 0xF0:
584 | // characters U-00010000 - U-001FFFFF, mask 11110XXX
585 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
586 | $utf8 .= substr($chrs, $c, 4);
587 | $c += 3;
588 | break;
589 |
590 | case ($ord_chrs_c & 0xFC) == 0xF8:
591 | // characters U-00200000 - U-03FFFFFF, mask 111110XX
592 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
593 | $utf8 .= substr($chrs, $c, 5);
594 | $c += 4;
595 | break;
596 |
597 | case ($ord_chrs_c & 0xFE) == 0xFC:
598 | // characters U-04000000 - U-7FFFFFFF, mask 1111110X
599 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
600 | $utf8 .= substr($chrs, $c, 6);
601 | $c += 5;
602 | break;
603 |
604 | }
605 |
606 | }
607 |
608 | return $utf8;
609 |
610 | } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
611 | // array, or object notation
612 |
613 | if ($str{0} == '[') {
614 | $stk = array(SERVICES_JSON_IN_ARR);
615 | $arr = array();
616 | } else {
617 | if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
618 | $stk = array(SERVICES_JSON_IN_OBJ);
619 | $obj = array();
620 | } else {
621 | $stk = array(SERVICES_JSON_IN_OBJ);
622 | $obj = new stdClass();
623 | }
624 | }
625 |
626 | array_push($stk, array('what' => SERVICES_JSON_SLICE,
627 | 'where' => 0,
628 | 'delim' => false));
629 |
630 | $chrs = substr($str, 1, -1);
631 | $chrs = $this->reduce_string($chrs);
632 |
633 | if ($chrs == '') {
634 | if (reset($stk) == SERVICES_JSON_IN_ARR) {
635 | return $arr;
636 |
637 | } else {
638 | return $obj;
639 |
640 | }
641 | }
642 |
643 | //print("\nparsing {$chrs}\n");
644 |
645 | $strlen_chrs = strlen($chrs);
646 |
647 | for ($c = 0; $c <= $strlen_chrs; ++$c) {
648 |
649 | $top = end($stk);
650 | $substr_chrs_c_2 = substr($chrs, $c, 2);
651 |
652 | if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
653 | // found a comma that is not inside a string, array, etc.,
654 | // OR we've reached the end of the character list
655 | $slice = substr($chrs, $top['where'], ($c - $top['where']));
656 | array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
657 | //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
658 |
659 | if (reset($stk) == SERVICES_JSON_IN_ARR) {
660 | // we are in an array, so just push an element onto the stack
661 | array_push($arr, $this->decode($slice));
662 |
663 | } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
664 | // we are in an object, so figure
665 | // out the property name and set an
666 | // element in an associative array,
667 | // for now
668 | $parts = array();
669 |
670 | if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
671 | // "name":value pair
672 | $key = $this->decode($parts[1]);
673 | $val = $this->decode($parts[2]);
674 |
675 | if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
676 | $obj[$key] = $val;
677 | } else {
678 | $obj->$key = $val;
679 | }
680 | } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
681 | // name:value pair, where name is unquoted
682 | $key = $parts[1];
683 | $val = $this->decode($parts[2]);
684 |
685 | if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
686 | $obj[$key] = $val;
687 | } else {
688 | $obj->$key = $val;
689 | }
690 | }
691 |
692 | }
693 |
694 | } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
695 | // found a quote, and we are not inside a string
696 | array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
697 | //print("Found start of string at {$c}\n");
698 |
699 | } elseif (($chrs{$c} == $top['delim']) &&
700 | ($top['what'] == SERVICES_JSON_IN_STR) &&
701 | ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
702 | // found a quote, we're in a string, and it's not escaped
703 | // we know that it's not escaped becase there is _not_ an
704 | // odd number of backslashes at the end of the string so far
705 | array_pop($stk);
706 | //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
707 |
708 | } elseif (($chrs{$c} == '[') &&
709 | in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
710 | // found a left-bracket, and we are in an array, object, or slice
711 | array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
712 | //print("Found start of array at {$c}\n");
713 |
714 | } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
715 | // found a right-bracket, and we're in an array
716 | array_pop($stk);
717 | //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
718 |
719 | } elseif (($chrs{$c} == '{') &&
720 | in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
721 | // found a left-brace, and we are in an array, object, or slice
722 | array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
723 | //print("Found start of object at {$c}\n");
724 |
725 | } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
726 | // found a right-brace, and we're in an object
727 | array_pop($stk);
728 | //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
729 |
730 | } elseif (($substr_chrs_c_2 == '/*') &&
731 | in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
732 | // found a comment start, and we are in an array, object, or slice
733 | array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
734 | $c++;
735 | //print("Found start of comment at {$c}\n");
736 |
737 | } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
738 | // found a comment end, and we're in one now
739 | array_pop($stk);
740 | $c++;
741 |
742 | for ($i = $top['where']; $i <= $c; ++$i)
743 | $chrs = substr_replace($chrs, ' ', $i, 1);
744 |
745 | //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
746 |
747 | }
748 |
749 | }
750 |
751 | if (reset($stk) == SERVICES_JSON_IN_ARR) {
752 | return $arr;
753 |
754 | } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
755 | return $obj;
756 |
757 | }
758 |
759 | }
760 | }
761 | }
762 |
763 | /**
764 | * @todo Ultimately, this should just call PEAR::isError()
765 | */
766 | function isError($data, $code = null)
767 | {
768 | if (class_exists('pear')) {
769 | return PEAR::isError($data, $code);
770 | } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
771 | is_subclass_of($data, 'services_json_error'))) {
772 | return true;
773 | }
774 |
775 | return false;
776 | }
777 | }
778 |
779 | if (class_exists('PEAR_Error')) {
780 |
781 | class Services_JSON_Error extends PEAR_Error
782 | {
783 | function Services_JSON_Error($message = 'unknown error', $code = null,
784 | $mode = null, $options = null, $userinfo = null)
785 | {
786 | parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
787 | }
788 | }
789 |
790 | } else {
791 |
792 | /**
793 | * @todo Ultimately, this class shall be descended from PEAR_Error
794 | */
795 | class Services_JSON_Error
796 | {
797 | function Services_JSON_Error($message = 'unknown error', $code = null,
798 | $mode = null, $options = null, $userinfo = null)
799 | {
800 |
801 | }
802 | }
803 |
804 | }
805 |
806 | ?>
807 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/README.txt:
--------------------------------------------------------------------------------
1 | Open Flash Chart - PHP libraries. These help create data files for Open Flash Chart.
2 | Copyright (C) 2007
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/dot_base.php:
--------------------------------------------------------------------------------
1 | type = $type;
16 | if( isset( $value ) )
17 | $this->value( $value );
18 | }
19 |
20 | /**
21 | * For line charts that only require a Y position
22 | * for each point.
23 | * @param $value as integer, the Y position
24 | */
25 | function value( $value )
26 | {
27 | $this->value = $value;
28 | }
29 |
30 | /**
31 | * For scatter charts that require an X and Y position for
32 | * each point.
33 | *
34 | * @param $x as integer
35 | * @param $y as integer
36 | */
37 | function position( $x, $y )
38 | {
39 | $this->x = $x;
40 | $this->y = $y;
41 | }
42 |
43 | /**
44 | * @param $colour is a string, HEX colour, e.g. '#FF0000' red
45 | */
46 | function colour($colour)
47 | {
48 | $this->colour = $colour;
49 | return $this;
50 | }
51 |
52 | /**
53 | * The tooltip for this dot.
54 | */
55 | function tooltip( $tip )
56 | {
57 | $this->tip = $tip;
58 | return $this;
59 | }
60 |
61 | /**
62 | * @param $size is an integer. Size of the dot.
63 | */
64 | function size($size)
65 | {
66 | $tmp = 'dot-size';
67 | $this->$tmp = $size;
68 | return $this;
69 | }
70 |
71 | /**
72 | * a private method
73 | */
74 | function type( $type )
75 | {
76 | $this->type = $type;
77 | return $this;
78 | }
79 |
80 | /**
81 | * @param $size is an integer. The size of the hollow 'halo' around the dot that masks the line.
82 | */
83 | function halo_size( $size )
84 | {
85 | $tmp = 'halo-size';
86 | $this->$tmp = $size;
87 | return $this;
88 | }
89 |
90 | /**
91 | * @param $do as string. One of three options (examples):
92 | * - "http://example.com" - browse to this URL
93 | * - "https://example.com" - browse to this URL
94 | * - "trace:message" - print this message in the FlashDevelop debug pane
95 | * - all other strings will be called as Javascript functions, so a string "hello_world"
96 | * will call the JS function "hello_world(index)". It passes in the index of the
97 | * point.
98 | */
99 | function on_click( $do )
100 | {
101 | $tmp = 'on-click';
102 | $this->$tmp = $do;
103 | }
104 | }
105 |
106 | /**
107 | * Draw a hollow dot
108 | */
109 | class hollow_dot extends dot_base
110 | {
111 | function hollow_dot($value=null)
112 | {
113 | parent::dot_base( 'hollow-dot', $value );
114 | }
115 | }
116 |
117 | /**
118 | * Draw a star
119 | */
120 | class star extends dot_base
121 | {
122 | /**
123 | * The constructor, takes an optional $value
124 | */
125 | function star($value=null)
126 | {
127 | parent::dot_base( 'star', $value );
128 | }
129 |
130 | /**
131 | * @param $angle is an integer.
132 | */
133 | function rotation($angle)
134 | {
135 | $this->rotation = $angle;
136 | return $this;
137 | }
138 |
139 | /**
140 | * @param $is_hollow is a boolean.
141 | */
142 | function hollow($is_hollow)
143 | {
144 | $this->hollow = $is_hollow;
145 | }
146 | }
147 |
148 | /**
149 | * Draw a 'bow tie' shape.
150 | */
151 | class bow extends dot_base
152 | {
153 | /**
154 | * The constructor, takes an optional $value
155 | */
156 | function bow($value=null)
157 | {
158 | parent::dot_base( 'bow', $value );
159 | }
160 |
161 | /**
162 | * Rotate the anchor object.
163 | * @param $angle is an integer.
164 | */
165 | function rotation($angle)
166 | {
167 | $this->rotation = $angle;
168 | return $this;
169 | }
170 | }
171 |
172 | /**
173 | * An n sided shape.
174 | */
175 | class anchor extends dot_base
176 | {
177 | /**
178 | * The constructor, takes an optional $value
179 | */
180 | function anchor($value=null)
181 | {
182 | parent::dot_base( 'anchor', $value );
183 | }
184 |
185 | /**
186 | * Rotate the anchor object.
187 | * @param $angle is an integer.
188 | */
189 | function rotation($angle)
190 | {
191 | $this->rotation = $angle;
192 | return $this;
193 | }
194 |
195 | /**
196 | * @param $sides is an integer. Number of sides this shape has.
197 | */
198 | function sides($sides)
199 | {
200 | $this->sides = $sides;
201 | return $this;
202 | }
203 | }
204 |
205 | /**
206 | * A simple dot
207 | */
208 | class dot extends dot_base
209 | {
210 | /**
211 | * The constructor, takes an optional $value
212 | */
213 | function dot($value=null)
214 | {
215 | parent::dot_base( 'dot', $value );
216 | }
217 | }
218 |
219 | /**
220 | * A simple dot
221 | */
222 | class solid_dot extends dot_base
223 | {
224 | /**
225 | * The constructor, takes an optional $value
226 | */
227 | function solid_dot($value=null)
228 | {
229 | parent::dot_base( 'solid-dot', $value );
230 | }
231 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/json_format.php:
--------------------------------------------------------------------------------
1 | 0 && $json[$c-1] != '\\')
76 | {
77 | $in_string = !$in_string;
78 | }
79 | default:
80 | $new_json .= $char;
81 | break;
82 | }
83 | }
84 |
85 | return $new_json;
86 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_area_base.php:
--------------------------------------------------------------------------------
1 | type = "area";
11 | }
12 |
13 | /**
14 | * the fill colour
15 | */
16 | function set_fill_colour( $colour )
17 | {
18 | $this->fill = $colour;
19 | }
20 |
21 | /**
22 | * sugar: see set_fill_colour
23 | */
24 | function fill_colour( $colour )
25 | {
26 | $this->set_fill_colour( $colour );
27 | return $this;
28 | }
29 |
30 | function set_fill_alpha( $alpha )
31 | {
32 | $tmp = "fill-alpha";
33 | $this->$tmp = $alpha;
34 | }
35 |
36 | function set_loop()
37 | {
38 | $this->loop = true;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_area_hollow.php:
--------------------------------------------------------------------------------
1 | type = "area_hollow";
8 | parent::area_base();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_area_line.php:
--------------------------------------------------------------------------------
1 | type = "area_line";
8 | parent::area_base();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_arrow.php:
--------------------------------------------------------------------------------
1 | type = "arrow";
16 | $this->start = array("x"=>$x, "y"=>$y);
17 | $this->end = array("x"=>$a, "y"=>$b);
18 | $this->colour($colour);
19 | $this->{"barb-length"} = $barb_length;
20 | }
21 |
22 | function colour( $colour )
23 | {
24 | $this->colour = $colour;
25 | return $this;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_bar.php:
--------------------------------------------------------------------------------
1 | top = $top;
10 |
11 | if( isset( $bottom ) )
12 | $this->bottom = $bottom;
13 | }
14 |
15 | function set_colour( $colour )
16 | {
17 | $this->colour = $colour;
18 | }
19 |
20 | function set_tooltip( $tip )
21 | {
22 | $this->tip = $tip;
23 | }
24 | }
25 |
26 | class bar extends bar_base
27 | {
28 | function bar()
29 | {
30 | $this->type = "bar";
31 | parent::bar_base();
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_bar_3d.php:
--------------------------------------------------------------------------------
1 | top = $top;
10 | }
11 |
12 | function set_colour( $colour )
13 | {
14 | $this->colour = $colour;
15 | }
16 |
17 | function set_tooltip( $tip )
18 | {
19 | $this->tip = $tip;
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_bar_base.php:
--------------------------------------------------------------------------------
1 | text = $text;
16 | $tmp = 'font-size';
17 | $this->$tmp = $size;
18 | }
19 |
20 | /**
21 | * syntatical sugar.
22 | */
23 | function key( $text, $size )
24 | {
25 | $this->set_key( $text, $size );
26 | }
27 |
28 | /**
29 | * @param $v as an array, a mix of:
30 | * - a bar_value class. You can use this to customise the paramters of each bar.
31 | * - integer. This is the Y position of the top of the bar.
32 | */
33 | function set_values( $v )
34 | {
35 | $this->values = $v;
36 | }
37 |
38 | /**
39 | * see set_values
40 | */
41 | function append_value( $v )
42 | {
43 | $this->values[] = $v;
44 | }
45 |
46 | /**
47 | * @param $colour as string, a HEX colour, e.g. '#ff0000' red
48 | */
49 | function set_colour( $colour )
50 | {
51 | $this->colour = $colour;
52 | }
53 |
54 | /**
55 | *syntatical sugar
56 | */
57 | function colour( $colour )
58 | {
59 | $this->set_colour( $colour );
60 | }
61 |
62 | /**
63 | * @param $alpha as real number (range 0 to 1), e.g. 0.5 is half transparent
64 | */
65 | function set_alpha( $alpha )
66 | {
67 | $this->alpha = $alpha;
68 | }
69 |
70 | /**
71 | * @param $tip as string, the tip to show. May contain various magic variables.
72 | */
73 | function set_tooltip( $tip )
74 | {
75 | $this->tip = $tip;
76 | }
77 |
78 | /**
79 | *@param $on_show as line_on_show object
80 | */
81 | function set_on_show($on_show)
82 | {
83 | $this->{'on-show'} = $on_show;
84 | }
85 |
86 | function set_on_click( $text )
87 | {
88 | $tmp = 'on-click';
89 | $this->$tmp = $text;
90 | }
91 |
92 | function attach_to_right_y_axis()
93 | {
94 | $this->axis = 'right';
95 | }
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_bar_filled.php:
--------------------------------------------------------------------------------
1 | $tmp = $outline_colour;
16 | }
17 | }
18 |
19 | class bar_filled extends bar_base
20 | {
21 | function bar_filled( $colour=null, $outline_colour=null )
22 | {
23 | $this->type = "bar_filled";
24 | parent::bar_base();
25 |
26 | if( isset( $colour ) )
27 | $this->set_colour( $colour );
28 |
29 | if( isset( $outline_colour ) )
30 | $this->set_outline_colour( $outline_colour );
31 | }
32 |
33 | function set_outline_colour( $outline_colour )
34 | {
35 | $tmp = 'outline-colour';
36 | $this->$tmp = $outline_colour;
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_bar_glass.php:
--------------------------------------------------------------------------------
1 | type = $type;
22 | $this->cascade = (float)$cascade;
23 | $this->delay = (float)$delay;
24 | }
25 | }
26 |
27 | class bar_value
28 | {
29 | /**
30 | * @param $top as integer. The Y value of the top of the bar
31 | * @param OPTIONAL $bottom as integer. The Y value of the bottom of the bar, defaults to Y min.
32 | */
33 | function bar_value( $top, $bottom=null )
34 | {
35 | $this->top = $top;
36 |
37 | if( isset( $bottom ) )
38 | $this->bottom = $bottom;
39 | }
40 |
41 | function set_colour( $colour )
42 | {
43 | $this->colour = $colour;
44 | }
45 |
46 | function set_tooltip( $tip )
47 | {
48 | $this->tip = $tip;
49 | }
50 | }
51 |
52 | class bar extends bar_base
53 | {
54 | function bar()
55 | {
56 | $this->type = "bar";
57 | parent::bar_base();
58 | }
59 | }
60 |
61 | class bar_glass extends bar_base
62 | {
63 | function bar_glass()
64 | {
65 | $this->type = "bar_glass";
66 | parent::bar_base();
67 | }
68 | }
69 |
70 | class bar_cylinder extends bar_base
71 | {
72 | function bar_cylinder()
73 | {
74 | $this->type = "bar_cylinder";
75 | parent::bar_base();
76 | }
77 | }
78 |
79 | class bar_cylinder_outline extends bar_base
80 | {
81 | function bar_cylinder_outline()
82 | {
83 | $this->type = "bar_cylinder_outline";
84 | parent::bar_base();
85 | }
86 | }
87 |
88 | class bar_rounded_glass extends bar_base
89 | {
90 | function bar_rounded_glass()
91 | {
92 | $this->type = "bar_round_glass";
93 | parent::bar_base();
94 | }
95 | }
96 |
97 | class bar_round extends bar_base
98 | {
99 | function bar_round()
100 | {
101 | $this->type = "bar_round";
102 | parent::bar_base();
103 | }
104 | }
105 |
106 | class bar_dome extends bar_base
107 | {
108 | function bar_dome()
109 | {
110 | $this->type = "bar_dome";
111 | parent::bar_base();
112 | }
113 | }
114 |
115 | class bar_round3d extends bar_base
116 | {
117 | function bar_round3d()
118 | {
119 | $this->type = "bar_round3d";
120 | parent::bar_base();
121 | }
122 | }
123 |
124 | class bar_3d extends bar_base
125 | {
126 | function bar_3d()
127 | {
128 | $this->type = "bar_3d";
129 | parent::bar_base();
130 | }
131 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_bar_sketch.php:
--------------------------------------------------------------------------------
1 | type = "bar_sketch";
16 | parent::bar_base();
17 |
18 | $this->set_colour( $colour );
19 | $this->set_outline_colour( $outline_colour );
20 | $this->offset = $fun_factor;
21 | }
22 |
23 | function set_outline_colour( $outline_colour )
24 | {
25 | $tmp = 'outline-colour';
26 | $this->$tmp = $outline_colour;
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_bar_stack.php:
--------------------------------------------------------------------------------
1 | type = "bar_stack";
10 | parent::bar_base();
11 | }
12 |
13 | function append_stack( $v )
14 | {
15 | $this->append_value( $v );
16 | }
17 |
18 | // an array of HEX colours strings
19 | // e.g. array( '#ff0000', '#00ff00' );
20 | function set_colours( $colours )
21 | {
22 | $this->colours = $colours;
23 | }
24 |
25 | // an array of bar_stack_value
26 | function set_keys( $keys )
27 | {
28 | $this->keys = $keys;
29 | }
30 | }
31 |
32 | class bar_stack_value
33 | {
34 | function bar_stack_value( $val, $colour )
35 | {
36 | $this->val = $val;
37 | $this->colour = $colour;
38 | }
39 |
40 | function set_tooltip( $tip )
41 | {
42 | $this->tip = $tip;
43 | }
44 | }
45 |
46 | class bar_stack_key
47 | {
48 | function bar_stack_key( $colour, $text, $font_size )
49 | {
50 | $this->colour = $colour;
51 | $this->text = $text;
52 | $tmp = 'font-size';
53 | $this->$tmp = $font_size;
54 | }
55 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_candle.php:
--------------------------------------------------------------------------------
1 | high = $high;
13 | $this->top = $open;
14 | $this->bottom = $close;
15 | $this->low = $low;
16 | }
17 |
18 | function set_colour( $colour )
19 | {
20 | $this->colour = $colour;
21 | }
22 |
23 | function set_tooltip( $tip )
24 | {
25 | $this->tip = $tip;
26 | }
27 | }
28 |
29 | class candle extends bar_base
30 | {
31 | function candle($colour, $negative_colour=null)
32 | {
33 | $this->type = "candle";
34 | parent::bar_base();
35 |
36 | $this->set_colour( $colour );
37 | if(!is_null($negative_colour))
38 | $this->{'negative-colour'} = $negative_colour;
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_hbar.php:
--------------------------------------------------------------------------------
1 | left = $left;
10 | $this->right = $right;
11 | }
12 | else
13 | $this->right = $left;
14 | }
15 |
16 | function set_colour( $colour )
17 | {
18 | $this->colour = $colour;
19 | }
20 |
21 | function set_tooltip( $tip )
22 | {
23 | $this->tip = $tip;
24 | }
25 | }
26 |
27 | class hbar
28 | {
29 | function hbar( $colour )
30 | {
31 | $this->type = "hbar";
32 | $this->values = array();
33 | $this->set_colour( $colour );
34 | }
35 |
36 | function append_value( $v )
37 | {
38 | $this->values[] = $v;
39 | }
40 |
41 | function set_values( $v )
42 | {
43 | foreach( $v as $val )
44 | $this->append_value( new hbar_value( $val ) );
45 | }
46 |
47 | function set_colour( $colour )
48 | {
49 | $this->colour = $colour;
50 | }
51 |
52 | function set_key( $text, $size )
53 | {
54 | $this->text = $text;
55 | $tmp = 'font-size';
56 | $this->$tmp = $size;
57 | }
58 |
59 | function set_tooltip( $tip )
60 | {
61 | $this->tip = $tip;
62 | }
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_line.php:
--------------------------------------------------------------------------------
1 | type = $type;
20 | $this->cascade = (float)$cascade;
21 | $this->delay = (float)$delay;
22 | }
23 | }
24 |
25 | class line
26 | {
27 | function line()
28 | {
29 | $this->type = "line";
30 | $this->values = array();
31 | }
32 |
33 | /**
34 | * Set the default dot that all the real
35 | * dots inherit their properties from. If you set the
36 | * default dot to be red, all values in your chart that
37 | * do not specify a colour will be red. Same for all the
38 | * other attributes such as tooltip, on-click, size etc...
39 | *
40 | * @param $style as any class that inherits base_dot
41 | */
42 | function set_default_dot_style( $style )
43 | {
44 | $tmp = 'dot-style';
45 | $this->$tmp = $style;
46 | }
47 |
48 | /**
49 | * @param $v as array, can contain any combination of:
50 | * - integer, Y position of the point
51 | * - any class that inherits from dot_base
52 | * - null
53 | */
54 | function set_values( $v )
55 | {
56 | $this->values = $v;
57 | }
58 |
59 | /**
60 | * Append a value to the line.
61 | *
62 | * @param mixed $v
63 | */
64 | function append_value($v)
65 | {
66 | $this->values[] = $v;
67 | }
68 |
69 | function set_width( $width )
70 | {
71 | $this->width = $width;
72 | }
73 |
74 | function set_colour( $colour )
75 | {
76 | $this->colour = $colour;
77 | }
78 |
79 | /**
80 | * sytnatical sugar for set_colour
81 | */
82 | function colour( $colour )
83 | {
84 | $this->set_colour( $colour );
85 | return $this;
86 | }
87 |
88 | function set_halo_size( $size )
89 | {
90 | $tmp = 'halo-size';
91 | $this->$tmp = $size;
92 | }
93 |
94 | function set_key( $text, $font_size )
95 | {
96 | $this->text = $text;
97 | $tmp = 'font-size';
98 | $this->$tmp = $font_size;
99 | }
100 |
101 | function set_tooltip( $tip )
102 | {
103 | $this->tip = $tip;
104 | }
105 |
106 | /**
107 | * @param $text as string. A javascript function name as a string. The chart will
108 | * try to call this function, it will pass the chart id as the only parameter into
109 | * this function. E.g:
110 | *
111 | */
112 | function set_on_click( $text )
113 | {
114 | $tmp = 'on-click';
115 | $this->$tmp = $text;
116 | }
117 |
118 | function loop()
119 | {
120 | $this->loop = true;
121 | }
122 |
123 | function line_style( $s )
124 | {
125 | $tmp = "line-style";
126 | $this->$tmp = $s;
127 | }
128 |
129 | /**
130 | * Sets the text for the line.
131 | *
132 | * @param string $text
133 | */
134 | function set_text($text)
135 | {
136 | $this->text = $text;
137 | }
138 |
139 | function attach_to_right_y_axis()
140 | {
141 | $this->axis = 'right';
142 | }
143 |
144 | /**
145 | *@param $on_show as line_on_show object
146 | */
147 | function set_on_show($on_show)
148 | {
149 | $this->{'on-show'} = $on_show;
150 | }
151 |
152 | function on_show($on_show)
153 | {
154 | $this->set_on_show($on_show);
155 | return $this;
156 | }
157 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_line_base.php:
--------------------------------------------------------------------------------
1 | type = "line";
8 | $this->text = "Page views";
9 | $tmp = 'font-size';
10 | $this->$tmp = 10;
11 |
12 | $this->values = array();
13 | }
14 |
15 | function set_values( $v )
16 | {
17 | $this->values = $v;
18 | }
19 |
20 | /**
21 | * Append a value to the line.
22 | *
23 | * @param mixed $v
24 | */
25 | function append_value($v)
26 | {
27 | $this->values[] = $v;
28 | }
29 |
30 | function set_width( $width )
31 | {
32 | $this->width = $width;
33 | }
34 |
35 | function set_colour( $colour )
36 | {
37 | $this->colour = $colour;
38 | }
39 |
40 | function set_dot_size( $size )
41 | {
42 | $tmp = 'dot-size';
43 | $this->$tmp = $size;
44 | }
45 |
46 | function set_halo_size( $size )
47 | {
48 | $tmp = 'halo-size';
49 | $this->$tmp = $size;
50 | }
51 |
52 | function set_key( $text, $font_size )
53 | {
54 | $this->text = $text;
55 | $tmp = 'font-size';
56 | $this->$tmp = $font_size;
57 | }
58 |
59 | function set_tooltip( $tip )
60 | {
61 | $this->tip = $tip;
62 | }
63 |
64 | function set_on_click( $text )
65 | {
66 | $tmp = 'on-click';
67 | $this->$tmp = $text;
68 | }
69 |
70 | function loop()
71 | {
72 | $this->loop = true;
73 | }
74 |
75 | function line_style( $s )
76 | {
77 | $tmp = "line-style";
78 | $this->$tmp = $s;
79 | }
80 |
81 | /**
82 | * Sets the text for the line.
83 | *
84 | * @param string $text
85 | */
86 | function set_text($text)
87 | {
88 | $this->text = $text;
89 | }
90 |
91 |
92 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_line_dot.php:
--------------------------------------------------------------------------------
1 | value = $value;
8 | $this->colour = $colour;
9 | }
10 |
11 | function set_colour( $colour )
12 | {
13 | $this->colour = $colour;
14 | }
15 |
16 | function set_size( $size )
17 | {
18 | $this->size = $size;
19 | }
20 |
21 | function set_tooltip( $tip )
22 | {
23 | $this->tip = $tip;
24 | }
25 | }
26 |
27 | class line_dot extends line_base
28 | {
29 | function line_dot()
30 | {
31 | $this->type = "line_dot";
32 | }
33 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_line_hollow.php:
--------------------------------------------------------------------------------
1 | type = "line_hollow";
8 | }
9 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_line_style.php:
--------------------------------------------------------------------------------
1 | style = "dash";
8 | $this->on = $on;
9 | $this->off = $off;
10 | }
11 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_menu.php:
--------------------------------------------------------------------------------
1 | type = "text";
14 | $this->text = $text;
15 | $tmp = 'javascript-function';
16 | $this->$tmp = $javascript_function_name;
17 | }
18 | }
19 |
20 | class ofc_menu_item_camera
21 | {
22 | /**
23 | * @param $text as string. The menu item text.
24 | * @param $javascript_function_name as string. The javascript function name, the
25 | * js function takes one parameter, the chart ID. So for example, our js function
26 | * could look like this:
27 | *
28 | * function save_image( chart_id )
29 | * {
30 | * alert( chart_id );
31 | * }
32 | *
33 | * to make a menu item call this: ofc_menu_item_camera('Save chart', 'save_image');
34 | */
35 | function ofc_menu_item_camera($text, $javascript_function_name)
36 | {
37 | $this->type = "camera-icon";
38 | $this->text = $text;
39 | $tmp = 'javascript-function';
40 | $this->$tmp = $javascript_function_name;
41 | }
42 | }
43 |
44 | class ofc_menu
45 | {
46 | function ofc_menu($colour, $outline_colour)
47 | {
48 | $this->colour = $colour;
49 | $this->outline_colour = $outline_colour;
50 | }
51 |
52 | function values($values)
53 | {
54 | $this->values = $values;
55 | }
56 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_pie.php:
--------------------------------------------------------------------------------
1 | value = $value;
8 | $this->label = $label;
9 | }
10 |
11 | function set_colour( $colour )
12 | {
13 | $this->colour = $colour;
14 | }
15 |
16 | function set_label( $label, $label_colour, $font_size )
17 | {
18 | $this->label = $label;
19 |
20 | $tmp = 'label-colour';
21 | $this->$tmp = $label_colour;
22 |
23 | $tmp = 'font-size';
24 | $this->$tmp = $font_size;
25 |
26 | }
27 |
28 | function set_tooltip( $tip )
29 | {
30 | $this->tip = $tip;
31 | }
32 |
33 | function on_click( $event )
34 | {
35 | $tmp = 'on-click';
36 | $this->$tmp = $event;
37 | }
38 |
39 |
40 | /**
41 | * An object that inherits from base_pie_animation
42 | */
43 | function add_animation( $animation )
44 | {
45 | if( !isset( $this->animate ) )
46 | $this->animate = array();
47 |
48 | $this->animate[] = $animation;
49 |
50 | return $this;
51 | }
52 | }
53 |
54 | class base_pie_animation{}
55 |
56 | /**
57 | * fade the pie slice from $alpha (pie set_alpha) to 100% opaque.
58 | */
59 | class pie_fade extends base_pie_animation
60 | {
61 | function pie_fade()
62 | {
63 | $this->type="fade";
64 | }
65 | }
66 |
67 | /**
68 | * Bounce the pie slice out a little
69 | */
70 | class pie_bounce extends base_pie_animation
71 | {
72 | /**
73 | * @param $distance as integer, distance to bounce in pixels
74 | */
75 | function pie_bounce( $distance )
76 | {
77 | $this->type="bounce";
78 | $this->distance = $distance;
79 | }
80 | }
81 |
82 | /**
83 | * Make a pie chart and fill it with pie slices
84 | */
85 | class pie
86 | {
87 | function pie()
88 | {
89 | $this->type = 'pie';
90 | }
91 |
92 | function set_colours( $colours )
93 | {
94 | $this->colours = $colours;
95 | }
96 |
97 | /**
98 | * Sugar wrapped around set_colours
99 | */
100 | function colours( $colours )
101 | {
102 | $this->set_colours( $colours );
103 | return $this;
104 | }
105 |
106 | /**
107 | * @param $alpha as float (0-1) 0.75 = 3/4 visible
108 | */
109 | function set_alpha( $alpha )
110 | {
111 | $this->alpha = $alpha;
112 | }
113 |
114 | /**
115 | *sugar wrapped set_alpha
116 | **/
117 | function alpha( $alpha )
118 | {
119 | $this->set_alpha( $alpha );
120 | return $this;
121 | }
122 |
123 | /**
124 | * @param $v as array containing one of
125 | * - null
126 | * - real or integer number
127 | * - a pie_value object
128 | */
129 | function set_values( $v )
130 | {
131 | $this->values = $v;
132 | }
133 |
134 | /**
135 | * sugar for set_values
136 | */
137 | function values( $v )
138 | {
139 | $this->set_values( $v );
140 | return $this;
141 | }
142 |
143 | /**
144 | * HACK to keep old code working.
145 | */
146 | function set_animate( $bool )
147 | {
148 | if( $bool )
149 | $this->add_animation( new pie_fade() );
150 |
151 | }
152 |
153 | /**
154 | * An object that inherits from base_pie_animation
155 | */
156 | function add_animation( $animation )
157 | {
158 | if( !isset( $this->animate ) )
159 | $this->animate = array();
160 |
161 | $this->animate[] = $animation;
162 |
163 | return $this;
164 | }
165 |
166 | /**
167 | * @param $angle as real number
168 | */
169 | function set_start_angle( $angle )
170 | {
171 | $tmp = 'start-angle';
172 | $this->$tmp = $angle;
173 | }
174 |
175 | /**
176 | * sugar for set_start_angle
177 | */
178 | function start_angle($angle)
179 | {
180 | $this->set_start_angle( $angle );
181 | return $this;
182 | }
183 |
184 | /**
185 | * @param $tip as string. The tooltip text. May contain magic varibles
186 | */
187 | function set_tooltip( $tip )
188 | {
189 | $this->tip = $tip;
190 | }
191 |
192 | /**
193 | * sugar for set_tooltip
194 | */
195 | function tooltip( $tip )
196 | {
197 | $this->set_tooltip( $tip );
198 | return $this;
199 | }
200 |
201 | function set_gradient_fill()
202 | {
203 | $tmp = 'gradient-fill';
204 | $this->$tmp = true;
205 | }
206 |
207 | function gradient_fill()
208 | {
209 | $this->set_gradient_fill();
210 | return $this;
211 | }
212 |
213 | /**
214 | * By default each label is the same colour as the slice,
215 | * but you can ovveride that behaviour using this method.
216 | *
217 | * @param $label_colour as string HEX colour;
218 | */
219 | function set_label_colour( $label_colour )
220 | {
221 | $tmp = 'label-colour';
222 | $this->$tmp = $label_colour;
223 | }
224 |
225 | function label_colour( $label_colour )
226 | {
227 | $this->set_label_colour( $label_colour );
228 | return $this;
229 | }
230 |
231 | /**
232 | * Turn off the labels
233 | */
234 | function set_no_labels()
235 | {
236 | $tmp = 'no-labels';
237 | $this->$tmp = true;
238 | }
239 |
240 | function on_click( $event )
241 | {
242 | $tmp = 'on-click';
243 | $this->$tmp = $event;
244 | }
245 |
246 | /**
247 | * Fix the radius of the pie chart. Take a look at the magic variable #radius#
248 | * for helping figure out what radius to set it to.
249 | *
250 | * @param $radius as number
251 | */
252 | function radius( $radius )
253 | {
254 | $this->radius = $radius;
255 | return $this;
256 | }
257 | }
258 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_radar_axis.php:
--------------------------------------------------------------------------------
1 | set_max( $max );
8 | }
9 |
10 | function set_max( $max )
11 | {
12 | $this->max = $max;
13 | }
14 |
15 | function set_steps( $steps )
16 | {
17 | $this->steps = $steps;
18 | }
19 |
20 | function set_stroke( $s )
21 | {
22 | $this->stroke = $s;
23 | }
24 |
25 | function set_colour( $colour )
26 | {
27 | $this->colour = $colour;
28 | }
29 |
30 | function set_grid_colour( $colour )
31 | {
32 | $tmp = 'grid-colour';
33 | $this->$tmp = $colour;
34 | }
35 |
36 | function set_labels( $labels )
37 | {
38 | $this->labels = $labels;
39 | }
40 |
41 | function set_spoke_labels( $labels )
42 | {
43 | $tmp = 'spoke-labels';
44 | $this->$tmp = $labels;
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_radar_axis_labels.php:
--------------------------------------------------------------------------------
1 | labels = $labels;
9 | }
10 |
11 | function set_colour( $colour )
12 | {
13 | $this->colour = $colour;
14 | }
15 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_radar_spoke_labels.php:
--------------------------------------------------------------------------------
1 | labels = $labels;
9 | }
10 |
11 | function set_colour( $colour )
12 | {
13 | $this->colour = $colour;
14 | }
15 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_scatter.php:
--------------------------------------------------------------------------------
1 | x = $x;
8 | $this->y = $y;
9 |
10 | if( $dot_size > 0 )
11 | {
12 | $tmp = 'dot-size';
13 | $this->$tmp = $dot_size;
14 | }
15 | }
16 | }
17 |
18 | class scatter
19 | {
20 | function scatter( $colour )
21 | {
22 | $this->type = "scatter";
23 | $this->set_colour( $colour );
24 | }
25 |
26 | function set_colour( $colour )
27 | {
28 | $this->colour = $colour;
29 | }
30 |
31 | function set_default_dot_style( $style )
32 | {
33 | $tmp = 'dot-style';
34 | $this->$tmp = $style;
35 | }
36 |
37 | /**
38 | * @param $v as array, can contain any combination of:
39 | * - integer, Y position of the point
40 | * - any class that inherits from scatter_value
41 | * - null
42 | */
43 | function set_values( $values )
44 | {
45 | $this->values = $values;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_scatter_line.php:
--------------------------------------------------------------------------------
1 | type = "scatter_line";
8 | $this->set_colour( $colour );
9 | $this->set_width( $width );
10 | }
11 |
12 | function set_default_dot_style( $style )
13 | {
14 | $tmp = 'dot-style';
15 | $this->$tmp = $style;
16 | }
17 |
18 | function set_colour( $colour )
19 | {
20 | $this->colour = $colour;
21 | }
22 |
23 | function set_width( $width )
24 | {
25 | $this->width = $width;
26 | }
27 |
28 | function set_values( $values )
29 | {
30 | $this->values = $values;
31 | }
32 |
33 | function set_step_horizontal()
34 | {
35 | $this->stepgraph = 'horizontal';
36 | }
37 |
38 | function set_step_vertical()
39 | {
40 | $this->stepgraph = 'vertical';
41 | }
42 |
43 | function set_key( $text, $font_size )
44 | {
45 | $this->text = $text;
46 | $tmp = 'font-size';
47 | $this->$tmp = $font_size;
48 | }
49 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_shape.php:
--------------------------------------------------------------------------------
1 | x = $x;
8 | $this->y = $y;
9 | }
10 | }
11 |
12 | class shape
13 | {
14 | function shape( $colour )
15 | {
16 | $this->type = "shape";
17 | $this->colour = $colour;
18 | $this->values = array();
19 | }
20 |
21 | function append_value( $p )
22 | {
23 | $this->values[] = $p;
24 | }
25 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_sugar.php:
--------------------------------------------------------------------------------
1 | colour($colour)->size($size);
16 | }
17 | }
18 |
19 | class s_box extends anchor
20 | {
21 | /**
22 | * I use this wrapper for default dot types,
23 | * it just makes the code easier to read.
24 | */
25 | function s_box($colour, $size)
26 | {
27 | parent::anchor();
28 | $this->colour($colour)->size($size)->rotation(45)->sides(4);
29 | }
30 | }
31 |
32 | class s_hollow_dot extends hollow_dot
33 | {
34 | /**
35 | * I use this wrapper for default dot types,
36 | * it just makes the code easier to read.
37 | */
38 | function s_hollow_dot($colour, $size)
39 | {
40 | parent::hollow_dot();
41 | $this->colour($colour)->size($size);
42 | }
43 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_tags.php:
--------------------------------------------------------------------------------
1 | type = "tags";
8 | $this->values = array();
9 | }
10 |
11 | function colour( $colour )
12 | {
13 | $this->colour = $colour;
14 | return $this;
15 | }
16 |
17 | /**
18 | *@param $font as string. e.g. "Verdana"
19 | *@param $size as integer. Size in px
20 | */
21 | function font($font, $size)
22 | {
23 | $this->font = $font;
24 | $this->{'font-size'} = $size;
25 | return $this;
26 | }
27 |
28 | /**
29 | *@param $x as integer. Size of x padding in px
30 | *@param $y as integer. Size of y padding in px
31 | */
32 | function padding($x, $y)
33 | {
34 | $this->{"pad-x"} = $x;
35 | $this->{"pad-y"} = $y;
36 | return $this;
37 | }
38 |
39 | function rotate($angle)
40 | {
41 | $this->rotate($angle);
42 | return $this;
43 | }
44 |
45 | function align_x_center()
46 | {
47 | $this->{"align-x"} = "center";
48 | return $this;
49 | }
50 |
51 | function align_x_left()
52 | {
53 | $this->{"align-x"} = "left";
54 | return $this;
55 | }
56 |
57 | function align_x_right()
58 | {
59 | $this->{"align-x"} = "right";
60 | return $this;
61 | }
62 |
63 | function align_y_above()
64 | {
65 | $this->{"align-y"} = "above";
66 | return $this;
67 | }
68 |
69 | function align_y_below()
70 | {
71 | $this->{"align-y"} = "below";
72 | return $this;
73 | }
74 |
75 | function align_y_center()
76 | {
77 | $this->{"align-y"} = "center";
78 | return $this;
79 | }
80 |
81 | /**
82 | * This can contain some HTML, e.g:
83 | * - "More info"
84 | * - "ofc"
85 | */
86 | function text($text)
87 | {
88 | $this->text = $text;
89 | return $this;
90 | }
91 |
92 | /**
93 | * This works, but to get the mouse pointer to change
94 | * to a little hand you need to use "stuff"-- see text()
95 | */
96 | function on_click($on_click)
97 | {
98 | $this->{'on-click'} = $on_click;
99 | return $this;
100 | }
101 |
102 | /**
103 | *@param $bold boolean.
104 | *@param $underline boolean.
105 | *@param $border boolean.
106 | *@prarm $alpha real (0 to 1.0)
107 | */
108 | function style($bold, $underline, $border, $alpha )
109 | {
110 | $this->bold = $bold;
111 | $this->border = $underline;
112 | $this->underline = $border;
113 | $this->alpha = $alpha;
114 | return $this;
115 | }
116 |
117 | /**
118 | *@param $tag as ofc_tag
119 | */
120 | function append_tag($tag)
121 | {
122 | $this->values[] = $tag;
123 | }
124 | }
125 |
126 | class ofc_tag extends ofc_tags
127 | {
128 | function ofc_tag($x, $y)
129 | {
130 | $this->x = $x;
131 | $this->y = $y;
132 | }
133 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_title.php:
--------------------------------------------------------------------------------
1 | text = $text;
12 | }
13 |
14 | /**
15 | * A css string. Can optionally contain:
16 | * - font-size
17 | * - font-family
18 | * - font-weight
19 | * - color
20 | * - background-color
21 | * - text-align
22 | * - margin
23 | * - margin-left
24 | * - margin-right
25 | * - margin-top
26 | * - margin-bottom
27 | * - padding
28 | * - padding-left
29 | * - padding-right
30 | * - padding-top
31 | * - padding-bottom
32 | * just like the css we use all the time :-)
33 | */
34 | function set_style( $css )
35 | {
36 | $this->style = $css;
37 | //"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
38 | }
39 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_tooltip.php:
--------------------------------------------------------------------------------
1 | shadow = $shadow;
15 | }
16 |
17 | /**
18 | * @param $stroke as integer, border width in pixels (e.g. 5 )
19 | */
20 | function set_stroke( $stroke )
21 | {
22 | $this->stroke = $stroke;
23 | }
24 |
25 | /**
26 | * @param $colour as string, HEX colour e.g. '#0000ff'
27 | */
28 | function set_colour( $colour )
29 | {
30 | $this->colour = $colour;
31 | }
32 |
33 | /**
34 | * @param $bg as string, HEX colour e.g. '#0000ff'
35 | */
36 | function set_background_colour( $bg )
37 | {
38 | $this->background = $bg;
39 | }
40 |
41 | /**
42 | * @param $style as string. A css style.
43 | */
44 | function set_title_style( $style )
45 | {
46 | $this->title = $style;
47 | }
48 |
49 | /**
50 | * @param $style as string. A css style.
51 | */
52 | function set_body_style( $style )
53 | {
54 | $this->body = $style;
55 | }
56 |
57 | function set_proximity()
58 | {
59 | $this->mouse = 1;
60 | }
61 |
62 | function set_hover()
63 | {
64 | $this->mouse = 2;
65 | }
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_upload_image.php:
--------------------------------------------------------------------------------
1 | save_image debug mode, you
5 | // will see the 'echo' text in a new window.
6 | //
7 |
8 | /*
9 |
10 | print_r( $_GET );
11 | print_r( $_POST );
12 | print_r( $_FILES );
13 |
14 | print_r( $GLOBALS );
15 | print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
16 |
17 | */
18 |
19 |
20 | // default path for the image to be stored //
21 | $default_path = '../tmp-upload-images/';
22 |
23 | if (!file_exists($default_path)) mkdir($default_path, 0777, true);
24 |
25 | // full path to the saved image including filename //
26 | $destination = $default_path . basename( $_GET[ 'name' ] );
27 |
28 | echo 'Saving your image to: '. $destination;
29 | // print_r( $_POST );
30 | // print_r( $_SERVER );
31 | // echo $HTTP_RAW_POST_DATA;
32 |
33 | //
34 | // POST data is usually string data, but we are passing a RAW .png
35 | // so PHP is a bit confused and $_POST is empty. But it has saved
36 | // the raw bits into $HTTP_RAW_POST_DATA
37 | //
38 |
39 | $jfh = fopen($destination, 'w') or die("can't open file");
40 | fwrite($jfh, $HTTP_RAW_POST_DATA);
41 | fclose($jfh);
42 |
43 | //
44 | // LOOK:
45 | //
46 | exit();
47 |
48 |
49 | //
50 | // PHP5:
51 | //
52 |
53 |
54 | // default path for the image to be stored //
55 | $default_path = 'tmp-upload-images/';
56 |
57 | if (!file_exists($default_path)) mkdir($default_path, 0777, true);
58 |
59 | // full path to the saved image including filename //
60 | $destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
61 |
62 | // move the image into the specified directory //
63 | if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {
64 | echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";
65 | } else {
66 | echo "FILE UPLOAD FAILED";
67 | }
68 |
69 |
70 | ?>
71 |
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_x_axis.php:
--------------------------------------------------------------------------------
1 | stroke = $stroke;
13 | }
14 |
15 | function stroke( $stroke )
16 | {
17 | $this->set_stroke( $stroke );
18 | return $this;
19 | }
20 |
21 | /**
22 | *@param $colour as string HEX colour
23 | *@param $grid_colour as string HEX colour
24 | */
25 | function set_colours( $colour, $grid_colour )
26 | {
27 | $this->set_colour( $colour );
28 | $this->set_grid_colour( $grid_colour );
29 | }
30 |
31 | /**
32 | *@param $colour as string HEX colour
33 | */
34 | function set_colour( $colour )
35 | {
36 | $this->colour = $colour;
37 | }
38 |
39 | function colour( $colour )
40 | {
41 | $this->set_colour($colour);
42 | return $this;
43 | }
44 |
45 | function set_tick_height( $height )
46 | {
47 | $tmp = 'tick-height';
48 | $this->$tmp = $height;
49 | }
50 |
51 | function tick_height( $height )
52 | {
53 | $this->set_tick_height($height);
54 | return $this;
55 | }
56 |
57 | function set_grid_colour( $colour )
58 | {
59 | $tmp = 'grid-colour';
60 | $this->$tmp = $colour;
61 | }
62 |
63 | function grid_colour( $colour )
64 | {
65 | $this->set_grid_colour($colour);
66 | return $this;
67 | }
68 |
69 | /**
70 | * @param $o is a boolean. If true, the X axis start half a step in
71 | * This defaults to True
72 | */
73 | function set_offset( $o )
74 | {
75 | $this->offset = $o?true:false;
76 | }
77 |
78 | function offset( $o )
79 | {
80 | $this->set_offset($o);
81 | return $this;
82 | }
83 |
84 | /**
85 | * @param $steps as integer. Which grid lines and ticks are visible.
86 | */
87 | function set_steps( $steps )
88 | {
89 | $this->steps = $steps;
90 | }
91 |
92 | function steps( $steps )
93 | {
94 | $this->set_steps($steps);
95 | return $this;
96 | }
97 |
98 | /**
99 | * @param $val as an integer, the height in pixels of the 3D bar. Mostly
100 | * used for the 3D bar chart.
101 | */
102 | function set_3d( $val )
103 | {
104 | $tmp = '3d';
105 | $this->$tmp = $val;
106 | }
107 |
108 | /**
109 | * @param $x_axis_labels as an x_axis_labels object
110 | * Use this to customize the labels (colour, font, etc...)
111 | */
112 | function set_labels( $x_axis_labels )
113 | {
114 | //$this->labels = $v;
115 | $this->labels = $x_axis_labels;
116 | }
117 |
118 | /**
119 | * Sugar syntax: helper function to make the examples simpler.
120 | * @param $a is an array of labels
121 | */
122 | function set_labels_from_array( $a )
123 | {
124 | $x_axis_labels = new x_axis_labels();
125 | $x_axis_labels->set_labels( $a );
126 | $this->labels = $x_axis_labels;
127 |
128 | if( isset( $this->steps ) )
129 | $x_axis_labels->set_steps( $this->steps );
130 | }
131 |
132 | /**
133 | * min and max.
134 | */
135 | function set_range( $min, $max )
136 | {
137 | $this->min = $min;
138 | $this->max = $max;
139 | }
140 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_x_axis_label.php:
--------------------------------------------------------------------------------
1 | set_text( $text );
11 | $this->set_colour( $colour );
12 | $this->set_size( $size );
13 | $this->set_rotate( $rotate );
14 | }
15 |
16 | function set_text( $text )
17 | {
18 | $this->text = $text;
19 | }
20 |
21 | function set_colour( $colour )
22 | {
23 | $this->colour = $colour;
24 | }
25 |
26 | function set_size( $size )
27 | {
28 | $this->size = $size;
29 | }
30 |
31 | function set_rotate( $rotate )
32 | {
33 | $this->rotate = $rotate;
34 | }
35 |
36 | function set_vertical()
37 | {
38 | $this->rotate = "vertical";
39 | }
40 |
41 | function set_visible()
42 | {
43 | $this->visible = true;
44 | }
45 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_x_axis_labels.php:
--------------------------------------------------------------------------------
1 | steps = $steps;
13 | }
14 |
15 | /**
16 | * @param $steps as integer which labels are visible
17 | */
18 | function visible_steps( $steps )
19 | {
20 | $this->{"visible-steps"} = $steps;
21 | return $this;
22 | }
23 |
24 | /**
25 | *
26 | * @param $labels as an array of [x_axis_label or string]
27 | */
28 | function set_labels( $labels )
29 | {
30 | $this->labels = $labels;
31 | }
32 |
33 | function set_colour( $colour )
34 | {
35 | $this->colour = $colour;
36 | }
37 |
38 | /**
39 | * font size in pixels
40 | */
41 | function set_size( $size )
42 | {
43 | $this->size = $size;
44 | }
45 |
46 | /**
47 | * rotate labels
48 | */
49 | function set_vertical()
50 | {
51 | $this->rotate = 270;
52 | }
53 |
54 | /**
55 | * @param @angle as real. The angle of the text.
56 | */
57 | function rotate( $angle )
58 | {
59 | $this->rotate = $angle;
60 | }
61 |
62 | /**
63 | * @param $text as string. Replace and magic variables with actual x axis position.
64 | */
65 | function text( $text )
66 | {
67 | $this->text = $text;
68 | }
69 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_x_legend.php:
--------------------------------------------------------------------------------
1 | text = $text;
8 | }
9 |
10 | function set_style( $css )
11 | {
12 | $this->style = $css;
13 | //"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
14 | }
15 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_y_axis.php:
--------------------------------------------------------------------------------
1 | $tmp = $colour;
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_y_axis_base.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openHPI/nginx-hls-analyzer/3bdcba05b6a8fd25f386f77c4da2f74506164ccb/webroot/OFC/php-ofc-library/ofc_y_axis_base.php
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_y_axis_label.php:
--------------------------------------------------------------------------------
1 | y = $y;
11 | $this->set_text( $text );
12 | }
13 |
14 | function set_text( $text )
15 | {
16 | $this->text = $text;
17 | }
18 |
19 | function set_colour( $colour )
20 | {
21 | $this->colour = $colour;
22 | }
23 |
24 | function set_size( $size )
25 | {
26 | $this->size = $size;
27 | }
28 |
29 | function set_rotate( $rotate )
30 | {
31 | $this->rotate = $rotate;
32 | }
33 |
34 | function set_vertical()
35 | {
36 | $this->rotate = "vertical";
37 | }
38 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_y_axis_labels.php:
--------------------------------------------------------------------------------
1 | steps = $steps;
13 | }
14 |
15 | /**
16 | *
17 | * @param $labels as an array of [y_axis_label or string]
18 | */
19 | function set_labels( $labels )
20 | {
21 | $this->labels = $labels;
22 | }
23 |
24 | function set_colour( $colour )
25 | {
26 | $this->colour = $colour;
27 | }
28 |
29 | /**
30 | * font size in pixels
31 | */
32 | function set_size( $size )
33 | {
34 | $this->size = $size;
35 | }
36 |
37 | /**
38 | * rotate labels
39 | */
40 | function set_vertical()
41 | {
42 | $this->rotate = 270;
43 | }
44 |
45 | function rotate( $angle )
46 | {
47 | $this->rotate = $angle;
48 | }
49 |
50 | /**
51 | * @param $text default text that all labels inherit
52 | */
53 | function set_text( $text )
54 | {
55 | $this->text = $text;
56 | }
57 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/ofc_y_axis_right.php:
--------------------------------------------------------------------------------
1 | text = $text;
8 | }
9 |
10 | function set_style( $css )
11 | {
12 | $this->style = $css;
13 | //"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
14 | }
15 | }
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/open-flash-chart-object.php:
--------------------------------------------------------------------------------
1 | ';
65 |
66 | if( !isset( $open_flash_chart_seqno ) )
67 | {
68 | $open_flash_chart_seqno = 1;
69 | $out[] = '';
70 | }
71 | else
72 | {
73 | $open_flash_chart_seqno++;
74 | $obj_id .= '_'. $open_flash_chart_seqno;
75 | $div_name .= '_'. $open_flash_chart_seqno;
76 | }
77 |
78 | if( $use_swfobject )
79 | {
80 | // Using library for auto-enabling Flash object on IE, disabled-Javascript proof
81 | $out[] = '';
82 | $out[] = '';
90 | $out[] = '';
105 | }
106 |
107 | return implode("\n",$out);
108 | }
109 | ?>
--------------------------------------------------------------------------------
/webroot/OFC/php-ofc-library/open-flash-chart.php:
--------------------------------------------------------------------------------
1 | title = new title( "Many data lines" );
68 | $this->elements = array();
69 | }
70 |
71 | function set_title( $t )
72 | {
73 | $this->title = $t;
74 | }
75 |
76 | function set_x_axis( $x )
77 | {
78 | $this->x_axis = $x;
79 | }
80 |
81 | function set_y_axis( $y )
82 | {
83 | $this->y_axis = $y;
84 | }
85 |
86 | function add_y_axis( $y )
87 | {
88 | $this->y_axis = $y;
89 | }
90 |
91 | function set_y_axis_right( $y )
92 | {
93 | $this->y_axis_right = $y;
94 | }
95 |
96 | function add_element( $e )
97 | {
98 | $this->elements[] = $e;
99 | }
100 |
101 | function set_x_legend( $x )
102 | {
103 | $this->x_legend = $x;
104 | }
105 |
106 | function set_y_legend( $y )
107 | {
108 | $this->y_legend = $y;
109 | }
110 |
111 | function set_bg_colour( $colour )
112 | {
113 | $this->bg_colour = $colour;
114 | }
115 |
116 | function set_radar_axis( $radar )
117 | {
118 | $this->radar_axis = $radar;
119 | }
120 |
121 | function set_tooltip( $tooltip )
122 | {
123 | $this->tooltip = $tooltip;
124 | }
125 |
126 | /**
127 | * This is a bit funky :(
128 | *
129 | * @param $num_decimals as integer. Truncate the decimals to $num_decimals, e.g. set it
130 | * to 5 and 3.333333333 will display as 3.33333. 2.0 will display as 2 (or 2.00000 - see below)
131 | * @param $is_fixed_num_decimals_forced as boolean. If true it will pad the decimals.
132 | * @param $is_decimal_separator_comma as boolean
133 | * @param $is_thousand_separator_disabled as boolean
134 | *
135 | * This needs a bit of love and attention
136 | */
137 | function set_number_format($num_decimals, $is_fixed_num_decimals_forced, $is_decimal_separator_comma, $is_thousand_separator_disabled )
138 | {
139 | $this->num_decimals = $num_decimals;
140 | $this->is_fixed_num_decimals_forced = $is_fixed_num_decimals_forced;
141 | $this->is_decimal_separator_comma = $is_decimal_separator_comma;
142 | $this->is_thousand_separator_disabled = $is_thousand_separator_disabled;
143 | }
144 |
145 | /**
146 | * This is experimental and will change as we make it work
147 | *
148 | * @param $m as ofc_menu
149 | */
150 | function set_menu($m)
151 | {
152 | $this->menu = $m;
153 | }
154 |
155 | function toString()
156 | {
157 | if (function_exists('json_encode'))
158 | {
159 | return json_encode($this);
160 | }
161 | else
162 | {
163 | $json = new Services_JSON();
164 | return $json->encode( $this );
165 | }
166 | }
167 |
168 | function toPrettyString()
169 | {
170 | return json_format( $this->toString() );
171 | }
172 | }
173 |
174 |
175 |
176 | //
177 | // there is no PHP end tag so we don't mess the headers up!
178 | //
--------------------------------------------------------------------------------
/webroot/concurrent.php:
--------------------------------------------------------------------------------
1 | error_msg()) die($CONFIG->error_msg());
8 |
9 | // Database connection
10 | $db_username = $CONFIG->items['Database']['Username'];
11 | $db_password = $CONFIG->items['Database']['Password'];
12 | $db_host = $CONFIG->items['Database']['Server'];
13 | $db_database = $CONFIG->items['Database']['Database'];
14 |
15 | $DB = mysql_connect($db_host, $db_username, $db_password);
16 | if(!$DB) die(mysql_error());
17 | $result = mysql_select_db($db_database, $DB);
18 | if(!$result) die(mysql_error());
19 |
20 | $xtime = 0;
21 |
22 | if (isset ($_REQUEST["xtime"]))
23 | {
24 | $xtime = $_REQUEST["xtime"] + 0;
25 | }
26 |
27 | $liveonly = isset ($_REQUEST["live"]);
28 | $teletestonly = isset ($_REQUEST["teletest"]);
29 |
30 | ?>
31 |
33 |
34 |
35 |
36 | Time period: last 80 days 43 | | Page generated:
44 | 45 | 46 | 47 | 48 | 52 | 53 |Date | 58 |concurrent connections | 59 |'.$v[0].' | 69 |'.number_format($v[2]).' | 70 | '; 71 | $i++; 72 | } 73 | ?> 74 | 75 |
---|
Date | 87 |Stream name | 88 |concurrent connections | 89 |'.$v[0].' | 99 |'.$v[1].' | 100 |'.number_format($v[2]).' | 101 | '; 102 | $i++; 103 | } 104 | ?> 105 | 106 |
---|
Date | 115 |Stream name | 116 |number of seconds this stream was active | 117 |'.$v[0].' | 127 |'.$v[1].' | 128 |'.number_format($v[2]).' | 129 | '; 130 | $i++; 131 | } 132 | ?> 133 | 134 |
---|
Time period: 69 | | Page generated:
70 | 71 |
74 |
75 |
76 | 99 | 100 | 116 | 117 | 118 | |
119 |
97 |
98 |
120 |
121 |
122 | Summary Stats123 |
Access stats143 | 144 |TOP 20 streams145 |
[+/-] Show all/Show TOP 20 176 | 177 | Visitor stats178 | 179 |Hits by Country180 | 181 | 182 | 183 |TOP 20 Unique IPs184 |
[+/-] Show all/Show TOP 20 215 | 216 | 217 | Activity stats218 | 219 |Daily Hits220 | 221 | 222 |Daily Traffic223 | 224 | 225 |Monthly Hits226 | 227 | 228 |Monthly Traffic229 | 230 | 231 |Bandwidth232 | 233 | 234 |Peak Bandwidth235 | 236 | 237 | 238 | 239 | |
240 |