/** * Vote on this * * @param \user User voting * @return bool */ public function vote(\user $user) { $a = \Kofradia\DB::get()->exec("\n\t\t\tINSERT IGNORE INTO polls_votes\n\t\t\tSET pv_p_id = {$this->poll->id}, pv_po_id = {$this->id}, pv_up_id = {$user->player->id}, pv_time = " . time()); if ($a > 0) { \Kofradia\DB::get()->exec("UPDATE polls_options SET po_votes = po_votes + 1 WHERE po_id = {$this->id}"); \Kofradia\DB::get()->exec("UPDATE polls SET p_votes = p_votes + 1 WHERE p_id = {$this->poll->id}"); // delete vote cache \cache::delete("polls_options_list"); } return $ok; }
public function doAction() { $answers = system::POST('answers'); $error = 2; $msg = ''; if (count($answers) > 0) { if ($vote = ormPages::get(system::POST('vote_id'), 'vote')) { if (!$vote->close) { $sel = new ormSelect('answer'); $sel->fields('name, count'); $sel->where('parents', '=', $vote->id); while ($answ = $sel->getObject()) { if (in_array($answ->id, $answers)) { $answ->count = $answ->count + 1; $answ->save(); if (!$vote->multiselect) { break; } } } cache::delete('vote' . $vote->id . '1'); cache::delete('vote' . $vote->id . '0'); $_SESSION['voting_' . $vote->id] = 1; $error = 0; } else { // Голосование закрыто $msg = lang::get('VOTING_MSG_CLOSE'); $error = 1; } } else { $msg = lang::get('VOTING_MSG_NOT_FOUND'); } } else { $msg = lang::get('VOTING_MSG_CHOSE_VAR'); } if (system::isAjax()) { if ($error < 2 && $vote instanceof ormPage) { $data = page::macros('voting')->objView($vote->id); } system::json(array('error' => 0, 'html' => $data, 'msg' => $msg)); } else { if (!empty($_POST['back_url'])) { system::redirect($_POST['back_url'], true); } else { system::redirect('/'); } } }
public function proc() { $obj = user::getObject(); // Если произошли ошибки, перенаправляем на главную страницу админки if (!$obj instanceof ormObject) { system::redirect('/'); } // Присваиваем пришедшие значения полям в объекте $obj->tabuList('active', 'groups', 'login'); $obj->loadFromPost(); // Сохраняем изменения $obj_id = $obj->save(); // Если объект не сохранился, выводим пользователю текст ошибки. if ($obj_id === false) { system::savePostToSession(); ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), $obj->getErrorListText()); ui::selectErrorFields($obj->getErrorFields()); } cache::delete('user' . $obj_id); system::redirect('/core/profile'); }
$sql = "update v_dialplan_details set "; $sql .= "dialplan_detail_data = '" . check_str($dialplan_detail_data) . "' "; $sql .= "where domain_uuid = '" . $_SESSION['domain_uuid'] . "' "; $sql .= "and dialplan_detail_tag = 'action' "; $sql .= "and dialplan_detail_type = 'set' "; $sql .= "and dialplan_uuid = '{$dialplan_uuid}' "; $sql .= "and dialplan_detail_data like 'api_hangup_hook=%' "; $db->query(check_sql($sql)); } //save the xml save_dialplan_xml(); //apply settings reminder $_SESSION["reload_xml"] = true; //clear the cache $cache = new cache(); $cache->delete("dialplan:" . $_SESSION["context"]); //redirect the browser if ($action == "update" && permission_exists('fax_extension_edit')) { $_SESSION["message"] = $text['confirm-update']; } if ($action == "add" && permission_exists('fax_extension_add')) { $_SESSION["message"] = $text['confirm-add']; } header("Location: fax.php"); return; } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (strlen($_GET['id']) > 0 && $_POST["persistformvar"] != "true") {
/** * Add a dialplan for call center * @var string $domain_uuid the multi-tenant id * @var string $value string to be cached */ public function dialplan() { //normalize the fax forward number if (strlen($this->fax_forward_number) > 3) { //$fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number); $this->fax_forward_number = str_replace(" ", "", $this->fax_forward_number); $this->fax_forward_number = str_replace("-", "", $this->fax_forward_number); } //set the forward prefix if (strripos($this->fax_forward_number, '$1') === false) { $this->forward_prefix = ''; //not found } else { $this->forward_prefix = $this->forward_prefix . $this->fax_forward_number . '#'; //found } //delete previous dialplan if (strlen($this->dialplan_uuid) > 0) { //delete the previous dialplan $sql = "delete from v_dialplans "; $sql .= "where dialplan_uuid = '" . $this->dialplan_uuid . "' "; $sql .= "and domain_uuid = '" . $this->domain_uuid . "' "; $this->db->exec($sql); $sql = "delete from v_dialplan_details "; $sql .= "where dialplan_uuid = '" . $this->dialplan_uuid . "' "; $sql .= "and domain_uuid = '" . $this->domain_uuid . "' "; $this->db->exec($sql); unset($sql); } unset($prep_statement); //build the dialplan array $dialplan["app_uuid"] = "24108154-4ac3-1db6-1551-4731703a4440"; $dialplan["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_name"] = $this->fax_name != '' ? $this->fax_name : format_phone($this->destination_number); $dialplan["dialplan_number"] = $this->fax_extension; $dialplan["dialplan_context"] = $_SESSION['context']; $dialplan["dialplan_continue"] = "false"; $dialplan["dialplan_order"] = "310"; $dialplan["dialplan_enabled"] = "true"; $dialplan["dialplan_description"] = $this->fax_description; $dialplan_detail_order = 10; //add the public condition $y = 1; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "^" . $this->destination_number . "\$"; $dialplan["dialplan_details"][$y]["dialplan_detail_break"] = ""; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "answer"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = ""; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "fax_uuid=" . $this->fax_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "api_hangup_hook=lua app/fax/resources/scripts/hangup_rx.lua"; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; foreach ($_SESSION['fax']['variable'] as $data) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; if (substr($data, 0, 8) == "inbound:") { $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = substr($data, 8, strlen($data)); } elseif (substr($data, 0, 9) == "outbound:") { } else { $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $data; } $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; } $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; if (strlen($_SESSION['fax']['last_fax']['text']) > 0) { $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "last_fax=" . $_SESSION['fax']['last_fax']['text']; } else { $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "last_fax=\${caller_id_number}-\${strftime(%Y-%m-%d-%H-%M-%S)}"; } $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "playback"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "silence_stream://2000"; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "rxfax"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $_SESSION['switch']['storage']['dir'] . '/fax/' . $_SESSION['domain_name'] . '/' . $this->fax_extension . '/inbox/' . $this->forward_prefix . '${last_fax}.tif'; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "hangup"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = ""; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; //add the dialplan permission $p = new permissions(); $p->add("dialplan_add", 'temp'); $p->add("dialplan_detail_add", 'temp'); $p->add("dialplan_edit", 'temp'); $p->add("dialplan_detail_edit", 'temp'); //save the dialplan $orm = new orm(); $orm->name('dialplans'); $orm->save($dialplan); $dialplan_response = $orm->message; $this->dialplan_uuid = $dialplan_response['uuid']; //if new dialplan uuid then update the call center queue $sql = "update v_fax "; $sql .= "set dialplan_uuid = '" . $this->dialplan_uuid . "' "; $sql .= "where fax_uuid = '" . $this->fax_uuid . "' "; $sql .= "and domain_uuid = '" . $this->domain_uuid . "' "; $this->db->exec($sql); unset($sql); //remove the temporary permission $p->delete("dialplan_add", 'temp'); $p->delete("dialplan_detail_add", 'temp'); $p->delete("dialplan_edit", 'temp'); $p->delete("dialplan_detail_edit", 'temp'); //synchronize the xml config save_dialplan_xml(); //clear the cache $cache = new cache(); $cache->delete("dialplan:" . $_SESSION['context']); //return the dialplan_uuid return $dialplan_response; }
public function ClearCache($path = "", $private = true, $recurse = false) { global $AR; $norealnode = false; if (!$path) { $path = $this->path; } else { $realpath = current($this->get($path, "system.get.path.phtml")); if ($realpath != false) { $path = $realpath; } else { $norealnode = true; } } if ($norealnode !== true) { /* we don't want to recurse to the currentsite, because the path doesn't exists in the database, so it doesn't have a currentsite the privatecache should be emptied by delete, or by the cleanup cronjob. The current path doesn't exists in the database, so a object id which is needed to find the node in the cache, isn't available */ if ($private) { // now remove any private cache entries. // FIXME: this doesn't scale very well. // only scalable solution is storage in a database // but it will need the original path info to // remove recursively fast enough. // this means a change in the filestore api. -> 2.5 // Use chunks of max 5000 objects at a time to be more memory-efficient; $pcache = $this->store->get_filestore("privatecache"); if ($recurse) { $offset = 0; $limit = 5000; $ids = $this->store->info($this->store->find($path, "", $limit, $offset)); while (is_array($ids) && count($ids)) { foreach ($ids as $value) { $eventData = new object(); $eventData = ar_events::fire('onbeforeclearprivatecache', $eventData, $value['type'], $value['path']); if (!$eventData) { continue; } $pcache->purge($value["id"]); ar_events::fire('onclearprivatecache', $eventData, $value['type'], $value['path']); } $offset += $limit; $ids = $this->store->info($this->store->find($path, "", $limit, $offset)); } } else { $eventData = new object(); $eventData = ar_events::fire('onbeforeclearprivatecache', $eventData, $this->type, $this->path); if ($eventData) { $pcache->purge($this->id); ar_events::fire('onclearprivatecache', $eventData, $this->type, $this->path); } } } // now clear all parents untill the current site $site = $this->currentsite($path); $project = $this->currentproject($path); if ($path != $site && $path != $project && $path != '/') { $parent = $this->make_path($path . '../'); $this->ClearCache($parent, $private, false); } } $recursed = array(); // filesystem cache image filenames are always lower case, so // use special path for that. Remember 'real' path name for // recursion and stuff $fs_path = strtolower($path); $nlslist = $AR->nls->list; $nlslist["."] = "default"; $cache_types[] = "normal"; $cache_types[] = "compressed"; $cache_types[] = "session"; global $cache_config, $store_config; $cachestore = new cache($cache_config); $filestore = $this->store->get_config("files"); foreach ($cache_types as $type) { foreach ($nlslist as $nls => $language) { // break away if nls doesn't exists // is dir is cached, so it should not cost more that it add's in speed if (!is_dir($filestore . "cache/{$type}/{$nls}")) { continue; } $fpath = $filestore . "cache/{$type}/{$nls}" . $fs_path; $hpath = $filestore . "cacheheaders/{$type}/{$nls}" . $fs_path; if ($dir = @dir($fpath)) { while (false !== ($entry = $dir->read())) { if ($entry != "." && $entry != "..") { if (is_file($fpath . $entry)) { @unlink($fpath . $entry); @unlink($hpath . $entry); $cachestore->delete("/" . $type . "/" . $nls . $fs_path . $entry); } else { if ($recurse && !$recursed[$entry]) { $this->ClearCache($path . $entry . "/", false, true); $recursed[$entry] = true; } } } } $dir->close(); // remove empty directory entry's, hide errors about directory entry's with content @rmdir($fpath); @rmdir($hpath); } else { if (file_exists(substr($fpath, 0, -1) . "=")) { @unlink(substr($fpath, 0, -1) . "="); @unlink(substr($hpath, 0, -1) . "="); $cachestore->delete("/" . $type . "/" . $nls . substr($fs_path, 0, -1) . "="); } } } } }
function buildThread($id, $return = false, $mod = false) { global $board, $config, $build_pages; $id = round($id); if (event('build-thread', $id)) { return; } if ($config['cache']['enabled'] && !$mod) { // Clear cache cache::delete("thread_index_{$board['uri']}_{$id}"); cache::delete("thread_{$board['uri']}_{$id}"); } if ($config['try_smarter'] && !$mod) { $build_pages[] = thread_find_page($id); } if (!$config['smart_build'] || $return || $mod) { $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { if (!isset($thread)) { $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); } else { $thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod)); } } // Check if any posts were found if (!isset($thread)) { error($config['error']['nonexistant']); } $hasnoko50 = $thread->postCount() >= $config['noko50_min']; $antibot = $mod || $return ? false : create_antibot($board['uri'], $id); $body = Element('thread.html', array('board' => $board, 'thread' => $thread, 'body' => $thread->build(), 'config' => $config, 'id' => $id, 'mod' => $mod, 'hasnoko50' => $hasnoko50, 'isnoko50' => false, 'antibot' => $antibot, 'boardlist' => createBoardlist($mod), 'return' => $mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])); // json api if ($config['api']['enabled']) { $api = new Api(); $json = json_encode($api->translateThread($thread)); $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; file_write($jsonFilename, $json); } } else { $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; file_unlink($jsonFilename); } if ($config['smart_build'] && !$return && !$mod) { $noko50fn = $board['dir'] . $config['dir']['res'] . sprintf($config['file_page50'], $id); file_unlink($noko50fn); file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $id)); } else { if ($return) { return $body; } else { $noko50fn = $board['dir'] . $config['dir']['res'] . sprintf($config['file_page50'], $id); if ($hasnoko50 || file_exists($noko50fn)) { buildThread50($id, $return, $mod, $thread, $antibot); } file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $id), $body); } } }
$orm->name('dialplans'); if (isset($dialplan["dialplan_uuid"])) { $orm->uuid($dialplan["dialplan_uuid"]); } $orm->save($dialplan); $dialplan_response = $orm->message; //remove the temporary permission $p->delete("dialplan_add", 'temp'); $p->delete("dialplan_detail_add", 'temp'); $p->delete("dialplan_edit", 'temp'); $p->delete("dialplan_detail_edit", 'temp'); //synchronize the xml config save_dialplan_xml(); //clear the cache $cache = new cache(); $cache->delete("dialplan:" . $destination_context); } else { //remove empty dialplan details from POST array so doesn't attempt to insert below unset($_POST["dialplan_details"]); } //get the destination_uuid if (strlen($dialplan_response['uuid']) > 0) { $_POST["dialplan_uuid"] = $dialplan_response['uuid']; } //add the dialplan permission $permission = "dialplan_edit"; $p = new permissions(); $p->add($permission, 'temp'); //save the destination $orm = new orm(); $orm->name('destinations');
$time = $_base->date->get(); $time->setDate($date[3], $date[2], $date[1]); $time->setTime($date[4], $date[5], $date[6]); } // kontroller beløp $amount = round(str_replace(",", ".", $_POST['amount']), 2); // ugyldig dato if (!$date) { $_base->page->add_message("Ugyldig dato.", "error"); } elseif ($amount <= 0) { $_base->page->add_message("Ugyldig beløp.", "error"); } elseif (isset($_POST['approve'])) { // legg til \Kofradia\DB::get()->exec("INSERT INTO donations SET d_up_id = " . ($up_id ? $up_id : 'NULL') . ", d_amount = {$amount}, d_time = " . $time->format("U")); // tøm cache cache::delete("donation_list"); $_base->page->add_message("Donasjonsoppføringen ble lagt til."); redirect::handle(); } else { echo box_start("Registrer donasjon", "xsmall") . ' <form action="" method="post"> <input type="hidden" name="up_id" value="' . $up_id . '" /> <input type="hidden" name="time" value="' . htmlspecialchars($_POST['time']) . '" /> <input type="hidden" name="amount" value="' . $amount . '" /> <dl class="dd_right"> <dt>Bruker</dt> <dd>' . ($player ? game::profile_link($player['up_id'], $player['up_name'], $player['up_access_level']) : 'Anonym') . '</dd> <dt>Tidspunkt</dt> <dd>' . $time->format(date::FORMAT_SEC) . '</dd> <dt>Beløp</dt> <dd>' . game::format_nok($amount) . '</dd>
//if ($action == "add") if ($action == "update") { $sql = " select c.call_block_number, d.domain_name from v_call_block as c "; $sql .= "JOIN v_domains as d ON c.domain_uuid=d.domain_uuid "; $sql .= "where c.domain_uuid = '" . $_SESSION['domain_uuid'] . "' "; $sql .= "and c.call_block_uuid = '{$call_block_uuid}'"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(); $result_count = count($result); if ($result_count > 0) { //set the domain_name $domain_name = $result[0]["domain_name"]; //clear the cache $cache = new cache(); $cache->delete("app:call_block:" . $domain_name . ":" . $call_block_number); } unset($prep_statement, $sql); $sql = "update v_call_block set "; $sql .= "call_block_name = '{$call_block_name}', "; $sql .= "call_block_number = '{$call_block_number}', "; $sql .= "call_block_action = '{$call_block_action}', "; $sql .= "call_block_enabled = '{$call_block_enabled}' "; $sql .= "where domain_uuid = '" . $_SESSION['domain_uuid'] . "' "; $sql .= "and call_block_uuid = '{$call_block_uuid}'"; $db->exec(check_sql($sql)); unset($sql); $_SESSION["message"] = $text['label-update-complete']; header("Location: call_block.php"); return; }
function mod_new_pm($username) { global $config, $mod; if (!hasPermission($config['mod']['create_pm'])) { error($config['error']['noaccess']); } $query = prepare("SELECT `id` FROM ``mods`` WHERE `username` = :username"); $query->bindValue(':username', $username); $query->execute() or error(db_error($query)); if (!($id = $query->fetchColumn())) { // Old style ?/PM: by user ID $query = prepare("SELECT `username` FROM ``mods`` WHERE `id` = :username"); $query->bindValue(':username', $username); $query->execute() or error(db_error($query)); if ($username = $query->fetchColumn()) { header('Location: ?/new_PM/' . $username, true, $config['redirect_http']); } else { error($config['error']['404']); } } if (isset($_POST['message'])) { $_POST['message'] = escape_markup_modifiers($_POST['message']); markup($_POST['message']); $query = prepare("INSERT INTO ``pms`` VALUES (NULL, :me, :id, :message, :time, 1)"); $query->bindValue(':me', $mod['id']); $query->bindValue(':id', $id); $query->bindValue(':message', $_POST['message']); $query->bindValue(':time', time()); $query->execute() or error(db_error($query)); if ($config['cache']['enabled']) { cache::delete('pm_unread_' . $id); cache::delete('pm_unreadcount_' . $id); } modLog('Sent a PM to ' . utf8tohtml($username)); header('Location: ?/', true, $config['redirect_http']); } mod_page(sprintf('%s %s', _('New PM for'), $username), 'mod/new_pm.html', array('username' => $username, 'id' => $id, 'token' => make_secure_link_token('new_PM/' . $username))); }
if (permission_exists('extension_add') || permission_exists('extension_edit')) { //synchronize configuration if (is_writable($_SESSION['switch']['extensions']['dir'])) { require_once "app/extensions/resources/classes/extension.php"; $ext = new extension(); $ext->xml(); unset($ext); } //write the provision files if (is_dir($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/app/provision')) { require_once "app/provision/provision_write.php"; $ext = new extension(); } //clear the cache $cache = new cache(); $cache->delete("directory:" . $extension . "@" . $user_context); if (strlen($number_alias) > 0) { $cache->delete("directory:" . $number_alias . "@" . $user_context); } } //show the action and redirect the user if ($action == "add") { //prepare for alternating the row style $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; //show the action and redirect the user if (count($generated_users) == 0) { //action add $_SESSION["message"] = $text['message-add']; header("Location: extension_edit.php?id=" . $extension_uuid);
public function del() { if (system::issetUrl(2) && is_numeric(system::url(2))) { // Одиночное удаление $obj = ormObjects::get(system::url(2)); if ($obj->isInheritor('user') && $obj->id != user::get('id')) { $this->sendMailDel($obj); cache::delete('user' . $obj->id); $obj->toTrash(); echo 'delete'; } } else { if (isset($_POST['objects'])) { // Множественное удаление while (list($id, $val) = each($_POST['objects'])) { if (is_numeric($id)) { $obj = ormObjects::get($id); if ($obj->isInheritor('user') && $obj->id != user::get('id')) { $this->sendMailDel($obj); cache::delete('user' . $obj->id); $obj->toTrash(); } } } echo 'delete'; } } system::stop(); }
function mod_8_settings($b) { global $config, $mod; //if ($b === 'infinity' && $mod['type'] !== ADMIN) // error('Settings temporarily disabled for this board.'); if (!in_array($b, $mod['boards']) and $mod['boards'][0] != '*') { error($config['error']['noaccess']); } if (!hasPermission($config['mod']['edit_settings'], $b)) { error($config['error']['noaccess']); } if (!openBoard($b)) { error("Could not open board!"); } $possible_languages = array_diff(scandir('inc/locale/'), array('..', '.', '.tx', 'README.md')); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $board_type = $_POST['board_type']; $imgboard = $board_type == 'imgboard'; $txtboard = $board_type == 'txtboard'; $fileboard = $board_type == 'fileboard'; $title = $_POST['title']; $subtitle = $_POST['subtitle']; $country_flags = isset($_POST['country_flags']) ? 'true' : 'false'; $field_disable_name = isset($_POST['field_disable_name']) ? 'true' : 'false'; $enable_embedding = isset($_POST['enable_embedding']) ? 'true' : 'false'; $force_image_op = $imgboard && isset($_POST['force_image_op']) ? 'true' : 'false'; $disable_images = $txtboard ? 'true' : 'false'; $poster_ids = isset($_POST['poster_ids']) ? 'true' : 'false'; $show_sages = isset($_POST['show_sages']) ? 'true' : 'false'; $auto_unicode = isset($_POST['auto_unicode']) ? 'true' : 'false'; $strip_combining_chars = isset($_POST['strip_combining_chars']) ? 'true' : 'false'; $allow_roll = isset($_POST['allow_roll']) ? 'true' : 'false'; $image_reject_repost = isset($_POST['image_reject_repost']) ? 'true' : 'false'; $image_reject_repost_in_thread = isset($_POST['image_reject_repost_in_thread']) ? 'true' : 'false'; $early_404 = isset($_POST['early_404']) ? 'true' : 'false'; $allow_delete = isset($_POST['allow_delete']) ? 'true' : 'false'; $allow_flash = $imgboard && isset($_POST['allow_flash']) ? '$config[\'allowed_ext_files\'][] = \'swf\';' : ''; $allow_pdf = $imgboard && isset($_POST['allow_pdf']) ? '$config[\'allowed_ext_files\'][] = \'pdf\';' : ''; $code_tags = isset($_POST['code_tags']) ? '$config[\'additional_javascript\'][] = \'js/code_tags/run_prettify.js\';$config[\'markup\'][] = array("/\\[code\\](.+?)\\[\\/code\\]/ms", "<code><pre class=\'prettyprint\' style=\'display:inline-block\'>\\$1</pre></code>");' : ''; $katex = isset($_POST['katex']) ? '$config[\'katex\'] = true;$config[\'additional_javascript\'][] = \'js/katex/katex.min.js\'; $config[\'markup\'][] = array("/\\[tex\\](.+?)\\[\\/tex\\]/ms", "<span class=\'tex\'>\\$1</span>"); $config[\'additional_javascript\'][] = \'js/katex-enable.js\';' : ''; $user_flags = isset($_POST['user_flags']) ? "if (file_exists('{$b}/flags.php')) { include 'flags.php'; }\n" : ''; $captcha = isset($_POST['captcha']) ? 'true' : 'false'; $force_subject_op = isset($_POST['force_subject_op']) ? 'true' : 'false'; $force_flag = isset($_POST['force_flag']) ? 'true' : 'false'; $tor_posting = isset($_POST['tor_posting']) ? 'true' : 'false'; $tor_image_posting = isset($_POST['tor_image_posting']) ? 'true' : 'false'; $robot_enable = isset($_POST['robot_enable']) ? 'true' : 'false'; $new_thread_capt = isset($_POST['new_thread_capt']) ? 'true' : 'false'; $oekaki = ($imgboard || $fileboard) && isset($_POST['oekaki']) ? 'true' : 'false'; $view_bumplock = isset($_POST['view_bumplock']) ? '-1' : 'MOD'; if ($tor_image_posting === 'true' && isset($_POST['meta_noindex'])) { error('Please index your board to enable this.'); } if ($_POST['locale'] !== 'en' && in_array($_POST['locale'], $possible_languages)) { $locale = "\$config['locale'] = '{$_POST['locale']}.UTF-8';"; } else { $locale = ''; } if (isset($_POST['max_images']) && (int) $_POST['max_images'] && (int) $_POST['max_images'] <= 5) { $_POST['max_images'] = (int) $_POST['max_images']; $multiimage = "\$config['max_images'] = {$_POST['max_images']};\n\t\t\t\t\t \$config['additional_javascript'][] = 'js/multi-image.js';"; } else { $multiimage = ''; } if (isset($_POST['custom_assets'])) { $assets = "\$config['custom_assets'] = true;\n\t\t\t\t \$config['spoiler_image'] = 'static/assets/{$b}/spoiler.png';\n\t\t\t\t \$config['image_deleted'] = 'static/assets/{$b}/deleted.png';\n\t\t\t\t \$config['no_file_image'] = 'static/assets/{$b}/no-file.png';\n\t\t\t\t"; } else { $assets = ''; } $file_board = ''; if ($fileboard) { $force_image_op = true; $file_board = "\$config['threads_per_page'] = 30;\n\t\t\t\t\t \$config['file_board'] = true;\n\t\t\t\t\t \$config['threads_preview'] = 0;\n\t\t\t\t \$config['threads_preview_sticky'] = 0;\n\t\t\t\t\t \$config['allowed_ext_files'] = array();\n"; if (isset($_POST['allowed_type'])) { foreach ($_POST['allowed_type'] as $val) { if (in_array($val, $config['fileboard_allowed_types'])) { $file_board .= "\$config['allowed_ext_files'][] = '{$val}';\n"; } } } if (isset($_POST['allowed_ext_op'])) { $file_board .= "\$config['allowed_ext_op'] = \$config['allowed_ext_files'];\n"; if (isset($_POST['allowed_ext_op_video'])) { $file_board .= "\$config['allowed_ext_op'][] = 'webm';\n\t\t\t\t\t\t\t\t\$config['allowed_ext_op'][] = 'mp4';\n"; } } if (isset($_POST['tag_id'])) { $file_board .= "\$config['allowed_tags'] = array();\n"; foreach ($_POST['tag_id'] as $id => $v) { $file_board .= "\$config['allowed_tags']["; $file_board .= 'base64_decode("'; $file_board .= base64_encode($_POST['tag_id'][$id]); $file_board .= '")'; $file_board .= "] = "; $file_board .= 'base64_decode("'; $file_board .= base64_encode($_POST['tag_desc'][$id]); $file_board .= '")'; $file_board .= ";\n"; } } } $anal_filenames = $fileboard && isset($_POST['anal_filenames']) ? "\$config['filename_func'] = 'filename_func';\n" : ''; $anonymous = base64_encode($_POST['anonymous']); $blotter = base64_encode(purify_html(html_entity_decode($_POST['blotter']))); $add_to_config = @file_get_contents($b . '/extra_config.php'); $replace = ''; if (isset($_POST['replace'])) { if (sizeof($_POST['replace']) > 200 || sizeof($_POST['with']) > 200) { error(_('Sorry, max 200 wordfilters allowed.')); } if (count($_POST['replace']) == count($_POST['with'])) { foreach ($_POST['replace'] as $i => $r) { if ($r !== '') { $w = $_POST['with'][$i]; if (strlen($w) > 255) { error(sprintf(_('Sorry, %s is too long. Max replacement is 255 characters'), utf8tohtml($w))); } $replace .= '$config[\'wordfilters\'][] = array(base64_decode(\'' . base64_encode($r) . '\'), base64_decode(\'' . base64_encode($w) . '\'));'; } } } if (is_billion_laughs($_POST['replace'], $_POST['with'])) { error(_('Wordfilters may not wordfilter previous wordfilters. For example, if a filters to bb and b filters to cc, that is not allowed.')); } } if (isset($_POST['hour_max_threads']) && (int) $_POST['hour_max_threads'] > 0 && (int) $_POST['hour_max_threads'] < 101) { $hour_max_threads = (int) $_POST['hour_max_threads']; } else { $hour_max_threads = 'false'; } if (isset($_POST['max_pages'])) { $mp = (int) $_POST['max_pages']; if ($mp > 25 || $mp < 1) { $max_pages = 15; } else { $max_pages = $mp; } } else { $max_pages = 15; } if (isset($_POST['reply_limit'])) { $rl = (int) $_POST['reply_limit']; if ($rl > 750 || $rl < 250 || $rl % 25) { $reply_limit = 250; } else { $reply_limit = $rl; } } else { $reply_limit = 250; } if (isset($_POST['max_newlines'])) { $mn = (int) $_POST['max_newlines']; if ($mn < 20 || $mn > 300) { $max_newlines = 0; } else { $max_newlines = $mn; } } else { $max_newlines = 0; } if (isset($_POST['min_body'])) { $mb = (int) $_POST['min_body']; if ($mb < 0 || $mb > 1024) { $min_body = 0; } else { $min_body = $mb; } } else { $min_body = 0; } if (!(strlen($title) < 40)) { error('Invalid title'); } if (!(strlen($subtitle) < 200)) { error('Invalid subtitle'); } $query = prepare('UPDATE ``boards`` SET `title` = :title, `subtitle` = :subtitle, `indexed` = :indexed, `public_bans` = :public_bans, `public_logs` = :public_logs, `8archive` = :8archive WHERE `uri` = :uri'); $query->bindValue(':title', $title); $query->bindValue(':subtitle', $subtitle); $query->bindValue(':uri', $b); $query->bindValue(':indexed', !isset($_POST['meta_noindex'])); $query->bindValue(':public_bans', isset($_POST['public_bans'])); $query->bindValue(':public_logs', (int) $_POST['public_logs']); $query->bindValue(':8archive', isset($_POST['8archive'])); $query->execute() or error(db_error($query)); $config_file = <<<EOT <?php \$config['country_flags'] = {$country_flags}; \$config['field_disable_name'] = {$field_disable_name}; \$config['enable_embedding'] = {$enable_embedding}; \$config['force_image_op'] = {$force_image_op}; \$config['disable_images'] = {$disable_images}; \$config['poster_ids'] = {$poster_ids}; \$config['show_sages'] = {$show_sages}; \$config['auto_unicode'] = {$auto_unicode}; \$config['strip_combining_chars'] = {$strip_combining_chars}; \$config['allow_roll'] = {$allow_roll}; \$config['image_reject_repost'] = {$image_reject_repost}; \$config['image_reject_repost_in_thread'] = {$image_reject_repost_in_thread}; \$config['early_404'] = {$early_404}; \$config['allow_delete'] = {$allow_delete}; \$config['anonymous'] = base64_decode('{$anonymous}'); \$config['blotter'] = base64_decode('{$blotter}'); \$config['stylesheets']['Custom'] = 'board/{$b}.css'; \$config['default_stylesheet'] = array('Custom', \$config['stylesheets']['Custom']); \$config['captcha']['enabled'] = {$captcha}; \$config['force_subject_op'] = {$force_subject_op}; \$config['force_flag'] = {$force_flag}; \$config['tor_posting'] = {$tor_posting}; \$config['tor_image_posting'] = {$tor_image_posting}; \$config['robot_enable'] = {$robot_enable}; \$config['new_thread_capt'] = {$new_thread_capt}; \$config['hour_max_threads'] = {$hour_max_threads}; \$config['reply_limit'] = {$reply_limit}; \$config['max_pages'] = {$max_pages}; \$config['max_newlines'] = {$max_newlines}; \$config['oekaki'] = {$oekaki}; \$config['min_body'] = {$min_body}; \$config['mod']['view_bumplock'] = {$view_bumplock}; {$code_tags} {$katex} {$replace} {$multiimage} {$allow_flash} {$allow_pdf} {$user_flags} {$assets} {$locale} {$anal_filenames} {$file_board} if (\$config['disable_images']) \t\$config['max_pages'] = 10000; {$add_to_config} EOT; // Clean up our CSS...no more expression() or off-site URLs. $clean_css = preg_replace('/expression\\s*\\(/', '', $_POST['css']); $matched = array(); preg_match_all("#{$config['link_regex']}#im", $clean_css, $matched); if (isset($matched[0])) { foreach ($matched[0] as $match) { $match_okay = false; foreach ($config['allowed_offsite_urls'] as $allowed_url) { if (strpos($match, $allowed_url) !== false && strpos($match, '#') === false && strpos($match, '?') === false && strpos($match, ';') === false) { $match_okay = true; } } if ($match_okay !== true) { error(sprintf(_("Off-site link \"%s\" is not allowed in the board stylesheet"), $match)); } } } //Filter out imports from sites with potentially unsafe content $match_imports = '@import[^;]*'; $matched = array(); preg_match_all("#{$match_imports}#im", $clean_css, $matched); $unsafe_import_urls = array('https://a.pomf.se/'); if (isset($matched[0])) { foreach ($matched[0] as $match) { $match_okay = true; foreach ($unsafe_import_urls as $unsafe_import_url) { if (strpos($match, $unsafe_import_url) !== false && strpos($match, '#') === false) { $match_okay = false; } } if ($match_okay !== true) { error(sprintf(_("Potentially unsafe import \"%s\" is not allowed in the board stylesheet"), $match)); } } } $query = query('SELECT `uri`, `title`, `subtitle` FROM ``boards`` WHERE `8archive` = TRUE'); file_write('8archive.json', json_encode($query->fetchAll(PDO::FETCH_ASSOC))); file_write($b . '/config.php', $config_file); file_write('stylesheets/board/' . $b . '.css', $clean_css); $_config = $config; unset($config['wordfilters']); // Faster than openBoard and bypasses cache...we're trusting the PHP output // to be safe enough to run with every request, we can eval it here. eval(str_replace('flags.php', "{$b}/flags.php", preg_replace('/^\\<\\?php$/m', '', $config_file))); // czaks: maybe reconsider using it, now that config is cached? // be smarter about rebuilds...only some changes really require us to rebuild all threads if ($_config['captcha']['enabled'] != $config['captcha']['enabled'] || $_config['new_thread_capt'] != $config['new_thread_capt'] || $_config['captcha']['extra'] != $config['captcha']['extra'] || $_config['blotter'] != $config['blotter'] || $_config['field_disable_name'] != $config['field_disable_name'] || $_config['show_sages'] != (isset($config['show_sages']) && $config['show_sages'])) { buildIndex(); $query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $b)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { buildThread($post['id']); } } modLog('Edited board settings', $b); } $query = prepare('SELECT * FROM boards WHERE uri = :board'); $query->bindValue(':board', $b); $query->execute() or error(db_error($query)); $board = $query->fetchAll()[0]; // Clean the cache if ($config['cache']['enabled']) { cache::delete('board_' . $board['uri']); cache::delete('all_boards'); cache::delete('config_' . $board['uri']); cache::delete('events_' . $board['uri']); unlink('tmp/cache/locale_' . $board['uri']); } $css = @file_get_contents('stylesheets/board/' . $board['uri'] . '.css'); mod_page(_('Board configuration'), 'mod/settings.html', array('board' => $board, 'css' => prettify_textarea($css), 'token' => make_secure_link_token('settings/' . $board['uri']), 'languages' => $possible_languages, 'allowed_urls' => $config['allowed_offsite_urls'])); }
$dialplan->dialplan_detail_type = 'lua'; //$dialplan->dialplan_detail_data = $call_flow_extension . ' LUA call_flow.lua'; $dialplan->dialplan_detail_data = 'call_flow.lua'; //$dialplan->dialplan_detail_break = ''; //$dialplan->dialplan_detail_inline = ''; $dialplan->dialplan_detail_group = '2'; $dialplan->dialplan_detail_order = '030'; $dialplan->dialplan_detail_add(); unset($dialplan); //save the xml save_dialplan_xml(); //apply settings reminder $_SESSION["reload_xml"] = true; //clear the cache $cache = new cache(); $cache->delete("dialplan:" . $call_flow_context); //set the message if ($action == "add") { $_SESSION["message"] = $text['message-add']; } if ($action == "update") { $_SESSION["message"] = $text['message-update']; } //redirect the browser header("Location: call_flows.php"); return; } } //if ($_POST["persistformvar"] != "true") } //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0)
if (permission_exists('extension_add') || permission_exists('extension_edit')) { //synchronize configuration if (is_writable($_SESSION['switch']['extensions']['dir'])) { require_once "app/extensions/resources/classes/extension.php"; $ext = new extension(); $ext->xml(); unset($ext); } //write the provision files if (is_dir($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/app/provision')) { require_once "app/provision/provision_write.php"; $ext = new extension(); } //clear the cache $cache = new cache(); $cache->delete("directory:" . $extension . "@" . $user_context); } //show the action and redirect the user if ($action == "add") { //prepare for alternating the row style $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; //show the action and redirect the user if (count($generated_users) == 0) { //action add $_SESSION["message"] = $text['message-add']; header("Location: extension_edit.php?id=" . $extension_uuid); } else { //auto-generate user with extension as login name require_once "resources/header.php";
private function clearCache() { cache::delete('comments' . $this->getObjId()); cache::delete('count_comments' . $this->getObjId()); }
public function set() { //set the global variable global $db; //determine whether to update the dial string $sql = "select * from v_extensions "; $sql .= "where domain_uuid = '" . $this->domain_uuid . "' "; $sql .= "and extension_uuid = '" . $this->extension_uuid . "' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); if (count($result) > 0) { foreach ($result as &$row) { $this->extension = $row["extension"]; $this->number_alias = $row["number_alias"]; $this->accountcode = $row["accountcode"]; $this->toll_allow = $row["toll_allow"]; $this->outbound_caller_id_name = $row["outbound_caller_id_name"]; $this->outbound_caller_id_number = $row["outbound_caller_id_number"]; } } unset($prep_statement); //set the dial string if ($this->forward_all_enabled == "true") { $dial_string = "{presence_id=" . $this->forward_all_destination . "@" . $_SESSION['domain_name']; $dial_string .= ",instant_ringback=true"; $dial_string .= ",domain_uuid=" . $_SESSION['domain_uuid']; $dial_string .= ",sip_invite_domain=" . $_SESSION['domain_name']; $dial_string .= ",domain_name=" . $_SESSION['domain_name']; $dial_string .= ",domain=" . $_SESSION['domain_name']; $dial_string .= ",extension_uuid=" . $this->extension_uuid; $dial_string .= ",toll_allow='" . $this->toll_allow . "'"; if (strlen($this->accountcode) > 0) { $dial_string .= ",sip_h_X-accountcode=" . $this->accountcode; $dial_string .= ",accountcode=" . $this->accountcode; } if (strlen($this->forward_caller_id_uuid) > 0) { $sql_caller = "select destination_number, destination_description from v_destinations where domain_uuid = '{$this->domain_uuid}' and destination_type = 'inbound' and destination_uuid = '{$this->forward_caller_id_uuid}'"; $prep_statement_caller = $db->prepare($sql_caller); if ($prep_statement_caller) { $prep_statement_caller->execute(); $row_caller = $prep_statement_caller->fetch(PDO::FETCH_ASSOC); if (strlen($row_caller['destination_description']) > 0) { $dial_string_caller_id_name = $row_caller['destination_description']; $dial_string .= ",origination_caller_id_name={$dial_string_caller_id_name}"; } if (strlen($row_caller['destination_number']) > 0) { $dial_string_caller_id_number = $row_caller['destination_number']; $dial_string .= ",origination_caller_id_number={$dial_string_caller_id_number}"; $dial_string .= ",outbound_caller_id_number={$dial_string_caller_id_number}"; } } } else { if ($_SESSION['cdr']['call_forward_fix']['boolean'] == "true") { $dial_string .= ",outbound_caller_id_name=" . $this->outbound_caller_id_name; $dial_string .= ",outbound_caller_id_number=" . $this->outbound_caller_id_number; $dial_string .= ",origination_caller_id_name=" . $this->outbound_caller_id_name; $dial_string .= ",origination_caller_id_number=" . $this->outbound_caller_id_number; } } $dial_string .= "}"; if (extension_exists($this->forward_all_destination)) { $dial_string .= "user/" . $this->forward_all_destination . "@" . $_SESSION['domain_name']; } else { if ($_SESSION['domain']['bridge']['text'] == "outbound" || $_SESSION['domain']['bridge']['text'] == "bridge") { $bridge = outbound_route_to_bridge($_SESSION['domain_uuid'], $this->forward_all_destination); $dial_string .= $bridge[0]; } elseif ($_SESSION['domain']['bridge']['text'] == "lcr") { $dial_string .= "lcr/" . $_SESSION['lcr']['profile']['text'] . "/" . $_SESSION['domain_name'] . "/" . $this->forward_all_destination; } elseif ($_SESSION['domain']['bridge']['text'] === "loopback") { $dial_string .= "loopback/" . $this->forward_all_destination; } else { $dial_string .= "loopback/" . $this->forward_all_destination; } } $this->dial_string = $dial_string; } else { $this->dial_string = ''; } //update the extension $sql = "update v_extensions set "; if (strlen($this->forward_all_destination) == 0 || $this->forward_all_enabled == "false") { if (strlen($this->forward_all_destination) == 0) { $sql .= "forward_all_destination = null, "; } $sql .= "dial_string = null, "; $sql .= "forward_all_enabled = 'false' "; } else { $sql .= "forward_all_destination = '{$this->forward_all_destination}', "; $sql .= "dial_string = '" . check_str($this->dial_string) . "', "; $sql .= "forward_all_enabled = 'true' "; } $sql .= "where domain_uuid = '{$this->domain_uuid}' "; $sql .= "and extension_uuid = '{$this->extension_uuid}' "; if ($this->debug) { echo $sql; } $db->exec(check_sql($sql)); unset($sql); //delete extension from memcache $cache = new cache(); $cache->delete("directory:" . $this->extension . "@" . $this->domain_name); if (strlen($this->number_alias) > 0) { $cache->delete("directory:" . $this->number_alias . "@" . $this->domain_name); } }
} //update the destination dialplan_uuid if (strlen($destination_uuid) > 0) { $sql = "update v_destinations set "; $sql .= "dialplan_uuid = '" . $dialplan_uuid . "' "; $sql .= "where domain_uuid = '" . $_SESSION['domain_uuid'] . "' "; $sql .= "and destination_uuid = '" . $destination_uuid . "' "; $db->exec(check_sql($sql)); unset($sql); } //commit the atomic transaction $count = $db->exec("COMMIT;"); //returns affected rows //clear the cache $cache = new cache(); $cache->delete("dialplan:public"); //synchronize the xml config save_dialplan_xml(); //redirect message $_SESSION["message"] = $text['confirm-update-complete']; header("Location: " . PROJECT_PATH . "/app/dialplan/dialplans.php?app_uuid=c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4"); return; } //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //initialize the destinations object $destination = new destinations(); ?> <script type="text/javascript"> <!-- function type_onchange(dialplan_detail_type) {
echo "</pre>\n"; exit; } //save the ivr menu $ivr = new ivr_menu(); $ivr->domain_uuid = $_SESSION["domain_uuid"]; if (strlen($ivr_menu_uuid) > 0) { $ivr->ivr_menu_uuid = $ivr_menu_uuid; } $response = $ivr->save($_POST); if (strlen($response['uuid']) > 0) { $ivr_menu_uuid = $response['uuid']; } //clear the cache $cache = new cache(); $cache->delete("dialplan:" . $_SESSION["context"]); $cache->delete("configuration:ivr.conf:" . $ivr_menu_uuid); //redirect the user $_SESSION["message"] = $text['message-update']; header("Location: ivr_menu_edit.php?id=" . $ivr_menu_uuid); return; } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //initialize the destinations object $destination = new destinations(); //pre-populate the form if (strlen($ivr_menu_uuid) == 0) { $ivr_menu_uuid = check_str($_REQUEST["id"]); }
function remove_config_from_cache($name) { $cache = new cache(); $cache->delete($name); $hostname = trim(event_socket_request_cmd('api switchname')); if ($hostname) { $cache->delete($name . ':' . $hostname); } }
$array['dialplan_details'][$x]['dialplan_detail_group'] = $row["dialplan_detail_group"] != '' ? $row["dialplan_detail_group"] : '0'; $array['dialplan_details'][$x]['dialplan_detail_order'] = $row["dialplan_detail_order"]; } $x++; } //add or update the database if ($_POST["persistformvar"] != "true") { $orm = new orm(); $orm->name('dialplans'); $orm->uuid($dialplan_uuid); $orm->save($array); //$message = $orm->message; } //clear the cache $cache = new cache(); $cache->delete("dialplan:" . $dialplan_context); //synchronize the xml config save_dialplan_xml(); //set the message if ($action == "add") { $_SESSION['message'] = $text['message-add']; } else { if ($action == "update") { $_SESSION['message'] = $text['message-update']; } } header("Location: ?id=" . $dialplan_uuid . ($app_uuid != '' ? "&app_uuid=" . $app_uuid : null)); exit; } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form
$database->fields['domain_uuid'] = $_SESSION['domain_uuid']; $database->fields['dialplan_uuid'] = $dialplan_uuid; $database->fields['dialplan_detail_uuid'] = uuid(); $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction $database->fields['dialplan_detail_type'] = 'lua'; $database->fields['dialplan_detail_data'] = 'app.lua ring_groups'; $database->fields['dialplan_detail_order'] = '030'; $database->add(); //save the xml save_dialplan_xml(); //apply settings reminder $_SESSION["reload_xml"] = true; //clear the cache $cache = new cache(); $cache->delete("dialplan:" . $ring_group_context); //set the message if ($action == "add") { //save the message to a session variable $_SESSION['message'] = $text['message-add']; //redirect the browser header("Location: ring_group_edit.php?id={$ring_group_uuid}"); exit; } if ($action == "update") { //save the message to a session variable $_SESSION['message'] = $text['message-update']; } } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form
$dialplan->dialplan_detail_type = 'lua'; //$dialplan->dialplan_detail_data = $call_flow_extension . ' LUA call_flow.lua'; $dialplan->dialplan_detail_data = 'call_flow.lua'; //$dialplan->dialplan_detail_break = ''; //$dialplan->dialplan_detail_inline = ''; $dialplan->dialplan_detail_group = '2'; $dialplan->dialplan_detail_order = '030'; $dialplan->dialplan_detail_add(); unset($dialplan); //save the xml save_dialplan_xml(); //apply settings reminder $_SESSION["reload_xml"] = true; //clear the cache $cache = new cache(); $cache->delete("memcache delete dialplan:" . $call_flow_context); //set the message if ($action == "add") { $_SESSION["message"] = $text['message-add']; } if ($action == "update") { $_SESSION["message"] = $text['message-update']; } //redirect the browser header("Location: call_flows.php"); return; } } //if ($_POST["persistformvar"] != "true") } //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0)
$query = prepare('INSERT INTO ``mods`` VALUES (NULL, :username, :password, :salt, :type, :boards, :email)'); $query->bindValue(':username', $username); $query->bindValue(':password', $password); $query->bindValue(':salt', $salt); $query->bindValue(':type', 20); $query->bindValue(':boards', $uri); $query->bindValue(':email', $email); $query->execute() or error(db_error($query)); $query = prepare('INSERT INTO ``boards`` (`uri`, `title`, `subtitle`) VALUES (:uri, :title, :subtitle)'); $query->bindValue(':uri', $_POST['uri']); $query->bindValue(':title', $_POST['title']); $query->bindValue(':subtitle', $_POST['subtitle']); $query->execute() or error(db_error($query)); $query = Element('posts.sql', array('board' => $uri)); query($query) or error(db_error()); if (!openBoard($_POST['uri'])) { error(_("Couldn't open board after creation.")); } if ($config['cache']['enabled']) { cache::delete('all_boards'); } // Build the board buildIndex(); rebuildThemes('boards'); $query = prepare("INSERT INTO ``board_create``(uri) VALUES(:uri)"); $query->bindValue(':uri', $uri); $query->execute() or error(db_error()); _syslog(LOG_NOTICE, "New board: {$uri}"); $body = Element("8chan/create_success.html", array("config" => $config, "password" => $_POST['password'], "uri" => $uri)); echo Element("page.html", array("config" => $config, "body" => $body, "title" => _("Success"), "subtitle" => _("This was a triumph"))); }
if (strlen($vm_password) > 0) { $sql = "update v_voicemails set "; $sql .= "voicemail_password = '******' "; $sql .= "where domain_uuid = '{$domain_uuid}' "; if (is_numeric($extension)) { $sql .= "and voicemail_id = '{$extension}'"; } else { $sql .= "and voicemail_id = '{$number_alias}'"; } $db->exec(check_sql($sql)); unset($sql); } } //clear the cache $cache = new cache(); $cache->delete("directory:" . $extension . "@" . $_SESSION['domain_name']); //set message and redirect user if ($action == "add") { $_SESSION["message"] = $text['message-add']; } if ($action == "update") { $_SESSION["message"] = $text['message-update']; } header("Location: index.php"); return; } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if ($_POST["persistformvar"] != "true") {
/** * Delete the given key from the cache. * * @param string|int $key The key to delete. * @param bool $recurse When set to true the key will also be deleted from all stacked cache loaders and their stores. * This happens by default and ensure that all the caches are consistent. It is NOT recommended to change this. * @return bool True of success, false otherwise. */ public function delete($key, $recurse = true) { if ($this->requirelockingwrite && !$this->acquire_lock($key)) { return false; } $result = parent::delete($key, $recurse); if ($this->requirelockingwrite && !$this->release_lock($key)) { debugging('Failed to release cache lock on delete operation... this should not happen.', DEBUG_DEVELOPER); } return $result; }
$sql .= "where sip_profile_uuid = '{$sip_profile_uuid}'"; $db->exec(check_sql($sql)); unset($sql); } //if ($action == "update") //get the hostname if ($sip_profile_name == nul) { $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $switch_cmd = "hostname"; $sip_profile_hostname = event_socket_request($fp, 'api ' . $switch_cmd); } } //clear the cache $cache = new cache(); $cache->delete("configuration:sofia.conf:" . $sip_profile_hostname); //redirect the browser $_SESSION["message"] = $text['message-update']; header("Location: sip_profiles.php"); return; } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { $sip_profile_uuid = $_GET["id"]; $sql = "select * from v_sip_profiles "; $sql .= "where sip_profile_uuid = '{$sip_profile_uuid}' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute();
static function clearCache() { cache::delete('global-settings'); }
/** * Add a dialplan for call center * @var string $domain_uuid the multi-tenant id * @var string $value string to be cached */ public function dialplan() { //delete previous dialplan if (strlen($this->dialplan_uuid) > 0) { //delete the previous dialplan $sql = "delete from v_dialplans "; $sql .= "where dialplan_uuid = '" . $this->dialplan_uuid . "' "; $sql .= "and domain_uuid = '" . $this->domain_uuid . "' "; $this->db->exec($sql); $sql = "delete from v_dialplan_details "; $sql .= "where dialplan_uuid = '" . $this->dialplan_uuid . "' "; $sql .= "and domain_uuid = '" . $this->domain_uuid . "' "; $this->db->exec($sql); unset($sql); } unset($prep_statement); //build the dialplan array $dialplan["app_uuid"] = "95788e50-9500-079e-2807-fd530b0ea370"; $dialplan["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_name"] = $this->queue_name != '' ? $this->queue_name : format_phone($this->destination_number); $dialplan["dialplan_number"] = $this->destination_number; $dialplan["dialplan_context"] = $_SESSION['context']; $dialplan["dialplan_continue"] = "false"; $dialplan["dialplan_order"] = "210"; $dialplan["dialplan_enabled"] = "true"; $dialplan["dialplan_description"] = $this->queue_description; $dialplan_detail_order = 10; //add the public condition $y = 1; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "\${caller_id_name}"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "^([^#]+#)(.*)\$"; $dialplan["dialplan_details"][$y]["dialplan_detail_break"] = "never"; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "caller_id_name=\$2"; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "^" . $this->destination_number . "\$"; $dialplan["dialplan_details"][$y]["dialplan_detail_break"] = ""; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "answer"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = ""; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "hangup_after_bridge=true"; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; if (strlen($this->queue_cid_prefix) > 0) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "effective_caller_id_name=" . $this->queue_cid_prefix . "#\${caller_id_name}"; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; } $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "callcenter"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $this->queue_name . '@' . $_SESSION["domain_name"]; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; if (strlen($this->queue_timeout_action) > 0) { $action_array = explode(":", $this->queue_timeout_action); $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $action_array[0]; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = substr($this->queue_timeout_action, strlen($action_array[0]) + 1, strlen($this->queue_timeout_action)); $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; } $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "hangup"; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = ""; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; //add the dialplan permission $p = new permissions(); $p->add("dialplan_add", 'temp'); $p->add("dialplan_detail_add", 'temp'); $p->add("dialplan_edit", 'temp'); $p->add("dialplan_detail_edit", 'temp'); //save the dialplan $orm = new orm(); $orm->name('dialplans'); $orm->save($dialplan); $dialplan_response = $orm->message; $this->dialplan_uuid = $dialplan_response['uuid']; //if new dialplan uuid then update the call center queue $sql = "update v_call_center_queues "; $sql .= "set dialplan_uuid = '" . $this->dialplan_uuid . "' "; $sql .= "where call_center_queue_uuid = '" . $this->call_center_queue_uuid . "' "; $sql .= "and domain_uuid = '" . $this->domain_uuid . "' "; $this->db->exec($sql); unset($sql); //remove the temporary permission $p->delete("dialplan_add", 'temp'); $p->delete("dialplan_detail_add", 'temp'); $p->delete("dialplan_edit", 'temp'); $p->delete("dialplan_detail_edit", 'temp'); //synchronize the xml config save_dialplan_xml(); //clear the cache $cache = new cache(); $cache->delete("dialplan:" . $_SESSION['context']); //return the dialplan_uuid return $dialplan_response; }