@@ -22,8 +22,7 @@ |
||
22 | 22 | |
23 | 23 | # Ensure a user is logged in. |
24 | 24 | |
25 | - if ($OC_user_id == null) |
|
26 | - { |
|
25 | + if ($OC_user_id == null) { |
|
27 | 26 | $after_login = "okapi/apps/"; # it is correct, if you're wondering |
28 | 27 | $login_url = Settings::get('SITE_URL')."login.php?target=".urlencode($after_login); |
29 | 28 | return new OkapiRedirectResponse($login_url); |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | if ($OC_user_id == null) |
27 | 27 | { |
28 | - $after_login = "okapi/apps/".(($langpref != Settings::get('SITELANG'))?"?langpref=".$langpref:""); |
|
28 | + $after_login = "okapi/apps/".(($langpref != Settings::get('SITELANG')) ? "?langpref=".$langpref : ""); |
|
29 | 29 | $login_url = Settings::get('SITE_URL')."login.php?target=".urlencode($after_login); |
30 | 30 | return new OkapiRedirectResponse($login_url); |
31 | 31 | } |
@@ -23,8 +23,7 @@ discard block |
||
23 | 23 | require_once($GLOBALS['rootpath']."okapi/lib/oc_session.php"); |
24 | 24 | $OC_user_id = OCSession::get_user_id(); |
25 | 25 | |
26 | - if ($OC_user_id == null) |
|
27 | - { |
|
26 | + if ($OC_user_id == null) { |
|
28 | 27 | $after_login = "okapi/apps/".(($langpref != Settings::get('SITELANG'))?"?langpref=".$langpref:""); |
29 | 28 | $login_url = Settings::get('SITE_URL')."login.php?target=".urlencode($after_login); |
30 | 29 | return new OkapiRedirectResponse($login_url); |
@@ -48,8 +47,9 @@ discard block |
||
48 | 47 | $vars['site_name'] = Okapi::get_normalized_site_name(); |
49 | 48 | $vars['site_logo'] = Settings::get('SITE_LOGO'); |
50 | 49 | $vars['apps'] = array(); |
51 | - while ($row = Db::fetch_assoc($rs)) |
|
52 | - $vars['apps'][] = $row; |
|
50 | + while ($row = Db::fetch_assoc($rs)) { |
|
51 | + $vars['apps'][] = $row; |
|
52 | + } |
|
53 | 53 | Db::free_result($rs); |
54 | 54 | |
55 | 55 | $response = new OkapiHttpResponse(); |
@@ -33,8 +33,7 @@ |
||
33 | 33 | and t.consumer_key = c.`key` |
34 | 34 | "); |
35 | 35 | |
36 | - if (!$token) |
|
37 | - { |
|
36 | + if (!$token) { |
|
38 | 37 | # Probably Request Token has expired or it was already used. We'll |
39 | 38 | # just redirect to the Opencaching main page. |
40 | 39 | return new OkapiRedirectResponse(Settings::get('SITE_URL')); |
@@ -82,7 +82,7 @@ |
||
82 | 82 | if (self::domains_are_equal($inst_ref['site_url'], $site_url)) |
83 | 83 | { |
84 | 84 | $inst_ref['site_url'] = $site_url; |
85 | - $inst_ref['okapi_base_url'] = $site_url . 'okapi/'; |
|
85 | + $inst_ref['okapi_base_url'] = $site_url.'okapi/'; |
|
86 | 86 | $inst_ref['selected'] = true; |
87 | 87 | } |
88 | 88 | else |
@@ -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"); |
@@ -43,24 +44,24 @@ discard block |
||
43 | 44 | # We'll break them up into modules, for readability. |
44 | 45 | |
45 | 46 | $module_methods = array(); |
46 | - foreach ($methodnames as $methodname) |
|
47 | - { |
|
47 | + foreach ($methodnames as $methodname) { |
|
48 | 48 | $pos = strrpos($methodname, "/"); |
49 | 49 | $modulename = substr($methodname, 0, $pos); |
50 | 50 | $method_short_name = substr($methodname, $pos + 1); |
51 | - if (!isset($module_methods[$modulename])) |
|
52 | - $module_methods[$modulename] = array(); |
|
51 | + if (!isset($module_methods[$modulename])) { |
|
52 | + $module_methods[$modulename] = array(); |
|
53 | + } |
|
53 | 54 | $module_methods[$modulename][] = $method_short_name; |
54 | 55 | } |
55 | 56 | $modulenames = array_keys($module_methods); |
56 | 57 | sort($modulenames); |
57 | 58 | |
58 | - foreach ($modulenames as $modulename) |
|
59 | - { |
|
59 | + foreach ($modulenames as $modulename) { |
|
60 | 60 | $chunks[] = "<div class='module'>$modulename</div>"; |
61 | 61 | $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"); |
|
62 | + foreach ($module_methods[$modulename] as $method_short_name) { |
|
63 | + $chunks[] = self::link($current_path, "$modulename/$method_short_name.html", "$method_short_name"); |
|
64 | + } |
|
64 | 65 | $chunks[] = "</div>"; |
65 | 66 | } |
66 | 67 | return implode("", $chunks); |
@@ -72,21 +73,17 @@ discard block |
||
72 | 73 | new OkapiInternalRequest(new OkapiInternalConsumer(), null, array())); |
73 | 74 | $site_url = Settings::get('SITE_URL'); |
74 | 75 | |
75 | - foreach ($installations as &$inst_ref) |
|
76 | - { |
|
76 | + foreach ($installations as &$inst_ref) { |
|
77 | 77 | # $inst_ref['site_url'] and $site_url can have different protocols |
78 | 78 | # (http / https). We compare only the domain parts and use |
79 | 79 | # $site_url (which has the current request's protocol) for the menu |
80 | 80 | # so that the menu works properly. |
81 | 81 | |
82 | - if (self::domains_are_equal($inst_ref['site_url'], $site_url)) |
|
83 | - { |
|
82 | + if (self::domains_are_equal($inst_ref['site_url'], $site_url)) { |
|
84 | 83 | $inst_ref['site_url'] = $site_url; |
85 | 84 | $inst_ref['okapi_base_url'] = $site_url . 'okapi/'; |
86 | 85 | $inst_ref['selected'] = true; |
87 | - } |
|
88 | - else |
|
89 | - { |
|
86 | + } else { |
|
90 | 87 | $inst_ref['selected'] = false; |
91 | 88 | } |
92 | 89 | } |
@@ -19,8 +19,8 @@ |
||
19 | 19 | $query_extensions = array('exif', 'gd', 'imagick'); |
20 | 20 | $ok = array_intersect($query_extensions, $loaded_extensions); |
21 | 21 | $missing = array_diff($query_extensions, $loaded_extensions); |
22 | - $body .= "Loaded PHP extensions: " . ($ok ? implode(', ', $ok) : "-none-") . "\n"; |
|
23 | - $body .= "Missing PHP extensions: " . ($missing ? implode(', ', $missing) : "-none-") . "\n"; |
|
22 | + $body .= "Loaded PHP extensions: ".($ok ? implode(', ', $ok) : "-none-")."\n"; |
|
23 | + $body .= "Missing PHP extensions: ".($missing ? implode(', ', $missing) : "-none-")."\n"; |
|
24 | 24 | |
25 | 25 | $response = new OkapiHttpResponse(); |
26 | 26 | $response->content_type = "text/plain; charset=utf-8"; |
@@ -26,33 +26,37 @@ discard block |
||
26 | 26 | ob_start(); |
27 | 27 | |
28 | 28 | print "Cache Types:\n\n"; |
29 | - foreach (self::get_all_cachetypes() as $id => $name) |
|
30 | - print "$id: $name\n"; |
|
29 | + foreach (self::get_all_cachetypes() as $id => $name) { |
|
30 | + print "$id: $name\n"; |
|
31 | + } |
|
31 | 32 | |
32 | 33 | print "\nLog Types:\n\n"; |
33 | - foreach (self::get_all_logtypes() as $id => $name) |
|
34 | - print "$id: $name\n"; |
|
34 | + foreach (self::get_all_logtypes() as $id => $name) { |
|
35 | + print "$id: $name\n"; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | print "\nAttributes:\n\n"; |
37 | 39 | require_once($GLOBALS['rootpath'].'okapi/services/attrs/attr_helper.inc.php'); |
38 | 40 | $internal2acode = AttrHelper::get_internal_id_to_acode_mapping(); |
39 | 41 | $dict = self::get_all_attribute_names(); |
40 | - foreach ($dict as $internal_id => $langs) |
|
41 | - { |
|
42 | + foreach ($dict as $internal_id => $langs) { |
|
42 | 43 | print $internal_id.": "; |
43 | 44 | $langkeys = array_keys($langs); |
44 | 45 | sort($langkeys); |
45 | - if (in_array('en', $langkeys)) |
|
46 | - print strtoupper($langs['en']); |
|
47 | - else |
|
48 | - print ">>>> ENGLISH NAME UNSET! <<<<"; |
|
49 | - if (isset($internal2acode[$internal_id])) |
|
50 | - print " - ".$internal2acode[$internal_id]; |
|
51 | - else |
|
52 | - print " - >>>> MISSING A-CODE MAPPING <<<<"; |
|
46 | + if (in_array('en', $langkeys)) { |
|
47 | + print strtoupper($langs['en']); |
|
48 | + } else { |
|
49 | + print ">>>> ENGLISH NAME UNSET! <<<<"; |
|
50 | + } |
|
51 | + if (isset($internal2acode[$internal_id])) { |
|
52 | + print " - ".$internal2acode[$internal_id]; |
|
53 | + } else { |
|
54 | + print " - >>>> MISSING A-CODE MAPPING <<<<"; |
|
55 | + } |
|
53 | 56 | print "\n"; |
54 | - foreach ($langkeys as $langkey) |
|
55 | - print " $langkey: ".$langs[$langkey]."\n"; |
|
57 | + foreach ($langkeys as $langkey) { |
|
58 | + print " $langkey: ".$langs[$langkey]."\n"; |
|
59 | + } |
|
56 | 60 | } |
57 | 61 | |
58 | 62 | print "\nAttribute notices:\n\n"; |
@@ -60,30 +64,24 @@ discard block |
||
60 | 64 | print "(the last one ( ) can be safely ignored)\n\n"; |
61 | 65 | |
62 | 66 | $attrdict = AttrHelper::get_attrdict(); |
63 | - foreach ($dict as $internal_id => $langs) |
|
64 | - { |
|
65 | - if (!isset($internal2acode[$internal_id])) |
|
66 | - { |
|
67 | + foreach ($dict as $internal_id => $langs) { |
|
68 | + if (!isset($internal2acode[$internal_id])) { |
|
67 | 69 | print "(!) Attribute ".$internal_id." is not mapped to any A-code.\n"; |
68 | 70 | continue; |
69 | 71 | } |
70 | 72 | $acode = $internal2acode[$internal_id]; |
71 | 73 | $attr = $attrdict[$acode]; |
72 | - foreach ($langs as $lang => $value) |
|
73 | - { |
|
74 | - if ($lang == 'en') |
|
75 | - { |
|
74 | + foreach ($langs as $lang => $value) { |
|
75 | + if ($lang == 'en') { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | - if (!isset($attr['names'][$lang])) |
|
79 | - { |
|
78 | + if (!isset($attr['names'][$lang])) { |
|
80 | 79 | print "(-) Attribute $acode is missing a name in the '$lang' language.\n"; |
81 | 80 | print " Local name: $value\n"; |
82 | 81 | print " OKAPI name: >> none <<\n"; |
83 | 82 | continue; |
84 | 83 | } |
85 | - if ($attr['names'][$lang] !== $value) |
|
86 | - { |
|
84 | + if ($attr['names'][$lang] !== $value) { |
|
87 | 85 | print "( ) Attribute $acode has a different name in the '$lang' language\n"; |
88 | 86 | print " Local name: $value\n"; |
89 | 87 | print " OKAPI name: ".$attr['names'][$lang]."\n"; |
@@ -103,16 +101,13 @@ discard block |
||
103 | 101 | */ |
104 | 102 | private static function get_all_attribute_names() |
105 | 103 | { |
106 | - if (Settings::get('OC_BRANCH') == 'oc.pl') |
|
107 | - { |
|
104 | + if (Settings::get('OC_BRANCH') == 'oc.pl') { |
|
108 | 105 | # OCPL branch uses cache_attrib table to store attribute names. It has |
109 | 106 | # different structure than the OCDE cache_attrib table. OCPL does not |
110 | 107 | # have translation tables. |
111 | 108 | |
112 | 109 | $rs = Db::query("select id, language, text_long from cache_attrib order by id"); |
113 | - } |
|
114 | - else |
|
115 | - { |
|
110 | + } else { |
|
116 | 111 | # OCDE branch uses translation tables. Let's make a select which will |
117 | 112 | # produce results compatible with the one above. |
118 | 113 | |
@@ -141,14 +136,11 @@ discard block |
||
141 | 136 | */ |
142 | 137 | private static function get_all_cachetypes() |
143 | 138 | { |
144 | - if (Settings::get('OC_BRANCH') == 'oc.pl') |
|
145 | - { |
|
139 | + if (Settings::get('OC_BRANCH') == 'oc.pl') { |
|
146 | 140 | # OCPL branch does not store cache types in many languages (just two). |
147 | 141 | |
148 | 142 | $rs = Db::query("select id, en from cache_type order by id"); |
149 | - } |
|
150 | - else |
|
151 | - { |
|
143 | + } else { |
|
152 | 144 | # OCDE branch uses translation tables. |
153 | 145 | |
154 | 146 | $rs = Db::query(" |
@@ -176,14 +168,11 @@ discard block |
||
176 | 168 | */ |
177 | 169 | private static function get_all_logtypes() |
178 | 170 | { |
179 | - if (Settings::get('OC_BRANCH') == 'oc.pl') |
|
180 | - { |
|
171 | + if (Settings::get('OC_BRANCH') == 'oc.pl') { |
|
181 | 172 | # OCPL branch does not store cache types in many languages (just two). |
182 | 173 | |
183 | 174 | $rs = Db::query("select id, en from log_types order by id"); |
184 | - } |
|
185 | - else |
|
186 | - { |
|
175 | + } else { |
|
187 | 176 | # OCDE branch uses translation tables. |
188 | 177 | |
189 | 178 | $rs = Db::query(" |
@@ -33,7 +33,7 @@ |
||
33 | 33 | ob_start(); |
34 | 34 | |
35 | 35 | $start = isset($_GET['start']) ? $_GET['start'] : date( |
36 | - "Y-m-d 00:00:00", time() - 7*86400); |
|
36 | + "Y-m-d 00:00:00", time() - 7 * 86400); |
|
37 | 37 | $end = isset($_GET['end']) ? $_GET['end'] : date("Y-m-d 23:59:59"); |
38 | 38 | |
39 | 39 | print "From: $start\n"; |
@@ -57,21 +57,16 @@ discard block |
||
57 | 57 | $calls = array('A' => 0, 'B' => 0, 'C' => 0, 'D' => 0); |
58 | 58 | $runtime = array('A' => 0.0, 'B' => 0.0, 'C' => 0.0, 'D' => 0.0); |
59 | 59 | |
60 | - while (list($name, $c, $r) = Db::fetch_row($rs)) |
|
61 | - { |
|
62 | - if ($name == 'services/caches/map/tile') |
|
63 | - { |
|
60 | + while (list($name, $c, $r) = Db::fetch_row($rs)) { |
|
61 | + if ($name == 'services/caches/map/tile') { |
|
64 | 62 | $total_calls = $c; |
65 | 63 | $total_runtime = $r; |
66 | - } |
|
67 | - elseif (strpos($name, 'extra/caches/map/tile/checkpoint') === 0) |
|
68 | - { |
|
64 | + } elseif (strpos($name, 'extra/caches/map/tile/checkpoint') === 0) { |
|
69 | 65 | $calls[$name[32]] = $c; |
70 | 66 | $runtime[$name[32]] = $r; |
71 | 67 | } |
72 | 68 | } |
73 | - if ($total_calls != $calls['A']) |
|
74 | - { |
|
69 | + if ($total_calls != $calls['A']) { |
|
75 | 70 | print "Partial results. Only ".$calls['A']." out of $total_calls are covered.\n"; |
76 | 71 | print "All other will count as \"unaccounted for\".\n\n"; |
77 | 72 | $total_calls = $calls['A']; |
@@ -82,8 +77,7 @@ discard block |
||
82 | 77 | |
83 | 78 | $perc = function($a, $b) { return ($b > 0) ? sprintf("%.1f", 100 * $a / $b)."%" : "(?)"; }; |
84 | 79 | $avg = function($a, $b) { return ($b > 0) ? sprintf("%.4f", $a / $b)."s" : "(?)"; }; |
85 | - $get_stats = function() use (&$calls_left, &$runtime_left, &$total_calls, &$total_runtime, &$perc) |
|
86 | - { |
|
80 | + $get_stats = function() use (&$calls_left, &$runtime_left, &$total_calls, &$total_runtime, &$perc) { |
|
87 | 81 | return ( |
88 | 82 | str_pad($perc($calls_left, $total_calls), 6, " ", STR_PAD_LEFT). |
89 | 83 | str_pad($perc($runtime_left, $total_runtime), 7, " ", STR_PAD_LEFT) |
@@ -151,8 +145,7 @@ discard block |
||
151 | 145 | where score is not null |
152 | 146 | group by floor(log2(score)) |
153 | 147 | "); |
154 | - while (list($log2, $count, $size) = Db::fetch_row($rs)) |
|
155 | - { |
|
148 | + while (list($log2, $count, $size) = Db::fetch_row($rs)) { |
|
156 | 149 | print $count." elements ($size bytes) with score between ".pow(2, $log2)." and ".pow(2, $log2 + 1).".\n"; |
157 | 150 | } |
158 | 151 |
@@ -28,47 +28,51 @@ |
||
28 | 28 | |
29 | 29 | require_once($GLOBALS['rootpath']."okapi/cronjobs.php"); |
30 | 30 | $schedule = Cache::get("cron_schedule"); |
31 | - if ($schedule == null) |
|
32 | - $schedule = array(); |
|
31 | + if ($schedule == null) { |
|
32 | + $schedule = array(); |
|
33 | + } |
|
33 | 34 | print "Nearest event: "; |
34 | - if (Okapi::get_var('cron_nearest_event')) |
|
35 | - print "in ".(Okapi::get_var('cron_nearest_event') - time())." seconds.\n\n"; |
|
36 | - else |
|
37 | - print "NOT SET\n\n"; |
|
35 | + if (Okapi::get_var('cron_nearest_event')) { |
|
36 | + print "in ".(Okapi::get_var('cron_nearest_event') - time())." seconds.\n\n"; |
|
37 | + } else { |
|
38 | + print "NOT SET\n\n"; |
|
39 | + } |
|
38 | 40 | $cronjobs = CronJobController::get_enabled_cronjobs(); |
39 | 41 | usort($cronjobs, function($a, $b) { |
40 | 42 | $cmp = function($a, $b) { return ($a < $b) ? -1 : (($a > $b) ? 1 : 0); }; |
41 | 43 | $by_type = $cmp($a->get_type(), $b->get_type()); |
42 | - if ($by_type != 0) |
|
43 | - return $by_type; |
|
44 | + if ($by_type != 0) { |
|
45 | + return $by_type; |
|
46 | + } |
|
44 | 47 | return $cmp($a->get_name(), $b->get_name()); |
45 | 48 | }); |
46 | 49 | print str_pad("TYPE", 11)." ".str_pad("NAME", 40)." SCHEDULE\n"; |
47 | 50 | print str_pad("----", 11)." ".str_pad("----", 40)." --------\n"; |
48 | - foreach ($cronjobs as $cronjob) |
|
49 | - { |
|
51 | + foreach ($cronjobs as $cronjob) { |
|
50 | 52 | $type = $cronjob->get_type(); |
51 | 53 | $name = $cronjob->get_name(); |
52 | 54 | print str_pad($type, 11)." ".str_pad($name, 40)." "; |
53 | - if (!isset($schedule[$name])) |
|
54 | - print "NOT YET SCHEDULED\n"; |
|
55 | - elseif ($schedule[$name] <= time()) |
|
56 | - print "DELAYED: should be run ".(time() - $schedule[$name])." seconds ago\n"; |
|
57 | - else |
|
58 | - print "scheduled to run in ".str_pad($schedule[$name] - time(), 6, " ", STR_PAD_LEFT)." seconds\n"; |
|
55 | + if (!isset($schedule[$name])) { |
|
56 | + print "NOT YET SCHEDULED\n"; |
|
57 | + } elseif ($schedule[$name] <= time()) { |
|
58 | + print "DELAYED: should be run ".(time() - $schedule[$name])." seconds ago\n"; |
|
59 | + } else { |
|
60 | + print "scheduled to run in ".str_pad($schedule[$name] - time(), 6, " ", STR_PAD_LEFT)." seconds\n"; |
|
61 | + } |
|
59 | 62 | } |
60 | 63 | print "\n"; |
61 | 64 | print "Crontab last ping: "; |
62 | - if (Cache::get('crontab_last_ping')) |
|
63 | - print (time() - Cache::get('crontab_last_ping'))." seconds ago"; |
|
64 | - else |
|
65 | - print "NEVER"; |
|
65 | + if (Cache::get('crontab_last_ping')) { |
|
66 | + print (time() - Cache::get('crontab_last_ping'))." seconds ago"; |
|
67 | + } else { |
|
68 | + print "NEVER"; |
|
69 | + } |
|
66 | 70 | print " (crontab_check_counter: ".Cache::get('crontab_check_counter').").\n"; |
67 | 71 | print "clog_revisions_daily: "; |
68 | - if (Cache::get('clog_revisions_daily')) |
|
69 | - { |
|
70 | - foreach (Cache::get('clog_revisions_daily') as $time => $rev) |
|
71 | - print "$rev "; |
|
72 | + if (Cache::get('clog_revisions_daily')) { |
|
73 | + foreach (Cache::get('clog_revisions_daily') as $time => $rev) { |
|
74 | + print "$rev "; |
|
75 | + } |
|
72 | 76 | print "\n"; |
73 | 77 | } else { |
74 | 78 | print "NULL\n"; |
@@ -18,30 +18,28 @@ |
||
18 | 18 | { |
19 | 19 | public static function call() |
20 | 20 | { |
21 | - if (isset($_REQUEST['posted'])) |
|
22 | - { |
|
21 | + if (isset($_REQUEST['posted'])) { |
|
23 | 22 | $appname = isset($_REQUEST['appname']) ? $_REQUEST['appname'] : ""; |
24 | 23 | $appname = trim($appname); |
25 | 24 | $appurl = isset($_REQUEST['appurl']) ? $_REQUEST['appurl'] : ""; |
26 | 25 | $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : ""; |
27 | 26 | $accepted_terms = isset($_REQUEST['terms']) ? $_REQUEST['terms'] : ""; |
28 | 27 | $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 |
|
44 | - { |
|
28 | + if (!$appname) { |
|
29 | + $notice = "Please provide a valid application name."; |
|
30 | + } elseif (mb_strlen($appname) > 100) { |
|
31 | + $notice = "Application name should be less than 100 characters long."; |
|
32 | + } elseif (mb_strlen($appurl) > 250) { |
|
33 | + $notice = "Application URL should be less than 250 characters long."; |
|
34 | + } elseif ($appurl && (substr($appurl, 0, 7) != "http://") && (substr($appurl, 0, 8) != "https://")) { |
|
35 | + $notice = "Application homepage URL should start with http(s)://. (Note: this URL is OPTIONAL and it is NOT for OAuth callback.)"; |
|
36 | + } elseif (!$email) { |
|
37 | + $notice = "Please provide a valid email address."; |
|
38 | + } elseif (mb_strlen($email) > 70) { |
|
39 | + $notice = "Email address should be less than 70 characters long."; |
|
40 | + } elseif (!$accepted_terms) { |
|
41 | + $notice = "You have to read and accept OKAPI Terms of Use."; |
|
42 | + } else { |
|
45 | 43 | $ok = true; |
46 | 44 | Okapi::register_new_consumer($appname, $appurl, $email); |
47 | 45 | $notice = "Consumer Key generated successfully.\nCheck your email!"; |