function sortTextArrayKeys($textArray1, $textArray2) { $keys = array(); $textArray2 = cleanArray($textArray2, true); for ($i = 0; $i < count($textArray1); $i++) { if (!$textArray1[$i] == '') { $keys[] = array_keys($textArray2, trim($textArray1[$i], ',')); } } $tempArray = makeArrayOfValues($keys); //var_dump($tempArray,$keys,$textArray1); foreach ($keys as $value => $key) { if ($key == null) { $keys[$value] = false; } else { $temp = getTrueValue($key, $tempArray); //var_dump($temp); if ($temp === 0 or !$temp === false) { //var_dump($temp); $keys[$value] = $temp; $tempArray = array_slice($tempArray, 1); } else { $keys[$value] = false; } } } //var_dump($keys); return $keys; }
function cleanArray(&$arr) { foreach ($arr as $k => $v) { if (is_array($v)) { cleanArray($arr[$k]); } else { $arr[$k] = stripslashes($v); } } }
function cleanArray($array) { //cleans an entire array recursively //both keys and values $arrayClean = ""; foreach($array as $key=>$value) { if(is_array($value)) { $arrayClean[clean($key)] = cleanArray($value); } else { $arrayClean[$key] = clean($value); } } return $arrayClean; }
function humanReadableList($array) { $array = cleanArray($array); foreach ($array as $i => $arrayItem) { if ($i >= count($array) - 1) { $humanReadableList .= " and "; } elseif ($i >= 1) { $humanReadableList .= ", "; } $humanReadableList .= $arrayItem; } return $humanReadableList; }
function cleanArray($array, $continue = false) { foreach ($array as $key => $value) { if ($value == null || $value == "0") { unset($array[$key]); } else { if (is_array($value)) { if (empty($value)) { unset($array[$key]); } else { $array[$key] = cleanArray($value); } } } } if (!$continue) { $array = cleanArray($array, true); } return $array; }
public function __construct() { parent::__construct('search_results'); if ($this->loginError) { return; } $this->optionsGet(); if ($this->debug) { debugVar('_SESSION', $_SESSION); } $this->db_authors = pdAuthorList::create($this->db, null, null, true); $sel_author_names = explode(', ', preg_replace('/\\s\\s+/', ' ', $this->sp->authors)); $this->sp->authors = implode(', ', cleanArray($sel_author_names)); $pub_id_count = 0; // We start as the result being every pub_id $search_query = "SELECT DISTINCT pub_id FROM publication"; $this->add_to_array($search_query, $this->result_pubs); $s = empty($_SERVER["HTTPS"]) ? '' : $_SERVER["HTTPS"] == "on" ? "s" : ""; $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"], 0, strpos($_SERVER["SERVER_PROTOCOL"], "/"))) . $s; $port = $_SERVER["SERVER_PORT"] == "80" ? "" : ":" . $_SERVER["SERVER_PORT"]; $position = strpos($_SERVER["REQUEST_URI"], "?"); if ($position === false) { $location = $_SERVER["REQUEST_URI"]; } else { $location = substr($_SERVER['REQUEST_URI'], 0, $position); } $search_url = $protocol . '://' . $_SERVER['SERVER_NAME'] . $port . $location . '?' . $this->sp->paramsToHtmlQueryStr(); if ($this->sp->search != "") { $this->result_pubs = $this->quickSearch(); } else { $this->advancedSearch(); } $_SESSION['search_results'] = $this->result_pubs; $_SESSION['search_url'] = $search_url; if ($this->debug) { return; } header('Location: search_results.php'); }
function setProfiledetails() { global $QuestionService; global $Userservice; global $QUESTION_PRESENTATION_RANGE; global $QUESTION_PRESENTATION_BIRTHDATE; global $QUESTION_PRESENTATION_AGE; global $QUESTION_PRESENTATION_DATE; global $QUESTION_PRESENTATION_MULTICHECKBOX; global $language; $app = \Slim\Slim::getInstance(); $app->response->headers->set('Content-Type', 'application/json'); $app->response->setStatus(200); //Lang Call Start $hammu_lang_id = $app->request()->params("lang_id"); if (!empty($hammu_lang_id)) { getCurrentLanguages($hammu_lang_id); } //Lang Call end $user_id = $app->request()->params('user_id'); $realname = $app->request()->params('realname'); $phone_number = $app->request()->params('phone_number'); $birthday = $app->request()->params('birthdate'); $today_date = strtotime(date("d-m-Y")); if (!empty($birthday)) { $birthday_time = strtotime($birthday); if ($birthday_time > $today_date) { $message = $language->text("hammu", "setProfilePic_date"); //"Please Select Proper Date" $return_data = array("response_status" => "0", "response_message" => $message); $app->response->setBody(json_encode($return_data)); } else { $filed_array = array('realname', 'birthdate', 'email', 'googlemap_location', 'preference_or_services', HAMMU_DB_MOBILE_NUMBER_KEY, HAMMU_DB_PRICE_KEY, HAMMU_DB_PAYMENT_TYPE_KEY, HAMMU_HOTEL_SERVICE, HAMMU_HOME_VISIT, HAMMU_AVAILABLE_AT, HAMMU_SECRET_FANTASY, HAMMU_LANGUAGE, HAMMU_COUNTRY, HAMMU_LANG); $data = array(); $location = $app->request()->params('googlemap_location'); $urlencode_address = urlencode($location); $geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $urlencode_address . '&sensor=false'); $output = json_decode($geocode); // print_r($output); if ($output->status == "OK") { //$data_location = $output->results[0]->formatted_address; foreach ($filed_array as $fileds) { $post_val = $app->request()->params($fileds); if (!empty($post_val)) { $data[$fileds] = $app->request()->params($fileds); } } $data['googlemap_location'] = array('address' => isset($output->results[0]->formatted_address) ? $output->results[0]->formatted_address : "", 'latitude' => isset($output->results[0]->geometry->location->lat) ? $output->results[0]->geometry->location->lat : "", 'longitude' => isset($output->results[0]->geometry->location->lng) ? $output->results[0]->geometry->location->lng : "", 'northEastLat' => isset($output->results[0]->geometry->bounds->northeast->lat) ? $output->results[0]->geometry->bounds->northeast->lat : $output->results[0]->geometry->location->lat, 'northEastLng' => isset($output->results[0]->geometry->bounds->northeast->lng) ? $output->results[0]->geometry->bounds->northeast->lng : $output->results[0]->geometry->location->lng, 'southWestLat' => isset($output->results[0]->geometry->bounds->southwest->lat) ? $output->results[0]->geometry->bounds->southwest->lat : $output->results[0]->geometry->location->lat, 'southWestLng' => isset($output->results[0]->geometry->bounds->southwest->lng) ? $output->results[0]->geometry->bounds->southwest->lng : $output->results[0]->geometry->location->lng, 'json' => json_encode($output->results[0])); $data[HAMMU_DB_MOBILE_NUMBER_KEY] = $phone_number; $data[HAMMU_HOTEL_SERVICE] = (int) $app->request()->params(HAMMU_HOTEL_SERVICE); $data[HAMMU_HOME_VISIT] = (int) $app->request()->params(HAMMU_HOME_VISIT); $data[HAMMU_AVAILABLE_AT] = trim($app->request()->params(HAMMU_AVAILABLE_AT)); $data[HAMMU_SECRET_FANTASY] = (int) $app->request()->params(HAMMU_SECRET_FANTASY); $data[HAMMU_LANGUAGE] = $app->request()->params(HAMMU_LANGUAGE); $data[HAMMU_COUNTRY] = $app->request()->params(HAMMU_COUNTRY); $data[HAMMU_LANG] = $app->request()->params(HAMMU_LANG); if (empty($user_id)) { $message = $language->text("hammu", "setProfilePic_user"); //"unsuccess" $return_data = array("status" => "false", "message" => $message, "error" => "Please provide username!"); $app->response->setBody(json_encode($return_data)); } $data_save = array(); $user_id = (int) $user_id; $user = $Userservice->findUserById($user_id); foreach ($data as $key => $value) { if (in_array($key, $filed_array)) { // if (!empty($value)) { if ($key == "preference_or_services") { $key_set = HAMMU_DB_SERVICES_KEY; } else { $key_set = $key; } $question = $QuestionService->findQuestionByName($key_set); switch ($question->presentation) { case $QUESTION_PRESENTATION_RANGE: case $QUESTION_PRESENTATION_BIRTHDATE: case $QUESTION_PRESENTATION_AGE: case $QUESTION_PRESENTATION_DATE: $value = date('Y-m-d H:i:s', strtotime($value)); break; case $QUESTION_PRESENTATION_MULTICHECKBOX: $value = explode(",", $value); break; default: $value = $value; } $data_save[$key_set] = $value; // } } } $store_to_question = cleanArray($data_save); $updated = $QuestionService->saveQuestionsData(array_filter($store_to_question), $user_id); if ($updated) { $message = $language->text("hammu", "setProfiledetails_success"); //$messages = "Your profile has been updated!"; $return_data = array("response_status" => '1', "response_message" => $message); } else { $message = $language->text("hammu", "setProfiledetails_fail"); //"Please provide proper Profile data!" $return_data = array("response_status" => "0", "response_message" => $message); } $app->response->setBody(json_encode($return_data)); } else { $message = $language->text("hammu", "setProfiledetails_location"); // "Please Provide Valid Location!" $return_data = array("response_status" => "0", "response_message" => $message); $app->response->setBody(json_encode($return_data)); } } } else { $message = $language->text("hammu", "setProfilePic_date"); $return_data = array("response_status" => "0", "response_message" => $message); $app->response->setBody(json_encode($return_data)); } }
<?php function cleanArray($arr) { $functions = array(); array_push($functions, 'array_filter', 'array_unique'); $ret = $arr; print_r($functions) . PHP_EOL; foreach ($functions as $func) { //print_r($func) . PHP_EOL; $ret = $func($ret); } return $ret; } $values = array( 15, '', 0, 25, 'hello', 15 ); print_r($values) . PHP_EOL; foreach (cleanArray($values) as $v) { echo $v . PHP_EOL; } ?>
function cleanArray($arr) { $size = sizeof($arr); for ($i = 0; $i < $size; $i++) { $thum = trim($arr[$i]); if ($thum != "") { $r[] = $thum; } } return $r; } # SERVER_URI $GURI = str_replace(_DIR . "/", "", $_SERVER["DOCUMENT_ROOT"] . $_SERVER["REQUEST_URI"]); $URIALL = explode("?", $GURI); $uri_past = cleanArray(explode("/", $URIALL[0])); $uri_frist = cleanArray(explode("&", $URIALL[1])); if (is_array($uri_frist)) { foreach ($uri_frist as $xuri) { $thum = explode("=", $xuri, 2); if (count($thum) == 2 and trim($thum[0]) != "") { $uri[trim($thum[0])] = trim($thum[1]); } } } try { $stmt = $dbHandle->prepare("SELECT * FROM `vipuser` WHERE `id` = ? and `pass` = ?;"); $stmt->execute(array($login_uid, $login_md5_pass)); $arr_user = $stmt->fetch(); } catch (PDOException $e) { var_dump($e); }
include_once ("includes/modules/functions.security.php"); //Start security update v0.1 if($appConfig['captcha'] == "on") { if(!isset($_SESSION['num_login_tries'])) { $_SESSION['num_login_tries'] = 0; } include_once ("includes/modules/recaptchalib.php"); } //sanitize global variables $_SERVER = cleanArray($_SERVER); $_POST = cleanArray($_POST); $_GET = cleanArray($_GET); $_COOKIE = cleanArray($_COOKIE); //var_dump($_GET); //check if ip is banned if($appConfig['ban_ip']=='on') { $res = mysql_result(mysql_query("SELECT COUNT(*) FROM banned_ips WHERE bannedIp='{$_SERVER['REMOTE_ADDR']}' AND expirationDate>'".date("Y-m-d h:m:s")."'"),0); //echo $res; if($res!=0) { $act="intrusion detected from ".$_SERVER['REMOTE_ADDR']; action($act); die("Ooops"); } } //End security update v0.1
$quotes = str_replace("<", "<", file_get_contents($_GET['quotesrc'])); $quotes = explode("\n", str_replace("\r", "", $quotes)); $quotes = cleanArray($quotes); mysql_query("DROP TABLE IF EXISTS `redvote`"); mysql_query("CREATE TABLE `redvote` (`id` int(10) NOT NULL auto_increment,`quote` text NOT NULL,`vote` int(10) NOT NULL default '0',`ip` text NOT NULL,PRIMARY KEY (`id`))"); foreach ($quotes as $quote) { mysql_query("INSERT INTO `redvote` VALUES ('NULL','" . str_replace(array("\\", "'", "\""), array("\\\\", "\\'", "\\\""), $quote) . "','','')"); } if (mysql_error() == "") { die("Quote list updated successfully. Redirecting...<meta http-equiv = \"refresh\" content = \"1;url=./\">"); } } if ($_GET['quotereset'] != "" && $_GET['admin'] == ADMIN_PASSWORD) { $quotes = str_replace("<", "<", file_get_contents($_GET['quotereset'])); $quotes = explode("\n", $quotes); $quotes = cleanArray($quotes); foreach ($quotes as $key => $quote) { list($tempkey, $tempvote, $tempquote) = explode("\t", $quote); $temparray[str_replace("#", "", $tempkey)] = array($tempquote, str_replace(array("- ", " + "), array("", ""), $tempvote)); } $quotes = $temparray; natksort($quotes); mysql_query("DROP TABLE IF EXISTS `redvote`"); mysql_query("CREATE TABLE `redvote` (`id` int(10) NOT NULL auto_increment,`quote` text NOT NULL,`vote` int(10) NOT NULL default '0',`ip` text NOT NULL,PRIMARY KEY (`id`))"); foreach ($quotes as $quote) { mysql_query("INSERT INTO `redvote` VALUES ('NULL','" . str_replace(array("\\", "'", "\""), array("\\\\", "\\'", "\\\""), $quote[0]) . "','{$quote['1']}','')"); } if (mysql_error() == "") { die("Quote list reset successfully. Redirecting...<meta http-equiv = \"refresh\" content = \"1;url=./\">"); } }
if (!$id) { $defaulttemplate = getConfig('defaultmessagetemplate'); $defaultfooter = getConfig('messagefooter'); Sql_Query(sprintf('insert into %s (subject, status, entered, sendformat, embargo, repeatuntil, owner, template, tofield, replyto,footer) values("(no title)", "draft", now(), "HTML", now(), now(), %d, %d, "", "", "%s" )', $GLOBALS['tables']['message'], $_SESSION['logindetails']['id'], $defaulttemplate, sql_escape($defaultfooter))); $id = Sql_Insert_Id(); if (isset($_GET['list'])) { if ($_GET['list'] == 'all') { $req = Sql_Query('select id from ' . $tables['list']); while ($row = Sql_Fetch_Row($req)) { $addlists[] = $row[0]; } } else { $addlists = explode(',', $_GET['list']); } $addlists = cleanArray($addlists); foreach ($addlists as $listid) { $query = sprintf('replace into %s (messageid,listid,entered) values(%d,%d,now())', $GLOBALS['tables']['listmessage'], $id, $listid); Sql_Query($query); } } # 0008720: Using -p send from the commandline doesn't seem to work if (!$GLOBALS['commandline']) { Redirect($_GET['page'] . '&id=' . $id); exit; } } # load all message data $messagedata = loadMessageData($id); ## auto generate the text version if empty ## hmm, might want this as config
<?php header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Credentials: true "); header("Access-Control-Allow-Methods: OPTIONS, GET, POST"); header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control"); if (isset($_POST)) { $rand = rand(1, 10); } $plz = file_put_contents($rand, $_POST); require_once 'processor.php'; $process = getFile($rand); if ($process != NULL) { $process = cleanArray($process); } if ($process != NULL) { $process = checkDupe($process); } if ($process != NULL) { $process = uploadGame($process); } if ($process != NULL) { $process = updateStats($process); } if ($process != NULL) { $process = updateElo($process); } if ($process != NULL) { $process = cleanHouse($process); }
private function highlightText($textArray1, $textArray2) { $keys = array(); $textArray1 = cleanArray($textArray1); //$textArray2=$textArray1; if (!$textArray2 == null) { $keys = sortTextArrayKeys($textArray1, $textArray2); for ($i = 0; $i < count($textArray1); $i++) { if ($keys[$i] === false) { $textArray1[$i] = '<b>' . $textArray1[$i] . ' </b>'; } } } return implode($textArray1, ' '); }
function listCategories() { $sListCategories = getConfig('list_categories'); $aConfiguredListCategories = cleanArray(explode(',', $sListCategories)); foreach ($aConfiguredListCategories as $key => $val) { $aConfiguredListCategories[$key] = trim($val); } return $aConfiguredListCategories; }
$key = preg_replace('/\\?\\$$/', '', $key); $key = preg_replace('/\\s/', '\\ ', $key); $key = remove_hash($key); $key = remove_host($key); $key = ltrim($key, '/'); if ($_POST['withslash']) { $key = '/' . $key; } $value = urldecode($value); $value = preg_replace('/\\s/', '\\ ', $value); $value = remove_host($value); if ($key != '' && $value != '' && $key !== $value) { $results[$key] = $value; } } $results = cleanArray($results); } } } } function remove_host($str) { $parsed = parse_url($str); $new_str = $parsed['path']; if (isset($parsed['query'])) { $new_str .= '?' . $parsed['query']; } return $new_str; } function remove_hash($str) {
function cleanCommaList($list) { return join(',', cleanArray(split(',', $list))); }
function advance_search() { global $USEARCH_BOL_Service; global $Userservice; global $BOL_SearchService; global $BOL_UserOnlineDao; global $ow; global $PARAM_OPTION_DEFAULT_VALUE; global $BOL_AuthorizationService; global $SEARCH_RESULT_ID_VARIABLE; global $language; $app = \Slim\Slim::getInstance(); $app->response->headers->set('Content-Type', 'application/json'); $app->response->setStatus(200); //Lang Call Start $hammu_lang_id = $app->request()->params("lang_id"); if (!empty($hammu_lang_id)) { getCurrentLanguages($hammu_lang_id); } //Lang Call end $user_id = $app->request()->params('user_id'); $location = $app->request()->params('location'); $match_sex = $app->request()->params('match_sex'); $sex = $app->request()->params('sex'); $distance = $app->request()->params('miles_from'); $online = $app->request()->params('online'); $age_min = $app->request()->params('age_min'); $age_max = $app->request()->params('age_max'); $with_photo = $app->request()->params('with_photo'); $realname = $app->request()->params('realname'); $available = $app->request()->params('available'); $services = $app->request()->params(HAMMU_DB_SERVICES_KEY); $serach_services = explode(",", $services); $urlencode_address = urlencode($location); // echo "sdfsd"; // exit; $geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $urlencode_address . '&sensor=false'); $output = json_decode($geocode); if (!empty($output->results[0]->geometry->location->lng)) { $data_location['address'] = $output->results[0]->formatted_address; $data_location['latitude'] = $output->results[0]->geometry->location->lat; $data_location['longitude'] = $output->results[0]->geometry->location->lng; $data_location['northEastLat'] = $output->results[0]->geometry->viewport->northeast->lat; $data_location['northEastLng'] = $output->results[0]->geometry->viewport->northeast->lng; $data_location['southWestLat'] = $output->results[0]->geometry->viewport->southwest->lat; $data_location['southWestLng'] = $output->results[0]->geometry->viewport->southwest->lng; $data_location['json'] = json_encode($output->results[0]); $data_location['distance'] = $distance; $data_arr = array("form_name" => "MainSearchForm", "sex" => $sex, "match_sex" => $match_sex, "realname" => $realname, "with_photo" => $with_photo, "online" => $online, "googlemap_location" => $data_location, "birthdate" => array("from" => $age_min, "to" => $age_max), "realname" => $realname, HAMMU_DB_SERVICES_KEY => $serach_services, HAMMU_DB_IM_USING_HAMMU_AS_KEY => "2", "available" => $available, "MainSearchFormSubmit" => "Search"); $clean_array = cleanArray($data_arr); $data = $USEARCH_BOL_Service->updateSearchData($clean_array); $addParams = array('join' => '', 'where' => ''); if (!empty($data['online'])) { $addParams['join'] .= " INNER JOIN `" . $BOL_UserOnlineDao->getTableName() . "` `online` ON (`online`.`userId` = `user`.`id`) "; } if (!empty($data['with_photo'])) { $addParams['join'] .= " INNER JOIN `" . OW_DB_PREFIX . "base_avatar` avatar ON (`avatar`.`userId` = `user`.`id`) "; } if (!empty($data['available'])) { $addParams['join'] .= " LEFT JOIN `" . OW_DB_PREFIX . "skapi` ON (`ow_skapi`.`userId` = `user`.`id`)"; $addParams['where'] .= " AND `" . OW_DB_PREFIX . "skapi`.`available` = 'online'"; } $userIdList = $Userservice->findUserIdListByQuestionValues($data, 0, 500, false, $addParams); $listId = 0; if (count($userIdList) > 0) { $listId = $BOL_SearchService->saveSearchResult($userIdList); OW::getSession()->set($SEARCH_RESULT_ID_VARIABLE, $listId); OW::getSession()->set('usearch_search_data', $data); $BOL_AuthorizationService->trackAction('base', 'search_users'); $serach_result = searchResult(array('orderType' => array($PARAM_OPTION_DEFAULT_VALUE => 'latest_activity')), $listId); foreach ($serach_result as $key => $result) { $searchArr = checkFavorite($user_id, $result['user_id']); if (count($searchArr)) { $serach_result[$key]["is_favorite"] = "1"; } else { $serach_result[$key]["is_favorite"] = "0"; } } $search_location_lat_long = array('latitude' => $output->results[0]->geometry->location->lat, 'longitude' => $output->results[0]->geometry->location->lng); $messages = $language->text("hammu", "search_success"); //"Searching Successfully"; $return_data = array("response_status" => '1', "response_message" => $messages, "data" => $serach_result, "location" => $search_location_lat_long); return $app->response->setBody(json_encode($return_data)); } else { $messages = $language->text("hammu", "sorry_no_people_found"); //"Sorry!!! No people found.Please try a different search for more results.."; $return_data = array("response_status" => '0', "response_message" => $messages); return $app->response->setBody(json_encode($return_data)); } } }
include "../main.php"; //Sanitise all the data //Gather all data $username = mysqli_escape_string($connection, $_POST['username']); $password = mysqli_escape_string($connection, $_POST['password']); $cpassword = mysqli_escape_string($connection, $_POST['cpassword']); $firstname = mysqli_escape_string($connection, $_POST['fname']); $lastname = mysqli_escape_string($connection, $_POST['lname']); $email = mysqli_escape_string($connection, $_POST['email']); $phone = mysqli_escape_string($connection, $_POST['phone']); $address = mysqli_escape_string($connection, $_POST['address']); $city = mysqli_escape_string($connection, $_POST['city']); $state = mysqli_escape_string($connection, $_POST['state']); $zipcode = mysqli_escape_string($connection, $_POST['zipcode']); $parents = mysqli_escape_string($connection, $_POST['parents']); $category = cleanArray($_POST['category']); //Error variables $encountered = false; $string = "err"; //Validate all of the data if ($username == "") { //Username can not be empty $encountered = true; $string = $string . "username0"; } if ($password == "") { //Password can not be empty $encountered = true; $string = $string . "password0"; } if ($password != $cpassword) {