function smarty_function_ifisinrequest($params, &$smarty) { /* param name(string,required): name of key that is searched through request param default_var(string,optional): if name is not in request, return value of smarty variable default_var if it's available. if this param is not available or value is not set in smarty, default will be returned param default(string,optional): default value, if name is not in request, and default var is not set in smarty default is returned. if this param is not available , return an empty string param value(string,optional): if this param is available , and name is in request or default_var was available , this param value will be returned. default behaviour is return value of name in $_REQUEST when this param is not available */ if (isInRequest($params["name"])) { if (isset($params["value"])) { return $params["value"]; } else { return $_REQUEST[$params["name"]]; } } else { if (isset($params["default_var"]) and $smarty->is_assigned($params["default_var"])) { if (isset($params["value"])) { return $params["value"]; } else { return $smarty->get_assigned_value($params["default_var"]); } } else { return isset($params["default"]) ? $params["default"] : ""; } } }
function intSetReport(&$smarty) { $do_empty = TRUE; if (isInRequest("show")) { $smarty->assign("show_report", TRUE); $conds = collectConditions(); $report_helper = new ReportHelper(); $req = new GetConnections($conds, $report_helper->getFrom(), $report_helper->getTo(), $report_helper->getOrderBy(), $report_helper->getDesc()); $resp = $req->sendAndRecv(); if ($resp->isSuccessful()) { $result = $resp->getResult(); $report = $result["report"]; $total_rows = $result["total_rows"]; $total_credit = $result["total_credit"]; $total_duration = $result["total_duration"]; $do_empty = FALSE; } else { $resp->setErrorInSmarty($smarty); } } if ($do_empty) { $report = array(); $total_rows = 0; $total_credit = 0; $total_duration = 0; } $smarty->assign_by_ref("report", $report); $smarty->assign("total_rows", $total_rows); $smarty->assign("total_credit", $total_credit); $smarty->assign("total_duration", $total_duration); }
function intShowCreditChanges(&$smarty) { if (isInRequest("show")) { intSetReport($smarty); } intAssignVars($smarty); $smarty->display("admin/report/credit_change.tpl"); }
function largeUrlRestore($request_key) { /* this's second part of large url handling, that should be put in target php to restore $_REQUEST */ if (!isInRequest($request_key) and isInRequest("{$request_key}__large_id")) { $_REQUEST[$request_key] = $_SESSION["{$request_key}__values"][(int) $_REQUEST["{$request_key}__large_id"]]; } }
function getLeftPad() { if (isInRequest("left_pad")) { if ($_REQUEST["left_pad"] == "t") { $left_pad = TRUE; } else { $left_pad = FALSE; } } else { $left_pad = TRUE; } return $left_pad; }
function setDateTypeParam($date_type) { /* set "date_type" of this request. if $date_type is null, we try to find a "date_type" in request and set it as date_type */ if (is_null($date_type) and isInRequest("date_type")) { $this->params_arr["date_type"] = $_REQUEST["date_type"]; } else { if (!is_null($date_type)) { $this->params_arr["date_type"] = $date_type; } } }
function redirectToUserSearchInc($conds) { if (!isInRequest("search")) { $_REQUEST["search"] = 1; $_REQUEST["show__normal_username"] = 1; $_REQUEST["show__group"] = 1; $_REQUEST["show__credit"] = 1; $_REQUEST["show__owner"] = 1; } foreach ($conds as $key => $value) { $_REQUEST[$key] = $value; } intDoSearch(new IBSSmarty()); }
function requestValWithDefaultArr($key, $default_arr, $default = "") { /* return value of $key in request, if it's not available in request, it will check $default_arr and return if it has key $key, if not, return $default */ if (isInRequest($key)) { return $_REQUEST[$key]; } else { if (isset($default_arr[$key])) { return $default_arr[$key]; } else { return $default; } } }
function intGetRasPortsRequest($ras) { /* return string "all" or an array of port names that is in request for ras with ip $ras */ if ($ras == "_ALL_" or isInRequest("{$ras}_ALL_")) { return "_ALL_"; } $ports = array(); foreach ($_REQUEST as $key => $value) { if (preg_match("/^{$ras}__(.+)/", $key, $matches)) { $ports[] = $matches[1]; } } return $ports; }
function smarty_function_checkBoxValue($params, &$smarty) { /* return "checked" or "" (empty string), based on params. param name(string,required): name of checkbox that will be search through the request, if this is set, always return "checked param always_in_form(string,optional): name of a form element, that's guranteed to be in submitted form normally can be an hidden input that is always in request when form submitted param default_checked(string,optional): if it's first time we see the form, default_checked is used. first time is determined by checked, always_in_form param */ if (isInRequest($params["name"])) { return "checked"; } else { if (isset($params["always_in_form"]) and isset($params["default_checked"])) { if (!isInRequest($params["always_in_form"]) and $params["default_checked"] == "TRUE") { return "checked"; } } } return ""; }
function intAssignSelectedPermVals(&$smarty) { if (isInRequest("selected")) { $has_perm = hasPerm($_REQUEST["selected"], $_REQUEST["admin_username"]); $smarty->assign("selected", $_REQUEST["selected"]); $smarty->assign("has_selected_perm", $has_perm); $smarty->assign("selected_value", requestVal("value")); if ($has_perm) { $perm_val_req = new AdminPermValue($_REQUEST["selected"], $_REQUEST["admin_username"]); list($success, $cur_val) = $perm_val_req->send(); if ($success) { $smarty->assign("cur_val", $cur_val); } else { $smarty->assign("cur_val", "ERR"); smartySetPageErr($smarty, $cur_val->getErrorMsgs()); } } } else { $smarty->assign("selected", ""); } }
function getSelectedAttrFromSmartyParams(&$smarty, &$params) { /* Get selected value of an attr, from smarty object and smarty params. This function is useful for smarty plugins that needs to get what is value of selected param default_request(string,optional): name of request key, that if has been set, will be returned as default, request is always prefered over other methods param target(string,optional): attribute target, should be "user" or "group" that attribute default would be seek in it param default_var(string,optional): name of target attribute, that if has been set, will be returned as default, this is preffered after default_request target attributes are searched through target array as set it target parameter param default_smarty(string,optional): name of smarty variable that if has been set will be set after above conditions failed param default(string,optional): optional string that will be returned if none of other default values matched */ if (isset($params["default_var"]) and isset($params["default_request"]) and isset($params["target"])) { $selected = attrDefault(getTargetAttrsFromSmarty($smarty, $params["target"]), $params["default_var"], $params["default_request"]); } else { if (isset($params["default_request"]) and isInRequest($params["default_request"])) { $selected = $_REQUEST[$params["default_request"]]; } else { if (isset($params["default_smarty"]) and $smarty->is_assigned($params["default_smarty"])) { $selected = $smarty->get_assigned_value($params["default_smarty"]); } else { if (isset($params["default"])) { $selected = $params["default"]; } else { $selected = ""; } } } } return $selected; }
function smarty_block_sortableHeader($params, $content, &$smarty, &$repeat) { /* Create a Sortable header, used for reports. this is done by making a new request link, with order_by and desc attribute values changed. parameter name(string,required): name that will be present in order_by if our link clicked parameter default(string,optional): if set to TRUE and order_by is not present in request, we assume we're the default order by parameter default_desc(string,optional): defaultly! are we desc? */ if (!is_null($content)) { $request_url = $_SERVER["PHP_SELF"] . "?" . convertRequestToUrl(array("order_by", "desc")); $ret = ""; $desc = "&desc=1"; if (isInRequest("order_by") and $_REQUEST["order_by"] == $params["name"]) { $ret .= currentSortImage(isInRequest("desc")); if (isInRequest("desc")) { $desc = ""; } } else { if (!isInRequest("order_by") and isset($params["default"]) and $params["default"] == "TRUE") { $ret .= currentSortImage($params["default_desc"] == "TRUE"); if ($params["default_desc"] == "TRUE") { $desc = ""; } } } $ret .= <<<END <a class="Header_Top_links" href="{$request_url}&order_by={$params["name"]}{$desc}"> \t{$content} </a> END; return $ret; } }
function intSetReport(&$smarty) { $do_empty = TRUE; if (isInRequest("show")) { $conds = collectConditions(); $report_helper = new ReportHelper(0, 30, "add_date", TRUE); $req = new SearchAddUserSaves($conds, $report_helper->getFrom(), $report_helper->getTo(), $report_helper->getOrderBy(), $report_helper->getDesc()); $resp = $req->sendAndRecv(); if ($resp->isSuccessful()) { $result = $resp->getResult(); $report = $result["result"]; $total_rows = $result["total_rows"]; $do_empty = FALSE; } else { $resp->setErrorInSmarty($smarty); } } if ($do_empty) { $report = array(); $total_rows = 0; } $smarty->assign_by_ref("results", $report); $smarty->assign("total_rows", $total_rows); }
<?php require_once "search_user_funcs.php"; needAuthType(ADMIN_AUTH_TYPE); $smarty = new IBSSmarty(); if (isInRequest("search")) { intDoSearch($smarty); } else { intShowUserSearch($smarty); }
<?php require_once "../../inc/init.php"; require_once IBSINC . "admin.php"; require_once IBSINC . "admin_face.php"; needAuthType(ADMIN_AUTH_TYPE); $smarty = new IBSSmarty(); if (isInRequest("admin_username", "deposit", "deposit_comment")) { intChangeDeposit($smarty, $_REQUEST["admin_username"], $_REQUEST["deposit"], $_REQUEST["deposit_comment"]); } else { if (isInRequest("admin_username")) { intShowChangeDepositFace($smarty, $_REQUEST["admin_username"]); } else { redirectToAdminList(); } } function intChangeDeposit(&$smarty, $admin_username, $deposit, $deposit_comment) { $req = new ChangeDeposit($admin_username, $deposit, $deposit_comment); $resp = $req->sendAndRecv(); if ($resp->isSuccessful()) { $smarty->assign("change_successfull", TRUE); } else { $resp->setErrorInSmarty($smarty); intSetErrors($smarty, $resp->getError()); } intShowChangeDepositFace($smarty, $admin_username); } function intShowChangeDepositFace(&$smarty, $admin_username) { $smarty->assign("admin_username", $admin_username);
<?php require_once "../../inc/init.php"; require_once IBSINC . "user.php"; if (isInRequest("type", "username", "image", "current_username")) { checkUser($_REQUEST["type"], $_REQUEST["username"], $_REQUEST["current_username"], $_REQUEST["image"] == "t"); } else { print "Invalid Input!"; exit; } function checkUser($type, $username, $current_username, $ret_image) { if ($type == "normal") { checkNormalUser($username, $current_username, $ret_image); } else { if ($type == "voip") { checkVoIPUser($username, $current_username, $ret_image); } } } function checkNormalUser($username, $current_username, $ret_image) { $req = new CheckNormalUsernameForAdd($username, $current_username); $resp = $req->sendAndRecv(); if ($ret_image) { returnImage($resp); } else { returnText($resp); } } function checkVoIPUser($username, $current_username, $ret_image)
<?php require_once "../../inc/init.php"; require_once IBSINC . "ibs_defs.php"; needAuthType(ADMIN_AUTH_TYPE); if (isInRequest("action")) { intSaveDefs(); } else { intShowDefs(); } function intSaveDefs() { $defs_arr = findDefsInRequest(); $save_defs_req = new SaveDefs($defs_arr); list($success, $err) = $save_defs_req->send(); if ($success) { intShowDefs(TRUE); } else { intShowDefs(FALSE, $err); } } function findDefsInRequest() { $def_arr = array(); foreach ($_REQUEST as $key => $value) { $value = trim($value); if (preg_match("/^def_(.*)\$/", $key, $matches)) { $def_var = $matches[1]; if (preg_match("/^(.*)__(.*)__/", $def_var, $matches)) { $def_var = $matches[1]; $index = $matches[2];
<?php require_once "../../inc/init.php"; require_once "edit_funcs.php"; needAuthType(ADMIN_AUTH_TYPE); $smarty = new IBSSmarty(); if (isInRequest("update", "edit_tpl_cs", "target", "target_id")) { intUpdateAttrs($smarty, $_REQUEST["target"], $_REQUEST["target_id"]); } else { if (isInRequest("group_name", "edit_group")) { intEditGroup($smarty, $_REQUEST["group_name"]); } else { if (isInRequest("user_id", "edit_user")) { intEditUser($smarty, $_REQUEST["user_id"]); } else { $err = new error("INVALID_INPUT"); redirectToGroupList($err->getErrorMsg()); } } }
<?php require_once "user_info_funcs.php"; require_once IBSINC . "large_url.php"; needAuthType(ADMIN_AUTH_TYPE); $smarty = new IBSSmarty(); largeUrlRestore("user_id_multi"); if (isInRequest("user_id")) { intShowSingleUserInfo($smarty, $_REQUEST["user_id"]); } else { if (isInRequest("normal_username")) { intShowSingleUserInfo($smarty, null, $_REQUEST["normal_username"]); } else { if (isInRequest("user_id_multi")) { intShowMultiUserInfo($smarty, $_REQUEST["user_id_multi"]); } else { if (isInRequest("normal_username_multi")) { intShowMultiNormalUserInfo($smarty, $_REQUEST["normal_username_multi"]); } else { if (isInRequest("voip_username_multi")) { intShowMultiVoIPUserInfo($smarty, $_REQUEST["voip_username_multi"]); } else { intShowSingleUserInfoInput($smarty); } } } } }
require_once "interface_info_face.php"; needAuthType(ADMIN_AUTH_TYPE); $smarty = new IBSSmarty(); if (isInRequest("interface_name", "delete_leaf_service", "leaf_service_id", "leaf_name", "leaf_id")) { intDelLeafService($smarty, $_REQUEST["interface_name"], $_REQUEST["leaf_name"], $_REQUEST["leaf_id"], $_REQUEST["leaf_service_id"]); } else { if (isInRequest("interface_name", "delete_node", "node_id")) { intDelNode($smarty, $_REQUEST["interface_name"], $_REQUEST["node_id"]); } else { if (isInRequest("interface_name", "delete_leaf", "leaf_name", "leaf_id")) { intDelLeaf($smarty, $_REQUEST["interface_name"], $_REQUEST["leaf_name"], $_REQUEST["leaf_id"]); } else { if (isInRequest("interface_name", "delete_interface")) { intDelInterface($smarty, $_REQUEST["interface_name"]); } else { if (isInRequest("interface_name")) { intShowInterfaceInfo($smarty, $_REQUEST["interface_name"]); } else { redirectToInterfaceList(); } } } } } function intShowInterfaceInfo(&$smarty, $interface_name) { $tree = createTree($smarty, $interface_name); $smarty->assign_by_ref("tree", $tree); intSetInterfaceInfo($smarty, $interface_name); $smarty->display("admin/bw/interface_info.tpl"); }
<?php require_once "../inc/init.php"; if (!isInRequest("subject", "category")) { showHelpError("Invalid inputs"); } else { showHelp($_REQUEST["subject"], $_REQUEST["category"]); } function showHelp($subject, $category) { $smarty = new IBSSmarty(); $smarty->default_template_handler_func = 'template_handler_func'; $smarty->assign("tpl_file", getTplFile($subject, $category)); $smarty->assign("subject", $subject); $smarty->assign("category", $category); $smarty->display("help/skeleton.tpl"); } function getTplFile($subject, $category) { $subject = quotemeta(helpFixFileName($subject)); $category = quotemeta(helpFixFileName($category)); return "help/{$category}/{$subject}.tpl"; } function helpFixFileName($file_name) { $file_name = str_replace(" ", "_", $file_name); $file_name = str_replace(".", "_", $file_name); return $file_name; } function template_handler_func($resource_type, $resource_name, &$template_source, &$template_timestamp, &$smarty_obj) {
<?php require_once "../../inc/init.php"; require_once IBSINC . "perm.php"; require_once IBSINC . "admin_face.php"; needAuthType(ADMIN_AUTH_TYPE); if (isInRequest("template_name")) { intShowTemplatePerms($_REQUEST["template_name"]); } function intShowTemplatePerms($template_name) { $smarty = new IBSSmarty(); intSetTemplatePerms($smarty, $template_name); intSetVars($smarty, $template_name); $smarty->display("admin/admins/show_permtemplate_perms.tpl"); } function intSetVars(&$smarty, $template_name) { $smarty->assign("template_name", $template_name); } function intSetTemplatePerms(&$smarty, $template_name) { list($success, $categorized_perms) = getPermsOfTemplateByCategory($template_name); if (!$success) { $smarty->set_page_error($categorized_perms->getErrorMsgs()); $smarty->assign("perms", array()); } else { $categories = array_keys($categorized_perms); $smarty->config_load("perm_category_names.conf"); $category_names = array(); foreach ($categories as $category) {
require_once IBSINC . "voip_tariff_face.php"; require_once IBSINC . "voip_tariff.php"; require_once IBSINC . "perm.php"; require_once IBSINC . "csv.php"; needAuthType(ADMIN_AUTH_TYPE); $smarty = new IBSSmarty(); if (isInRequest("csv", "tariff_name")) { intDownloadPrefixes($smarty, $_REQUEST["tariff_name"], $_REQUEST["csv"]); } else { if (isInRequest("del_prefix_checkbox", "tariff_name")) { intDelPrefixCheckBox($smarty, $_REQUEST["tariff_name"]); } else { if (isInRequest("del_prefix", "tariff_name")) { intDelPrefix($smarty, $_REQUEST["tariff_name"], $_REQUEST["del_prefix"]); } else { if (isInRequest("tariff_name")) { intShowTariffInfo($smarty, $_REQUEST["tariff_name"]); } else { redirectToTariffList(); } } } } function intDownloadPrefixes(&$smarty, $tariff_name, $separator) { $req = new GetTariffInfo($tariff_name, TRUE); $resp = $req->sendAndRecv(); if ($resp->isSuccessful()) { $result = $resp->getResult(); $csv = new CSVGenerator($separator); $csv->sendHeader("voip_tariff_{$tariff_name}.csv");
function getEditTemplateArray() { /* Find edit templates from request, and return template names in an array */ if (isInRequest("edit_tpl_cs")) { //we're runned from an update method return explode(",", $_REQUEST["edit_tpl_cs"]); } else { $edit_templates = array(); foreach ($_REQUEST as $key => $value) { if (preg_match("/^attr_edit_checkbox_[0-9]+\$/", $key)) { // single user info $edit_templates[] = $value; } else { if (preg_match("/^show__.+\$/", $key) and $value != "") { //user list $edit_templates[] = $value; } } } return $edit_templates; } }
<?php require_once "../../inc/init.php"; require_once IBSINC . "ras_face.php"; require_once IBSINC . "ras.php"; needAuthType(ADMIN_AUTH_TYPE); if (isInRequest("ras_ip", "port_name")) { intDelPort($_REQUEST["ras_ip"], $_REQUEST["port_name"]); } else { $err = error("INVALID_INPUT"); redirectToRasList($err->getErrorMsg()); } function intDelPort($ras_ip, $port_name) { $del_port_req = new DelRasPort($ras_ip, $port_name); list($success, $err) = $del_port_req->send(); if ($success) { redirectToRasInfo($ras_ip); } else { errorInterface($ras_ip, $err); } } function errorInterface($ras_ip, $err) { $smarty = new IBSSmarty(); $smarty->assign("ras_ip", $ras_ip); $smarty->set_page_error($err->getErrorMsgs()); $smarty->display("admin/ras/del_port.tpl"); }
<?php require_once "../../inc/init.php"; require_once IBSINC . "user.php"; needAuthType(ADMIN_AUTH_TYPE); $smarty = new IBSSmarty(); if (isInRequest("user_id", "username", "ras_ip", "unique_id_val", "kill")) { intKillUser($smarty, $_REQUEST["user_id"], $_REQUEST["username"], $_REQUEST["ras_ip"], $_REQUEST["unique_id_val"]); } elseif (isInRequest("user_id", "username", "ras_ip", "unique_id_val", "clear")) { intClearUser($smarty, $_REQUEST["user_id"], $_REQUEST["username"], $_REQUEST["ras_ip"], $_REQUEST["unique_id_val"]); } else { face($smarty, "", "Invalid Input"); } function face(&$smarty, $username, $err = "") { $smarty->assign("username", $username); if ($err != "") { $smarty->set_page_error($err); } $smarty->display("admin/user/kill_user.tpl"); } function intKillUser(&$smarty, $user_id, $username, $ras_ip, $unique_id_val) { $req = new KillUser($user_id, $ras_ip, $unique_id_val, TRUE); $resp = $req->sendAndRecv(); if ($resp->isSuccessful()) { $smarty->assign("kill_success", TRUE); } else { $resp->setErrorInSmarty($smarty); } face($smarty, $username);
function limitMacPluginUpdate(&$update_helper) { if (isInRequest("limit_mac")) { $update_helper->addToUpdateFromRequest("limit_mac"); } else { $update_helper->addToDelAttrs("limit_mac"); } }
$smarty->set_page_error("No users selected!"); intShowUserSearch($smarty); } else { if (isInRequest("edit")) { searchUserEdit($smarty, $user_ids); } else { if (isInRequest("change_credit")) { changeUserCredit($smarty, $user_ids); } else { if (isInRequest("connection_log")) { showConnectionLogs($smarty, $user_ids); } else { if (isInRequest("credit_change")) { showCreditChanges($smarty, $user_ids); } else { if (isInRequest("delete_users")) { showDeleteUserFace($smarty, $user_ids); } } } } } } function showCreditChanges(&$smarty, $user_ids) { redirect("/IBSng/admin/report/credit_change.php?user_ids=" . join(",", $user_ids)); } function showConnectionLogs(&$smarty, $user_ids) { redirect("/IBSng/admin/report/connections.php?user_ids=" . join(",", $user_ids)); }
<?php require_once "change_credit_funcs.php"; needAuthType(ADMIN_AUTH_TYPE); $smarty = new IBSSmarty(); if (isInRequest("user_id", "credit", "credit_comment")) { intChangeCredit($smarty, $_REQUEST["user_id"], $_REQUEST["credit"], $_REQUEST["credit_comment"]); } else { if (isInRequest("user_id")) { intShowChangeCreditFace($smarty, $_REQUEST["user_id"]); } else { redirectToUserSearch(""); } }