Error: ' . mysql_error() . '

"); mysql_select_db ($db_name); mysql_query ("SET character_set_client=latin2;"); mysql_query ("SET character_set_connection=latin2;"); mysql_query ("SET character_set_results=latin2;"); mysql_query ("SET character_set_system=latin2;"); return $connection; } //Authenticates the user on the basis of post paramters or the session, and the current script 9optional) function authenticate_user($script = "") { global $usr_other, $grants_array, $usr_mozilla; if ($_GET["sourceid"]) { unset($_SESSION); $_SESSION['type'] = $usr_mozilla; $_SESSION['grants'] = $grants_array[$usr_mozilla]; return true; } if (isset($_SESSION['uid'])) { $_SESSION['grants'] = $grants_array[$_SESSION['type']]; return true; } if ($_POST["user"] != "") { $res = mysql_query("SELECT * FROM usr WHERE usr_login = '" . $_POST["user"] . "' AND usr_passwd = password('" . $_POST["passwd"] . "') AND usr_active = 1"); if (mysql_num_rows($res) > 0) { $_SESSION['uid'] = mysql_result($res, 0, "usr_usrid"); $_SESSION['login'] = mysql_result($res, 0, "usr_login"); $_SESSION['email'] = mysql_result($res, 0, "usr_mail"); // Added (PK 2010-11-13) $_SESSION['type'] = mysql_result($res, 0, "usr_type"); $_SESSION['grants'] = $grants_array[$_SESSION['type']]; return true; } else return false; } $_SESSION['type'] = $usr_other; $_SESSION['grants'] = $grants_array[$usr_other]; $_SESSION['type'] = 0; return false; } //Checks if the user to log in is active function user_active() { global $usr_other, $grants_array, $usr_mozilla; $res = mysql_query("SELECT * FROM usr WHERE usr_login = '" . $_POST["user"] . "'"); if (mysql_num_rows($res) == 0) return false; return mysql_result($res, 0, "usr_active"); } //** Functions - Interface *// // default title, if not passed as a param is 'IFAConc'; Added second param class - default class is now specified (previously was empty); both params are optional (PK 2011-08-13), and third - favicon (PK 2011-08-14) function page_header($title = "IFAConc", $class = "main_bg_2", $favicon="concordance.ico") { ini_set("session.gc_maxlifetime", "18000"); // Changed 3600 (seconds) to 18000 seconds (= 5h). Perhaps this will prevent the frequent logouts.. (PK 2010-09-14) /* ustaw ogranicznik pamieci podrecznej na 'private' */ session_cache_limiter('private'); $cache_limiter = session_cache_limiter(); /* ustaw czas przedawnienia pamieci podrecznej na 5h */ session_cache_expire(300); // Changed 60 (minutes) to 300 minutes (= 5h). Perhaps this will prevent the frequent logouts.. (PK 2010-09-14) $cache_expire = session_cache_expire(); session_start(); ?> <? echo $title; ?> > IFAConctest - \"" . urldecode($_GET["node"]) . "\" - Wide context view"; // Unsuccessful attempts to report corpus name here: " . mysql_result($res, 0, "cpr_name") . " , $cpr_alias . Maybe one day I will be able to set the title of the context page directly in context.php. // } else { // echo "\"" . urldecode($_GET["node"]) . "\" - IFAConc Corpora Search Wide Context view"; // Added urldecode (PK 2010-12-09) // } ?> <? echo $title; ?> > $pages_no) $high = $pages_no; if ($low > 1) echo "1 ... "; for ($i = $low; $i <= $high; $i++) if ($i != $start) echo " ".$i.""; else echo " ".$i.""; if ($high < $pages_no) echo " ... ".$pages_no.""; return $start; } // Counts words in $file. Counts also types if $types function word_count($usr, $file, $types = false, $limit = 10) { $counter = array(); $fp = fopen($file, "r"); $word_no = 0; if ($types) { // Counts words and types while(!feof($fp)) { $line = str_replace("\n", "", fgetss($fp, 4096)); preg_match_all("/\\w+(('\\w+)|())/", $line, $out, PREG_OFFSET_CAPTURE); if (count($out[0]) > 0) foreach($out[0] as $match) { $counter[strtolower($match[0])]++; $word_no++; } } } else { // Counts only words while(!feof($fp)) { $line = str_replace("\n", "", fgetss($fp, 4096)); preg_match_all("/\\w+(('\\w+)|())/", $line, $out, PREG_OFFSET_CAPTURE); $word_no = $word_no + count($out[0]); } } fclose($fp); $res = mysql_query("SELECT cpr_cprid FROM cpr WHERE cpr_file = '".$file."'"); $corpus_id = mysql_result($res, 0, "cpr_cprid"); if ($types) { mysql_query("DELETE FROM wrd".$usr." WHERE wrd_cprid = ".$corpus_id.""); while (list($k, $v) = each($counter)) { $k = str_replace("'", "''", $k); set_time_limit(1); // to keep the procedure going if ($v >= $limit) { mysql_query("INSERT INTO wrd".$usr." (wrd_word, wrd_count, wrd_cprid) VALUES('".$k."', ".$v.", ".$corpus_id.")"); $added++; } } } mysql_query("UPDATE cpr SET cpr_words = ".$word_no." WHERE cpr_cprid = ".$corpus_id.""); // echo "UPDATE Cpr SET cpr_words = $word_no WHERE cpr_cprid = $corpus_id"; return $word_no; } //Strips language XML and POS tags function strip_lg_tags($str,$special_replace = false) { global $tag_chars,$replace; $str = str_replace("\n", "", strip_tags($str)); $str = str_replace("\r", "", $str); $str = str_replace("\t", "", $str); //if($special_replace) $str = str_replace("

","|||",$str); return preg_replace("/".$tag_chars."/", "", $str); // Added ".." around var . Testing - PK 2011-09-24 } //Prints a combo - opt is a hash (val => text), val is the slected value function print_combo($opt, $val) { while (list($k, $v) = each($opt)) { echo "\n"; } } //makes up for strrpos limitations in PHP4. function my_strrpos($haystack, $needle, $offset = 0) { if(trim($haystack) != "" && trim($needle) != "" && $offset <= strlen($haystack)) { $last_pos = $offset; $found = false; while(($curr_pos = strpos($haystack, $needle, $last_pos)) !== false) { $found = true; $last_pos = $curr_pos + 1; } if($found) return $last_pos - 1; else return false; } else return false; } //parse bool query for mysql function bool2mysql($query,$name){ if(strpos($query, "AND") !== false){ $pieces = explode("AND", $query); $result = "("; foreach($pieces as $node){ $result .= $name." LIKE '%".mysql_escape_string(trim($node))."%' AND "; } $result = substr($result,0,-4); $result .= ")"; $query = $result; } else if(strpos($query, "OR") !== false){ $pieces = explode("OR", $query); $result = "("; foreach($pieces as $node){ $result .= $name." LIKE '%".mysql_escape_string(trim($node))."%' OR "; } $result = substr($result,0,-4); $result .= ")"; $query = $result; } else { $query = $name." LIKE '%".mysql_escape_string(trim($query))."%'"; } return $query; } //print debugging info (for 'root' account with id=4, PK 2011-08-15) function print_code($text,$label = ""){ if($_SESSION['uid'] == 4){ echo '
'; if($label){ echo ''.$label.': '; } print(htmlspecialchars($text)); echo '
'; } } //generate array with cpr_cprid for this userid // PK note: what this function does is produce an array/list of corpora available for a user. Then other MySQL searches employed on particular pages match against it and retrieve other data for only these corpora (hence the use of WHERE IN in many MySQL statements, PK 2010-08-17) // Original version /* function get_cpr(){ $cpr = array(); if ($_SESSION["uid"]) $res = mysql_query("SELECT cpr_cprid FROM cpr WHERE cpr_restricted <= " . (int)($_SESSION["grants"]["restr_corpora"]) . " AND cpr_usrid IN (0, " . $_SESSION['uid'] . ") AND cpr_active = 1 ORDER BY cpr_group, cpr_cprid"); else $res = mysql_query("SELECT cpr_cprid FROM cpr WHERE cpr_restricted <= " . (int)($_SESSION["grants"]["restr_corpora"]) . " AND cpr_usrid = 0 AND cpr_active = 1 ORDER BY cpr_group, cpr_cprid"); while($row = mysql_fetch_array($res)){ $cpr[] = $row['cpr_cprid']; } if ($_SESSION["uid"]){ $res = mysql_query("SELECT cpr_cprid FROM group_cpr, group_usr WHERE group_usr.usr_usrid = ".$_SESSION["uid"]." AND group_cpr.group_id = group_usr.group_id"); while($row = mysql_fetch_array($res)){ if(!in_array($row['cpr_cprid'],$cpr)) $cpr[] = $row['cpr_cprid']; } } return $cpr; } */ // New version retrieving also all "Own" corpora for admins (PK 2010-08-17) function get_cpr(){ $cpr = array(); if ($_SESSION["uid"]) { if ($_SESSION["grants"]["admin"]) { $res = mysql_query("SELECT cpr_cprid FROM cpr WHERE ((cpr_restricted <= " . (int)($_SESSION["grants"]["restr_corpora"]) . " AND cpr_usrid IN (0, " . $_SESSION['uid'] . ")) OR (cpr_group ='Own' AND cpr_words > 0 ) ) AND cpr_active = 1 ORDER BY cpr_group, cpr_cprid"); } else { $res = mysql_query("SELECT cpr_cprid FROM cpr WHERE cpr_restricted <= " . (int)($_SESSION["grants"]["restr_corpora"]) . " AND cpr_usrid IN (0, " . $_SESSION['uid'] . ") AND cpr_active = 1 ORDER BY cpr_group, cpr_cprid"); } } else { $res = mysql_query("SELECT cpr_cprid FROM cpr WHERE cpr_restricted <= " . (int)($_SESSION["grants"]["restr_corpora"]) . " AND cpr_usrid = 0 AND cpr_active = 1 ORDER BY cpr_group, cpr_cprid"); } while($row = mysql_fetch_array($res)) $cpr[] = $row['cpr_cprid']; if ($_SESSION["uid"]){ $res = mysql_query("SELECT cpr_cprid FROM group_cpr, group_usr WHERE group_usr.usr_usrid = ".$_SESSION["uid"]." AND group_cpr.group_id = group_usr.group_id"); while($row = mysql_fetch_array($res)){ if(!in_array($row['cpr_cprid'],$cpr)) $cpr[] = $row['cpr_cprid']; } } return $cpr; } // Function responsible for issuing banner when tiny link includes hidden corpus, I think. See statistics.php (PK 2011-09-21) function log_in_to_view_the_full_result(){ $cpr = get_cpr(); foreach($_SESSION['get'] as $key => $val){ if($val == "y"){ if(preg_match("@^corpus([0-9]+)$@",$key,$match)){ if(!in_array($match[1],$cpr)){ return true; } } } } return false; } /************** PK functions ( ******************/ /* Where possible (single value or concatenation on output), and/or desirable (eg URL-worthy code to be re-invoked multiply on the same page) I should use return and not echo, so we can call the output from the main code and assign it to a reusable variable (PK 2010-07-22); return must be used as last command, as it stops the rest of the function. cf. http://www.htmlite.com/php038.php */ // list_corpora() - last update 2010-08-20 17:37:31 (PK) // For: statistics.php - only used once so far, so I am skipping the convwersion to return-based output (I am not re-using this function a lot) // PK: Lists all the corpora searched for re-use with input forms (function modelled after "print_corpora()" found in controls.php, PK 2010-06-08) function list_corpora() { $_cpr = get_cpr(); // Assigns output of earlier function defined in this lib_general.php file to a variable $res = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).") ORDER BY cpr_group, cpr_usrid, cpr_cprid"); // Retrieves all available corpora (incl. all from 'Own' group for admins.) for ($i = 0; $i < mysql_num_rows($res); $i++) { if(!($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="temp")){ continue; } // = "temp" group skipped for non-admins if(($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="own") && (mysql_result($res, $i, "cpr_usrid") != "{$_SESSION['uid']}") && ($_SESSION["corpus" . $corpus_id] != "y")) { continue; } // For admins - Skip *unused* other users' (= Own) corpora. Those used will be passed along and made available in results $corpus_id = mysql_result($res, $i, "cpr_cprid"); echo " "y") && (mysql_result($res, $i, "cpr_checked") == 1) && ($_GET["query"] == ""))) if ($_SESSION["corpus" . $corpus_id] == "y") { // Print used/unused param for the currently selected corpus echo "value='y' />"; } else { echo "value='n' />"; } } } // For: statistics.php // Lists all the corpora searched in URL-ready format (derived from function "print_corpora" in controls.php and list_corpora above), PK 2010-07-20 // $yes_no parameter must be 'y' or 'n' when this function is called from main code // deprecated, perhaps - better (= more economical) to use Reset_corpora_URL() - so I don't bother converting to return output (PK 2010-08-21) function list_corpora_URL($yes_no) { $_cpr = get_cpr(); $res = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).") ORDER BY cpr_group, cpr_usrid, cpr_cprid"); // Retrieves all available corpora (incl. all from 'Own' group for admins.) for ($i = 0; $i < mysql_num_rows($res); $i++) { if(!($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="temp")){ continue; } // = "temp" group skipped for non-admins if(($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="own") && (mysql_result($res, $i, "cpr_usrid") != "{$_SESSION['uid']}") && ($_SESSION["corpus" . $corpus_id] != "y")) { continue; } // For admins - Skip *unused* other users' (= Own) corpora. Those used will be passed along and made available in results $corpus_id = mysql_result($res, $i, "cpr_cprid"); echo "&corpus".$corpus_id.""; if ($_SESSION["corpus" . $corpus_id] == "y") { echo "=".$yes_no.""; // if param n passed, script will turn off all the searched corpora. May be used for resetting of URL corpus list - but only via simple method of adding this tweaked corpus list at the end of URL. This may net be dependable for Admins, where long URLS may occur because of currently inefficient handling of "Own"-group corpora. Therefore, for resetting it seems preferable to extract all the various search param and to truly reset the corpora - see reset_corpora_URL() below (PK 2010-08-20) } else { echo "=n"; } } } // For: statistics.php // Reset_corpora_URL() - function based on list_corpora_URL; only keeps corpora with 'y' in the URL // already uses return on output function reset_corpora_URL() { $_cpr = get_cpr(); $res = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).") ORDER BY cpr_group, cpr_usrid, cpr_cprid"); // Retrieves all available corpora (incl. all from 'Own' group for admins.) $short_corpora_list = ''; // Initialise variable BEFORE loop for ($i = 0; $i < mysql_num_rows($res); $i++) { if(!($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="temp")) { continue; } // = "temp" group skipped for non-admins if(($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="own") && (mysql_result($res, $i, "cpr_usrid") != "{$_SESSION['uid']}") && ($_SESSION["corpus" . $corpus_id] != "y")) { continue; } // For admins - Skip *unused* other users' (= Own) corpora. Those used will be passed along and made available in results $corpus_id = mysql_result($res, $i, "cpr_cprid"); if ($_SESSION["corpus" . $corpus_id] == "y") { $short_corpora_list .= "&corpus".$corpus_id."=y"; } // else { // $short_corpora_list = $short_corpora_list; } return $short_corpora_list; } // This function NO longer needed as counter of searched corpora is a session variable (PK 2011-09-21). So far only used in statistics.php // already uses return on output function count_corpora_searched() { $_cpr = get_cpr(); $res = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).")"); $corpuscount = 0; for ($i = 0; $i < mysql_num_rows($res); $i++) { // if(!($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="temp")){ continue; } $corpus_id = mysql_result($res, $i, "cpr_cprid"); // echo "&corpus$corpus_id"; // if (($_GET['corpus'.$corpus_id] == "y") || (($_GET['corpus'.$corpus_id] <> "y") && (mysql_result($res, $i, "cpr_checked") == 1) && ($_GET["query"] == ""))) // if ((mysql_result($res, $i, "cpr_checked") == 1) && ($_GET["query"] == "")) // if ($_GET['corpus'.$corpus_id] == "y") // PK: so far only success retrieving pre-checked corpora, with the mere line below; But Unable to force GET, 2010-06-08 16:00:26, PK // if (mysql_result($res, $i, "cpr_checked") == 1) { // the condition below copied from the section "Iterates through corpora" further down in this file, PK 2010-06-08 if ($_SESSION["corpus" . $corpus_id] == "y") { $corpuscount = $corpuscount+1; // echo "=y"; } else { $corpuscount = $corpuscount; // echo "=n"; } } return $corpuscount; } // PK: Lists default='checked' public corpora, as defined by various levels of access, in URL-ready format (used eg. in statistics.php) // $yes_no parameter must be 'y' or 'n' when this function is called from main code // already uses return on output // ++++ Function needs updating - so I can reliably use the output for dynamic search adjustment prompts. OR we need a separate function, producing mini lists of checked corpora for each corpus group... See more notes in statistics.php function list_checked_corpora_URL($yes_no) { $_cpr = get_cpr(); $res = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).") ORDER BY cpr_group, cpr_usrid, cpr_cprid"); $default_corpora_list_URL = ''; // initialised empty corpus list (so I can concatenate and use return at the end, PK 2010-08-15) for ($i = 0; $i < mysql_num_rows($res); $i++) { if(!($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="temp")){ continue; } // removes any "temp"-group corpora pre-checked by admin from the result that non-admins can see $corpus_id = mysql_result($res, $i, "cpr_cprid"); if (mysql_result($res, $i, "cpr_checked") == 1) { // != would select ALL the non-default corpora; not sure what other value to put there, 0 was no good (PK 2010-07-22) // echo "&corpus".$corpus_id."=".$yes_no.""; // Return and then variable assignment to output would probably not work, since the function is iterative, there is no one output cycle (PK 2010-07-22); NO !! See below, I managed to concatenate loops into a variable, then to use return and later to call the function to an external variable !! :) (PK 2010-08-15) // $default_corpora_list_URL = $default_corpora_list_URL . "&corpus".$corpus_id."=".$yes_no.""; $default_corpora_list_URL .="&corpus".$corpus_id."=".$yes_no.""; // This is the equivalent of the above , using .= } } // echo "

"; return $default_corpora_list_URL; } // PK: Lists default='checked' corpora, as defined by various levels of access, for use with initial Corpora Search forms (eg. welcome.php) // $yes_no parameter must be 'y' or 'n' when this function is called from main code // 2010-08-16 // already uses return on output function list_checked_corpora($yes_no) { $_cpr = get_cpr(); $res = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).") ORDER BY cpr_group, cpr_usrid, cpr_cprid"); $default_corpora_list = ''; // initialised empty corpus list (so I can concatenate and use return at the end, PK 2010-08-15) for ($i = 0; $i < mysql_num_rows($res); $i++) { if(!($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="temp")){ continue; } // removes any "temp"-group corpora pre-checked by admin from the result that non-admins can see $corpus_id = mysql_result($res, $i, "cpr_cprid"); if (mysql_result($res, $i, "cpr_checked") == 1) { // != would select ALL the non-default corpora; not sure what other value to put there, 0 was no good (PK 2010-07-22) //// $default_corpora_list .="&corpus".$corpus_id."=".$yes_no.""; // This is the equivalent of the above , using .= $default_corpora_list .=""; } } return $default_corpora_list; } //Lists all the NON-default' (non-checked) corpora (PK 2010-07-22), changed $res to $res1, which apparently prevented conflict with previous function // Deprecated ... - Not sure I will ever need this, so I don't bother converting to the return output ... function list_non_checked_corpora_URL($yes_no) { $_cpr = get_cpr(); $res1 = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).") ORDER BY cpr_group, cpr_usrid, cpr_cprid"); for ($i = 0; $i < mysql_num_rows($res1); $i++) { // if(!($_SESSION["grants"]["admin"]) && (strtolower(mysql_result($res, $i, "cpr_group"))=="temp")){ continue; } // ++++ Not sure if I should skip "Own" corpora (for admins) $corpus_id = mysql_result($res1, $i, "cpr_cprid"); // echo " "y") && (mysql_result($res1, $i, "cpr_checked") == 1) && ($_GET["query"] == ""))) // if ((mysql_result($res1, $i, "cpr_checked") == 1) && ($_GET["query"] == "")) // if ($_GET['corpus'.$corpus_id] == "y") // PK: so far only success retrieving pre-checked corpora, with the mere line below; But Unable to force GET, 2010-06-08 16:00:26, PK if (mysql_result($res1, $i, "cpr_checked") != 1) { // Selects ALL the non-default corpora, INCLUDING PERSONAL ONES !!; not sure what other value to put there, 0 was no good (PK 2010-07-22) // the condition below copied from the section "Iterates through corpora" further down in this file, PK 2010-06-08 // if ($_SESSION["corpus" . $corpus_id] == "y") { // echo "value='y' />"; echo "&corpus".$corpus_id."=".$yes_no.""; // Return and then variable assignment to output would probably not work, since the function is iterative, there is no one output cycle (PK 2010-07-22); $yes_no must be y or n // } else { // echo "value='n' />"; } } } // Return array with corpus id's of all corpora belonging to a given corpus group $cpr_group - Function added 2011-09-21 function grouped_corpora_array($cpr_group) { $_cpr = get_cpr(); $res = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).") ORDER BY cpr_group, cpr_usrid, cpr_cprid"); $corpus_group = array(); // Initialise ouput variable before the loop for ($i = 0; $i < mysql_num_rows($res); $i++) { $corpus_id = mysql_result($res, $i, "cpr_cprid"); if (strpos(mysql_result($res, $i, "cpr_group"), $cpr_group) !== false ) { // if (mysql_result($res2, $i, "cpr_group") == $cpr_group) { $corpus_group[] = $corpus_id; } } return $corpus_group; } // List all the corpora belonging to a group with y or n param (n not very useful, better to block, I think. Perhaps I will re-write this function accordinly, once, in the spirit of reset_corpora_URL). At the level of code taken group name as argument as well as the yes_no param ($res changes to $res2) function list_grouped_corpora_URL($cpr_group, $yes_no) { $_cpr = get_cpr(); $res2 = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).") ORDER BY cpr_group, cpr_usrid, cpr_cprid"); $corpus_group = ''; // Initialise ouput variable before the loop for ($i = 0; $i < mysql_num_rows($res2); $i++) { $corpus_id = mysql_result($res2, $i, "cpr_cprid"); if (mysql_result($res2, $i, "cpr_group") == $cpr_group) { $corpus_group .= "&corpus".$corpus_id."=".$yes_no.""; // } else { // echo "value='n' />"; } } return $corpus_group; } // Version of 'list_grouped_corpora_URL' with added corpus user/owner id param - needed to enable admin users to only retrieve their won "Own" corpora under some circumstances. Could also be used to specifically retrieve public corpora only (with third parameter equal "0") (2010-08-24) // Was lazy to think of using only this function also with the public groups. Maybe some day ... Maybe I will discover later that also other params are esential, so let's wait a bit and see ... (PK 2010-08-24) function list_grouped_corpora_URL2($cpr_group, $yes_no, $cpr_usrid) { $_cpr = get_cpr(); $res2 = mysql_query("SELECT * FROM cpr WHERE cpr_cprid IN (".implode(", ",$_cpr).") ORDER BY cpr_group, cpr_usrid, cpr_cprid"); $corpus_group = ''; // Initialise ouput variable before the loop for ($i = 0; $i < mysql_num_rows($res2); $i++) { $corpus_id = mysql_result($res2, $i, "cpr_cprid"); if ((mysql_result($res2, $i, "cpr_group") == $cpr_group) && (mysql_result($res2, $i, "cpr_usrid") == $cpr_usrid)) { $corpus_group .= "&corpus".$corpus_id."=".$yes_no.""; // } else { // echo "value='n' />"; } } return $corpus_group; } // Test function for diagnosing queries, so the description can be re-used by different modules (conc, coll, history, so eg search expressions can be interpreted in real time, 2010-09-15) function diagnose_query_params_test() { return $_SESSION['params']['query']; } //This function is not much used, was set as a temp function (see statistics.php), and is NOT effective. Sets a number of variables etc, but only returns the value of one of them on exit; I have therefore commented those unreturned variables below. Statistics and lib_search make use of complete duplicate scripts of what follows to be able to use $co_occur with or $from variables. If I wanted to use multiple variables outside this function , I would need to set these variables as globals, but overusing globals is NOT recommended programming practice, PK 2011-08-25 function colloc_params_test() { if ($_SESSION['params']['coll_mode'] < 0) { // $prefix = "L"; $coll_side_name = "left"; // PK 2010-09-13 - added for reporting collocation side in the results (did the same in lib_search.php) // $co_occur_with = "precede"; // PK 2010-09-15 - added for reporting collocation side in the results (did the same in lib_search.php) // $from = $_SESSION['params']['coll_mode']; // $_SESSION['params']['coll_type'] ? $to = $from : $to = -1; } else { // $prefix = "R"; $coll_side_name = "right"; // PK 2010-09-13 - added for reporting collocation side in the results (did the same in lib_search.php) // $co_occur_with = "follow"; // PK 2010-09-15 - added for reporting collocation side in the results (did the same in lib_search.php) // $to = $_SESSION['params']['coll_mode']; // $_SESSION['params']['coll_type'] ? $from = $to : $from = 1; } return $coll_side_name; } // http://php.net/manual/en/function.stats-standard-deviation.php. PK added 2011-09-19 function standard_deviation($aValues, $bSample = false) { global $fVariance; // PK (added global so I can use it outside the function if needed) $fMean = array_sum($aValues) / count($aValues); $fVariance = 0.0; foreach ($aValues as $i) { $fVariance += pow($i - $fMean, 2); } $fVariance /= ( $bSample ? count($aValues) - 1 : count($aValues) ); return (float) sqrt($fVariance); } /****************** ) END PK's functions **********************/ ?> array ( "name" => "Other", // Type name "query_type" => true, // Query types "exclude" => false, // Exclude "query_case" => true, // Query case-sensitiveness "boxes" => false, // Annotation boxes "contexts" => true, // Contexts "left_span" => 35, // Default width of the left span "right_span" => 45, // Default width of the right span "random" => false, // Random sample "random_num" => 20, // Default random sample "max_res" => 20, // Maximum no. of results "sort" => true, // Sort control "context_width" => 1, // Width of the context for context.php (0 means no access) "restr_corpora" => false, // Display all available coprora? "corpus_desc" => true, // Shall we display corpus descriptions? "admin" => false, // Access to administration "max_corpora" => 0, // Limits the number of corpora per user "file_size" => 100, // Maximum size of a corpus file, in KB "colloc" => true, // Access to the collocator "default_enrich" => true // Default enriched query ), "$usr_admin" => array ( "name" => "Admin", "query_type" => true, "exclude" => true, "query_case" => true, "boxes" => false, "contexts" => true, "left_span" => 45, "right_span" => 50, "random" => true, "random_num" => 20, "max_res" => 500, "sort" => true, "context_width" => 1, // Lowered value from 2 to 1 , since corpus browsing has now been introduced (PK 2010-07-10) "restr_corpora" => true, "corpus_desc" => true, "admin" => true, "max_corpora" => 30, "file_size" => 5000, "colloc" => true, "default_enrich" => true // Default enriched query ), "$usr_restr" => array ( "name" => "Restricted", "query_type" => true, "exclude" => true, "query_case" => true, "contexts" => true, "left_span" => 45, "right_span" => 50, "random" => true, "random_num" => 20, "max_res" => 500, "sort" => true, "context_width" => 1, // Lowered value from 2 to 1 , since corpus browsing has now been introduced (PK 2010-07-10) "restr_corpora" => true, "corpus_desc" => true, "admin" => false, "max_corpora" => 5, "file_size" => 600, "colloc" => true, "default_enrich" => true // Default enriched query ), "$usr_mozilla" => array ( "name" => "mozilla", "left_span" => 35, "right_span" => 45, "random_num" => 50, "context_width" => 1, "random_num" => 20 ) ); //Enriched type options $en_type_opt = array ( "in" => "within", "st" => "at the start of", "en" => "at the end of", "bf" => "before", "af" => "after", ); $scope_opt = array ( "text" => "all text", "p" => "paragraph", "s" => "sentence", "note" => "footnote text", "ackl" => "acknowledgment", "lquote" => "block quote", "exmpl" => "long example", "sect1" => "section title", "sect2" => "level 2 section title", "sect3" => "level 3 section title", "sect4" => "level 4 section title", "table" => "table caption", "fig" => "figure caption", "abs" => "abstract heading", "refer" => "references heading", "app" => "appendix heading", "xref" => "footnote marker", "intro" => "intro (experimental)", "theme" => "theme (experimental)", "rheme" => "rheme (experimental)" ); $punctuation = array( "PNXC" => "!", "PNQT" => "\"", "PNAP" => "'", "PNLP" => "\\(", "PNRP" => "\\)", "PNCM" => ",", "PNHY" => "-", "PNFS" => ".", "PNEL" => "...", "PNCL" => ":", "PNSC" => ";", "PNQM" => "?", "PN*" => "\\S+", "PNC*" => "\\S+" ); $replace = array( '

' => '||', '' => '|||', '' => '|||', '' => '|||', '' => '|||' ); $mozilla_corpus = "15"; // The corpus for Mozilla searches ?>