function get_pasien_check($val) { $val[tgl_periksa_tgl_start] = empty($val[tgl_periksa_tgl_start])?1:$val[tgl_periksa_tgl_start]; $val[tgl_periksa_bln_start] = empty($val[tgl_periksa_bln_start])?1:$val[tgl_periksa_bln_start]; $val[tgl_periksa_tgl_end] = empty($val[tgl_periksa_tgl_end])?1:$val[tgl_periksa_tgl_end]; $val[tgl_periksa_bln_end] = empty($val[tgl_periksa_bln_end])?1:$val[tgl_periksa_bln_end]; $objResponse = new xajaxResponse; $tgl_start = strtotime($val[tgl_periksa_thn_start] . "-" . $val[tgl_periksa_bln_start] . "-" . $val[tgl_periksa_tgl_start]); $tgl_end = strtotime($val[tgl_periksa_thn_end] . "-" . $val[tgl_periksa_bln_end] . "-" . $val[tgl_periksa_tgl_end]); if(!checkdate($val[tgl_periksa_bln_start], $val[tgl_periksa_tgl_start], $val[tgl_periksa_thn_start])) { $objResponse->addAlert("Tanggal Awal Tidak Valid"); $objResponse->addScriptCall("fokus", "tgl_periksa_tgl_start"); } elseif(!checkdate($val[tgl_periksa_bln_end], $val[tgl_periksa_tgl_end], $val[tgl_periksa_thn_end])) { $objResponse->addAlert("Tanggal Akhir Tidak Valid"); $objResponse->addScriptCall("fokus", "tgl_periksa_tgl_start"); } elseif($tgl_start > $tgl_end) { $objResponse->addAlert("Tanggal Awal Harus Kurang Dari Tanggal Akhir"); $objResponse->addScriptCall("fokus", "tgl_periksa_tgl_start"); } else { $objResponse->addScriptCall("xajax_get_pasien", $val); } return $objResponse; }
function processPersonalData($aFormValues) { $objResponse = new xajaxResponse(); $bError = false; if (trim($aFormValues['firstName']) == "") { $objResponse->addAlert("Please enter your first name."); $bError = true; } if (trim($aFormValues['lastName']) == "") { $objResponse->addAlert("Please enter your last name."); $bError = true; } if (!preg_match("/^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\\.[_a-z0-9-]+)*@[a-z??????0-9]+(-[a-z??????0-9]+)*(\\.[a-z??????0-9-]+)*(\\.[a-z]{2,4})\$/i", $aFormValues['email'])) { $objResponse->addAlert("Please enter a valid email address."); $bError = true; } if (!$bError) { $_SESSION['newaccount']['firstname'] = $aFormValues['firstName']; $_SESSION['newaccount']['lastname'] = $aFormValues['lastName']; $_SESSION['newaccount']['email'] = $aFormValues['email']; $objResponse->addAssign("formDiv", "style.textAlign", "center"); $sForm = "Account created.<br />Thank you."; $objResponse->addAssign("formDiv", "innerHTML", $sForm); $objResponse->addAssign("formWrapper", "style.backgroundColor", "rgb(67,97,149)"); $objResponse->addAssign("outputDiv", "innerHTML", "\$_SESSION:<pre>" . var_export($_SESSION, true) . "</pre>"); } else { $objResponse->addAssign("submitButton", "value", "done"); $objResponse->addAssign("submitButton", "disabled", false); } return $objResponse; }
/** * OpenX Schema Management Utility * * @author Monique Szpak <*****@*****.**> * * $Id$ * */ function testAjax($form) { $objResponse = new xajaxResponse(); $objResponse->addAlert('testing ajax'); $objResponse->addAlert(print_r($form, true)); return $objResponse; }
function testClassMethod($formData) { $objResponse = new xajaxResponse(); $objResponse->addAlert("This is a class method."); $objResponse->addAlert("formData: " . print_r($formData, true)); $objResponse->addAssign("submittedDiv", "innerHTML", nl2br(print_r($formData, true))); return $objResponse->getXML(); }
function simpan_tracer_check($value) { $cleaner = new FormCleaner; $cleaner->setValue($value); $cleaner->clean(); $val = $cleaner->getValue(); $objResponse = new xajaxResponse; if(!$val[no_rm]) { $objResponse->addAlert("Silakan Isi Nomor Rekam Medis"); $objResponse->addScriptCall("fokus", "no_rm"); } elseif(!$val[peminjam]) { $objResponse->addAlert("Silakan Isi Peminjam"); $objResponse->addScriptCall("fokus", "peminjam"); } else { $kon = new Konek; $arr_no_rm = explode("\n", $val[no_rm]); $str_no_rm = str_replace("\n", ", ", $val[no_rm]); //$objResponse->addAlert($str_no_rm); $kon->sql = " SELECT CONCAT_WS('-', SUBSTRING(trc.pasien_id, 1,2), SUBSTRING(trc.pasien_id, 3,2), SUBSTRING(trc.pasien_id, 5,2), SUBSTRING(trc.pasien_id, 7,2)) as no_rm, kmr.nama as nama_kamar, trc.peminjam as peminjam, DATE_FORMAT(trc.tgl_keluar, '%d/%m/%y') as tgl_keluar, p.nama as nama FROM tracer trc LEFT JOIN kunjungan_kamar kk ON (kk.id = trc.kunjungan_kamar_id) LEFT JOIN kamar kmr ON (kmr.id = kk.kamar_id) JOIN pasien p ON (p.id = trc.pasien_id) WHERE trc.pasien_id IN (".$str_no_rm.") AND trc.tgl_kembali IS NULL "; $kon->execute(); $data = $kon->getAll(); if(!empty($data)) { $str = "\n"; for($i=0;$i<sizeof($data);$i++) { $str .= "---------------------------------------\n"; $str .= "No RM : " . $data[$i][no_rm] . "\n"; $str .= "Pasien : " . $data[$i][nama] . "\n"; $str .= "Tgl Keluar : " . $data[$i][tgl_keluar] . "\n"; if( $data[$i][peminjam]) $str .= "Peminjam : " . $data[$i][peminjam] . "\n"; if( $data[$i][nama_kamar]) $str .= "Pelayanan : " . $data[$i][nama_kamar] . "\n"; $str .= "---------------------------------------\n"; } $objResponse->addAlert("Data Tidak Dapat Disimpan.\nNomor Rekam Medis Berikut Belum Kembali Ke Rak Penyimpanan :\n" . $str); $objResponse->addScriptCall("fokus", "no_rm"); } else { $objResponse->addScriptCall("xajax_simpan_tracer", $val, $arr_no_rm); } } return $objResponse; }
function preMethod($funcName, $args) { $objResponse = new xajaxResponse(); if ($args[1] == 0) { $objResponse->addAlert($this->message . ", which will now call " . $funcName); return $objResponse; } $objResponse->addAlert($this->message . ", which will now end the request."); return array(false, $objResponse); }
function confirmTest() { $objResponse = new xajaxResponse(); $objResponse->addAlert("Here is an alert."); $objResponse->addConfirmCommands(2, "Are you sure you want to show two (2) more alerts?"); $objResponse->addAlert("This will only happen if the user presses OK."); $objResponse->addAlert("This also will only happen if the user presses OK."); $objResponse->addAlert("This will always happen."); return $objResponse->getXML(); }
function nuevaCuenta($datos) { $objResponse = new xajaxResponse(); $controlCuenta = new ManejadorCuenta(); $resultado = $controlCuenta->registrarNuevaCuenta($datos[select], $datos[nombre], $datos[des]); if ($resultado) { $objResponse->addAlert("Nueva Cuenta registrada con exito"); } else { $objResponse->addAlert("Error: La cuenta ya existe"); } return $objResponse; }
function sendmail($formValues, $mailbody) { $resp = new xajaxResponse(); $resp->addAssign("state", "innerHTML", "<img src=\"images/loading.gif\">正在发送..."); if (send_mail($formValues['mailto'], $formValues['subject'], $mailbody)) { $resp->addAssign("state", "innerHTML", ""); $resp->addAlert("send ok"); } else { $resp->addAlert($mailbody); } return $resp; }
function enviar_mail($formulario) { $respuesta = new xajaxResponse('utf-8'); if ($formulario['nombre'] == "") { $error = "Por favor dinos tu nombre"; } elseif ($formulario['email'] == "") { $error = "Por favor escribe un correo electrónico para comunicarnos"; } elseif ($formulario['telefono'] == "") { $error = "Necesitamos un número telefónico para comunicarnos"; } elseif ($formulario['mensaje'] == "") { $error = "Cual es tu mensaje ?"; } else { $error = ""; } if ($error != "") { $respuesta->addAlert("{$error}"); return $respuesta; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: NuestraRed.org <*****@*****.**>\r\n"; $headers .= "Reply-To: correo@nuestrared.org\r\n"; $headers .= "Return-path: correo@nuestrared.org\r\n"; $headers .= "Cc: correo@nuestrared.org" . "\r\n"; $asunto = "Mensaje de Nuestra Red "; $cuerpo = "\n<img src='http://nuestrared.org/images/logo.png' style='width:100%'>\nGracias <strong>{$formulario['nombre']}</strong> por comunicarse con <a href='NuestraRed.org'>NuestraRed.org</a>\n<div>\n<h3>{$asunto}</h3>\n<li><strong>Nombre</strong> {$formulario['nombre']}</li>\n<li><strong>Email</strong> {$formulario['email']}</li>\n<li><strong>Teléfono</strong> {$formulario['telefono']}</li>\n<li><strong>Mensaje</strong> {$formulario['mensaje']}</li>\n</div> \n<p>Sigue en contacto con <a href='NuestraRed.org'>NuestraRed.org</a></p>\n\n"; if (mail("{$formulario['email']}", "{$asunto}", "{$cuerpo}", "{$headers}")) { $mensaje = "{$cuerpo}"; } else { $mensaje = "<div class='alert alert-danger'><h2>Error enviando correo </h2>"; } $respuesta->addAssign("div_contacto", "innerHTML", "{$mensaje}"); //$respuesta->addAlert("Hola Mundo"); return $respuesta; }
function test() { $objResponse = new xajaxResponse(); $objResponse->addAlert("hallo"); $objResponse->addAssign('testButton', 'label', 'Success!'); return $objResponse->getXML(); }
function myErrorRiddenFunction() { $value = $silly['nuts']; $objResponse = new xajaxResponse(); $objResponse->addAlert("Bad array value: {$value}"); include "file_doesnt_exist.php"; return $objResponse->getXML(); }
function testForm($formData, $strText) { global $useEncoding, $htmlEntities; $objResponse = new xajaxResponse($useEncoding, $htmlEntities); $objResponse->addAlert("formData: " . print_r($formData, true) . $strText); $objResponse->addAssign("submittedDiv", "innerHTML", nl2br(print_r($formData, true)) . '<br /><br />' . $strText); return $objResponse->getXML(); }
function asigna($ultimo) { $respuesta = new xajaxResponse(); javascript: alert("funciona"); $MSG = "Datos asignados con exito"; $respuesta->addAlert($MSG); return $respuesta; }
function simpan_perujuk_check($value) { $objResponse = new xajaxResponse(); $value[nama] = addslashes(trim($value[nama])); if(!$value[nama]) $objResponse->addAlert("Silakan Isi Nama Perujuk."); else $objResponse->addScriptCall("xajax_simpan_perujuk", $value); return $objResponse; }
function buscar($busqueda) { $respuesta = new xajaxResponse(); $conn = new conexionBD(); $sql = "SELECT * FROM profesores WHERE Nombre LIKE '%{$busqueda}%'"; if (!$conn->EjecutarSQL($sql)) { $MSG = "Ha ocurrido un error al buscar en la base de datos.\nPor favor, intentelo nuevamente."; } $respuesta->addAlert("Buscando: " . $sql); return $respuesta; }
function testForm($strText, $formData, $arrArray) { global $useEncoding, $htmlEntities; $objResponse = new xajaxResponse($useEncoding, $htmlEntities); $data = "Text:\n" . $strText; $data .= "\n\nFormData:\n" . print_r($formData, true); $data .= "\n\nArray:\n" . print_r($arrArray, true); $objResponse->addAlert($data); $objResponse->addAssign("submittedDiv", "innerHTML", "<pre>" . $data . "</pre>"); return $objResponse->getXML(); }
function chkPassword($value) { $mtview_controller = new MTViewController(); $matchResult = $mtview_controller->xajaxObjCall($value, 'CPW', 'password'); $objResponse = new xajaxResponse(); if ($matchResult) { $objResponse->addScript("addUpdate();"); } else { $objResponse->addAlert($GLOBALS['lang_Admin_Users_ErrorsPasswordMismatch']); } return $objResponse->getXML(); }
function insertInputAfter($aInputData) { $sId = $aInputData['inputId']; $sName = $aInputData['inputName']; $sType = $aInputData['inputType']; $sValue = $aInputData['inputValue']; $sAfter = $aInputData['inputAfter']; $objResponse = new xajaxResponse(); $objResponse->addAlert("inputData: " . print_r($aInputData, true)); $objResponse->addInsertInputAfter($sAfter, $sType, $sName, $sId); $objResponse->addAssign($sId, "value", $sValue); return $objResponse->getXML(); }
function showOutput() { $testResponse = new xajaxResponse(); $testResponse->addAlert("Hello"); // $testResponseOutput = htmlspecialchars($testResponse->getXML()); $testResponse2 = new xajaxResponse(); $testResponse2->loadXML($testResponse->getXML()); $testResponse2->addReplace("this", "is", "a", "replacement"); $testResponseOutput = htmlspecialchars($testResponse2->getXML()); $objResponse = new xajaxResponse(); $objResponse->addAssign("submittedDiv", "innerHTML", $testResponseOutput); return $objResponse; }
function deleteEntry($entry_id) { $CI =& get_instance(); $CI->load->model('feedback_model'); $xajax_response = new xajaxResponse(); if (is_numeric($entry_id) && $CI->feedback_model->DeleteFeedback($entry_id)) { $xajax_response->addAssign('new_entries', 'innerHTML', $CI->feedback_model->GetFeedbackCount()); $xajax_response->addAssign('deleted_entries', 'innerHTML', $CI->feedback_model->GetFeedbackCount(1)); $xajax_response->addAssign('feedback' . $entry_id, 'innerHTML', 'DELETED!'); $xajax_response->addScript('Effect.BlindUp(\'container' . $entry_id . '\');'); } else { $xajax_response->addAlert('Error deleting entry ' . $entry_id . ', reload the page and try again.'); } return $xajax_response; }
function borrar() { if ($flag == 0) { $conn->EjecutarSQL("COMMIT TRANSACTION A1"); $MSG = "Datos borrados con exito"; } $respuesta->addAlert($MSG); return $respuesta; // ajax = objetoAjax(); $respuesta = new xajaxResponse(); ajax . open("GET", "eliminar.php"); $MSG = "cambiando de pagina"; $respuesta->addAlert($MSG); return $respuesta; }
function simpan_pasien_check($value) { $objResponse = new xajaxResponse(); $cleaner = new FormCleaner; $cleaner->setValue($value); $cleaner->clean(); $new_value = $cleaner->getValue(); if(!$new_value[nama]) { $objResponse->addAlert("Silakan Isi Nama Pasien."); $objResponse->addScriptCall("fokus", "nama"); } elseif(!checkdate($new_value[tgl_lahir_bln],$new_value[tgl_lahir_tgl],$new_value[tgl_lahir_thn])) { $objResponse->addAlert("Tanggal Lahir Tidak Valid."); $objResponse->addScriptCall("fokus", "tgl_lahir_tgl"); } elseif(!$new_value[sex]) { $objResponse->addAlert("Silakan Isi Jenis Kelamin Pasien."); $objResponse->addScriptCall("fokus", "sex"); } elseif(!$new_value[agama]) { $objResponse->addAlert("Silakan Isi Agama Pasien."); $objResponse->addScriptCall("fokus", "agama"); } elseif(!$new_value[pendidikan_id]) { $objResponse->addAlert("Silakan Isi Pendidikan Pasien."); $objResponse->addScriptCall("fokus", "pendidikan_id"); } elseif(!$new_value[pekerjaan_id]) { $objResponse->addAlert("Silakan Isi Pekerjaan Pasien."); $objResponse->addScriptCall("fokus", "pekerjaan_id"); } elseif(!$new_value[status_nikah]) { $objResponse->addAlert("Silakan Isi Status Nikah Pasien."); $objResponse->addScriptCall("fokus", "status_nikah"); } elseif(!$new_value[alamat]) { $objResponse->addAlert("Silakan Isi Alamat Pasien."); $objResponse->addScriptCall("fokus", "alamat"); } elseif(!$new_value[propinsi_id]) { $objResponse->addAlert("Silakan Isi Propinsi Pasien."); $objResponse->addScriptCall("fokus", "propinsi_id"); } elseif(!$new_value[kabupaten_id]) { $objResponse->addAlert("Silakan Isi Kabupaten Pasien."); $objResponse->addScriptCall("fokus", "kabupaten_id"); } elseif(!$new_value[kecamatan_id]) { $objResponse->addAlert("Silakan Isi Kecamatan Pasien."); $objResponse->addScriptCall("fokus", "kecamatan_id"); } elseif(!$new_value[desa_id]) { $objResponse->addAlert("Silakan Isi Kelurahan Pasien."); $objResponse->addScriptCall("fokus", "desa_id"); } else { $objResponse->addScriptCall("xajax_simpan_pasien", $new_value); } return $objResponse; }
function updateWall() { $objResponse = new xajaxResponse(); if (file_exists(DATA_FILE)) { $aFile = @file(DATA_FILE); if (!$aFile) { $objResponse->addAlert("ERROR: the graffiti data file could not be written to the " . dirname(realpath(DATA_FILE)) . " folder."); return $objResponse; } $sHtmlSave = implode("\n", array_slice($aFile, -MAX_SCRIBBLES)); $sHtmlSave = str_replace("\n\n", "\n", $sHtmlSave); } else { $sHtmlSave = ""; $aFile = array(); } $rFile = @fopen(DATA_FILE, "w+"); if (!$rFile) { $objResponse->addAlert("ERROR: the graffiti data file could not be written to the " . dirname(realpath(DATA_FILE)) . " folder."); return $objResponse; } fwrite($rFile, $sHtmlSave); fclose($rFile); $sHtml = implode("\n", array_reverse(array_slice($aFile, -MAX_SCRIBBLES))); $objResponse->addAssign("theWall", "innerHTML", $sHtml); return $objResponse; }
function cambiar_password($formulario) { // if ( !isset ( $_SESSION['id'] ) ) { return;} $respuesta = new xajaxResponse('utf-8'); $formulario = mysql_seguridad($formulario); $actual = $formulario[password_actual]; $nuevo = $formulario[password_nuevo]; $confirmacion = $formulario[password_confirmacion]; $firma = $formulario[firma_recuperacion]; $firma_recuperacion = remplacetas("usuarios", "firma_recuperacion", $formulario[firma_recuperacion], "firma_recuperacion"); if (isset($firma)) { $actual = $firma; $id_usuario = $firma_recuperacion[1]; } else { $id_usuario = $_SESSION[id]; } $verifica = remplacetas("usuarios", "id", $_SESSION[id], "passwd"); $size = strlen($nuevo); if ($nuevo != $confirmacion or $actual == "") { $respuesta->addAlert("Los valores no coinciden ( {$formulario['firma_recuperacion']} ) {$nuevo} != {$confirmacion} {$formulario['firma_recuperacion']} {$firma} {$actual} \\OR {$actual}"); return $respuesta; } elseif ($size < 8) { $respuesta->addAlert("Use un password mas seguro: Mínimo 8 caracteres."); return $respuesta; } elseif ($firma_recuperacion[0] != $formulario[firma_recuperacion]) { $respuesta->addAlert("El link ya no es valido"); return $respuesta; } elseif ($formulario[firma_recuperacion] == '' and $verifica[0] != MD5($actual)) { $respuesta->addAlert("Error de password {$formulario['firma_recuperacion']}"); return $respuesta; } else { } $link = Conectarse(); mysql_query("SET NAMES 'utf8'"); $nueva_firma = sha1(mktime()); $consulta = "UPDATE usuarios SET passwd = '" . MD5($nuevo) . "' , firma_recuperacion = '{$nueva_firma}' WHERE id = {$id_usuario};"; $sql_consulta = mysql_query($consulta, $link); if ($sql_consulta) { $resultado = "<div class='alert alert-success'>La clave se cambió con éxito.</div>"; } else { $resultado = ""; } $respuesta->addAlert("La clave se cambió con éxito."); $respuesta->addRedirect("index.php"); return $respuesta; }
function ApplyTheme($theme) { $objResponse = new xajaxResponse(); global $userbank, $username; if (!$userbank->HasAccess(ADMIN_OWNER | ADMIN_WEB_SETTINGS)) { $objResponse->redirect("index.php?p=login&m=no_access", 0); $log = new CSystemLog("w", "Hacking Attempt", $username . " tried to change the theme to " . htmlspecialchars(addslashes($theme)) . ", but doesnt have access."); return $objResponse; } $theme = rawurldecode($theme); $theme = str_replace(array('../', '..\\', chr(0)), '', $theme); $theme = basename($theme); if ($theme[0] == '.' || !in_array($theme, scandir(SB_THEMES)) || !is_dir(SB_THEMES . $theme) || !file_exists(SB_THEMES . $theme . "/theme.conf.php")) { $objResponse->addAlert('Invalid theme selected.'); return $objResponse; } include SB_THEMES . $theme . "/theme.conf.php"; if (!defined('theme_screenshot')) { $objResponse->addAlert('Bad theme selected.'); return $objResponse; } $query = $GLOBALS['db']->Execute("UPDATE `" . DB_PREFIX . "_settings` SET `value` = ? WHERE `setting` = 'config.theme'", array($theme)); $objResponse->addScript('window.location.reload( false );'); return $objResponse; }
/** * function to verify user data * * @param $aFormValues (array) login form data $aFormValues['username'] $aFormValues['password'] $aFormValues['locate'] * @return $objResponse * @session $_SESSION['curuser']['username'] $_SESSION['curuser']['extension'] $_SESSION['curuser']['extensions'] $_SESSION['curuser']['country'] $_SESSION['curuser']['language'] $_SESSION['curuser']['channel'] $_SESSION['curuser']['accountcode'] */ function processAccountData($aFormValues) { global $db, $config; list($_SESSION['curuser']['country'], $_SESSION['curuser']['language']) = split("_", $aFormValues['locate']); //get locate parameter $locate = new Localization($_SESSION['curuser']['country'], $_SESSION['curuser']['language'], 'login'); $objResponse = new xajaxResponse(); /* check whether the pear had been installed */ $pear_exists_result = class_exists('PEAR'); if (empty($pear_exists_result)) { $objResponse->addAlert($locate->Translate("Please install php pear")); $objResponse->addAssign("loginButton", "value", $locate->Translate("submit")); $objResponse->addAssign("loginButton", "disabled", false); return $objResponse; } if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { if ($_SERVER["HTTP_CLIENT_IP"]) { $proxy = $_SERVER["HTTP_CLIENT_IP"]; } else { $proxy = $_SERVER["REMOTE_ADDR"]; } } else { if (isset($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } else { $ip = $_SERVER["REMOTE_ADDR"]; } } $query = "SELECT * FROM account_log WHERE ip='" . $ip . "' AND action='login' ORDER BY id DESC LIMIT 1"; $res = $db->query($query); if ($res->fetchInto($this_ip_log)) { $failedtimes = $this_ip_log['failedtimes']; } $log = array(); $log['action'] = 'login'; $log['ip'] = $ip; $log['username'] = $aFormValues['username']; if ($failedtimes >= $config['system']['max_incorrect_login'] && $config['system']['max_incorrect_login'] > 0) { $objResponse->addAlert($locate->Translate("login failed,your ip is locked for login")); $objResponse->addAssign("loginButton", "value", $locate->Translate("submit")); $objResponse->addAssign("loginButton", "disabled", false); return $objResponse; } $bError = false; $loginError = false; if (!$bError) { $query = "SELECT account.*, accountgroup.accountcode,accountgroup.allowcallback as allowcallbackgroup,resellergroup.allowcallback as allowcallbackreseller,accountgroup.limittype FROM account LEFT JOIN accountgroup ON accountgroup.id = account.groupid LEFT JOIN resellergroup ON resellergroup.id = account.resellerid WHERE username='******'username'] . "'"; $res = $db->query($query); if ($res->fetchInto($list)) { $log['account_id'] = $list['id']; $log['usertype'] = $list['usertype']; if ($list['password'] == $aFormValues['password']) { $log['status'] = 'success'; $log['failedtimes'] = 0; if ($aFormValues['rememberme'] == "forever") { // set cookies for three years setcookie("username", $aFormValues['username'], time() + 94608000); setcookie("password", $aFormValues['password'], time() + 94608000); setcookie("language", $aFormValues['locate'], time() + 94608000); setcookie("pagestyle", $aFormValues['pagestyle'], time() + 94608000); } else { // destroy cookies setcookie("username", "", time() - 3600); setcookie("password", "", time() - 3600); setcookie("language", "", time() - 3600); setcookie("pagestyle", $aFormValues['pagestyle'], time() + 94608000); $username = ''; $password = ''; $language = 'en_US'; $checked = false; } $_SESSION = array(); $_SESSION['curuser']['username'] = trim($aFormValues['username']); $_SESSION['curuser']['usertype'] = $list['usertype']; $_SESSION['curuser']['ipaddress'] = $_SERVER["REMOTE_ADDR"]; $_SESSION['curuser']['userid'] = $list['id']; $_SESSION['curuser']['groupid'] = $list['groupid']; $_SESSION['curuser']['resellerid'] = $list['resellerid']; $_SESSION['curuser']['limittype'] = $list['limittype']; $configstatus = common::read_ini_file($config['system']['astercc_path'] . '/astercc.conf', $asterccConfig); if ($configstatus == -2) { $html = "(fail to read " . $config['system']['astercc_path'] . "/astercc.conf)"; return $html; } else { $billingfield = trim($asterccConfig['system']['billingfield']); if ($billingfield == 'accountcode') { $_SESSION['curuser']['billingfield'] = $billingfield; } } $res = astercrm::getCalleridListByID($list['groupid']); while ($res->fetchInto($row)) { $_SESSION['curuser']['extensions'][] = $row['clid']; } if (!is_array($_SESSION['curuser']['extensions'])) { $_SESSION['curuser']['extensions'] = array(); } if ($list['usertype'] == 'reseller') { $_SESSION['curuser']['allowcallback'] = $list['allowcallbackreseller']; } else { $_SESSION['curuser']['allowcallback'] = $list['allowcallbackgroup']; } $_SESSION['curuser']['accountcode'] = $list['accountcode']; // if ($list['extensions'] != ''){ // $_SESSION['curuser']['extensions'] = split(',',$list['extensions']); // } // else{ // } list($_SESSION['curuser']['country'], $_SESSION['curuser']['language']) = split("_", $aFormValues['locate']); /* if you dont want check manager status and show device status when user login please uncomment these three line */ // $objResponse->addAlert($locate->Translate("login_success")); if ($_SESSION['curuser']['usertype'] == 'groupadmin' || $_SESSION['curuser']['usertype'] == 'operator') { if ($aFormValues['pagestyle'] == 'classic') { $objResponse->addScript('window.location.href="systemstatus.php";'); } else { $objResponse->addScript('window.location.href="systemstatus_simple.php";'); } } else { $objResponse->addScript('window.location.href="account.php";'); } astercrm::insertAccountLog($log); return $objResponse; //check AMI connection $myAsterisk = new Asterisk(); $myAsterisk->config['asmanager'] = $config['asterisk']; $res = $myAsterisk->connect(); $html .= $locate->Translate("server_connection_test"); if ($res) { $html .= '<font color=green>' . $locate->Translate("pass") . '</font><br>'; $html .= '<b>' . $_SESSION['curuser']['extension'] . ' ' . $locate->Translate("device_status") . '</b><br>'; $html .= asterisk::getPeerIP($_SESSION['curuser']['extension']) . '<br>'; $html .= asterisk::getPeerStatus($_SESSION['curuser']['extension']) . '<br>'; } else { $html .= '<font color=red>' . $locate->Translate("no_pass") . '</font>'; } if ($aFormValues['pagestyle'] == 'classic') { $html .= '<input type="button" value="' . $locate->Translate("continue") . '" id="btnContinue" name="btnContinue" onclick="window.location.href=\'systemstatus.php\';">'; } else { $html .= '<input type="button" value="' . $locate->Translate("continue") . '" id="btnContinue" name="btnContinue" onclick="window.location.href=\'systemstatus_simple.php\';">'; } $objResponse->addAssign("formDiv", "innerHTML", $html); $objResponse->addClear("titleDiv", "innerHTML"); $objResponse->addScript("xajax.\$('btnContinue').focus();"); } else { //$log['account_id'] = 0; $log['failedtimes'] = $failedtimes + 1; $log['status'] = 'failed'; $log['failedcause'] = 'incorrect password'; $loginError = true; } } else { $log['failedtimes'] = $failedtimes + 1; $log['account_id'] = 0; $log['usertype'] = 'manager_login'; $log['status'] = 'failed'; $log['failedcause'] = 'notexistent user'; $loginError = true; } astercrm::insertAccountLog($log); if (!$loginError) { return $objResponse; } else { $objResponse->addAlert($locate->Translate("login failed")); $objResponse->addAssign("loginButton", "value", $locate->Translate("submit")); $objResponse->addAssign("loginButton", "disabled", false); return $objResponse; } } else { $objResponse->addAssign("loginButton", "value", $locate->Translate("submit")); $objResponse->addAssign("loginButton", "disabled", false); } return $objResponse; }
/** * update account record * @param f array account record * @return objResponse object xajax response object */ function update($f) { global $locate, $db; $objResponse = new xajaxResponse(); if (trim($f['agent']) == '' || trim($f['password']) == '' || trim($f['name']) == '') { $objResponse->addAlert($locate->Translate("obligatory_fields")); return $objResponse->getXML(); } $arreglo =& Customer::getAllRecords($start, $limit, $order, $_SESSION['curuser']['groupid']); if (trim($f['agent']) != $f['id']) { foreach ($arreglo as $agents) { if ($agents['agent'] == trim($f['agent'])) { $objResponse->addAlert($locate->Translate("agent repeat")); return $objResponse->getXML(); } } } $content = ''; foreach ($arreglo as $agents) { if ($agents['agent'] == $f['id']) { $addstr = "\nagent => " . trim($f['agent']) . ',' . trim($f['password']) . ',' . trim($f['name']); } else { $addstr = "\nagent => " . trim($agents['agent']) . ',' . trim($agents['password']) . ',' . trim($agents['name']); } $content .= $addstr; } $agentsfile = '/etc/asterisk/agents_astercc.conf'; if ($fhandle = fopen($agentsfile, 'w')) { fwrite($fhandle, $content); $html = createGrid(0, ROWSXPAGE); $objResponse->addAssign("grid", "innerHTML", $html); $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("update_rec")); $objResponse->addAssign("formDiv", "style.visibility", "hidden"); } else { $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_update")); } return $objResponse->getXML(); }
function _data_preset_rra_item_xajax_remove($preset_rra_id) { require_once(CACTI_BASE_PATH . "/lib/data_preset/data_preset_rra_update.php"); require_once(CACTI_BASE_PATH . "/lib/data_preset/data_preset_rra_info.php"); require_once(CACTI_BASE_PATH . "/lib/data_template/data_template_update.php"); require_once(CACTI_BASE_PATH . "/lib/data_template/data_template_info.php"); require_once(CACTI_BASE_PATH . "/lib/data_source/data_source_update.php"); require_once(CACTI_BASE_PATH . "/lib/data_source/data_source_info.php"); $objResponse = new xajaxResponse(); if (basename($_SERVER["PHP_SELF"]) == "presets_rra.php") { $preset_rra_item = api_data_preset_rra_item_get($preset_rra_id); $result = api_data_preset_rra_item_remove($preset_rra_id); }else if (basename($_SERVER["PHP_SELF"]) == "data_templates.php") { $preset_rra_item = api_data_template_rra_item_get($preset_rra_id); $result = api_data_template_rra_item_remove($preset_rra_id); }else if (basename($_SERVER["PHP_SELF"]) == "data_sources.php") { $preset_rra_item = api_data_source_rra_item_get($preset_rra_id); $result = api_data_source_rra_item_remove($preset_rra_id); }else{ return false; } if ($result) { if (basename($_SERVER["PHP_SELF"]) == "presets_rra.php") { $num_items = sizeof(api_data_preset_rra_item_list($preset_rra_item["preset_rra_id"])); }else if (basename($_SERVER["PHP_SELF"]) == "data_templates.php") { $num_items = sizeof(api_data_template_rra_item_list($preset_rra_item["data_template_id"])); }else if (basename($_SERVER["PHP_SELF"]) == "data_sources.php") { $num_items = sizeof(api_data_source_rra_item_list($preset_rra_item["data_source_id"])); } /* if there are no rra items left, do not remove the row from the form but instead mark it as "new" */ if ($num_items == 0) { $objResponse->addScript("remove_rra_item_last_row(\"$preset_rra_id\");"); /* if there is at least one rra item left, visibly remove the row from the page */ }else{ $objResponse->addScript("remove_rra_item_row(\"$preset_rra_id\");"); } }else{ $objResponse->addAlert("Error removing RRA preset item!"); } return $objResponse->getXML(); }
/** * function to verify user data * * @param $aFormValues (array) login form data $aFormValues['username'] $aFormValues['password'] $aFormValues['locate'] * @return $objResponse * @session $_SESSION['curuser']['username'] $_SESSION['curuser']['extension'] $_SESSION['curuser']['extensions'] $_SESSION['curuser']['country'] $_SESSION['curuser']['language'] $_SESSION['curuser']['channel'] $_SESSION['curuser']['accountcode'] */ function processAccountData($aFormValues) { global $db, $config; list($_SESSION['curuser']['country'], $_SESSION['curuser']['language']) = split("_", $aFormValues['locate']); //get locate parameter $locate = new Localization($_SESSION['curuser']['country'], $_SESSION['curuser']['language'], 'login'); $objResponse = new xajaxResponse(); $bError = false; $loginError = false; if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { if ($_SERVER["HTTP_CLIENT_IP"]) { $proxy = $_SERVER["HTTP_CLIENT_IP"]; } else { $proxy = $_SERVER["REMOTE_ADDR"]; } } else { if (isset($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } else { $ip = $_SERVER["REMOTE_ADDR"]; } } $log = array(); $log['action'] = 'login'; $log['ip'] = $ip; $log['username'] = $aFormValues['username']; $log['usertype'] = 'clid'; $query = "SELECT * FROM account_log WHERE ip='" . $ip . "' AND action='login' ORDER BY id DESC LIMIT 1"; $res = $db->query($query); if ($res->fetchInto($this_ip_log)) { $failedtimes = $this_ip_log['failedtimes']; } if ($failedtimes >= $config['system']['max_incorrect_login'] && $config['system']['max_incorrect_login'] > 0) { $objResponse->addAlert($locate->Translate("login failed,your ip is locked for login")); $objResponse->addAssign("loginButton", "value", $locate->Translate("submit")); $objResponse->addAssign("loginButton", "disabled", false); return $objResponse; } if (!$bError) { $query = "SELECT * from clid where clid ='" . $aFormValues['username'] . "'"; $res = $db->query($query); if ($res->fetchInto($clid)) { $log['account_id'] = $clid['id']; if ($clid['pin'] == $aFormValues['password']) { $log['status'] = 'success'; $log['failedtimes'] = 0; if ($aFormValues['rememberme'] == "forever") { // set cookies for three years setcookie("username", $aFormValues['username'], time() + 94608000); setcookie("password", $aFormValues['password'], time() + 94608000); setcookie("language", $aFormValues['locate'], time() + 94608000); } else { // destroy cookies setcookie("username", "", time() - 3600); setcookie("password", "", time() - 3600); setcookie("language", "", time() - 3600); $username = ''; $password = ''; $language = 'en_US'; $checked = false; } $_SESSION['curuser']['username'] = trim($aFormValues['username']); $_SESSION['curuser']['usertype'] = "clid"; $_SESSION['curuser']['clidid'] = $clid['id']; $_SESSION['curuser']['groupid'] = $clid['groupid']; list($_SESSION['curuser']['country'], $_SESSION['curuser']['language']) = split("_", $aFormValues['locate']); $configstatus = common::read_ini_file($config['system']['astercc_path'] . '/astercc.conf', $asterccConfig); if ($configstatus == -2) { $html = "(fail to read " . $config['system']['astercc_path'] . "/astercc.conf)"; return $html; } else { $billingfield = trim($asterccConfig['system']['billingfield']); if ($billingfield == 'accountcode') { $_SESSION['curuser']['billingfield'] = $billingfield; } } //$objResponse->addAlert($locate->Translate("login_success")); $objResponse->addScript('window.location.href="cdr.php";'); } else { $log['failedtimes'] = $failedtimes + 1; $log['status'] = 'failed'; $log['failedcause'] = 'incorrect password'; $loginError = true; } } else { $log['failedtimes'] = $failedtimes + 1; $log['account_id'] = 0; $log['status'] = 'failed'; $log['failedcause'] = 'notexistent clid'; $loginError = true; } astercrm::insertAccountLog($log); if (!$loginError) { return $objResponse; } else { $objResponse->addAlert($locate->Translate("login_failed")); $objResponse->addAssign("loginButton", "value", $locate->Translate("submit")); $objResponse->addAssign("loginButton", "disabled", false); return $objResponse; } } else { $objResponse->addAssign("loginButton", "value", $locate->Translate("submit")); $objResponse->addAssign("loginButton", "disabled", false); } return $objResponse; }