function ryzom_unset_url_param($name) { if (!isset($GLOBALS['URL_PARAMS'])) { $GLOBALS['URL_PARAMS'] = parse_query($_SERVER['REQUEST_URI']); } unset($GLOBALS['URL_PARAMS'][$name]); return $GLOBALS['URL_PARAMS']; }
/** * @param string $task Task request to be fulfilled. * @param string $db_name Path to a database containing tables required by * @param string $hash * @param string $pubkey * @param string $crypt * @param string $password * @param string $salt * @param string $iv * @return array|string * @throws \ErrorException */ function run_crypt_task($task, $db_name, $hash, $pubkey, $crypt = NULL, $password = NULL, $salt = NULL, $iv = NULL) { $db = null; $success = array("result" => "success"); $failure = array("result" => "failure"); $error = ""; $error_flag = false; $tasks = array("addClient", "studentFunction"); try { $db = new ClientDeviceSQL($db_name); } catch (\Exception $e) { $failure["error"] = $e->getMessage(); return $failure; } if (!$error_flag) { switch ($task) { case $tasks[0]: $success[$tasks[0]] = $db->addKey($pubkey); break; case $tasks[1]: if (!$db->keyAuthorized($hash)) { $failure["error"] = "Key not authorized for action."; return $failure; } $task_string = $db->decryptString($crypt, $hash); $data = parse_query($task_string); if (array_key_exists("function", $data) && (array_key_exists("userID", $data) || is_exception($data["function"]))) { $ret = run_task($data["userID"], $data["function"], $db_name); $success[$tasks[1]] = $db->encrypt_string(json_encode($ret), $hash); } else { $error = "Malformed URL"; $error_flag = true; } break; } } if (!$error_flag) { return $success; } else { $failure["error"] = $error; return $error; } }
/** * rawurlencode function that is path-safe (does not encode /) * * @param string $path URL * @return string */ function pathurlencode($path) { $parts = parse_url($path); if (isset($parts['query'])) { // some kind of query link $pairs = parse_query($parts['query']); if (preg_match('/^a=.*\\&i=?/i', $parts['query'])) { //image URI, handle & in file/folder names $index = 'a'; foreach ($pairs as $p => $q) { switch ($p) { case 'i': $index = 'i'; case 'a': break; default: if (is_null($q)) { $pairs[$index] .= '&' . $p; } else { if (in_array($p, array('s', 'w', 'h', 'cw', 'ch', 'cx', 'cy', 'q', 'c', 't', 'wmk', 'admin', 'effects', 'z'))) { // image processor parameters break 2; } else { $pairs[$index] .= '&' . $p . '=' . $q; } } unset($pairs[$p]); break; } } } foreach ($pairs as $name => $value) { if ($value) { $pairs[$name] = implode("/", array_map("rawurlencode", explode("/", $value))); } } $parts['query'] = build_query($pairs); } $parts['path'] = implode("/", array_map("rawurlencode", explode("/", $parts['path']))); return build_url($parts); }
/** * put your comment there... * * @param mixed $query * @param mixed $search_type * @param mixed $parms * @param mixed $wg_ids * @param mixed $publicOnly */ function REQUEST_to_query($query, $search_type, $parms = NULL, $wg_ids = NULL, $publicOnly = false) { // wg_ids is a list of the workgroups we can access; Records records marked with a rec_OwnerUGrpID not in this list are omitted /* use the supplied _REQUEST variables (or $parms if supplied) to construct a query starting with $query */ if (!$parms) { $parms = $_REQUEST; } if (!defined('stype') && @$parms['stype']) { define('stype', @$parms['stype']); } if (!$wg_ids && function_exists('get_user_id')) { $wg_ids = mysql__select_array(USERS_DATABASE . '.sysUsrGrpLinks left join ' . USERS_DATABASE . '.sysUGrps grp on grp.ugr_ID=ugl_GroupID', 'ugl_GroupID', 'ugl_UserID=' . get_user_id() . ' and grp.ugr_Type != "User" order by ugl_GroupID'); } if (!@$parms['qq'] && !preg_match('/&&|\\bAND\\b/i', @$parms['q'])) { $query .= parse_query($search_type, @$parms['q'], @$parms['s'], $wg_ids, $publicOnly); } else { // search-within-search gives us top-level ANDing (full expressiveness of conjunctions and disjunctions! hot damn) // basically for free! /* $q_bits = explode('&&', $parms['qq']); if ($parms['q']) array_push($q_bits, $parms['q']); */ $qq = @$parms['qq']; if ($parms['q']) { if ($qq) { $qq .= ' && ' . $parms['q']; } else { $qq = $parms['q']; } } $q_bits = preg_split('/&&|\\bAND\\b/i', $qq); $where_clause = ''; $q_clauses = array(); foreach ($q_bits as $q_bit) { $q = parse_query($search_type, $q_bit, @$parms['s'], $wg_ids, $publicOnly); // for each qbit if there is owner/vis followed by clause followed by order by, capture it for and'ing preg_match('/.*?where [(]rec_OwnerUGrpID=[-0-9]* or (?:rec_NonOwnerVisibility="public"|not rec_NonOwnerVisibility="hidden")(?: or rec_OwnerUGrpID in \\([0-9,]*\\))?[)] and (.*?) order by/s', $q, $matches); if ($matches[1]) { array_push($q_clauses, '(' . $matches[1] . ')'); } } sort($q_clauses); $where_clause = join(' and ', $q_clauses); // check last qbits for form of owner/vis prefix and order by suffix, then capture and add them if (preg_match('/(.*?where [(]rec_OwnerUGrpID=[0-9]* or (?:rec_NonOwnerVisibility="public"|not rec_NonOwnerVisibility="hidden")(?: or rec_OwnerUGrpID in [(][0-9,]*[)])?[)] and ).*?( order by.*)$/s', $q, $matches)) { $query .= $matches[1] . $where_clause . $matches[2]; } } if (array_key_exists("l", $parms) || array_key_exists("limit", $parms)) { if (array_key_exists("l", $parms)) { $limit = intval(@$parms["l"]); unset($parms["l"]); } else { if (array_key_exists("limit", $parms)) { $limit = intval(@$parms["limit"]); // this is back in since hml.php passes through stuff from sitemap.xmap } else { $limit = 100; } } if ($limit < 1) { unset($limit); } if (@$limit) { //ARTEM. It should not overwrite the limit specified in dispPreferences $limit = min($limit, 1000); } else { $limit = 100; // Artem says 12/3/12 that this will not happen b/c it only happens if the parameter is bad. } if (array_key_exists("o", $parms)) { $offset = intval(@$parms["o"]); unset($parms["o"]); } else { if (array_key_exists("offset", $parms)) { $offset = intval(@$parms["offset"]); // this is back in since hml.php passes through stuff from sitemap.xmap } } $query .= (@$limit ? " limit {$limit}" : "") . (@$offset ? " offset {$offset} " : ""); } return $query; }
/** * main request to find crosstab data * * @param mixed $mysqli * @param mixed $params * dt_page - detail type for page/groups * dt_col - detail type for columns * dt_row - detail type for rows * agg_mode - aggreagation mode: sum, avg, count * agg_field - field for avg or sum mode * q - current Heurist query */ function getCrossTab($mysqli, $params) { $dt_page = @$params['dt_page']; if ($dt_page) { $pagefld = ", d4.dtl_Value as page"; } else { $pagefld = ""; } $dt_col = @$params['dt_col']; if ($dt_col) { $columnfld = "d1.dtl_Value as cls, "; } else { $columnfld = "0, "; } $mode = @$params['agg_mode']; $issum = ($mode == "avg" || $mode == "sum") && @$params['agg_field']; if ($issum) { $mode = $mode . "(cast(d3.dtl_Value as decimal(20,2)))"; //.$params['agg_field'].")"; } else { $mode = "count(*)"; } if (function_exists('get_user_id')) { $wg_ids = mysql__select_array(USERS_DATABASE . '.sysUsrGrpLinks left join ' . USERS_DATABASE . '.sysUGrps grp on grp.ugr_ID=ugl_GroupID', 'ugl_GroupID', 'ugl_UserID=' . get_user_id() . ' and grp.ugr_Type != "User" order by ugl_GroupID'); } else { $wg_ids = null; } $search_type = @$params['w'] == "bookmark" || @$params['w'] == "b" ? $params['w'] : "all"; $where = getWhereRecordIds($params); if ($where == null) { $where = parse_query($search_type, @$params['q'], null, $wg_ids, false); } else { $where = parse_query($search_type, 'ids:' . $where, null, $wg_ids, false); } //remove order by $pos = strrpos($where, " order by "); if ($pos) { $where = substr($where, 0, $pos); } //insert our where clauses $pos = strpos($where, " where "); $where_1 = substr($where, 0, $pos); $where_2 = substr($where, $pos + 7); $query = "select d2.dtl_Value as rws, " . $columnfld . $mode . " as cnt " . $pagefld . " " . $where_1; $query = $query . " left join recDetails d2 on d2.dtl_RecID=rec_ID and d2.dtl_DetailTypeID=" . $params['dt_row']; if ($dt_col) { $query = $query . " left join recDetails d1 on d1.dtl_RecID=rec_ID and d1.dtl_DetailTypeID=" . $dt_col; } if ($dt_page) { $query = $query . " left join recDetails d4 on d4.dtl_RecID=rec_ID and d4.dtl_DetailTypeID=" . $dt_page; } if ($issum) { $query = $query . " ,recDetails d3 " . " where d3.dtl_RecID=rec_ID and d3.dtl_Value is not null && d3.dtl_DetailTypeID=" . $params['agg_field'] . " and " . $where_2; } else { $query = $query . " where " . $where_2; //20130517 rec_RectypeID=".$params['rt']; } //20130517 $query = $query." and ".$where_2; $query = $query . " group by d2.dtl_Value "; if ($dt_col) { $query = $query . ", d1.dtl_Value"; } if ($dt_page) { $query = $query . ", d4.dtl_Value "; } $query = $query . " order by "; if ($dt_page) { if ($params['dt_pagetype'] == "integer" || $params['dt_pagetype'] == "float") { $query = $query . " cast(d4.dtl_Value as decimal(20,2)), "; } else { $query = $query . " d4.dtl_Value, "; } } if ($params['dt_rowtype'] == "integer" || $params['dt_rowtype'] == "float") { $query = $query . " cast(d2.dtl_Value as decimal(20,2)) "; } else { $query = $query . " d2.dtl_Value "; } if ($dt_col) { if ($params['dt_coltype'] == "integer" || $params['dt_coltype'] == "float") { $query = $query . ", cast(d1.dtl_Value as decimal(20,2))"; } else { $query = $query . ", d1.dtl_Value"; } } //error_log($query); $res = $mysqli->query($query); if (!$res) { $response = array("status" => "INVALID REQUEST", "message" => $mysqli->error); //$response = $system->addError(HEURIST_DB_ERROR, "Search query error", $mysqli->error); } else { $outp = array(); while ($row = $res->fetch_row()) { array_push($outp, $row); } $response = array("status" => "OK", "data" => $outp); $res->close(); } return $response; }
/** * * Prints a download link for an album zip of the current album (therefore to be used only on album.php/image.php). * This function only creates a download count and then redirects to the original Zenphoto album zip download. * * @param string $linktext * @param object $albumobj * @param bool $fromcache if true get the images from the cache */ function printDownloadAlbumZipURL($linktext = NULL, $albumobj = NULL, $fromcache = NULL) { global $_zp_current_album; $request = parse_url(getRequestURI()); if (isset($request['query'])) { $query = parse_query($request['query']); } else { $query = array(); } if (is_null($albumobj)) { $albumobj = $_zp_current_album; } if (!is_null($albumobj) && !$albumobj->isDynamic()) { $file = $albumobj->name . '.zip'; DownloadList::addListItem($file); if (getOption('downloadList_showdownloadcounter')) { $downloaditem = DownloadList::getListItemFromDB($file); if ($downloaditem) { $downloadcount = ' - ' . sprintf(ngettext('%u download', '%u downloads', $downloaditem['data']), $downloaditem['data']); } else { $downloadcount = ' - ' . gettext('0 downloads'); } $filesize = '<small>' . $downloadcount . '</small>'; } else { $filesize = ''; } if (!empty($linktext)) { $file = $linktext; } $query['download'] = $albumobj->name; $query['albumzip'] = 'true'; if ($fromcache) { $query['fromcache'] = 'true'; } $link = FULLWEBPATH . '/' . preg_replace('~^' . WEBPATH . '/~', '', $request['path']) . '?' . http_build_query($query); echo '<a href="' . html_encode($link) . '" rel="nofollow" class="downloadlist_link">' . html_encode($file) . '</a>' . $filesize; } }
$iconImgStyle = array(); $iconImgStyle["border"] = "0px"; $iconImgStyle["position"] = "absolute"; $iconImgStyle["top"] = "5px"; $iconImgStyle["left"] = "5px"; //$iconImgStyle["width"] = "100%"; //$iconImgStyle["height"] = "100%"; $overlayImgStyle = array(); $overlayImgStyle["position"] = "absolute"; $overlayImgStyle["border"] = "0px"; $overlayImgStyle["top"] = "0px"; $overlayImgStyle["left"] = "0px"; $overlayImgStyle["width"] = "100%"; $overlayImgStyle["height"] = "100%"; $urlComponents = parse_url($url); $queryParts = parse_query($url); //print_r($queryParts); if (array_key_exists("v", $queryParts)) { $videoId = $queryParts["v"]; } //$iconUrl = "http://i2.ytimg.com/vi/$videoId/default.jpg"; $targetFrame = $_GET["targetFrame"]; //print $targetFrame; ?> <div style="<?php foreach ($iconDivStyle as $key => $value) { print "{$key}:{$value};"; } ?> ">
/** * Prints the album password form * * @param string $hint hint to the password * @param bool $showProtected set false to supress the password protected message * @param bool $showuser set true to force the user name filed to be present * @param string $redirect optional URL to send the user to after successful login * * @since 1.1.3 */ function printPasswordForm($_password_hint, $_password_showuser = NULL, $_password_showProtected = true, $_password_redirect = NULL) { global $_zp_login_error, $_zp_password_form_printed, $_zp_current_search, $_zp_gallery, $_zp_gallery_page, $_zp_current_album, $_zp_current_image, $theme, $_zp_current_page, $_zp_authority; if ($_zp_password_form_printed) { return; } $_zp_password_form_printed = true; if (is_null($_password_redirect)) { $parts = parse_url(getRequestURI()); if (array_key_exists('query', $parts)) { $query = parse_query($parts['query']); } else { $query = array(); } $query['userlog'] = 1; if (isset($_GET['p']) && $_GET['p'] == 'password') { // redirecting here would be terribly confusing unset($query['p']); $parts['path'] = SEO_WEBPATH; } $parts['query'] = http_build_query($query); $action = build_url($parts); $_password_redirect = $action; } ?> <div id="passwordform"> <?php if ($_password_showProtected && !$_zp_login_error) { ?> <p> <?php echo gettext("The page you are trying to view is password protected."); ?> </p> <?php } if ($loginlink = zp_apply_filter('login_link', NULL)) { $logintext = gettext('login'); ?> <a href="<?php echo $loginlink; ?> " title="<?php echo $logintext; ?> "><?php echo $logintext; ?> </a> <?php } else { $_zp_authority->printLoginForm($_password_redirect, false, $_password_showuser, false, $_password_hint); } ?> </div> <?php }
# Three word book title (ie. Doctrine and Covenants, Words of Mormon) $book .= ' ' . $query[2]; $chapter = $query[3]; } } } if (strcspn($query[0], '0123456789') != strlen($query[0])) { # Book that starts with a number (ie. 1 Nephi, 2 Corinthians, 3 John) $book = $query[0] . ' ' . $query[1]; $chapter = $query[2]; } $get_verse = explode(':', $chapter); $result['book'] = $book; $result['chapter'] = $get_verse[0]; $result['verse'] = $get_verse[1]; return $result; } // End of parse_query() $query = parse_query($_REQUEST['query']); $book = mysql_escape_string($query['book']); $sql = <<<SQL \tSELECT b.* \tFROM lds_scriptures_books b \tWHERE b.book_title='{$book}' SQL; $results = mysql_query($sql, $conn) or die('Something went wrong! ' . mysql_error()); db_close($conn); $line = mysql_fetch_array($results); $verse_url = $query['verse'] ? '/' . $query['verse'] : ""; $url = "/" . $line['lds_org'] . "/" . $query['chapter'] . $verse_url; echo json_encode($url);
$to = $_REQUEST["to"]; $map_status = array(); $map_status = get_map_server_outgoing_queue_status($school_id, $from, $to); $html = ""; $html .= "<table class='table table-bordered tab-inc-stat'>"; $html .= "<thead>\n <th>Tablet-Id</th>\n <th>action</th>\n <th>table</th>\n <th id='data-width'>data</th>\n <th>status</th>\n <th>created_at</th>\n </thead>"; $html .= "<tbody>"; foreach ($map_status["status"] as $map) { $tab_id = $map["tab_id"]; $table = $map["table_name"]; $action = $map["action"]; $query = $map["query"]; $ack = $map["ack"]; $created_at = $map["created_at"]; $parse_map = array(); $parse_map = json_encode(parse_query($action, $query)); $parse_str = str_replace('\\"', '', $parse_map); if ($ack == 0) { $ack_icon = "<i class='icon-remove-sign'></i>"; } else { $ack_icon = "<i class='icon-ok-sign'></i>"; } $html .= "<tr>"; $html .= "<td>{$tab_id}</td>"; $html .= "<td>" . strtolower($action) . "</td>"; $html .= "<td>{$table}</td>"; $html .= "<td>{$parse_str}</td>"; $html .= "<td>{$ack_icon}</td>"; $html .= "<td>{$created_at}</td>"; $html .= "</tr>"; }
function ryzom_render_www_begin($url = '') { $style1 = 'position: relative; padding-top: 20px; padding-right: 30px; margin-bottom: -3px'; $style2 = 'position: absolute; bottom: 0; right: 0; '; if (ON_IPHONE) { $style1 = 'position: relative; padding-top: 30px; padding-right: 30px; '; $style2 = 'position: fixed; top: 0; right: 0; padding-right: 0px;'; $marginBottom = ''; } if (!$url) { $url_params = parse_query($_SERVER['REQUEST_URI']); unset($url_params['lang']); $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . http_build_query($url_params); } return ' <br /> <div id="main"> <div style="' . $style1 . '"> <a href="' . $url . '&lang=en"><img hspace="5" border="0" src="' . RYAPI_URL . 'data/img/lang/en.png" alt="English" /></a> <a href="' . $url . '&lang=fr"><img hspace="5" border="0" src="' . RYAPI_URL . 'data/img/lang/fr.png" alt="French" /></a> <a href="' . $url . '&lang=de"><img hspace="5" border="0" src="' . RYAPI_URL . 'data/img/lang/de.png" alt="German" /></a> <a href="' . $url . '&lang=es"><img hspace="5" border="0" src="' . RYAPI_URL . 'data/img/lang/es.png" alt="Spanish" /></a> <a href="' . $url . '&lang=ru"><img hspace="5" border="0" src="' . RYAPI_URL . 'data/img/lang/ru.png" alt="Russian" /></a> <div style="' . $style2 . '"> <a href="http://www.ryzom.com/"><img border="0" src="' . RYAPI_URL . 'data/img/logo.gif" alt=""/></a> </div> </div> '; }
/** * 分拆url的参数为数组 * * @param type $url */ function http_parse_query($url, $decode = false) { $parsed_link = parse_url($url); if (empty($parsed_link["query"])) { return array(); } return parse_query($parsed_link["query"], $decode); }
/** * rawurlencode function that is path-safe (does not encode /) * * @param string $path URL * @return string */ function pathurlencode($path) { $parts = parse_url($path); if (isset($parts['query'])) { // some kind of query link $pairs = parse_query($parts['query']); $parts['query'] = http_build_query($pairs); } if (array_key_exists('path', $parts)) { $parts['path'] = implode("/", array_map("rawurlencode", explode("/", $parts['path']))); } return build_url($parts); }
/** * * Prints a download link for an album zip of the current album (therefore to be used only on album.php/image.php). * This function only creates a download count and then redirects to the original album zip download. * * @param string $linktext * @param object $albumobj * @param bool $fromcache if true get the images from the cache */ function printDownloadAlbumZipURL($linktext = NULL, $albumobj = NULL, $fromcache = NULL) { global $_zp_current_album; $request = parse_url(getRequestURI()); if (isset($request['query'])) { $query = parse_query($request['query']); } else { $query = array(); } if (is_null($albumobj)) { $albumobj = $_zp_current_album; } if (!is_null($albumobj)) { $query['albumzip'] = 'true'; if (get_class($albumobj) == 'favorites') { $query['download'] = $file = gettext('My favorites'); $query['user'] = $albumobj->name; $instance = $query['instance'] = $albumobj->instance; if ($instance) { $file .= '[' . $instance . ']'; $query['download'] .= '[' . $instance . ']'; } $file .= '.zip'; } else { $query['download'] = $albumobj->name; $file = $albumobj->name . '.zip'; } if ($fromcache) { $query['fromcache'] = 'true'; } DownloadList::addListItem($file); if (getOption('downloadList_showdownloadcounter')) { $downloaditem = DownloadList::getListItemFromDB($file); if ($downloaditem) { $downloadcount = $downloaditem['data']; } else { $downloadcount = 0; } $filesize = '<small> - ' . sprintf(ngettext('%u download', '%u downloads', $downloadcount), $downloadcount) . '</small>'; } else { $filesize = ''; } if (!empty($linktext)) { $file = $linktext; } $link = preg_replace('~^' . WEBPATH . '/~', '', $request['path']); echo '<a href="' . FULLWEBPATH . '/' . html_encode(pathurlencode($link)) . '?' . http_build_query($query) . '" rel="nofollow class="downloadlist_link"">' . html_encode($file) . '</a>' . $filesize; } }
/** * Use the supplied _REQUEST variables (or $params if supplied) to construct a query starting with $query prefix * * @param System $system * @param mixed $query - prefix (usually SELECT with list of fields) * @param mixed $params * parameters: stype - (OUTDATED) type of search: key - by tag title, all - by title of record and titles of its resource, by default by record title s - sort order (NOTE!!! sort may be defined in "q" parameter also) l or limit - limit of records o or offset w - domain of search a|all, b|bookmark, e (everything) qq - several conjunctions and disjunctions q - query string keywords for 'q' parameter url: url title: title contains t: record type id f: field id tag: tag id: id n: description usr: user id any: relatedto: sortby: * * @param mixed $currentUser - array with indexes ugr_ID, ugr_Groups (list of group ids) * we can access; Records records marked with a rec_OwnerUGrpID not in this list are omitted */ function get_sql_query_clauses($db, $params, $currentUser = null) { global $mysqli; $mysqli = $db; /* use the supplied _REQUEST variables (or $params if supplied) to construct a query starting with $select_clause */ if (!$params) { $params = array(); } //$_REQUEST; if (!defined('stype') && @$params['stype']) { define('stype', @$params['stype']); } // 1. DETECT CURRENT USER AND ITS GROUPS, if not logged search only all records (no bookmarks) ---------------------- $wg_ids = array(); //may be better use $system->get_user_group_ids() ??? if ($currentUser && @$currentUser['ugr_ID'] > 0) { if (@$currentUser['ugr_Groups']) { $wg_ids = array_keys($currentUser['ugr_Groups']); } $currUserID = $currentUser['ugr_ID']; array_push($wg_ids, $currUserID); } else { $currUserID = 0; $params['w'] = 'all'; } array_push($wg_ids, 0); // be sure to include the generic everybody workgroup $publicOnly = @$params['publiconly'] == 1; //@todo // 2. DETECT SEARCH DOMAIN ------------------------------------------------------------------------------------------ if (strcasecmp(@$params['w'], 'B') == 0 || strcasecmp(@$params['w'], BOOKMARK) == 0) { // my bookmark entries $search_domain = BOOKMARK; } else { if (@$params['w'] == 'e') { //everything - including temporary $search_domain = EVERYTHING; } else { // all records entries $search_domain = null; } } // 3a. SPECIAL CASE for _BROKEN_ $needbroken = false; if (@$params['q'] && preg_match('/\\b_BROKEN_\\b/', $params['q'])) { $params['q'] = preg_replace('/\\b_BROKEN_\\b/', '', $params['q']); $needbroken = true; } // 3b. SPECIAL CASE for _NOTLINKED_ $neednotlinked = false; if (@$params['q'] && preg_match('/\\b_NOTLINKED_\\b/', $params['q'])) { $params['q'] = preg_replace('/\\b_NOTLINKED_\\b/', '', $params['q']); $neednotlinked = true; } // 4. QUERY MAY BE SIMPLE or full expressiveness ---------------------------------------------------------------------- $query = parse_query($search_domain, @$params['q'], @$params['s'], @$params['parentquery'], $currUserID); $where_clause = $query->where_clause; // 4a. SPECIAL CASE for _BROKEN_ if ($needbroken) { $where_clause = '(to_days(now()) - to_days(rec_URLLastVerified) >= 8) ' . ($where_clause ? ' and ' . $where_clause : ''); } // 4b. SPECIAL CASE for _NOTLINKED_ if ($neednotlinked) { $where_clause = '(not exists (select rl_ID from recLinks where rl_SourceID=TOPBIBLIO.rec_ID or rl_TargetID=TOPBIBLIO.rec_ID )) ' . ($where_clause ? ' and ' . $where_clause : ''); } // 5. DEFINE USERGROUP RESTRICTIONS --------------------------------------------------------------------------------- if ($search_domain != EVERYTHING) { if ($where_clause) { $where_clause = '(' . $where_clause . ') and '; } if ($search_domain == BOOKMARK) { $where_clause .= ' (bkm_UGrpID=' . $currUserID . ' and not TOPBIBLIO.rec_FlagTemporary) '; } else { if ($search_domain == BIBLIO) { //NOT USED $where_clause .= ' (bkm_UGrpID is null and not TOPBIBLIO.rec_FlagTemporary) '; } else { $where_clause .= ' not TOPBIBLIO.rec_FlagTemporary '; } } } if ($publicOnly) { $query->recVisibilityType = "public"; } if ($query->recVisibilityType && $query->recVisibilityType != "hidden") { $where2 = '(TOPBIBLIO.rec_NonOwnerVisibility="' . $query->recVisibilityType . '")'; //'pending','public','viewable' } else { if ($query->recVisibilityType) { //hidden $where2 = 'TOPBIBLIO.rec_NonOwnerVisibility="hidden" and '; } else { $where2 = '(not TOPBIBLIO.rec_NonOwnerVisibility="hidden") or '; } $where2 = '( ' . $where2 . 'TOPBIBLIO.rec_OwnerUGrpID in (' . join(',', $wg_ids) . ') )'; } $where_clause = $where_clause . ' and ' . $where2; // 6. DEFINE LIMIT AND OFFSET --------------------------------------------------------------------------------------- $limit = get_limit($params); $offset = get_offset($params); // 7. COMPOSE QUERY ------------------------------------------------------------------------------------------------ return array("from" => $query->from_clause, "where" => $where_clause, "sort" => $query->sort_clause, "limit" => " LIMIT {$limit}", "offset" => $offset > 0 ? " OFFSET {$offset} " : ""); }