<?php rg_log("FILE: /inc/dispatch/dispatch"); $rg['menu'][$_op] = 1; $rg['url_up'] = $rg['url']; $rg['url'] .= '/' . rawurlencode($_op); switch ($_op) { case 'login': include($INC . "/login/login.php"); $body .= $_login; break; case 'logout': if (!rg_valid_referer()) rg_log("Invalid referer"); // Session expired if ($rg['login_ui']['uid'] == 0) { $body .= rg_template("user/logout.html", $rg, TRUE /*xss*/); break; } if (!rg_token_valid($db, $rg, 'logout', TRUE)) break; rg_user_set_last_seen($db, $rg['login_ui']['uid'], time(), $rg['ip']); if (rg_sess_destroy($db, $rg['sid'], $rg['login_ui'])) { $body .= rg_template("user/logout.html", $rg, TRUE /* xss */); } else { $body .= rg_template("user/logout_err.html", $rg, TRUE /* xss */); } break; case 'repo': include($INC . "/repo/repo.php"); $body .= $_repo; break; case 'repopage': include($INC . "/repo/repo_page.php"); $body .= $_repo; break; case 'admin': include($INC . "/admin/admin.php"); $body .= $_admin; break; case 'forgot_link': // forgot pass link include($INC . "/user/forgot.php"); $body .= $_forgot; break; case 'forgot_send': // forgot pass - send mail include($INC . "/user/forgot_send.php"); $body .= $_forgot; break; case 'create_account': $rg['ask_for_pass'] = 1; $rg['no_tos'] = 0; $body .= rg_user_edit_high_level($db, $rg); break; case 'confirm': include($INC . "/user/confirm.php"); $body .= $_confirm; break; case 'suggestion': include($INC . "/feedback/suggestion.php"); $body .= $_suggestion; break; case 'settings': include($INC . "/user/settings.php"); $body .= $_settings; break; case 'tos': $body .= rg_template('tos.html', $rg, TRUE /* xss */); break; case 'download': $_sub = empty($paras) ? "" : array_shift($paras); if (strcmp($_sub, 'vm') == 0) $body .= rg_template('download-vm.html', $rg, TRUE /* xss */); else $body .= rg_template('download.html', $rg, TRUE /* xss */); break; case 'features': $_sub = empty($paras) ? '' : array_shift($paras); if (strcmp($_sub, 'anonpush') == 0) $body .= rg_template('features/anonpush.html', $rg, TRUE /*xss*/); else $body .= rg_template('features.html', $rg, TRUE /*xss*/); break; case 'pricing': $body .= rg_template('pricing.html', $rg, TRUE /*xss*/); break; case 'donate': $body .= rg_template('donate.html', $rg, TRUE /*xss*/); break; case 'discover': $_op = empty($paras) ? "" : array_shift($paras); $_ui = array('uid' => 0, 'admin' => 0); $body .= rg_repo_discover($db, $_op, $rg, $_ui); break; case 'stats': include($INC . "/stats/stats.php"); break; case 'doc': $sec = array_shift($paras); switch ($sec) { case 'api': $body .= rg_template('doc/api.html', $rg, TRUE /*xss*/); break; case 'worker': $body .= rg_template('doc/worker.html', $rg, TRUE /*xss*/); break; case 'demo': $body .= rg_demo($rg, $paras); break; case 'compare': $body .= rg_template('compare.html', $rg, TRUE /*xss*/); break; case 'thanks': $body .= rg_template('doc/thanks.html', $rg, TRUE /*xss*/); break; } break; case 'ask_email_conf': $r = rg_user_ask_for_email_confirmation($db, $rg['login_ui']['uid']); if ($r === TRUE) $body .= rg_template('user/email_conf.html', $rg, TRUE /*xss*/); else $body .= rg_template('user/email_conf_error.html', $rg, TRUE /*xss*/); break; default: // can be the main page or user page or repo page rg_log("DEBUG:paras=" . rg_array2string($paras)); $type = empty($paras) ? "" : $paras[0]; rg_log("DEBUG: type=[$type]"); if (strcmp($type, "user") == 0) { array_shift($paras); $user = empty($paras) ? "" : array_shift($paras); $repo = empty($paras) ? "" : array_shift($paras); } else if (empty($type)) { $body .= rg_template("main.html", $rg, TRUE /* xss */); } else { // organization $organization = 1; $user = empty($paras) ? "" : array_shift($paras); $repo = empty($paras) ? "" : array_shift($paras); } if (!empty($user)) { rg_log("DEBUG: user=[$user] repo=[$repo]"); if (empty($repo)) { include($INC . "/user/home-page.php"); $body .= $_home; } else { // TODO: destroy repo-page // TODO: repo-page: use $paras include($INC . "/user/repo-page.php"); $body .= $_repo_page; } } break; } $rg['url'] = $rg['url_up'];