/** * ajax call to determine suggestions * @since 1.0.0 */ function GoogleKS_getSuggestion() { // collect data from AJAX request via POST $l_str_Language = array_key_exists("lang", $_POST) ? $_POST["lang"] : ""; $l_str_Country = array_key_exists("cr", $_POST) ? $_POST["cr"] : ""; $l_str_Keyword = array_key_exists("keyword", $_POST) ? utf8_encode(urlencode(trim($_POST['keyword']))) : ""; // abort if a requested value is empty, return an empty string to clear the current list if (empty($l_str_Language) || empty($l_str_Country) || empty($l_str_Keyword)) { echo '<li>' . __("Bad request. Please fill in all input fields.", GOOGLE_KS_INTERNAL_PLUGIN_NAME) . '</li>'; exit; } // get response utf8 encoded $l_str_Response = getSuggestions($l_str_Keyword, $l_str_Language, $l_str_Country); // convert response to XML /** @var SimpleXMLElement $l_obj_xml */ $l_obj_xml = simplexml_load_string($l_str_Response); if (empty($l_obj_xml)) { returnSuggestions('<li>' . sprintf(__("Error reading response from API.", GOOGLE_KS_INTERNAL_PLUGIN_NAME)) . '</li>'); } // iterate through each suggestion $l_str_Result = ""; foreach ($l_obj_xml->CompleteSuggestion as $l_obj_Value) { // append suggestion to output list $l_str_Result .= '<li>' . $l_obj_Value->suggestion['data'] . '</li>'; } // alert suggestions returnSuggestions($l_str_Result); }
define('MAX_SUGGESTIONS', 10); // Set whether to use a personal dictionary. $usePersonalDict = false; //Set whether users are allowed to update the personal dictionary. $editablePersonalDict = true; // If using a personal dictionary, set the path to it. Default is in the // personal_dictionary subdirectory of the location of spell_checker.php. $path_to_personal_dictionary = dirname(__FILE__) . "/personal_dictionary/personal_dictionary.txt"; // Create and configure a link to the silpa module. $silpaspell_module = silpaspell_create(); switch ($_POST['action']) { case 'spellcheck': spellCheck($_POST['spellText']); break; case 'suggest': getSuggestions($_POST['suggestionText']); break; default: echo "Unknown Action"; break; } /************************************************************* * showSuggestions($word, $id) * * The showSuggestions function creates the list of up to 10 * suggestions to return for the given misspelled word. * * $word - The misspelled word that was clicked on * $id - The id of the span containing the misspelled word. * *************************************************************/
header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-Type: text/xml'); function getSuggestions($keyword) { DbConnect(); $patterns = array('/\\s+/', '/"+/', '/%+/'); $replace = array(''); $keyword = preg_replace($patterns, $replace, $keyword); if ($keyword != '' and preg_match('/^[ _a-zà-ÿA-ZÀ-ß0-9]*$/i', $keyword)) { $keyword = mysql_escape_string($keyword); $query = "SELECT name FROM game_items_factsheet WHERE name LIKE '" . $keyword . "%' ORDER BY BINARY name"; } else { $query = "SELECT name FROM game_items_factsheet WHERE name=''"; } $result = myquery($query); $output = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; $output .= '<response>'; if ($result != false) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_array($result)) { $output .= '<name>' . iconv("Windows-1251", "UTF-8//IGNORE", $row['name']) . '</name>'; } } } $output .= '</response>'; mysql_close(); return $output; } echo getSuggestions(iconv("UTF-8", "Windows-1251//IGNORE", $keyword));
} } else { $output_array[] = $page_row['infopages_title']; } } } $output_array = array_unique($output_array); foreach ($output_array as $key => $value) { $output .= '<name>' . $value . '</name>'; } // close the result stream // add the final closing tag $output .= '</response>'; // return the results return $output; } // retrieve the keyword passed as parameter $keyword = $_GET['keyword']; // clear the output if (ob_get_length()) { ob_clean(); } // headers are sent to prevent browsers from caching header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-Type: text/xml'); // send the results to the client echo getSuggestions($keyword);
function getSuggestions($pattern, $patternType = 'username') { if ($patternType == 'username') { return getSuggestions($pattern); } else { if ($patternType == 'designation') { $suggestionsQuery = "SELECT `qaos_designation_name` FROM `qaos_designations` WHERE `qaos_designation_name` LIKE \"%{$pattern}%\""; $suggestionsResult = mysql_query($suggestionsQuery) or die(mysql_error()); $suggestions = array($pattern); while ($suggestionsRow = mysql_fetch_row($suggestionsResult)) { $suggestions[] = $suggestionsRow[0]; } return join($suggestions, ','); } else { if ($patternType == 'team') { $suggestionsQuery = "SELECT `qaos_team_name` FROM `qaos_teams` WHERE `qaos_team_name` LIKE \"%{$pattern}%\""; $suggestionsResult = mysql_query($suggestionsQuery) or die(mysql_error()); $suggestions = array($pattern); while ($suggestionsRow = mysql_fetch_row($suggestionsResult)) { $suggestions[] = $suggestionsRow[0]; } return join($suggestions, ','); } } } }
$r['url'] = $url; $results[$d] = $r; } } } if (sizeof($matches) == 0) { echo "size of matches is 0:-------------\n\n " . $contents . "\n-------------\n\n "; continue; } foreach ($results as $r) { $sql = "INSERT INTO serps.chris_serps(gs_page, gs_query, gs_position, gs_domain, gs_url) \n\t\t\t\tVALUES ({$page_id},\n\t\t\t\t\t\t{$dbw->addQuotes($query)},\n\t\t\t\t\t\t{$r['position']},\n\t\t\t\t\t\t'{$r['domain']}',\n\t\t\t\t\t\t{$dbw->addQuotes($r['url'])}\n\t\t\t\t\t);"; $dbw->query($sql); } #echo "adding " . sizeof($results) . " for $query " . print_r($results, true) . "\n"; } $suggestions = getSuggestions(); foreach ($suggestions as $s) { checkGoogle($s, 0, $domains, $dbw); } // get dates $dbr = wfGetDB(DB_SLAVE); $res = $dbr->query('select distinct(substr(gs_timestamp, 1,10)) as date from serps.chris_serps'); $dates = array(); while ($row = $dbr->fetchObject($res)) { $dates[] = $row->date; } echo "<table><tr><td>Query</td>"; foreach ($dates as $d) { echo "<td>{$d}</td>"; } echo "</tr>";
<?php if (!isset($_GET['currentInput'])) { return -1; } //TODO: manage errors $text = $_GET['currentInput']; echo implode('|', getSuggestions($text)); // getSuggestions($text); //return an array containing all the towns from the file with $text within function getSuggestions($text) { //pb du 'greoble'TO DO $file = 'towns.txt'; $towns = unserialize(file_get_contents($file)); $nbTowns = count($towns); $res = array(); for ($i = 0; $i < $nbTowns; $i++) { if (stripos(strtoupper($towns[$i]), strtoupper($text)) !== FALSE) { array_push($res, $towns[$i]); } } return $res; }
function admin($pageid, $userid) { if (isset($_GET['doaction']) && $_GET['doaction'] == 'getsuggestions' && isset($_GET['forwhat'])) { if (strlen($_GET['forwhat']) >= 3) { echo getSuggestions($_GET['forwhat']); disconnect(); exit; } } global $urlRequestRoot, $templateFolder, $cmsFolder, $ICONS; if (isset($_GET['indexsite'])) { global $sourceFolder; require "{$sourceFolder}/modules/search/admin/spider.php"; if ($_GET['indexsite'] == 1) { $serveruri = isset($_SERVER['ORIG_SCRIPT_NAME']) ? $_SERVER['ORIG_SCRIPT_NAME'] : $_SERVER['SCRIPT_NAME']; $uri = substr($serveruri, 0, stripos($serveruri, "index.php")); $site = "http://" . $_SERVER['HTTP_HOST'] . $uri . "home/"; index_site($site, 0, -1, 'full', "", "+\n&", 0); displayinfo("Index for site created"); } else { index_all(); } } $result = mysql_fetch_array(mysql_query("SELECT `value` FROM `" . MYSQL_DATABASE_PREFIX . "global` WHERE `attribute` = 'reindex_frequency'")); if ($result != NULL) { $threshold = $result['value']; } else { $threshold = 30; } $result = mysql_fetch_array(mysql_query("SELECT to_days(CURRENT_TIMESTAMP)-to_days(`indexdate`) AS 'diff' FROM `sites` WHERE `url` LIKE '%home%'")); if ($result == NULL) { displayinfo("It seems the site doesn't have index for the search to work. Click <a href='./+admin&indexsite=1'>here</a> to index the site."); } else { if ($result['diff'] > $threshold) { displayinfo("Your site index was created {$result['diff']} days before. Click <a href='./+admin&indexsite=2'>here</a> to reindex your site."); } } $quicklinks = <<<ADMINPAGE \t<fieldset> \t<legend>{$ICONS['Website Administration']['small']}Website Administration</legend> \t<a name='quicklinks'></a> \t<table class="iconspanel"> \t<tr> \t<td><a href="./+admin&subaction=global"><div>{$ICONS['Global Settings']['large']}<br/>Global Settings</div></a></td>\t \t<td><a href="./+admin&subaction=template"><div>{$ICONS['Templates Management']['large']}<br/>Templates Management</div></a></td> \t<td><a href="./+admin&subaction=module"><div>{$ICONS['Modules Management']['large']}<br/>Module Management</div></a></td> \t<td><a href="./+admin&subaction=widgets"><div>{$ICONS['Widgets']['large']}<br/>Widgets Management</div></a></td> \t</tr> \t<tr> \t<td><a href="./+admin&subaction=icon"><div>{$ICONS['Icons']['large']}<br/>Icons Management</div></a></td> \t<td><a href="./+admin&subaction=email"><div>{$ICONS['Email Registrants']['large']}<br/>Email Registrants</div></a></td> \t<td><a href="./+admin&subaction=editgroups"><div>{$ICONS['User Groups']['large']}<br/>Group Management</div></a></td> \t<td><a href="./+admin&subaction=expert"><div>{$ICONS['Site Maintenance']['large']}<br/>Site Maintenance</div></a></td> \t</tr> \t<tr> \t \t<td colspan=2><a href="./+admin&subaction=useradmin"><div>{$ICONS['User Management']['large']}<br/>User Management</div></a></td> \t<td colspan=2><a href="./+admin&subaction=editprofileform"><div>{$ICONS['User Profile']['large']}<br/>User Profiles</div></a></td> \t</tr> \t</table> \t</fieldset> ADMINPAGE; if (isset($_GET['subaction'])) { require_once "email.lib.php"; if ($_GET['subaction'] == "email") { return displayEmail() . $quicklinks; } else { if ($_GET['subaction'] == "openemail") { return displayEmail(escape($_GET['name'])) . $quicklinks; } else { if ($_GET['subaction'] == "emailsend") { sendEmail(); return displayEmail(escape($_POST['emailtemplates'])) . $quicklinks; } else { if ($_GET['subaction'] == "emailsave") { saveEmail(); return displayEmail(escape($_POST['emailtemplates'])) . $quicklinks; } } } } } if (isset($_GET['subaction']) && ($_GET['subaction'] == 'module' || $_GET['subaction'] == 'template')) { $type = escape($_GET['subaction']); if ($type == 'module') { displaywarning("Module Installation/Uninstallation has the potential to completely bring down the CMS, so Install only modules from trusted source"); } require_once "module.lib.php"; require_once "template.lib.php"; $type = ucfirst($type); $function = "handle{$type}Management"; $op = $function(); if ($op != "") { return $op . $quicklinks; } return managementForm($type) . $quicklinks; } global $sourceFolder; if (!isset($_GET['subaction']) && !isset($_GET['subsubaction'])) { return $quicklinks; } require_once "users.lib.php"; $op = ""; $ophead = ""; $str = ""; if (isset($_GET['subaction']) || isset($_GET['subsubaction']) || isset($_GET['id']) || isset($_GET['movePermId']) || isset($_GET['module'])) { if (isset($_GET['subaction']) && $_GET['subaction'] == 'global' && isset($_POST['update_global_settings'])) { updateGlobalSettings(); } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'global' && isset($_GET['del_black'])) { delete_blacklist(); } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'useradmin') { $op .= handleUserMgmt(); $ophead = "{$ICONS['User Management']['small']}User Management"; } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'widgets') { $op .= handleWidgetAdmin($pageid); $ophead = "{$ICONS['Widgets']['small']}Widgets Management"; } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'icon') { require_once "iconmanagement.lib.php"; $res = handleIconManagement(); if (isset($_GET['iconURL'])) { return $res; } $op .= $res; $ophead = "{$ICONS['Icons']['small']}Icons Management"; } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'editgroups') { require_once "permission.lib.php"; $pagepath = array(); parseUrlDereferenced($pageid, $pagepath); $virtue = ''; $maxPriorityGroup = getMaxPriorityGroup($pagepath, $userid, array_reverse(getGroupIds($userid)), $virtue); $modifiableGroups = getModifiableGroups($userid, $maxPriorityGroup); $op .= groupManagementForm($userid, $modifiableGroups, $pagepath); $ophead = "{$ICONS['Group Management']['small']}Group Management"; } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'reloadtemplates') { $op .= reloadTemplates(); $ophead = "{$ICONS['Templates Management']['small']}Reloading Templates"; } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'reloadmodules') { $op .= reloadModules(); $ophead = "{$ICONS['Modules Management']['small']}Reloading Modules"; } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'checkPerm') { $op .= admin_checkFunctionPerms(); $ophead = "{$ICONS['Access Permissions']['small']}Checking Permissions Consistency"; } elseif (isset($_GET['subaction']) && $_GET['subaction'] == 'checkAdminUser') { $op .= admin_checkAdminUser(); $ophead = "Checking Administrator User"; } elseif (isset($_GET['subaction']) && $_GET['subaction'] == 'checkAdminPerms') { $op .= admin_checkAdminPerms(); $ophead = "Checking Administrator Permissions"; } elseif (isset($_GET['subaction']) && $_GET['subaction'] == 'changePermRank') { $op .= admin_changePermRank(); $ophead = "{$ICONS['Access Permissions']['small']}Changing Permissions Rank"; } elseif (isset($_GET['subaction']) && $_GET['subaction'] == 'editprofileform' || isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'editprofileform') { $op .= admin_editProfileForm(); $ophead = "{$ICONS['User Profile']['small']}Edit User Profile Form"; } elseif (isset($_GET['id'])) { $op .= admin_userAdmin(); } elseif (isset($_GET['movePermId'])) { $op .= admin_changePermRank(); $ophead = "{$ICONS['Access Permissions']['small']}Changing Permissions Rank"; } elseif (isset($_GET['module'])) { $op .= admin_changePermRank(escape($_GET['module'])); $ophead = "{$ICONS['Access Permissions']['small']}Changing Permissions Rank for module '" . escape($_GET['module']) . "'"; } } } } } } } } } } if ($op != "") { $op = "<fieldset><legend>{$ophead}</legend>{$op}</fieldset>"; } if (isset($_GET['subaction']) && $_GET['subaction'] == 'global') { $str .= globalSettingsForm(); } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'editgroups') { //do nothing so that "expert only" doesn't comes up } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'useradmin') { $op .= userManagementForm(); } else { if (isset($_GET['subaction']) && $_GET['subaction'] == 'expert') { $str .= "<fieldset><legend>{$ICONS['Site Maintenance']['small']}Experts Only</legend>"; $str .= '<a href="./+admin&subaction=checkPerm">Check Permission List</a><br />'; $str .= '<a href="./+admin&subaction=checkAdminUser">Check Admin User</a><br />'; $str .= '<a href="./+admin&subaction=checkAdminPerms">Check Admin Perms</a><br />'; $str .= '<a href="./+admin&subaction=changePermRank">Change Perm Ranks</a><br />'; $str .= '<a href="./+admin&subaction=reloadtemplates">Reload Templates</a><br />'; $str .= '<a href="./+admin&subaction=reloadmodules">Reload Modules</a><br />'; $str .= '<a href="./+admin&indexsite=2">Reindex Site for Searching</a></br/></fieldset>'; } } } } return $str . $op . $quicklinks; }
if ($function == "get_employee_username") { getEmployeeUsername(); } if ($function == "get_warehouses") { getWarehouses(); } if ($function == "add_warehouse") { addWarehouse(); } if ($function == "get_inventory") { getInventory(); } if ($function == "add_inventory") { addInventory(); } if ($function == "get_outstanding_orders") { getOutstandingOrders(); } if ($function == "fill_order") { fillOrder(); } if ($function == "get_suggestions") { getSuggestions(); } if ($function == "get_monthly_sales_item") { getMonthlySalesItem(); } if ($function == "get_monthly_sales_order") { getMonthlySalesOrder(); } //getAllItems();
} return $result; } if (isset($_GET["suggestion"])) { $suggestion = $_GET["suggestion"]; $motivation = ""; $verification = ""; if (isset($_GET["motivation"])) { $motivation = $_GET["motivation"]; } if (isset($verification)) { $verification = $_GET["verification"]; } else { header("Content-Type: application/json;charset=utf-8"); die(json_encode(array("error" => "Missing validation"))); } header("Content-Type: application/json;charset=utf-8"); echo json_encode(array("result" => addSuggestion($suggestion, $verification, $motivation))); } if (isset($_GET["list"])) { header("Content-Type: application/json;charset=utf-8"); echo json_encode(getSuggestions()); } if (isset($_GET["vote"])) { header("Content-Type: application/json;charset=utf-8"); echo json_encode(vote(filter_var($_GET["id"], FILTER_SANITIZE_NUMBER_INT))); } if (isset($_GET["votes"])) { header("Content-Type: application/json;charset=utf-8"); echo json_encode(getVotes()); }