public function getIndex(Request $request, $param1 = null, $param2 = null, $param3 = null, $param4 = null) { if (strtolower($param1) === 'generate') { return $this->getGenerate($request); } else { if (is_year($param1) && is_null($param2) && is_null($param3) && is_null($param4)) { return $this->makeMonthsView($request, $param1); } else { if (is_year($param1) && is_month($param2) && is_null($param3) && is_null($param4)) { return $this->makeListView($request, $param1, $param2, $param3); } else { if (is_year($param1) && is_month($param2) && !is_null($param3) && is_null($param4)) { if (is_day($param3)) { return $this->makeDayView($request, $param1, $param2, $param3); } else { if (is_uuid($param3)) { return $this->makeMonthEmployeeView($request, $param1, $param2, $param3); } else { return redirect('/dtr/' . now('year')); } } } else { if (is_year($param1) && is_month($param2) && is_day($param3)) { return $this->makeDayEmployeeView($request, $param1, $param2, $param3, $param4); } else { return redirect('/dtr/' . now('year')); } } } } } //.'/'.now('month'));//return $this->makeListView($request, $param1, $param2, $param3); }
/** * @param $request * @return mixed */ public function guidOrAction($request) { $segment = $request->segment(4, 'index'); if (is_uuid($segment)) { $this->uuid = $segment; return $request->segment(5, 'index'); } return $segment; }
public function getDaily(Request $request) { $where = []; $fields = ['component', 'supplier', 'expense', 'expscat', 'compcat']; $filter = new StdClass(); if ($request->has('itemid') && $request->has('table') && $request->has('item')) { $id = strtolower($request->input('itemid')); $table = strtolower($request->input('table')); $c = '\\App\\Models\\' . ucfirst($table); $i = $c::find($id); if (strtolower($request->input('item')) == strtolower($i->descriptor)) { $item = $request->input('item'); if (is_uuid($id) && in_array($table, $fields)) { $where[$table . '.id'] = $id; } else { if ($table === 'payment') { $where['purchase.terms'] = $id; } } $filter->table = $table; $filter->id = $id; $filter->item = $item; } else { $filter->table = ''; $filter->id = ''; $filter->item = ''; } } else { $filter->table = ''; $filter->id = ''; $filter->item = ''; } $bb = $this->bossBranch(); $res = $this->setDateRangeMode($request, 'daily'); //if(!$request->has('branchid')) { if (is_null($request->input('branchid'))) { return $this->setDailyViewVars('component.purchased.daily', null, $bb, null, $filter, null, null, null, null, null); } if (!is_uuid($request->input('branchid')) || !in_array(strtoupper($request->input('branchid')), $this->branch->all()->pluck('id')->all())) { return redirect('/component/purchases')->with('alert-warning', 'Please select a branch.'); } try { $branch = $this->branch->find(strtolower($request->input('branchid'))); } catch (Exception $e) { return $this->setDailyViewVars('component.purchased.daily', null, $bb, null, $filter, null, null, null, null, null); } $where['purchase.branchid'] = $branch->id; $purchases = $this->purchased->branchByDR($branch, $this->dr)->findWhere($where); $components = $this->purchased->brComponentByDR($this->dr)->findWhere($where); $compcats = $this->purchased->brCompCatByDR($this->dr)->findWhere($where); $expenses = $this->purchased->brExpenseByDR($this->dr)->findWhere($where); $expscats = $this->purchased->brExpsCatByDR($this->dr)->findWhere($where); $suppliers = $this->purchased->brSupplierByDR($this->dr)->findWhere($where); $payments = $this->purchased->brPaymentByDR($this->dr)->findWhere($where); return $this->setDailyViewVars('component.purchased.daily', $purchases, $bb, $branch, $filter, $components, $compcats, $expenses, $expscats, $suppliers, $payments); }
public function getRoute(Request $request, $param1 = null) { if (!is_null($param1) && $param1 == 'print') { return $this->getPrintIndex($request); } else { if (!is_null($param1) && is_uuid($param1)) { return $this->getEmployeeDtr($request, $param1); } else { return $this->getIndex($request); } } }
public function getStatus(Request $request, $branchid = NULL) { $branches = $this->repository->all(['code', 'descriptor', 'id']); if (is_null($branchid)) { $branch = null; $dailysales = null; return $this->setViewWithDR(view('status.branch')->with('dailysales', $dailysales)->with('branches', $branches)->with('branch', $branch)); } if (!is_uuid($branchid)) { return redirect('/status/branch')->withErrors(['message' => 'Invalid branchid']); } $branch = $this->repository->find($branchid, ['code', 'descriptor', 'mancost', 'id']); $dailysales = $this->ds->branchByDR($branch, $this->dr); return $this->setViewWithDR(view('status.branch')->with('dailysales', $dailysales)->with('branches', $branches)->with('branch', $branch)); }
function sim_to_db($uuid1, $uuid2) { is_uuid($uuid1) or die('invalid uuid1'); is_uuid($uuid2) or die('invalid uuid2'); if (!$this->sim_in_db($uuid1, $uuid2)) { $query = sprintf("INSERT INTO %s (uuid1, uuid2) VALUES ('%s', '%s');", TBL_SIM, $uuid1, $uuid2); if (!$this->db->queryExec($query, $error)) { die($error); } } }
$hud[$n]['html'] .= "<span class='hud_title' onclick=\"document.location.href='" . PROJECT_PATH . "/app/voicemails/voicemail_messages.php';\">" . $text['label-voicemail'] . "</span>"; $hud[$n]['html'] .= "<span class='hud_stat' onclick=\"\$('#hud_'+" . $n . "+'_details').slideToggle('fast');\">" . $messages['new'] . "</span>"; $hud[$n]['html'] .= "<span class='hud_stat_title' onclick=\"\$('#hud_'+" . $n . "+'_details').slideToggle('fast');\">" . $text['label-new_messages'] . "</span>\n"; $hud[$n]['html'] .= "<div class='hud_details' id='hud_" . $n . "_details'>"; if (sizeof($voicemails) > 0) { $hud[$n]['html'] .= "<table class='tr_hover' cellpadding='2' cellspacing='0' border='0' width='100%'>"; $hud[$n]['html'] .= "<tr>"; $hud[$n]['html'] .= "\t<th class='hud_heading' width='50%'>" . $text['label-voicemail'] . "</th>"; $hud[$n]['html'] .= "\t<th class='hud_heading' style='text-align: center;' width='50%'>" . $text['label-new'] . "</th>"; $hud[$n]['html'] .= "\t<th class='hud_heading' style='text-align: center;'>" . $text['label-total'] . "</th>"; $hud[$n]['html'] .= "</tr>"; $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; foreach ($messages as $voicemail_uuid => $row) { if (is_uuid($voicemail_uuid)) { $tr_link = "href='" . PROJECT_PATH . "/app/voicemails/voicemail_messages.php?id=" . $voicemail_uuid . "'"; $hud[$n]['html'] .= "<tr " . $tr_link . " style='cursor: pointer;'>"; $hud[$n]['html'] .= "\t<td class='" . $row_style[$c] . " hud_text'><a href='" . PROJECT_PATH . "/app/voicemails/voicemail_messages.php?id=" . $voicemail_uuid . "'>" . $row['ext'] . "</a></td>"; $hud[$n]['html'] .= "\t<td class='" . $row_style[$c] . " hud_text' style='text-align: center;'>" . $row['new'] . "</td>"; $hud[$n]['html'] .= "\t<td class='" . $row_style[$c] . " hud_text' style='text-align: center;'>" . $row['total'] . "</td>"; $hud[$n]['html'] .= "</tr>"; $c = $c ? 0 : 1; } } $hud[$n]['html'] .= "</table>"; } else { $hud[$n]['html'] .= "<br />" . $text['label-no_voicemail_assigned']; } $hud[$n]['html'] .= "</div>"; $n++;
function get_uuids_by_author($author) { $json = $this->fetch_docs_by_author($author); $res = json_decode($json, true); $uuids = array(); foreach ($res["documents"] as $doc) { if (isset($doc["uuid"]) && is_uuid($doc["uuid"])) { $uuids[] = $doc["uuid"]; } } return $uuids; }
} } } echo "\t</optgroup>\n"; //} echo "\t</select>\n"; //echo " <input type='button' id='btn_select_to_input_dialplan_detail_type' class='btn' style='visibility:hidden;' name='' alt='".$text['button-back']."' onclick='change_to_input(document.getElementById(\"dialplan_detail_type\"));this.style.visibility = \"hidden\";' value='◁'>\n"; echo "</td>\n"; //data echo "<td class='vtablerow' onclick=\"label_to_form('label_dialplan_detail_data_" . $x . "','dialplan_detail_data_" . $x . "');\" style='width: 100%; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;' nowrap='nowrap'>\n"; if ($element['hidden']) { $dialplan_detail_data_mod = $dialplan_detail_data; if ($dialplan_detail_type == 'bridge') { // parse out gateway uuid $bridge_statement = explode('/', $dialplan_detail_data); if ($bridge_statement[0] == 'sofia' && $bridge_statement[1] == 'gateway' && is_uuid($bridge_statement[2])) { // retrieve gateway name from db $sql = "select gateway from v_gateways where gateway_uuid = '" . $bridge_statement[2] . "' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); if (count($result) > 0) { $gateway_name = $result[0]['gateway']; $dialplan_detail_data_mod = str_replace($bridge_statement[2], $gateway_name, $dialplan_detail_data); } unset($prep_statement, $sql, $bridge_statement); } } echo "\t<label id=\"label_dialplan_detail_data_" . $x . "\">" . htmlspecialchars($dialplan_detail_data_mod) . "</label>\n"; } echo "\t<input id='dialplan_detail_data_" . $x . "' name='dialplan_details[" . $x . "][dialplan_detail_data]' class='formfld' type='text' style='width: 100%; min-width: 100%; max-width: 100%; " . $element['visibility'] . "' placeholder='' value=\"" . htmlspecialchars($dialplan_detail_data) . "\">\n";
/** * @param $namespace * @param $module * @param $controller * @param $uuidOrAction * @param $action * @param $extra * @param $extra2 */ public function route($namespace, $module, $controller, $uuidOrAction, $action, $extra, $extra2) { $this->route = ['namespace' => $namespace, 'module' => $module, 'controller' => $controller, 'action' => $this->getControllerMethod($uuidOrAction, $action), 'uuid' => is_uuid($uuidOrAction) ? $uuidOrAction : null, 'extra' => $extra, 'extra2' => $extra2]; }
//includes include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('device_add')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text(); $text = $language->get(); //set the http get/post variable(s) to a php variable if (isset($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { $device_profile_uuid = $_REQUEST["id"]; } //set the default $save = true; //get the device $sql = "SELECT * FROM v_device_profiles "; $sql .= "where device_profile_uuid = '" . $device_profile_uuid . "' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $device_profiles = $prep_statement->fetchAll(PDO::FETCH_NAMED); //get device keys $sql = "SELECT * FROM v_device_keys "; $sql .= "WHERE device_profile_uuid = '" . $device_profile_uuid . "' "; $sql .= "ORDER by "; $sql .= "CASE device_key_category ";
require_once "resources/require.php"; //check permissions require_once "resources/check_auth.php"; if (permission_exists('group_delete') || if_group("superadmin")) { //access allowed } else { echo "access denied"; return; } //add multi-lingual support $language = new text(); $text = $language->get(); //get the http value and set as a variable $group_uuid = check_str($_GET["id"]); //validate the uuid if (is_uuid($group_uuid)) { //get the group from v_groups $sql = "select domain_uuid, group_name from v_groups "; $sql .= "where group_uuid = '" . $group_uuid . "' "; if (!permission_exists('group_domain')) { $sql .= "and (domain_uuid = '" . $_SESSION['domain_uuid'] . "' or domain_uuid is null); "; } $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $domain_uuid = $row["domain_uuid"]; $group_name = $row["group_name"]; } unset($prep_statement); //delete the group users
$sql .= "ELSE 100 END, "; if ($db_type == "mysql") { $sql .= "device_key_id ASC "; } else { $sql .= "CAST(device_key_id as numeric) ASC, "; } $sql .= "CASE WHEN device_uuid IS NULL THEN 0 ELSE 1 END ASC "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $keys = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset($sql, $prep_statement); //override profile keys with device keys foreach ($keys as $row) { $id = $row['device_key_id']; $device_keys[$id] = $row; if (is_uuid($row['device_profile_uuid'])) { $device_keys[$id]['device_key_owner'] = "profile"; } else { $device_keys[$id]['device_key_owner'] = "device"; } } unset($keys); //get the vendor count and last and device information $vendor_count = 0; foreach ($device_keys as $row) { if ($previous_vendor != $row['device_key_vendor']) { $previous_vendor = $row['device_key_vendor']; $device_uuid = $row['device_uuid']; $device_key_vendor = $row['device_key_vendor']; $device_key_id = $row['device_key_id']; $device_key_line = $row['device_key_line'];
$record['fax_destination'] = $cdr['destination_number']; $record['fax_caller_id_name'] = $cdr['caller_id_name']; $record['fax_caller_id_number'] = $cdr['caller_id_number']; $record['fax_date'] = $cdr['start_stamp']; $record['fax_epoch'] = $cdr['start_epoch']; } else { $record['fax_caller_id_name'] = $fax_extension_cid[$domain_uuid][$fax_ext]['name']; $record['fax_caller_id_number'] = $fax_extension_cid[$domain_uuid][$fax_ext]['number']; $record['fax_epoch'] = filemtime($fax_file_path); $record['fax_date'] = date("Y-m-d H:i:s", $record['fax_epoch']); } unset($prep_statement, $sql, $cdr); } } //create record in the db if (is_uuid($record['fax_uuid']) && is_uuid($record['fax_file_uuid'])) { $sql = "insert into v_fax_files "; $sql .= "( "; $sql .= "fax_file_uuid, "; $sql .= "fax_uuid, "; $sql .= "domain_uuid, "; $sql .= "fax_mode, "; $sql .= "fax_destination, "; $sql .= "fax_file_type, "; $sql .= "fax_file_path, "; $sql .= "fax_caller_id_name, "; $sql .= "fax_caller_id_number, "; $sql .= "fax_date, "; $sql .= "fax_epoch "; $sql .= ") "; $sql .= "values ";
# Testeley - Testing the Mendeley API # # Script: details.php # # Takes a UUID and displays the document details. # # HS 2011-06-15 ########################################################## require_once 'config.inc.php'; require_once 'functions.inc.php'; require_once 'Mendeley.php'; require_once 'LitDb.php'; $mendeley = new Mendeley(API_KEY); if (isset($_GET['uuid']) && $_GET['uuid'] != "") { $uuid = $_GET['uuid']; is_uuid($uuid) or die('invalid uuid'); if (isset($_GET['format']) && $_GET['format'] == "raw") { $json = $mendeley->fetch_details($uuid); format_json($json); } else { html_header(); link_home(); $paper = $mendeley->get_document($uuid); $paper->format_html(); $db = new LitDb(DB_PATH); if ($db->in_db($paper->uuid)) { echo '</p>Paper already in DB</p>'; } else { $db->to_db($paper); echo '<p>Paper added to DB</p>'; }
require_once "resources/check_auth.php"; if (permission_exists('contact_group_delete')) { //access granted } else { echo "access denied"; exit; } // check if included in another file if (!$included) { //add multi-lingual support $language = new text(); $text = $language->get(); if (count($_REQUEST) > 0) { $contact_uuid = check_str($_REQUEST["contact_uuid"]); $contact_group_uuid = $_REQUEST["id"]; } } //delete the group if (is_uuid($contact_uuid) && is_uuid($contact_group_uuid)) { $sql = "delete from v_contact_groups "; $sql .= "where contact_uuid = '" . $contact_uuid . "' "; $sql .= "and contact_group_uuid = '" . $contact_group_uuid . "' "; $db->exec(check_sql($sql)); unset($sql); } //redirect the browser if (!$included) { $_SESSION["message"] = $text['message-delete']; header("Location: contact_edit.php?id=" . $contact_uuid); return; }
public function getYear(Request $request) { //return $request->all(); $bb = $this->bossBranch(); $res = $this->setDateRangeMode($request, 'yearly'); //return dd($this->dr); // get /status/branch if (is_null($request->input('branchid'))) { return $this->setDailyViewVars('analytics.year', null, $bb, null); } if (!is_uuid($request->input('branchid')) || !in_array(strtoupper($request->input('branchid')), $this->branch->all()->pluck('id')->all())) { return redirect('/status/branch/year')->with('alert-warning', 'Please select a branch.'); //return $this->setDailyViewVars('status.branch', null, $bb, null)->withError('dadada'); } try { $branch = $this->branch->find(strtolower($request->input('branchid'))); } catch (Exception $e) { return $this->setDailyViewVars('analytics.year', null, $bb, null); } $dailysales = $this->ds->pushCriteria(new BranchCriteria($branch))->getYear($request, $this->dr); if (!$res) { $request->session()->flash('alert-warning', 'Max months reached! Adjusted to ' . $this->dr->fr->format('M Y') . ' - ' . $this->dr->to->format('M Y')); } return $this->setDailyViewVars('analytics.year', $dailysales, $bb, $branch); }
//access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text(); $text = $language->get(); //get the id if (isset($_GET["id"])) { $id = $_GET["id"]; $device_uuid = check_str($_GET["device_uuid"]); $device_profile_uuid = check_str($_GET["device_profile_uuid"]); } //delete device keys if (is_uuid($id)) { $sql = "delete from v_device_keys "; $sql .= "where (domain_uuid = '" . $_SESSION["domain_uuid"] . "' or domain_uuid is null) "; $sql .= "and device_key_uuid = '" . $id . "' "; $db->exec($sql); unset($sql); } //send a redirect $_SESSION["message"] = $text['message-delete']; if ($device_uuid != '') { header("Location: device_edit.php?id=" . $device_uuid); } else { if ($device_profile_uuid != '') { header("Location: device_profile_edit.php?id=" . $device_profile_uuid); } }
include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('user_delete')) { //access allowed } else { echo "access denied"; return; } //add multi-lingual support $language = new text(); $text = $language->get(); //get the id $user_uuid = check_str($_GET["id"]); //validate the uuid if (is_uuid($user_uuid)) { //get the user's domain from v_users if (permission_exists('user_domain')) { $sql = "select domain_uuid from v_users "; $sql .= "where user_uuid = '" . $user_uuid . "' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $domain_uuid = $row["domain_uuid"]; } unset($prep_statement); } else { $domain_uuid = $_SESSION['domain_uuid']; } //required to be a superadmin to delete a member of the superadmin group
} else { echo "access denied"; return; } //requires a superadmin to add a user to the superadmin group if (!if_group("superadmin") && $_GET["group_name"] == "superadmin") { echo "access denied"; return; } //get the http values and set them as variables $domain_uuid = check_str($_POST["domain_uuid"]); $group_uuid = check_str($_POST["group_uuid"]); $group_name = check_str($_POST["group_name"]); $user_uuid = check_str($_POST["user_uuid"]); //add the user to the group if (is_uuid($user_uuid) && is_uuid($group_uuid) && strlen($group_name) > 0) { $sql = "insert into v_group_users "; $sql .= "("; $sql .= "group_user_uuid, "; $sql .= "domain_uuid, "; $sql .= "group_uuid, "; $sql .= "group_name, "; $sql .= "user_uuid "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'" . uuid() . "', "; $sql .= "'" . $domain_uuid . "', "; $sql .= "'" . $group_uuid . "', "; $sql .= "'" . $group_name . "', "; $sql .= "'" . $user_uuid . "' ";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<tr>\n"; echo "<th>" . $text['label-name'] . "</th>\n"; echo "<th>" . $text['label-participant-pin'] . "</th>\n"; echo "<th>" . $text['label-member-count'] . "</th>\n"; echo "<th> </th>\n"; echo "</tr>\n"; foreach ($xml->conference as $row) { //set the variables $name = $row['name']; $member_count = $row['member-count']; //show the conferences that have a matching domain $tmp_domain = substr($name, -strlen($_SESSION['domain_name'])); if ($tmp_domain == $_SESSION['domain_name']) { $conference_name = substr($name, 0, strlen($name) - strlen('-' . $_SESSION['domain_name'])); if (is_uuid($conference_name)) { $meeting_uuid = $conference_name; $sql = "select "; $sql .= "cr.conference_room_name, "; $sql .= "v.participant_pin "; $sql .= "from "; $sql .= "v_meetings as v, "; $sql .= "v_conference_rooms as cr "; $sql .= "where "; $sql .= "v.meeting_uuid = cr.meeting_uuid "; $sql .= "and v.meeting_uuid = '" . $conference_name . "' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(); foreach ($result as $row2) { $conference_name = $row2['conference_room_name'];
require_once "resources/check_auth.php"; if (permission_exists('contact_group_delete')) { //access granted } else { echo "access denied"; exit; } // check if included in another file if (!$included) { //add multi-lingual support $language = new text(); $text = $language->get(); if (count($_REQUEST) > 0) { $contact_user_uuid = check_str($_REQUEST["id"]); $contact_uuid = check_str($_REQUEST["contact_uuid"]); } } //delete the user if (is_uuid($contact_uuid) && is_uuid($contact_user_uuid)) { $sql = "delete from v_contact_users "; $sql .= "where domain_uuid = '" . $_SESSION['domain_uuid'] . "' "; $sql .= "and contact_user_uuid = '{$contact_user_uuid}' "; $db->exec(check_sql($sql)); unset($sql); } //redirect the browser if (!$included) { $_SESSION["message"] = $text['message-delete']; header("Location: contact_edit.php?id=" . $contact_uuid); return; }
require_once "resources/check_auth.php"; if (permission_exists('fax_file_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text(); $text = $language->get(); //get variables used to control the order $order_by = check_str($_GET["order_by"]); $order = check_str($_GET["order"]); //get fax extension if (strlen($_GET['id']) > 0) { if (is_uuid($_GET["id"])) { $fax_uuid = $_GET["id"]; } if (if_group("superadmin") || if_group("admin")) { //show all fax extensions $sql = "select fax_name, fax_extension from v_fax "; $sql .= "where domain_uuid = '" . $_SESSION['domain_uuid'] . "' "; $sql .= "and fax_uuid = '{$fax_uuid}' "; } else { //show only assigned fax extensions $sql = "select fax_name, fax_extension from v_fax as f, v_fax_users as u "; $sql .= "where f.fax_uuid = u.fax_uuid "; $sql .= "and f.domain_uuid = '" . $_SESSION['domain_uuid'] . "' "; $sql .= "and f.fax_uuid = '{$fax_uuid}' "; $sql .= "and u.user_uuid = '" . $_SESSION['user_uuid'] . "' "; }
function __construct($uuid) { is_uuid($uuid) or die('invalid uuid'); $this->uuid = $uuid; }
function render() { //debug $debug = $_REQUEST['debug']; // array //get the variables $domain_uuid = $this->domain_uuid; $device_template = $this->device_template; $template_dir = $this->template_dir; $mac = $this->mac; $file = $this->file; //get the device template if (strlen($_REQUEST['template']) > 0) { $device_template = $_REQUEST['template']; $search = array('..', '/./'); $device_template = str_replace($search, "", $device_template); $device_template = str_replace('//', '/', $device_template); } //remove ../ and slashes in the file name $search = array('..', '/', '\\', '/./', '//'); $file = str_replace($search, "", $file); //get the domain_name if (strlen($domain_name) == 0) { $sql = "SELECT domain_name FROM v_domains "; $sql .= "WHERE domain_uuid=:domain_uuid "; $prep_statement = $this->db->prepare(check_sql($sql)); if ($prep_statement) { //use the prepared statement $prep_statement->bindParam(':domain_uuid', $domain_uuid); $prep_statement->execute(); $row = $prep_statement->fetch(); unset($prep_statement); //set the variables from values in the database $domain_name = $row["domain_name"]; } } //build the provision array foreach ($_SESSION['provision'] as $key => $val) { if (strlen($val['var']) > 0) { $value = $val['var']; } if (strlen($val['text']) > 0) { $value = $val['text']; } $provision[$key] = $value; } //check to see if the mac_address exists in devices if (strlen($_REQUEST['user_id']) == 0 || strlen($_REQUEST['userid']) == 0) { if ($this->mac_exists($mac)) { //get the device_template if (strlen($device_template) == 0) { $sql = "SELECT * FROM v_devices "; $sql .= "WHERE device_mac_address=:mac "; //$sql .= "WHERE device_mac_address= '$mac' "; $prep_statement_2 = $this->db->prepare(check_sql($sql)); if ($prep_statement_2) { //use the prepared statement $prep_statement_2->bindParam(':mac', $mac); $prep_statement_2->execute(); $row = $prep_statement_2->fetch(); //set the variables from values in the database $device_uuid = $row["device_uuid"]; $device_label = $row["device_label"]; if (strlen($row["device_vendor"]) > 0) { $device_vendor = strtolower($row["device_vendor"]); } $device_model = $row["device_model"]; $device_firmware_version = $row["device_firmware_version"]; $device_provision_enable = $row["device_provision_enable"]; $device_template = $row["device_template"]; $device_profile_uuid = $row["device_profile_uuid"]; $device_description = $row["device_description"]; } } //find a template that was defined on another phone and use that as the default. if (strlen($device_template) == 0) { $sql = "SELECT * FROM v_devices "; $sql .= "WHERE domain_uuid=:domain_uuid "; $sql .= "limit 1 "; $prep_statement_3 = $this->db->prepare(check_sql($sql)); if ($prep_statement_3) { $prep_statement_3->bindParam(':domain_uuid', $domain_uuid); $prep_statement_3->execute(); $row = $prep_statement_3->fetch(); $device_label = $row["device_label"]; $device_vendor = strtolower($row["device_vendor"]); $device_model = $row["device_model"]; $device_firmware_version = $row["device_firmware_version"]; $device_provision_enable = $row["device_provision_enable"]; $device_template = $row["device_template"]; $device_profile_uuid = $row["device_profile_uuid"]; $device_description = $row["device_description"]; } } } else { //use the user_agent to pre-assign a template for 1-hit provisioning. Enter the a unique string to match in the user agent, and the template it should match. $template_list = array("Linksys/SPA-2102" => "linksys/spa2102", "Linksys/SPA-3102" => "linksys/spa3102", "Linksys/SPA-9212" => "linksys/spa921", "Cisco/SPA301" => "cisco/spa301", "Cisco/SPA301D" => "cisco/spa302d", "Cisco/SPA303" => "cisco/spa303", "Cisco/SPA501G" => "cisco/spa501g", "Cisco/SPA502G" => "cisco/spa502g", "Cisco/SPA504G" => "cisco/spa504g", "Cisco/SPA508G" => "cisco/spa508g", "Cisco/SPA509G" => "cisco/spa509g", "Cisco/SPA512G" => "cisco/spa512g", "Cisco/SPA514G" => "cisco/spa514g", "Cisco/SPA525G2" => "cisco/spa525g2", "snom300-SIP" => "snom/300", "snom320-SIP" => "snom/320", "snom360-SIP" => "snom/360", "snom370-SIP" => "snom/370", "snom820-SIP" => "snom/820", "snom-m3-SIP" => "snom/m3", "yealink SIP-T20" => "yealink/t20", "yealink SIP-T22" => "yealink/t22", "yealink SIP-T26" => "yealink/t26", "Yealink SIP-T32" => "yealink/t32", "HW GXP1450" => "grandstream/gxp1450", "HW GXP2124" => "grandstream/gxp2124", "HW GXV3140" => "grandstream/gxv3140", "HW GXV3175" => "grandstream/gxv3175", "Wget/1.11.3" => "konftel/kt300ip"); foreach ($template_list as $key => $val) { if (stripos($_SERVER['HTTP_USER_AGENT'], $key) !== false) { $device_template = $val; break; } } unset($template_list); //mac address does not exist in the table so add it if ($_SESSION['provision']['auto_insert_enabled']['boolean'] == "true" and strlen($domain_uuid) > 0) { $device_uuid = uuid(); $sql = "INSERT INTO v_devices "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "device_uuid, "; $sql .= "device_mac_address, "; $sql .= "device_vendor, "; $sql .= "device_model, "; $sql .= "device_provision_enable, "; $sql .= "device_template, "; $sql .= "device_description "; $sql .= ") "; $sql .= "VALUES "; $sql .= "("; $sql .= "'" . $domain_uuid . "', "; $sql .= "'{$device_uuid}', "; $sql .= "'{$mac}', "; $sql .= "'{$device_vendor}', "; $sql .= "'', "; $sql .= "'true', "; $sql .= "'{$device_template}', "; $sql .= "'auto {$_SERVER['HTTP_USER_AGENT']}' "; $sql .= ")"; $this->db->exec(check_sql($sql)); unset($sql); } } } //alternate device_uuid if (strlen($device_uuid) > 0) { $sql = "SELECT * FROM v_devices "; $sql .= "WHERE device_uuid = '" . $device_uuid . "' "; $prep_statement_3 = $this->db->prepare(check_sql($sql)); if ($prep_statement_3) { $prep_statement_3->execute(); $row = $prep_statement_3->fetch(); $device_uuid_alternate = $row["device_uuid_alternate"]; if (is_uuid($device_uuid_alternate)) { //override the original device_uuid $device_uuid = $device_uuid_alternate; //get the new devices information $sql = "SELECT * FROM v_devices "; $sql .= "WHERE device_uuid = '" . $device_uuid . "' "; $prep_statement_4 = $this->db->prepare(check_sql($sql)); if ($prep_statement_4) { $prep_statement_4->execute(); $row = $prep_statement_4->fetch(); $device_label = $row["device_label"]; $device_vendor = strtolower($row["device_vendor"]); $device_firmware_version = $row["device_firmware_version"]; $device_provision_enable = $row["device_provision_enable"]; //keep the original template $device_profile_uuid = $row["device_profile_uuid"]; $device_description = $row["device_description"]; } unset($prep_statement_4); } } unset($prep_statement_3); } //get the device settings table in the provision category and update the provision array if (strlen($device_uuid) > 0) { $sql = "SELECT * FROM v_device_settings "; $sql .= "WHERE device_uuid = '" . $device_uuid . "' "; $sql .= "AND device_setting_enabled = 'true' "; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); foreach ($result as $row) { $key = $row['device_setting_subcategory']; $value = $row['device_setting_value']; $provision[$key] = $value; } unset($prep_statement); } //initialize a template object $view = new template(); if (strlen($_SESSION['provision']['template_engine']['text']) > 0) { $view->engine = $_SESSION['provision']['template_engine']['text']; //raintpl, smarty, twig } else { $view->engine = "smarty"; } $view->template_dir = $template_dir . "/" . $device_template . "/"; $view->cache_dir = $_SESSION['server']['temp']['dir']; $view->init(); //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number //get the time zone $time_zone_name = $_SESSION['domain']['time_zone']['name']; if (strlen($time_zone_name) > 0) { $time_zone_offset_raw = get_time_zone_offset($time_zone_name) / 3600; $time_zone_offset_hours = floor($time_zone_offset_raw); $time_zone_offset_minutes = ($time_zone_offset_raw - $time_zone_offset_hours) * 60; $time_zone_offset_minutes = number_pad($time_zone_offset_minutes, 2); if ($time_zone_offset_raw > 0) { $time_zone_offset_hours = number_pad($time_zone_offset_hours, 2); $time_zone_offset_hours = "+" . $time_zone_offset_hours; } else { $time_zone_offset_hours = str_replace("-", "", $time_zone_offset_hours); $time_zone_offset_hours = "-" . number_pad($time_zone_offset_hours, 2); } $time_zone_offset = $time_zone_offset_hours . ":" . $time_zone_offset_minutes; $view->assign("time_zone_offset", $time_zone_offset); } //create a mac address with back slashes for backwards compatability $mac_dash = substr($mac, 0, 2) . '-' . substr($mac, 2, 2) . '-' . substr($mac, 4, 2) . '-' . substr($mac, 6, 2) . '-' . substr($mac, 8, 2) . '-' . substr($mac, 10, 2); //get the contacts array and add to the template engine if (strlen($device_uuid) > 0 and strlen($domain_uuid) > 0 and $_SESSION['provision']['directory']['boolean'] == "true") { //get contacts from the database $sql = "select c.contact_organization, c.contact_name_given, c.contact_name_family, p.phone_number, p.phone_extension "; $sql .= "from v_contacts as c, v_contact_phones as p "; $sql .= "where c.domain_uuid = '" . $domain_uuid . "' "; $sql .= "and c.contact_uuid = p.contact_uuid "; $sql .= "and p.phone_type_voice = '1' "; $sql .= "order by c.contact_organization desc, c.contact_name_given asc, c.contact_name_family asc "; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); $contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset($prep_statement, $sql); //assign the contacts array $view->assign("contacts", $contacts); } //get the provisioning information from device lines table if (strlen($device_uuid) > 0) { //get the device lines array $sql = "select * from v_device_lines "; $sql .= "where device_uuid = '" . $device_uuid . "' "; $sql .= "and (enabled = 'true' or enabled is null or enabled = '') "; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); $device_lines = $prep_statement->fetchAll(PDO::FETCH_NAMED); //assign the keys array $view->assign("lines", $device_lines); //set the variables foreach ($device_lines as $row) { //set the variables $line_number = $row['line_number']; $register_expires = $row['register_expires']; $sip_transport = strtolower($row['sip_transport']); $sip_port = $row['sip_port']; //set defaults if (strlen($register_expires) == 0) { $register_expires = "120"; } if (strlen($sip_transport) == 0) { $sip_transport = "tcp"; } if (strlen($sip_port) == 0) { if ($line_number == "" || $line_number == "1") { $sip_port = "5060"; } else { $sip_port = "506" . ($line_number + 1); } } //set a lines array index is the line number $lines[$line_number]['register_expires'] = $register_expires; $lines[$line_number]['sip_transport'] = strtolower($sip_transport); $lines[$line_number]['sip_port'] = $sip_port; $lines[$line_number]['server_address'] = $row["server_address"]; $lines[$line_number]['outbound_proxy'] = $row["outbound_proxy"]; $lines[$line_number]['display_name'] = $row["display_name"]; $lines[$line_number]['auth_id'] = $row["auth_id"]; $lines[$line_number]['user_id'] = $row["user_id"]; $lines[$line_number]['password'] = $row["password"]; //assign the variables $view->assign("server_address_" . $line_number, $row["server_address"]); $view->assign("outbound_proxy_" . $line_number, $row["outbound_proxy"]); $view->assign("display_name_" . $line_number, $row["display_name"]); $view->assign("auth_id_" . $line_number, $row["auth_id"]); $view->assign("user_id_" . $line_number, $row["user_id"]); $view->assign("user_password_" . $line_number, $row["password"]); $view->assign("sip_transport_" . $line_number, $sip_transport); $view->assign("sip_port_" . $line_number, $sip_port); $view->assign("register_expires_" . $line_number, $register_expires); } unset($prep_statement); } //get the provisioning information from device keys if (strlen($device_uuid) > 0) { //get the device keys array $sql = "SELECT * FROM v_device_keys "; $sql .= "WHERE ("; $sql .= "device_uuid = '" . $device_uuid . "' "; if (strlen($device_profile_uuid) > 0) { $sql .= "or device_profile_uuid = '" . $device_profile_uuid . "' "; } $sql .= ") "; //$sql .= "AND domain_uuid = '".$domain_uuid."' "; $sql .= "ORDER BY device_key_category asc, device_key_id asc, device_uuid desc"; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); $device_keys = $prep_statement->fetchAll(PDO::FETCH_NAMED); //rebuild the array to allow profile keys to be overridden by keys assigned to this device $x = 0; $previous_category = ''; $previous_id = ''; foreach ($device_keys as $row) { //set the variables if ($row['device_key_category'] == $previous_category && $row['device_key_id'] == $previous_id) { $device_keys[$x]['device_key_override'] = "true"; $device_keys[$x]['device_key_message'] = "value=" . $device_keys[$x - 1]['device_key_value'] . "&label=" . $device_keys[$x - 1]['device_key_label']; unset($device_keys[$x - 1]); } $device_keys[$x]['device_key_category'] = $row['device_key_category']; $device_keys[$x]['device_key_id'] = $row['device_key_id']; //1 $device_keys[$x]['device_key_type'] = $row['device_key_type']; //line, memory, expansion $device_keys[$x]['device_key_line'] = $row['device_key_line']; $device_keys[$x]['device_key_value'] = $row['device_key_value']; //1 $device_keys[$x]['device_key_extension'] = $row['device_key_extension']; $device_keys[$x]['device_key_label'] = $row['device_key_label']; //label if (is_uuid($row['device_profile_uuid'])) { $device_keys[$x]['device_key_owner'] = "profile"; } else { $device_keys[$x]['device_key_owner'] = "device"; } //set previous values $previous_category = $row['device_key_category']; $previous_id = $row['device_key_id']; //increment the key $x++; } } //debug information if ($debug == "array") { echo "<pre>\n"; print_r($device_keys); echo "<pre>\n"; exit; } //assign the keys array $view->assign("keys", $device_keys); //set the variables foreach ($device_keys as $row) { //set the variables $device_key_category = $row['device_key_category']; $device_key_id = $row['device_key_id']; //1 $device_key_type = $row['device_key_type']; //line $device_key_line = $row['device_key_line']; $device_key_value = $row['device_key_value']; //1 $device_key_extension = $row['device_key_extension']; $device_key_label = $row['device_key_label']; //label //set the line key $x = $device_key_line; //add a simple variable with the index if ($x === 0 || $x === 1) { $device_key_value = str_replace("\${user_id}", $lines[$x]['user_id'], $device_key_value); $device_key_value = str_replace("\${auth_id}", $lines[$x]['auth_id'], $device_key_value); $device_key_value = str_replace("\${extension}", $lines[$x]['user_id'], $device_key_value); $device_key_value = str_replace("\${password}", $lines[$x]['password'], $device_key_value); $device_key_value = str_replace("\${register_expires}", $lines[$x]['register_expires'], $device_key_value); $device_key_value = str_replace("\${sip_transport}", $lines[$x]['sip_transport'], $device_key_value); $device_key_value = str_replace("\${sip_port}", $lines[$x]['sip_port'], $device_key_value); $device_key_value = str_replace("\${server_address}", $lines[$x]['server_address'], $device_key_value); $device_key_value = str_replace("\${outbound_proxy}", $lines[$x]['outbound_proxy'], $device_key_value); $device_key_value = str_replace("\${display_name}", $lines[$x]['display_name'], $device_key_value); $device_key_extension = str_replace("\${user_id}", $lines[$x]['user_id'], $device_key_extension); $device_key_extension = str_replace("\${auth_id}", $lines[$x]['auth_id'], $device_key_extension); $device_key_extension = str_replace("\${extension}", $lines[$x]['user_id'], $device_key_extension); $device_key_extension = str_replace("\${password}", $lines[$x]['password'], $device_key_extension); $device_key_extension = str_replace("\${register_expires}", $lines[$x]['register_expires'], $device_key_extension); $device_key_extension = str_replace("\${sip_transport}", $lines[$x]['sip_transport'], $device_key_extension); $device_key_extension = str_replace("\${sip_port}", $lines[$x]['sip_port'], $device_key_extension); $device_key_extension = str_replace("\${server_address}", $lines[$x]['server_address'], $device_key_extension); $device_key_extension = str_replace("\${outbound_proxy}", $lines[$x]['outbound_proxy'], $device_key_extension); $device_key_extension = str_replace("\${display_name}", $lines[$x]['display_name'], $device_key_extension); $device_key_label = str_replace("\${user_id}", $lines[$x]['user_id'], $device_key_label); $device_key_label = str_replace("\${auth_id}", $lines[$x]['auth_id'], $device_key_label); $device_key_label = str_replace("\${extension}", $lines[$x]['user_id'], $device_key_label); $device_key_label = str_replace("\${password}", $lines[$x]['password'], $device_key_label); $device_key_label = str_replace("\${register_expires}", $lines[$x]['register_expires'], $device_key_label); $device_key_label = str_replace("\${sip_transport}", $lines[$x]['sip_transport'], $device_key_label); $device_key_label = str_replace("\${sip_port}", $lines[$x]['sip_port'], $device_key_label); $device_key_label = str_replace("\${server_address}", $lines[$x]['server_address'], $device_key_label); $device_key_label = str_replace("\${outbound_proxy}", $lines[$x]['outbound_proxy'], $device_key_label); $device_key_label = str_replace("\${display_name}", $lines[$x]['display_name'], $device_key_label); } //add variables with the index $device_key_value = str_replace("\${user_id_{$x}}", $lines[$x]['user_id'], $device_key_value); $device_key_value = str_replace("\${auth_id_{$x}}", $lines[$x]['auth_id'], $device_key_value); $device_key_value = str_replace("\${extension_{$x}}", $lines[$x]['user_id'], $device_key_value); $device_key_value = str_replace("\${password_{$x}}", $lines[$x]['password'], $device_key_value); $device_key_value = str_replace("\${register_expires_{$x}}", $lines[$x]['register_expires'], $device_key_value); $device_key_value = str_replace("\${sip_transport_{$x}}", $lines[$x]['sip_transport'], $device_key_value); $device_key_value = str_replace("\${sip_port_{$x}}", $lines[$x]['sip_port'], $device_key_value); $device_key_value = str_replace("\${server_address_{$x}}", $lines[$x]['server_address'], $device_key_value); $device_key_value = str_replace("\${outbound_proxy_{$x}}", $lines[$x]['outbound_proxy'], $device_key_value); $device_key_value = str_replace("\${display_name_{$x}}", $lines[$x]['display_name'], $device_key_value); $device_key_extension = str_replace("\${user_id_{$x}}", $lines[$x]['user_id'], $device_key_label); $device_key_extension = str_replace("\${auth_id_{$x}}", $lines[$x]['auth_id'], $device_key_label); $device_key_extension = str_replace("\${extension_{$x}}", $lines[$x]['user_id'], $device_key_label); $device_key_extension = str_replace("\${password_{$x}}", $lines[$x]['password'], $device_key_label); $device_key_extension = str_replace("\${register_expires_{$x}}", $lines[$x]['register_expires'], $device_key_label); $device_key_extension = str_replace("\${sip_transport_{$x}}", $lines[$x]['sip_transport'], $device_key_label); $device_key_extension = str_replace("\${sip_port_{$x}}", $lines[$x]['sip_port'], $device_key_label); $device_key_extension = str_replace("\${server_address_{$x}}", $lines[$x]['server_address'], $device_key_label); $device_key_extension = str_replace("\${outbound_proxy_{$x}}", $lines[$x]['outbound_proxy'], $device_key_label); $device_key_extension = str_replace("\${display_name_{$x}}", $lines[$x]['display_name'], $device_key_label); $device_key_label = str_replace("\${user_id_{$x}}", $lines[$x]['user_id'], $device_key_label); $device_key_label = str_replace("\${auth_id_{$x}}", $lines[$x]['auth_id'], $device_key_label); $device_key_label = str_replace("\${extension_{$x}}", $lines[$x]['user_id'], $device_key_label); $device_key_label = str_replace("\${password_{$x}}", $lines[$x]['password'], $device_key_label); $device_key_label = str_replace("\${register_expires_{$x}}", $lines[$x]['register_expires'], $device_key_label); $device_key_label = str_replace("\${sip_transport_{$x}}", $lines[$x]['sip_transport'], $device_key_label); $device_key_label = str_replace("\${sip_port_{$x}}", $lines[$x]['sip_port'], $device_key_label); $device_key_label = str_replace("\${server_address_{$x}}", $lines[$x]['server_address'], $device_key_label); $device_key_label = str_replace("\${outbound_proxy_{$x}}", $lines[$x]['outbound_proxy'], $device_key_label); $device_key_label = str_replace("\${display_name_{$x}}", $lines[$x]['display_name'], $device_key_label); //add general variables $device_key_value = str_replace("\${domain_name}", $domain_name, $device_key_value); $device_key_extension = str_replace("\${domain_name}", $domain_name, $device_key_extension); $device_key_label = str_replace("\${domain_name}", $domain_name, $device_key_label); //grandstream modes are different based on the category if ($device_vendor == "grandstream") { if ($device_key_category == "line") { switch ($device_key_type) { case "line": $device_key_type = "0"; break; case "shared line": $device_key_type = "1"; break; case "speed dial": $device_key_type = "10"; break; case "blf": $device_key_type = "11"; break; case "presence watcher": $device_key_type = "12"; break; case "eventlist blf": $device_key_type = "13"; break; case "speed dial active": $device_key_type = "14"; break; case "dial dtmf": $device_key_type = "15"; break; case "voicemail": $device_key_type = "16"; break; case "call return": $device_key_type = "17"; break; case "transfer": $device_key_type = "18"; break; case "call park": $device_key_type = "19"; break; case "intercom": $device_key_type = "20"; break; case "ldap search": $device_key_type = "21"; break; } } if ($device_key_category == "memory") { switch ($device_key_type) { case "speed dial": $device_key_type = "0"; break; case "blf": $device_key_type = "1"; break; case "presence watcher": $device_key_type = "2"; break; case "eventlist blf": $device_key_type = "3"; break; case "speed dial active": $device_key_type = "4"; break; case "dial dtmf": $device_key_type = "5"; break; case "voicemail": $device_key_type = "6"; break; case "call return": $device_key_type = "7"; break; case "transfer": $device_key_type = "8"; break; case "call park": $device_key_type = "9"; break; case "intercom": $device_key_type = "10"; break; case "ldap search": $device_key_type = "11"; break; } } } //assign the variables if (strlen($device_key_category) == 0) { $view->assign("key_id_" . $device_key_id, $device_key_id); $view->assign("key_type_" . $device_key_id, $device_key_type); $view->assign("key_line_" . $device_key_id, $device_key_line); $view->assign("key_value_" . $device_key_id, $device_key_value); $view->assign("key_extension_" . $device_key_id, $device_key_extension); $view->assign("key_label_" . $device_key_id, $device_key_label); } else { $view->assign($device_key_category . "_key_id_" . $device_key_id, $device_key_id); $view->assign($device_key_category . "_key_type_" . $device_key_id, $device_key_type); $view->assign($device_key_category . "_key_line_" . $device_key_id, $device_key_line); $view->assign($device_key_category . "_key_value_" . $device_key_id, $device_key_value); $view->assign($device_key_category . "_key_extension_" . $device_key_id, $device_key_extension); $view->assign($device_key_category . "_key_label_" . $device_key_id, $device_key_label); } } unset($prep_statement); //set the mac address in the correct format switch (strtolower($device_vendor)) { case "aastra": $mac = strtoupper($mac); break; case "snom": $mac = strtolower($mac); break; case "polycom": $mac = strtolower($mac); break; default: $mac = strtolower($mac); $mac = substr($mac, 0, 2) . '-' . substr($mac, 2, 2) . '-' . substr($mac, 4, 2) . '-' . substr($mac, 6, 2) . '-' . substr($mac, 8, 2) . '-' . substr($mac, 10, 2); } //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number $view->assign("mac", $mac); $view->assign("label", $device_label); $view->assign("firmware_version", $device_firmware_version); $view->assign("domain_name", $domain_name); $view->assign("project_path", PROJECT_PATH); $view->assign("server1_address", $server1_address); $view->assign("proxy1_address", $proxy1_address); $view->assign("user_id", $user_id); $view->assign("password", $password); $view->assign("template", $device_template); //replace the dynamic provision variables that are defined in default, domain, and device settings foreach ($provision as $key => $val) { $view->assign($key, $val); } //set the template directory if (strlen($provision["template_dir"]) > 0) { $template_dir = $provision["template_dir"]; } //if the domain name directory exists then only use templates from it if (is_dir($template_dir . '/' . $domain_name)) { $device_template = $domain_name . '/' . $device_template; } //if $file is not provided then look for a default file that exists if (strlen($file) == 0) { if (file_exists($template_dir . "/" . $device_template . "/{\$mac}")) { $file = "{\$mac}"; } elseif (file_exists($template_dir . "/" . $device_template . "/{\$mac}.xml")) { $file = "{\$mac}.xml"; } elseif (file_exists($template_dir . "/" . $device_template . "/{\$mac}.cfg")) { $file = "{\$mac}.cfg"; } else { echo "file not found"; exit; } } else { //make sure the file exists if (!file_exists($template_dir . "/" . $device_template . "/" . $file)) { echo "file not found"; if ($_SESSION['provision']['debug']['boolean'] == 'true') { echo ":{$template_dir}/{$device_template}/{$file}<br/>"; echo "template_dir: {$template_dir}<br/>"; echo "device_template: {$device_template}<br/>"; echo "file: {$file}"; } exit; } } //output template to string for header processing $file_contents = $view->render($file); //log file for testing if ($_SESSION['provision']['debug']['boolean'] == 'true') { $tmp_file = "/tmp/provisioning_log.txt"; $fh = fopen($tmp_file, 'w') or die("can't open file"); $tmp_string = $mac . "\n"; fwrite($fh, $tmp_string); fclose($fh); } //returned the rendered template return $file_contents; }
public function getChecklist(Request $request) { $bb = $this->branch->orderBy('code')->getByCriteria(new ActiveBranch())->all(['code', 'descriptor', 'id']); $date = carbonCheckorNow($request->input('date')); if (!$request->has('branchid') && !isset($_GET['branchid'])) { return view('backup.checklist')->with('date', $date)->with('branches', $bb)->with('branch', null)->with('backups', null); } if (!is_uuid($request->input('branchid')) || !in_array(strtoupper($request->input('branchid')), $this->branch->all()->pluck('id')->all())) { return redirect('/backup/checklist')->with('alert-warning', 'Please select a branch.'); } try { $branch = $this->branch->find(strtolower($request->input('branchid'))); } catch (Exception $e) { return redirect('/backup/checklist')->with('alert-warning', 'Please select a branch.'); } $backups = $this->repository->monthlyLogs($date, $branch); return view('backup.checklist')->with('date', $date)->with('branches', $bb)->with('branch', $branch)->with('backups', $backups); }