@@ -39,13 +39,16 @@ discard block |
||
39 | 39 | |
40 | 40 | ini_set('memory_limit', '16M'); |
41 | 41 | $shell_arguments = "mysqldump --no-data -h$dbserver -u$user -p$password $dbname"; |
42 | - if (!strpos($shell_arguments,"--no-data")) |
|
43 | - throw new Exception("wrong database dump arguments"); |
|
42 | + if (!strpos($shell_arguments,"--no-data")) { |
|
43 | + throw new Exception("wrong database dump arguments"); |
|
44 | + } |
|
44 | 45 | $struct = shell_exec($shell_arguments); |
45 | - if (strlen($struct) > 1000000) |
|
46 | - throw new Exception("something went terribly wrong while dumping table structures"); |
|
47 | - if (stripos($struct,"dumping data") !== FALSE) |
|
48 | - throw new Exception("something went terribly wrong while dumping table structures"); |
|
46 | + if (strlen($struct) > 1000000) { |
|
47 | + throw new Exception("something went terribly wrong while dumping table structures"); |
|
48 | + } |
|
49 | + if (stripos($struct,"dumping data") !== FALSE) { |
|
50 | + throw new Exception("something went terribly wrong while dumping table structures"); |
|
51 | + } |
|
49 | 52 | |
50 | 53 | # Remove the "AUTO_INCREMENT=..." values. They break the diffs. |
51 | 54 | |
@@ -91,8 +94,7 @@ discard block |
||
91 | 94 | "-- 1. ".Settings::get('SITE_URL')."okapi/devel/dbstruct (".md5($struct).")\n". |
92 | 95 | "-- 2. ".$_GET['compare_to']." (".md5($alternate_struct).")\n\n"; |
93 | 96 | $alters = $updater->getUpdates($alternate_struct, $struct); |
94 | - } |
|
95 | - else |
|
97 | + } else |
|
96 | 98 | { |
97 | 99 | $response->body .= |
98 | 100 | "-- The following will alter [1], so that it has the structure of [2].\n". |
@@ -101,8 +103,9 @@ discard block |
||
101 | 103 | $alters = $updater->getUpdates($struct, $alternate_struct); |
102 | 104 | } |
103 | 105 | # Add semicolons |
104 | - foreach ($alters as &$alter_ref) |
|
105 | - $alter_ref .= ";"; |
|
106 | + foreach ($alters as &$alter_ref) { |
|
107 | + $alter_ref .= ";"; |
|
108 | + } |
|
106 | 109 | # Comment out all differences containing "okapi_". These should be executed |
107 | 110 | # by OKAPI update scripts. |
108 | 111 | foreach ($alters as &$alter_ref) |
@@ -114,17 +117,16 @@ discard block |
||
114 | 117 | implode("\n-- ", $lines)."\n-- }}}"; |
115 | 118 | } |
116 | 119 | } |
117 | - if (count($alters) > 0) |
|
118 | - $response->body .= implode("\n", $alters)."\n"; |
|
119 | - else |
|
120 | - $response->body .= "-- No differences found\n"; |
|
121 | - } |
|
122 | - else |
|
120 | + if (count($alters) > 0) { |
|
121 | + $response->body .= implode("\n", $alters)."\n"; |
|
122 | + } else { |
|
123 | + $response->body .= "-- No differences found\n"; |
|
124 | + } |
|
125 | + } else |
|
123 | 126 | { |
124 | 127 | $response->body = "HTTP(S) only!"; |
125 | 128 | } |
126 | - } |
|
127 | - else |
|
129 | + } else |
|
128 | 130 | { |
129 | 131 | $response->body = $struct; |
130 | 132 | } |
@@ -131,8 +131,7 @@ discard block |
||
131 | 131 | if (is_array($this->config['updateTypes'])) |
132 | 132 | { |
133 | 133 | $updateActions = $this->config['updateTypes']; |
134 | - } |
|
135 | - else |
|
134 | + } else |
|
136 | 135 | { |
137 | 136 | $updateActions = array_map('trim', explode(',', $this->config['updateTypes'])); |
138 | 137 | } |
@@ -146,15 +145,13 @@ discard block |
||
146 | 145 | { |
147 | 146 | $result[$table] = $info; |
148 | 147 | } |
149 | - } |
|
150 | - elseif ($info['destOrphan']) |
|
148 | + } elseif ($info['destOrphan']) |
|
151 | 149 | { |
152 | 150 | if (in_array('drop', $updateActions)) |
153 | 151 | { |
154 | 152 | $result[$table] = $info; |
155 | 153 | } |
156 | - } |
|
157 | - elseif($info['differs']) |
|
154 | + } elseif($info['differs']) |
|
158 | 155 | { |
159 | 156 | $resultInfo = $info; |
160 | 157 | unset($resultInfo['differs']); |
@@ -163,12 +160,10 @@ discard block |
||
163 | 160 | if (empty($diff['dest']) && in_array('add', $updateActions)) |
164 | 161 | { |
165 | 162 | $resultInfo['differs'][] = $diff; |
166 | - } |
|
167 | - elseif (empty($diff['source']) && in_array('remove', $updateActions)) |
|
163 | + } elseif (empty($diff['source']) && in_array('remove', $updateActions)) |
|
168 | 164 | { |
169 | 165 | $resultInfo['differs'][] = $diff; |
170 | - } |
|
171 | - elseif(in_array('modify', $updateActions)) |
|
166 | + } elseif(in_array('modify', $updateActions)) |
|
172 | 167 | { |
173 | 168 | $resultInfo['differs'][] = $diff; |
174 | 169 | } |
@@ -198,12 +193,10 @@ discard block |
||
198 | 193 | if ($info['sourceOrphan']) |
199 | 194 | { |
200 | 195 | $result['sourceOrphans'][] = $table; |
201 | - } |
|
202 | - elseif ($info['destOrphan']) |
|
196 | + } elseif ($info['destOrphan']) |
|
203 | 197 | { |
204 | 198 | $result['destOrphans'][] = $table; |
205 | - } |
|
206 | - else |
|
199 | + } else |
|
207 | 200 | { |
208 | 201 | $result['different'][] = $table; |
209 | 202 | } |
@@ -245,12 +238,10 @@ discard block |
||
245 | 238 | if(in_array($tab, $destOrphans)) |
246 | 239 | { |
247 | 240 | $info['destOrphan'] = true; |
248 | - } |
|
249 | - elseif (in_array($tab, $sourceOrphans)) |
|
241 | + } elseif (in_array($tab, $sourceOrphans)) |
|
250 | 242 | { |
251 | 243 | $info['sourceOrphan'] = true; |
252 | - } |
|
253 | - else |
|
244 | + } else |
|
254 | 245 | { |
255 | 246 | $destSql = $this->getTabSql($this->destStruct, $tab, true); |
256 | 247 | $sourceSql = $this->getTabSql($this->sourceStruct, $tab, true); |
@@ -259,12 +250,15 @@ discard block |
||
259 | 250 | { |
260 | 251 | trigger_error('[WARNING] error parsing definition of table "'.$tab.'" - skipped'); |
261 | 252 | continue; |
262 | - } |
|
263 | - elseif (!empty($diffs))//not empty array |
|
253 | + } elseif (!empty($diffs)) { |
|
254 | + //not empty array |
|
264 | 255 | { |
265 | 256 | $info['differs'] = $diffs; |
266 | 257 | } |
267 | - else continue;//empty array |
|
258 | + } else { |
|
259 | + continue; |
|
260 | + } |
|
261 | + //empty array |
|
268 | 262 | } |
269 | 263 | $result[$tab] = $info; |
270 | 264 | } |
@@ -281,10 +275,12 @@ discard block |
||
281 | 275 | $result = array(); |
282 | 276 | if (preg_match_all('/CREATE(?:\s*TEMPORARY)?\s*TABLE\s*(?:IF NOT EXISTS\s*)?(?:`?(\w+)`?\.)?`?(\w+)`?/i', $struct, $m)) |
283 | 277 | { |
284 | - foreach($m[2] as $match)//m[1] is a database name if any |
|
278 | + foreach($m[2] as $match) { |
|
279 | + //m[1] is a database name if any |
|
285 | 280 | { |
286 | 281 | $result[] = $match; |
287 | 282 | } |
283 | + } |
|
288 | 284 | } |
289 | 285 | return $result; |
290 | 286 | } |
@@ -312,8 +308,7 @@ discard block |
||
312 | 308 | if ($end === false) |
313 | 309 | { |
314 | 310 | $result = substr($struct, $start); |
315 | - } |
|
316 | - else |
|
311 | + } else |
|
317 | 312 | { |
318 | 313 | $result = substr($struct, $start, $end-$start);//already without ';' |
319 | 314 | } |
@@ -390,9 +385,11 @@ discard block |
||
390 | 385 | $result = array(); |
391 | 386 | //split with comma delimiter, not line breaks |
392 | 387 | $sourceParts = $this->splitTabSql($sourceSql); |
393 | - if ($sourceParts===false)//error parsing sql |
|
388 | + if ($sourceParts===false) { |
|
389 | + //error parsing sql |
|
394 | 390 | { |
395 | 391 | trigger_error('[WARNING] error parsing source sql'); |
392 | + } |
|
396 | 393 | return false; |
397 | 394 | } |
398 | 395 | $destParts = $this->splitTabSql($destSql); |
@@ -406,13 +403,17 @@ discard block |
||
406 | 403 | foreach($sourceParts as $line) |
407 | 404 | { |
408 | 405 | $lineInfo = $this->processLine($line); |
409 | - if (!$lineInfo) continue; |
|
406 | + if (!$lineInfo) { |
|
407 | + continue; |
|
408 | + } |
|
410 | 409 | $sourcePartsIndexed[$lineInfo['key']] = $lineInfo['line']; |
411 | 410 | } |
412 | 411 | foreach($destParts as $line) |
413 | 412 | { |
414 | 413 | $lineInfo = $this->processLine($line); |
415 | - if (!$lineInfo) continue; |
|
414 | + if (!$lineInfo) { |
|
415 | + continue; |
|
416 | + } |
|
416 | 417 | $destPartsIndexed[$lineInfo['key']] = $lineInfo['line']; |
417 | 418 | } |
418 | 419 | $sourceKeys = array_keys($sourcePartsIndexed); |
@@ -432,17 +433,16 @@ discard block |
||
432 | 433 | if ($sourceOrphan) |
433 | 434 | { |
434 | 435 | $info['source'] = $sourcePartsIndexed[$key]; |
435 | - } |
|
436 | - elseif ($destOrphan) |
|
436 | + } elseif ($destOrphan) |
|
437 | 437 | { |
438 | 438 | $info['dest'] = $destPartsIndexed[$key]; |
439 | - } |
|
440 | - elseif ($different) |
|
439 | + } elseif ($different) |
|
441 | 440 | { |
442 | 441 | $info['source'] = $sourcePartsIndexed[$key]; |
443 | 442 | $info['dest'] = $destPartsIndexed[$key]; |
443 | + } else { |
|
444 | + continue; |
|
444 | 445 | } |
445 | - else continue; |
|
446 | 446 | $result[] = $info; |
447 | 447 | } |
448 | 448 | return $result; |
@@ -461,20 +461,25 @@ discard block |
||
461 | 461 | $options = $this->config; |
462 | 462 | $result = array('key'=>'', 'line'=>''); |
463 | 463 | $line = rtrim(trim($line), ','); |
464 | - if (preg_match('/^(CREATE\s+TABLE)|(\) ENGINE=)/i', $line))//first or last table definition line |
|
464 | + if (preg_match('/^(CREATE\s+TABLE)|(\) ENGINE=)/i', $line)) { |
|
465 | + //first or last table definition line |
|
465 | 466 | { |
466 | 467 | return false; |
467 | 468 | } |
469 | + } |
|
468 | 470 | //if (preg_match('/^(PRIMARY KEY)|(((UNIQUE )|(FULLTEXT ))?KEY `?\w+`?)/i', $line, $m))//key definition |
469 | - if (preg_match('/^(PRIMARY\s+KEY)|(((UNIQUE\s+)|(FULLTEXT\s+))?KEY\s+`?\w+`?)/i', $line, $m))//key definition |
|
471 | + if (preg_match('/^(PRIMARY\s+KEY)|(((UNIQUE\s+)|(FULLTEXT\s+))?KEY\s+`?\w+`?)/i', $line, $m)) { |
|
472 | + //key definition |
|
470 | 473 | { |
471 | 474 | $key = $m[0]; |
472 | 475 | } |
473 | - elseif (preg_match('/^`?\w+`?/i', $line, $m))//field definition |
|
476 | + } elseif (preg_match('/^`?\w+`?/i', $line, $m)) { |
|
477 | + //field definition |
|
474 | 478 | { |
475 | - $key = '!'.$m[0];//to make sure fields will be synchronised before the keys |
|
479 | + $key = '!'.$m[0]; |
|
476 | 480 | } |
477 | - else |
|
481 | + //to make sure fields will be synchronised before the keys |
|
482 | + } else |
|
478 | 483 | { |
479 | 484 | return false;//line has no valuable info (empty or comment) |
480 | 485 | } |
@@ -514,13 +519,16 @@ discard block |
||
514 | 519 | } |
515 | 520 | foreach($diff as $tab=>$info) |
516 | 521 | { |
517 | - if ($info['sourceOrphan'])//delete it |
|
522 | + if ($info['sourceOrphan']) { |
|
523 | + //delete it |
|
518 | 524 | { |
519 | 525 | $sqls[] = 'DROP TABLE `'.$tab.'`'; |
520 | 526 | } |
521 | - elseif ($info['destOrphan'])//create destination table in source |
|
527 | + } elseif ($info['destOrphan']) { |
|
528 | + //create destination table in source |
|
522 | 529 | { |
523 | 530 | $database = ''; |
531 | + } |
|
524 | 532 | $destSql = $this->getTabSql($this->destStruct, $tab, $database); |
525 | 533 | if (!empty($options['ignoreIncrement'])) |
526 | 534 | { |
@@ -535,8 +543,7 @@ discard block |
||
535 | 543 | $destSql = preg_replace('/(CREATE(?:\s*TEMPORARY)?\s*TABLE\s*)(?:IF\sNOT\sEXISTS\s*)?(`?\w+`?)/i', '$1IF NOT EXISTS $2', $destSql); |
536 | 544 | } |
537 | 545 | $sqls[] = $destSql; |
538 | - } |
|
539 | - else |
|
546 | + } else |
|
540 | 547 | { |
541 | 548 | foreach($info['differs'] as $finfo) |
542 | 549 | { |
@@ -546,13 +553,11 @@ discard block |
||
546 | 553 | { |
547 | 554 | $sql = $finfo['source']; |
548 | 555 | $action = 'drop'; |
549 | - } |
|
550 | - elseif ($inDest && !$inSource) |
|
556 | + } elseif ($inDest && !$inSource) |
|
551 | 557 | { |
552 | 558 | $sql = $finfo['dest']; |
553 | 559 | $action = 'add'; |
554 | - } |
|
555 | - else |
|
560 | + } else |
|
556 | 561 | { |
557 | 562 | $sql = $finfo['dest']; |
558 | 563 | $action = 'modify'; |
@@ -590,8 +595,7 @@ discard block |
||
590 | 595 | if ($type=='primary') |
591 | 596 | { |
592 | 597 | $result.= 'DROP PRIMARY KEY'; |
593 | - } |
|
594 | - else |
|
598 | + } else |
|
595 | 599 | { |
596 | 600 | $result.= 'DROP INDEX `'.$name.'`'; |
597 | 601 | } |
@@ -600,12 +604,10 @@ discard block |
||
600 | 604 | if ($type=='primary') |
601 | 605 | { |
602 | 606 | $result.= 'ADD PRIMARY KEY '.$fields; |
603 | - } |
|
604 | - elseif ($type=='') |
|
607 | + } elseif ($type=='') |
|
605 | 608 | { |
606 | 609 | $result.= 'ADD INDEX `'.$name.'` '.$fields; |
607 | - } |
|
608 | - else |
|
610 | + } else |
|
609 | 611 | { |
610 | 612 | $result .='ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique |
611 | 613 | } |
@@ -614,20 +616,17 @@ discard block |
||
614 | 616 | if ($type=='primary') |
615 | 617 | { |
616 | 618 | $result.='DROP PRIMARY KEY, ADD PRIMARY KEY '.$fields; |
617 | - } |
|
618 | - elseif ($type=='') |
|
619 | + } elseif ($type=='') |
|
619 | 620 | { |
620 | 621 | $result.='DROP INDEX `'.$name.'`, ADD INDEX `'.$name.'` '.$fields; |
621 | - } |
|
622 | - else |
|
622 | + } else |
|
623 | 623 | { |
624 | 624 | $result.='DROP INDEX `'.$name.'`, ADD '.strtoupper($type).' `'.$name.'` '.$fields;//fulltext or unique |
625 | 625 | } |
626 | 626 | break; |
627 | 627 | |
628 | 628 | } |
629 | - } |
|
630 | - else //fields operations |
|
629 | + } else //fields operations |
|
631 | 630 | { |
632 | 631 | $sql = rtrim(trim($sql), ','); |
633 | 632 | $result.= strtoupper($action); |
@@ -635,8 +634,7 @@ discard block |
||
635 | 634 | { |
636 | 635 | $spacePos = strpos($sql, ' '); |
637 | 636 | $result.= ' '.substr($sql, 0, $spacePos); |
638 | - } |
|
639 | - else |
|
637 | + } else |
|
640 | 638 | { |
641 | 639 | $result.= ' '.$sql; |
642 | 640 | } |
@@ -660,8 +658,7 @@ discard block |
||
660 | 658 | if ($skipInBrackets) |
661 | 659 | { |
662 | 660 | $reg.='(\(|\))|'; |
663 | - } |
|
664 | - else |
|
661 | + } else |
|
665 | 662 | { |
666 | 663 | $reg.='()'; |
667 | 664 | } |
@@ -686,47 +683,51 @@ discard block |
||
686 | 683 | continue;//here we could also simplify regexp |
687 | 684 | } |
688 | 685 | |
689 | - if (!empty($m[7][0]))// ';' found |
|
686 | + if (!empty($m[7][0])) { |
|
687 | + // ';' found |
|
690 | 688 | { |
691 | 689 | if (empty($stack)) |
692 | 690 | { |
693 | 691 | return $m[7][1]; |
694 | - } |
|
695 | - else |
|
692 | + } |
|
693 | + } else |
|
696 | 694 | { |
697 | 695 | //var_dump($stack, substr($string, $offset-strlen($m[0][0]))); |
698 | 696 | } |
699 | 697 | } |
700 | - if (!empty($m[6][0]))// '(' or ')' found |
|
698 | + if (!empty($m[6][0])) { |
|
699 | + // '(' or ')' found |
|
701 | 700 | { |
702 | 701 | if (empty($stack) && $m[6][0]=='(') |
703 | 702 | { |
704 | 703 | array_push($stack, $m[6][0]); |
705 | - } |
|
706 | - elseif($m[6][0]==')' && end($stack)=='(') |
|
704 | + } |
|
705 | + } elseif($m[6][0]==')' && end($stack)=='(') |
|
707 | 706 | { |
708 | 707 | array_pop($stack); |
709 | 708 | } |
710 | - } |
|
711 | - elseif (!empty($m[1][0]))// ' or " found |
|
709 | + } elseif (!empty($m[1][0])) { |
|
710 | + // ' or " found |
|
712 | 711 | { |
713 | 712 | if (end($stack)==$m[1][0]) |
714 | 713 | { |
715 | 714 | array_pop($stack); |
716 | - } |
|
717 | - else |
|
715 | + } |
|
716 | + } else |
|
718 | 717 | { |
719 | 718 | array_push($stack, $m[1][0]); |
720 | 719 | } |
721 | - } |
|
722 | - elseif (!empty($m[2][0])) // opening comment / * |
|
720 | + } elseif (!empty($m[2][0])) { |
|
721 | + // opening comment / * |
|
723 | 722 | { |
724 | 723 | array_push($stack, $m[2][0]); |
725 | 724 | } |
726 | - elseif (!empty($m[4][0])) // opening comment -- |
|
725 | + } elseif (!empty($m[4][0])) { |
|
726 | + // opening comment -- |
|
727 | 727 | { |
728 | 728 | array_push($stack, $m[4][0]); |
729 | 729 | } |
730 | + } |
|
730 | 731 | } |
731 | 732 | return false; |
732 | 733 | } |
@@ -20,9 +20,10 @@ |
||
20 | 20 | { |
21 | 21 | require_once($GLOBALS['rootpath'].'okapi/service_runner.php'); |
22 | 22 | |
23 | - if (!OkapiServiceRunner::exists($methodname)) |
|
24 | - throw new BadRequest("Method '$methodname' does not exist. ". |
|
23 | + if (!OkapiServiceRunner::exists($methodname)) { |
|
24 | + throw new BadRequest("Method '$methodname' does not exist. ". |
|
25 | 25 | "See OKAPI docs at ".Settings::get('SITE_URL')."okapi/"); |
26 | + } |
|
26 | 27 | $options = OkapiServiceRunner::options($methodname); |
27 | 28 | $request = new OkapiHttpRequest($options); |
28 | 29 | return OkapiServiceRunner::call($methodname, $request); |
@@ -66,9 +66,12 @@ |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | $tiles = array(); |
69 | - for ($xx=$x; $xx<$x+4; $xx++) |
|
70 | - for ($yy=$y; $yy<$y+4; $yy++) |
|
71 | - $tiles[] = array($xx, $yy); |
|
69 | + for ($xx=$x; $xx<$x+4; $xx++) { |
|
70 | + for ($yy=$y; |
|
71 | + } |
|
72 | + $yy<$y+4; $yy++) { |
|
73 | + $tiles[] = array($xx, $yy); |
|
74 | + } |
|
72 | 75 | srand(); |
73 | 76 | shuffle($tiles); |
74 | 77 |
@@ -23,9 +23,10 @@ discard block |
||
23 | 23 | public static function get_menu_html($current_path = null) |
24 | 24 | { |
25 | 25 | $chunks = array(); |
26 | - if (Okapi::$version_number) |
|
27 | - $chunks[] = "<div class='revision'>ver. ".Okapi::$version_number. |
|
26 | + if (Okapi::$version_number) { |
|
27 | + $chunks[] = "<div class='revision'>ver. ".Okapi::$version_number. |
|
28 | 28 | " (".substr(Okapi::$git_revision, 0, 7).")</div>"; |
29 | + } |
|
29 | 30 | $chunks[] = "<div class='main'>"; |
30 | 31 | $chunks[] = self::link($current_path, "introduction.html", "Introduction"); |
31 | 32 | $chunks[] = self::link($current_path, "signup.html", "Sign up"); |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | $pos = strrpos($methodname, "/"); |
49 | 50 | $modulename = substr($methodname, 0, $pos); |
50 | 51 | $method_short_name = substr($methodname, $pos + 1); |
51 | - if (!isset($module_methods[$modulename])) |
|
52 | - $module_methods[$modulename] = array(); |
|
52 | + if (!isset($module_methods[$modulename])) { |
|
53 | + $module_methods[$modulename] = array(); |
|
54 | + } |
|
53 | 55 | $module_methods[$modulename][] = $method_short_name; |
54 | 56 | } |
55 | 57 | $modulenames = array_keys($module_methods); |
@@ -59,8 +61,9 @@ discard block |
||
59 | 61 | { |
60 | 62 | $chunks[] = "<div class='module'>$modulename</div>"; |
61 | 63 | $chunks[] = "<div class='methods'>"; |
62 | - foreach ($module_methods[$modulename] as $method_short_name) |
|
63 | - $chunks[] = self::link($current_path, "$modulename/$method_short_name.html", "$method_short_name"); |
|
64 | + foreach ($module_methods[$modulename] as $method_short_name) { |
|
65 | + $chunks[] = self::link($current_path, "$modulename/$method_short_name.html", "$method_short_name"); |
|
66 | + } |
|
64 | 67 | $chunks[] = "</div>"; |
65 | 68 | } |
66 | 69 | return implode("", $chunks); |
@@ -84,8 +87,7 @@ discard block |
||
84 | 87 | $inst_ref['site_url'] = $site_url; |
85 | 88 | $inst_ref['okapi_base_url'] = $site_url . 'okapi/'; |
86 | 89 | $inst_ref['selected'] = true; |
87 | - } |
|
88 | - else |
|
90 | + } else |
|
89 | 91 | { |
90 | 92 | $inst_ref['selected'] = false; |
91 | 93 | } |
@@ -26,8 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | $method = OkapiServiceRunner::call('services/apiref/method', new OkapiInternalRequest( |
28 | 28 | null, null, array('name' => $methodname))); |
29 | - } |
|
30 | - catch (BadRequest $e) |
|
29 | + } catch (BadRequest $e) |
|
31 | 30 | { |
32 | 31 | throw new Http404(); |
33 | 32 | } |
@@ -48,8 +48,9 @@ |
||
48 | 48 | $vars['site_name'] = Okapi::get_normalized_site_name(); |
49 | 49 | $vars['site_logo'] = Settings::get('SITE_LOGO'); |
50 | 50 | $vars['apps'] = array(); |
51 | - while ($row = Db::fetch_assoc($rs)) |
|
52 | - $vars['apps'][] = $row; |
|
51 | + while ($row = Db::fetch_assoc($rs)) { |
|
52 | + $vars['apps'][] = $row; |
|
53 | + } |
|
53 | 54 | Db::free_result($rs); |
54 | 55 | |
55 | 56 | $response = new OkapiHttpResponse(); |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | $langpref = isset($_GET['langpref']) ? $_GET['langpref'] : Settings::get('SITELANG'); |
21 | 21 | $langprefs = explode("|", $langpref); |
22 | 22 | $locales = array(); |
23 | - foreach (Locales::$languages as $lang => $attrs) |
|
24 | - $locales[$attrs['locale']] = $attrs; |
|
23 | + foreach (Locales::$languages as $lang => $attrs) { |
|
24 | + $locales[$attrs['locale']] = $attrs; |
|
25 | + } |
|
25 | 26 | |
26 | 27 | # Current implementation of the "interactivity" parameter is: If developer |
27 | 28 | # wants to "confirm_user", then just log out the current user before we |
@@ -96,8 +97,7 @@ discard block |
||
96 | 97 | # that's exactly the relogin that we want. |
97 | 98 | |
98 | 99 | $login_page .= 'action=logout&'; |
99 | - } |
|
100 | - else |
|
100 | + } else |
|
101 | 101 | { |
102 | 102 | # OCPL uses REAL MAGIC for session handling. I don't get ANY of it. |
103 | 103 | # The logout.php DOES NOT support the "target" parameter, so we |
@@ -158,8 +158,7 @@ discard block |
||
158 | 158 | ); |
159 | 159 | "); |
160 | 160 | $authorized = true; |
161 | - } |
|
162 | - else |
|
161 | + } else |
|
163 | 162 | { |
164 | 163 | # User denied access. Nothing sensible to do now. Will try to report |
165 | 164 | # back to the Consumer application with an error. |
@@ -175,8 +174,7 @@ discard block |
||
175 | 174 | return new OkapiRedirectResponse(Settings::get('SITE_URL')."index.php"); |
176 | 175 | } |
177 | 176 | } |
178 | - } |
|
179 | - else |
|
177 | + } else |
|
180 | 178 | { |
181 | 179 | # Not yet authorized. Display an authorization request. |
182 | 180 | $vars = array( |
@@ -26,21 +26,21 @@ |
||
26 | 26 | $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : ""; |
27 | 27 | $accepted_terms = isset($_REQUEST['terms']) ? $_REQUEST['terms'] : ""; |
28 | 28 | $ok = false; |
29 | - if (!$appname) |
|
30 | - $notice = "Please provide a valid application name."; |
|
31 | - elseif (mb_strlen($appname) > 100) |
|
32 | - $notice = "Application name should be less than 100 characters long."; |
|
33 | - elseif (mb_strlen($appurl) > 250) |
|
34 | - $notice = "Application URL should be less than 250 characters long."; |
|
35 | - elseif ($appurl && (substr($appurl, 0, 7) != "http://") && (substr($appurl, 0, 8) != "https://")) |
|
36 | - $notice = "Application homepage URL should start with http(s)://. (Note: this URL is OPTIONAL and it is NOT for OAuth callback.)"; |
|
37 | - elseif (!$email) |
|
38 | - $notice = "Please provide a valid email address."; |
|
39 | - elseif (mb_strlen($email) > 70) |
|
40 | - $notice = "Email address should be less than 70 characters long."; |
|
41 | - elseif (!$accepted_terms) |
|
42 | - $notice = "You have to read and accept OKAPI Terms of Use."; |
|
43 | - else |
|
29 | + if (!$appname) { |
|
30 | + $notice = "Please provide a valid application name."; |
|
31 | + } elseif (mb_strlen($appname) > 100) { |
|
32 | + $notice = "Application name should be less than 100 characters long."; |
|
33 | + } elseif (mb_strlen($appurl) > 250) { |
|
34 | + $notice = "Application URL should be less than 250 characters long."; |
|
35 | + } elseif ($appurl && (substr($appurl, 0, 7) != "http://") && (substr($appurl, 0, 8) != "https://")) { |
|
36 | + $notice = "Application homepage URL should start with http(s)://. (Note: this URL is OPTIONAL and it is NOT for OAuth callback.)"; |
|
37 | + } elseif (!$email) { |
|
38 | + $notice = "Please provide a valid email address."; |
|
39 | + } elseif (mb_strlen($email) > 70) { |
|
40 | + $notice = "Email address should be less than 70 characters long."; |
|
41 | + } elseif (!$accepted_terms) { |
|
42 | + $notice = "You have to read and accept OKAPI Terms of Use."; |
|
43 | + } else |
|
44 | 44 | { |
45 | 45 | $ok = true; |
46 | 46 | Okapi::register_new_consumer($appname, $appurl, $email); |