auth['uname']; } // -- CACHE ------------------------------------------------------------------- // CACHE_TTL defines the time in seconds the page will be stored in cache // (Time To Live) - in fact it can be infinity because of automatic cache // flushing on page change /** Create keystring from values, which exactly identifies resulting content */ // 25June03 - Mitra - added post2shtml into here, maybe should add all URL? // 25Sept03 - Honza - all apc_state is serialized instead of just // $apc_state['state'] (we store browser agent in state in kormidlo.cz) // 28Apr05 - Honza - added also $all_ids, $add_disc, $disc_type, $sh_itm, // $parent_id, $ids, $sel_ids, $disc_ids - for discussions // - it is in fact all global variables used in view.php3 $cache_key = get_hash('site', PageCache::globalKeyArray(), $_SERVER['REQUEST_URI'], $_SERVER['REDIRECT_URL'], $_SERVER['REDIRECT_QUERY_STRING_UNESCAPED'],$_SERVER['QUERY_STRING_UNESCAPED'], $_POST, $_GET, $auth4cache); // $_GET because $_SERVER['REQUEST_URI'] do not contain variables from Rewrite (site_id); *_STRING_UNESCAPED is for old sitemodule - see shtml_query_string(); PageCache::globalKeyArray - now only for _COOKIES and HTTP_HOST // store nocache to the variable (since it should be set for some view and we // do not want to have it set for whole site. // temporary solution - should be solved on view level (not global nocache) - TODO $site_nocache = $_REQUEST['nocache'] OR isset($_POST['aa']); if ($cacheentry = $GLOBALS['pagecache']->getPage($cache_key,$site_nocache)) { $cacheentry->processPage(); if ( AA::$debug ) { echo '

Site cache hit!!!'; echo '
Page generation time: '. (microtime(true) - $timestart); echo '
Dababase instances: '. DB_AA::$_instances_no; echo '
(spareDBs): '. count($spareDBs); AA::$dbg->duration_stat(); } exit; } // -- /CACHE ------------------------------------------------------------------ require_once AA_INC_PATH."util.php3"; function IsInDomain( $domain ) { return (($_SERVER['HTTP_HOST'] == $domain) || ($_SERVER['HTTP_HOST'] == 'www.'.$domain)); } function StripslashesDeep($value) { return is_array($value) ? array_map('StripslashesDeep', $value) : stripslashes($value); } function Die404($page=null) { function_exists('http_response_code') ? http_response_code(404) : header( ($_SERVER['SERVER_PROTOCOL'] ?: 'HTTP/1.0'). ' 404 Not Found'); if (!is_null($page)) { header('Content-Type: '. (AA::$headers['type'] ?: 'text/html') .'; charset='.(AA::$headers['encoding'] ?: AA::$encoding ?: $GLOBALS["LANGUAGE_CHARSETS"][get_mgettext_lang()])); echo AA_Stringexpand::unalias($page); } // else { echo '404 Not Found

Not Found

The requested URL was not found on this server.

'; } exit; } // ----------------- function definition end ----------------------------------- // change the state add_vars(); // get variables pased to stm page if ( get_magic_quotes_gpc() ) { $_POST = StripslashesDeep($_POST); $_GET = StripslashesDeep($_GET); $_REQUEST = StripslashesDeep($_REQUEST); $_COOKIE = StripslashesDeep($_COOKIE); } require_once AA_BASE_PATH."modules/site/router.class.php"; $err["Init"] = ""; // error array (Init - just for initializing variable if (strpos($host = $_SERVER['HTTP_HOST'], 'www.')===0) { $host2 = substr($host,4); } else { $host2 = 'www.'.$host; } $domain_arr = array("http://$host/", "https://$host/","http://$host", "https://$host","http://$host2/", "https://$host2/","http://$host2", "https://$host2"); AA::$site_id = $_REQUEST['site_id'] ?: unpack_id(DB_AA::select1("SELECT id FROM `module`", 'id', array(array('type','W'),array('slice_url', $domain_arr)))); if ( !($module = AA_Module_Site::getModule(AA::$site_id)) ) { Die404(); exit; } $lang_file = $module->getProperty('lang_file'); AA::$encoding = $module->getCharset(); // @deprecated - use AA_Router_Seo instead // There are two possibilities, how to control the apc_state variable. It could // be se in ./modules/site/sites/site_...php control file. The control file // could be managed only by people, who have the access to the AA sources on the // server. If we want to permit control of the site to extenal people, which do // not have access to AA scripts directory, then it is possible to them to not // fill "site control file" in site configuration dialog and then call this // script from their own file, where the new $apc_state, $slices4cache and // $site_id will be defined and passed by GET method. Just like this: // // $url = 'http://example.org/apc-aa/modules/site/site.php3?'; // $url .= http_build_query( array( 'apc_state' => $apc_state, // 'slices4cache' => $slices4cache, // 'site_id' => 'ae54378beac7c7e8a998e7de8a998e7a' // )); // readfile($url); // /@deprecated - use AA_Router_Seo instead $hit_lid = null; if ($module->getProperty('flag') == 1) { // 1 - Use AA_Router_Seo if (!is_object($sess)) { // could be already opened above pageOpen('nobody'); } $seo_slices = $module->getRelatedSlices(); // home can contain some logic like: {ifin:{server:SERVER_NAME}:czechweb.cz:/cz/home:/en/home} $home = AA_Stringexpand::unalias(trim($module->getProperty('state_file'))) ?: '/' .substr($lang_file,0,2). '/'; $router = AA_Router::singleton('AA_Router_Seo', $seo_slices, $home, $module->getProperty('web_languages')); // use REDIRECT_URL for homepage redirects: // RewriteRule ^/?$ /en/home [QSA] // RewriteRule ^/?en /apc-aa/modules/site/site.php3?site_id=439ee0af030d6b2598763de404aa5e34 [QSA,L,PT] // or (I think better) // RewriteEngine on // RewriteRule ^/?$ /apc-aa/modules/site/site.php3?site_id=439ee0af030d6b2598763de404aa5e34 [QSA,L,PT] // RewriteRule ^/?en /apc-aa/modules/site/site.php3?site_id=439ee0af030d6b2598763de404aa5e34 [QSA,L,PT] $uri = (strlen($_SERVER['REQUEST_URI']) > 1) ? $_SERVER['REQUEST_URI'] : $_SERVER['REDIRECT_URL']; $apc_state = $router->parse($uri); $lang_file = substr_replace($lang_file, $apc_state['xlang'], 0, 2); // count hit for current page - deffered after the page is sent to user if (!($hit_lid = $router->xid())) { if ($module->getProperty('page404') == '2') { Die404(); exit; } if ($module->getProperty('page404') == '3') { Die404($module->getProperty('page404_code')); exit; } // else - older behavior - site cares } // } elseif( $uri AND $router->xid(null, "/$lang_file/_404-not-found")) { // item not found => 404 // $apc_state = $router->parse("/$lang_file/_404-not-found"); } elseif ( $module->getProperty('state_file') ) { // in the following file we should define apc_state variable require_once AA_BASE_PATH."modules/site/sites/site_".$module->getProperty('state_file'); $apc_state['4cacheQS'] = shtml_query_string(); $_REQUEST['nocache'] = $_REQUEST['nocache'] ?: $nocache; } if ( !isset($apc_state) ) { Die404(($module->getProperty('page404') == '3') ? $module->getProperty('page404_code') : null); exit; } require_once AA_BASE_PATH."modules/site/util.php3"; // module specific utils require_once AA_BASE_PATH."modules/site/sitetree.php3"; require_once AA_INC_PATH."searchlib.php3"; require_once AA_INC_PATH."easy_scroller.php3"; require_once AA_INC_PATH."view.php3"; require_once AA_INC_PATH."discussion.php3"; require_once AA_INC_PATH."item.php3"; if ($lang_file) { mgettext_bind(GetLang($lang_file), 'output'); AA::$lang = strtolower(substr($lang_file,0,2)); // actual language - two letter shortcut cz / es / en AA::$langnum = array(AA_Content::getLangNumber(AA::$lang)); // array of prefered languages in priority order. } if (is_array($_POST['aa']) AND IsAjaxCall()) { $grabber = new AA_Grabber_Form(); $saver = new AA_Saver($grabber, null, null, 'by_grabber'); // $saver - > check Perms @todo $saver->run(); $apc_state['xajax'] = 2; // to not be 1 $page_content = $module->getSite( $apc_state ); header("Content-type: application/json"); // print_r($page_content); // print_r($saver->changedModules()); // print_r(AA_Stringexpand::$dependent_parts); // print_r(AA_Stringexpand::getDependentParts($saver->changedModules())); $parts = AA_Stringexpand::getDependentParts($saver->changedModules()); if (AA::$encoding != 'utf-8') { $convertor = ConvertCharset::singleton(); foreach ($parts as $k => $v) { $parts[$k] = $convertor->Convert($v, AA::$encoding, 'utf-8'); } } echo json_encode($parts); exit; } $page_content = $module->getSite( $apc_state ); // AJAX check if ((AA::$headers['encoding'] != 'utf-8') && (AA::$encoding != 'utf-8') && IsAjaxCall()) { $page_content = ConvertCharset::singleton()->Convert($page_content, AA::$encoding, 'utf-8'); AA::$headers['encoding'] = 'utf-8'; } $cacheentry = new AA_Cacheentry($page_content, AA::getHeaders(), $hit_lid); $cacheentry->processPage(); // changed the way, how to get $slices4cache - now we ask for module ids realy // used during page generation. Honza 2015-12-29 $slices4cache = AA_Module::getUsedModules(); if (empty($slices4cache)) { // can't be combined empty() and assignment = for php 5.3 // probably not necessary $slices4cache = array(AA::$site_id); } // do not cache for logged users if (!$site_nocache AND empty($apc_state['xuser'])) { $str2find = new CacheStr2find($slices4cache, 'slice_id'); $GLOBALS['pagecache']->storePage($cache_key, $cacheentry, $str2find); } if (AA::$debug&2) { echo '

Site cache MIS!!!'; echo '
Page generation time: '. (microtime(true) - $timestart); echo '
Dababase instances: '. DB_AA::$_instances_no; echo '
(spareDBs): '. count($spareDBs); echo '
UsedModules:
- '. join('
- ', array_map(function($mid) {return AA_Module::getModuleName($mid);}, $slices4cache)); AA::$debug&4 && AA::$dbg->duration_stat(); } // ----------------- process status end --------------------------------------- function ModW_StoreIDs($spot_id, $depth) { $GLOBALS['show_ids'][] = $spot_id; } // id = an item id, unpacked or short // short_ids = boolean indicating type of $ids (default is false => unpacked) function ModW_id2item($id,$use_short_ids="false") { return AA_Items::getItem(new zids($id, $use_short_ids ? 's' : 'l')); } /** Convert a state string into an array, based on the variable names and * regular expression supplied, if str is not present or doesn't match * the regular expression then use $strdef * e.g. ModW_str2arr("tpmi",$apc,"--h-", "^([-p])([-]|[0-9]+)([hbsfcCt])([-]|[0-9]+)"; */ function ModW_str2arr($varnames, $str, $strdef, $reg) { if (!$str) { $str = $strdef; } $varout = array(); $reg = '`'.str_replace('`','\`',$reg).'`'; if (!(preg_match($reg, $str, $vars))) { if (!(preg_match($reg, $strdef, $vars))) { print("Error initial string $strdef doesn't match regexp $reg\n
"); } } for ($i=0, $ino=min(strlen($varnames),count($vars)-1); $i<$ino; ++$i) { $varout[substr($varnames,$i,1)] = $vars[$i+1]; } AA::$debug && AA::$dbg->info('State=',$varout); return $varout; } /** Convert an array into a state string, in the order from $varnames * This is fairly simplistic, just concatennating state, a more * sophisticated sprint version might be needed */ function ModW_arr2str($varnames, $arr) { $strout = ""; for ($i=0, $ino=strlen($varnames); $i<$ino; ++$i) { $strout .= $arr[substr($varnames,$i,1)]; } return $strout; } // do not remove this exit - we do not want to allow users // to include this script (honzam) exit; ?>
-86400 // generalized version of cmd[]-c // - fields and operators specifed // - unlimited number of conditions // - all default conditions from view definition are // completely redefined by the specified ones //optionaly set[] // setings to modify view behavior (can be combined with cmd) // set[23]=listlen-20 // set[23]=mlx-EN-FR-DE // - sets maximal number of viewed items in view 23 to 20 // - there can be more settings (future) - comma separated //optionaly als[] // user alias - see slice.php3 for more details // for more info see AA FAQ: http://apc-aa.sourceforge.net/faq/index.shtml#219 //ini_set('display_errors', 1); // ----- input variables normalization - start -------------------------------- // This code handles with "magic quotes" and "register globals" PHP (<5.4) setting // It make us sure, taht // 1) in $_POST,$_GET,$_COOKIE,$_REQUEST variables the values are not quoted // 2) the variables are imported in global scope and is quoted // We are trying to remove any dependecy on the point 2) and use only $_* superglobals function AddslashesDeep($value) { return is_array($value) ? array_map('AddslashesDeep', $value) : addslashes($value); } function StripslashesDeep($value) { return is_array($value) ? array_map('StripslashesDeep', $value) : stripslashes($value); } if ( get_magic_quotes_gpc() ) { $_POST = StripslashesDeep($_POST); $_GET = StripslashesDeep($_GET); $_COOKIE = StripslashesDeep($_COOKIE); $_REQUEST = StripslashesDeep($_REQUEST); } if (!ini_get('register_globals') OR !get_magic_quotes_gpc()) { foreach ($_REQUEST as $k => $v) { $$k = AddslashesDeep($v); } } // ----- input variables normalization - end ---------------------------------- require_once "./include/config.php3"; require_once AA_INC_PATH."easy_scroller.php3"; require_once AA_INC_PATH."util.php3"; require_once AA_INC_PATH."item.php3"; require_once AA_INC_PATH."view.php3"; require_once AA_INC_PATH."discussion.php3"; require_once AA_INC_PATH."pagecache.php3"; require_once AA_INC_PATH."searchlib.php3"; $encap = true; // just for calling extsessi.php require_once AA_INC_PATH."locsess.php3"; // DB_AA object definition add_vars(); // we tried to remove all global $db, so let's try to comment out following global object // honza 2015-12-30 // is_object( $db ) || ($db = getDB()); if (ctype_digit((string)$time_limit)) { @set_time_limit((int)$time_limit); } AA::$debug && AA::$dbg->group("/view.php3", "Start"); // Need to be able to set content-type for RSS, cannot do it in the view // because the cache wont reflect this if ($contenttype) { $contenttype = trim(strtolower($contenttype)); if ($len = strspn($contenttype,'abcdefghijklmnopqrstuvwxyz/')) { AA::$headers['type'] = substr($contenttype,0,$len); } } if ($filename) { header('Content-Description: File Transfer'); if (!$contenttype) { header('Content-Type: application/octet-stream'); } header('Content-Disposition: attachment; filename='.basename($filename)); header('Content-Transfer-Encoding: binary'); } $view_param = ParseViewParameters(); if ($convertfrom) { $view_param['convertfrom'] = $convertfrom; } if ($convertto) { $view_param['convertto'] = $convertto; } elseif (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')) { $view_param['convertto'] = 'utf-8'; } //create keystring from values, which exactly identifies resulting content $cache_key = get_hash($view_param, PageCache::globalKeyArray()); if ($cacheentry = $pagecache->getPage($cache_key, $nocache)) { $cacheentry->processPage(); } else { list($page_content, $cache_sid) = GetViewFromDB($view_param, true); $cacheentry = new AA_Cacheentry($page_content, AA::getHeaders()); $cacheentry->processPage(); if (!$nocache) { $str2find = new CacheStr2find($cache_sid, 'slice_id'); $pagecache->storePage($cache_key, $cacheentry, $str2find); } } AA::$debug && AA::$dbg->groupend("/view.php3", "Completed view"); if (AA::$debug) { AA::$dbg->duration_stat(); } exit; ?>

Para suscribirse al boletín hacer clic aquí.

$v) { $$k = AddslashesDeep($v); } } // ----- input variables normalization - end ---------------------------------- $encap = ( ($encap=="false") ? false : true ); require_once "./include/config.php3"; require_once AA_INC_PATH."easy_scroller.php3"; require_once AA_INC_PATH."util.php3"; require_once AA_INC_PATH."item.php3"; require_once AA_INC_PATH."view.php3"; require_once AA_INC_PATH."pagecache.php3"; require_once AA_INC_PATH."searchlib.php3"; require_once AA_INC_PATH."discussion.php3"; require_once AA_INC_PATH."mgettext.php3"; require_once AA_INC_PATH."slice.class.php3"; require_once AA_INC_PATH."hitcounter.class.php3"; // function definitions: require_once AA_INC_PATH."slice.php3"; require_once AA_INC_PATH."locsess.php3"; /** MyUrl function - was in sessions before, but now it is used just in this script, so moved here and rewritten to handle encap (=shtml)/not encap version * rewriten to return URL of shtml page that includes this script instead to return self url of this script. */ function MyUrl($encap, $scr_url) { //sliceID is here just for compatibility with MyUrl function in extsess.php3 $server = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; $server .= '://'. $_SERVER['HTTP_HOST']; if ( $scr_url ) { // if included into php script return $server.$scr_url; } elseif ($_SERVER["HTTP_X_FORWARDED_SERVER"]) { return ''; // it is impossible to get original script name when AA is hidden after proxy. In this case we will use reletive URL (which is not bad in any case, I think - Honza 2016-11-21) } $ret = $server; if ($encap) { if (isset($_SERVER['REDIRECT_DOCUMENT_URI'])) { // CGI --enable-force-cgi-redirect $ret .= $_SERVER['REDIRECT_DOCUMENT_URI']; } elseif (isset($_SERVER['DOCUMENT_URI'])) { $ret .= $_SERVER['DOCUMENT_URI']; } elseif (isset($_SERVER['REQUEST_URI'])) { $url_parsed = parse_url($_SERVER['REQUEST_URI']); $ret .= $url_parsed['path']; } else { $ret .= $_SERVER['SCRIPT_URL']; } } elseif (isset($_SERVER['REDIRECT_SCRIPT_NAME'])) { $ret .= $_SERVER['REDIRECT_SCRIPT_NAME']; } else { $ret .= $_SERVER['SCRIPT_NAME']; } // // not executed - mode is cookie. Could be removed (Honza 16-03-31) // if ( ($this->mode == 'get') AND (!$noquery) ) { // if ($encap) { // $ret .= "?".urlencode($this->name)."=".$this->id; // } else { // $ret .= "?slice_id=$sliceID" . ($encap?"":"&encap=false"). "&".urlencode($this->name)."=".$this->id; // } // } return $ret; } $slice_starttime = microtime(true); //MLX stuff require_once AA_INC_PATH."mlx.php"; // session is not working right now with PHP5 style sessions. It should not be // needed. We are testing the code, and if all will be OK, we remove sessions // from slice.php3 completely. It doesn-t work because of Cookies vs. SSI. // Honza 2016-07-12 pageOpen('noauth'); $sess->register('r_packed_state_vars'); $sess->register('slices'); $r_state_vars = unserialize($r_packed_state_vars); // there was problems with storing too much ids in session veriable, // so I commented it out. It is not necessary to have it in session. The only // reason to have it there is the display speed, but because of impementing // pagecache.php3, it is not so big problem now //$sess->register(item_ids); if ($encap) { // adds values from QUERY_STRING_UNESCAPED add_vars(""); // and REDIRECT_STRING_UNESCAPED // if we use input type="buton" for submitting of form, then it adds x and y // variables, which we do not want (x means (unfortunately) - item id in AA) if (isset($x) AND isset($y) AND ctype_digit((string)$x) AND ctype_digit((string)$y) AND isset($conds)) { unset($x); } } if (($key != $lock) OR $scrl) { // command is for other slice on page RestoreVariables(); // or scroller } // url posted command to display specified text instead of slice content ------- if ($slicetext) { echo $slicetext; ExitPage(); } // url posted command to display another file ---------------------------------- if ( $inc ) { // this section must be after add_vars() // StoreVariables(array("inc")); // store in session if ( !preg_match("/^([0-9a-z_])+(\.[0-9a-z]*)?$/i", $inc) ) { echo _m("Bad inc parameter - included file must be in the same directory as this .shtml file and must contain only alphanumeric characters"). " $inc"; ExitPage(); } else { $fp = @fopen(shtml_base().$inc, "r"); // if encapsulated if (!$fp) { echo _m("No such file") ." $inc"; } else { FPassThru($fp); } ExitPage(); } } // Take any slice to work with if (!$slice_id AND is_array($slices)) { reset ($slices); $slice_id = current($slices); } // if someone breaks '); } $add_aliases = $aliases = GetAliasesFromUrl($als); // this is not good way - aliases are then different on each call, so it isn't // cached. The better way is below // $add_aliases['_#SESSION_'] = GetAliasDef( 'f_s:'. $sess->id, '', _m('session id')); $add_aliases['_#SESSION_'] = GetAliasDef( 'f_e:session', 'id..............', _m('session id')); // if banner parameter supplied => set format $slice_info = array_merge( $slice_info, ParseBannerParam($banner)); // get alias list from database and possibly from url // if working with multi-slice, get aliases for all slices if (!is_array($slices)) { $aliases = $slice->aliases(); array_add($add_aliases, $aliases); } else { foreach ($slices as $sid) { // hack for searching in multiple slices. This is not so nice part // of code - we mix there $aliases[] with $aliases[][] // it is needed by itemview::set_column() (see include/itemview.php3) $aliases[q_pack_id($sid)] = AA_Slice::getModule($sid)->aliases($als); array_add($add_aliases, $aliases[q_pack_id($sid)]); } } // fulltext view --------------------------------------------------------------- if ( $sh_itm OR $x OR $o OR $seo ) { // $r_state_vars = StoreVariables(array("sh_itm")); // store in session if ( $x ) { $zid = new zids((int)$x, 's'); AA_Hitcounter::hit($zid); } elseif ( $seo ) { $zid = new zids(explode('-', StrExpand('AA_Stringexpand_Seo2ids', array($slice_id, $seo))), 'l'); AA_Hitcounter::hit($zid); } elseif ( $o ) { $zid = new zids((int)$o, 's'); } else { $zid = new zids($sh_itm, 'l'); AA_Hitcounter::hit($zid); } if (!isset ($hideFulltext)) { $itemview = new itemview($slice_info, '', $aliases, $zid, 0, 1, MyUrl($encap, $scr_url)); echo $itemview->get_output_cached("fulltext"); } // show discussion if assigned $discussion_vid = ( isset($dview) ? $dview : $slice_info['vid']); // you can set dview=0 to not show discussion if ($discussion_vid > 0) { $db->query("SELECT view.*, slice.flag FROM view, slice WHERE slice.id='".q_pack_id($slice_id)."' AND view.id=$discussion_vid"); if ($db->next_record()) { $view_info = $db->Record; // create array of parameters $disc = array('ids' => $all_ids ? "" : $ids, 'type' => $add_disc ? "adddisc" : (($sel_ids || $all_ids) ? "fulltext" : "thread"), 'item_id' => $zid->longids(0), 'vid' => $view_info['id'], 'html_format' => $view_info['flag'] & DISCUS_HTML_FORMAT, 'parent_id' => $parent_id ); $aliases = GetDiscussionAliases(); $format = GetDiscussionFormat($view_info); $format['id'] = $p_slice_id; // set slice_id because of caching $itemview = new itemview($format, '', $aliases, null,"", "", MyUrl($encap, $scr_url), $disc); echo $itemview->get_output("discussion"); // discussions should not be // cached or even better (TODO) discussions should have its separate slice // which is cached independently form the item itself through standard // AA caching } } ExitPage(); } // multiple items fulltext view ------------------------------------------------ if ( $items AND is_array($items) ) { // shows all $items[] as fulltext one after one // $r_state_vars = StoreVariables(array("items")); // store in session while (list($k) = each( $items )) { $ids[] = substr($k,1); //delete starting character ('x') - used for interpretation of index as string, not number (by PHP) } $zids = new zids($ids,"l"); $itemview = new itemview($slice_info, '', $aliases, $zids, 0,$zids->count(), MyUrl($encap, $scr_url)); ExitPage($itemview->get_output_cached("itemlist")); } // compact view ---------------------------------------------------------------- /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Parse parameters posted by query form and from $slice_info * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ $r_state_vars = StoreVariables(array("no_scr","scr_go","order","cat_id", "cat_name", "exact","restrict","res_val","highlight","conds","group_by", "sort","als","defaultCondsOperator","mlx")); // store in session, added mlx // ***** CONDS ***** if ($cat_id) { // optional parameter cat_id - deprecated - slow ------ $tmpobj = $slice->getFields(); $cat_field = $tmpobj->getCategoryFieldId(); $cat_group = GetCategoryGroup($slice_id); $SQL = "SELECT value FROM constant WHERE group_id = '$cat_group' AND id='". q_pack_id($cat_id) ."'"; $db->query($SQL); if ( $db->next_record() ) { $conds[] = array( $cat_field => 1, 'value' => $db->f('value'), 'operator' => ($exact ? '=' : 'LIKE')); } } elseif ($cat_name) { // optional parameter cat_name ------- $tmpobj = $slice->getFields(); $cat_field = $tmpobj->getCategoryFieldId(); $conds[] = array( $cat_field => 1, 'value' => $cat_name, 'operator' => ($exact ? '=' : 'LIKE')); } if ($restrict) { $conds[] = array( $restrict => 1, 'value' => ((($res_val[0] == '"' OR $res_val[0] == "'") AND $exact != 2 ) ? $res_val : "\"$res_val\""), 'operator' => ($exact ? '=' : 'LIKE')); } if ($highlight != "") { $conds[] = array('highlight.......' => 1); } if (!isset($defaultCondsOperator)) { $defaultCondsOperator = 'LIKE'; } if (is_array($conds)) { ParseEasyConds($conds, $defaultCondsOperator); foreach ( $conds as $k => $v ) { SubstituteAliases( $als, $conds[$k]['value'] ); } } elseif ( is_string($conds) AND strlen($conds) ) { // we can use also conds=d-switch..........-=-1 $tmp_set = new AA_Set(null, $conds); $conds = $tmp_set->getConds(); } // ***** SORT ***** /** order by field xy if other than publish date. * Syntax: [number]field_id[-] * (add minus sign for descending order (like "headline.......1-") * (add number before the field if you want to group limit (limit number of items of the same value)) */ if ($order) { $set = new AA_Set; $set->addSortFromString($order); $order = reset($set->getSort()); // get the first from array list($order, $orderdirection) = each($order); } if ($debug) { echo "
Group by: -$group_by-
Slice_info[category_sort] -$slice_info[category_sort]-
slice_info[group_by] -$slice_info[group_by]-"; } $sort_tmp = array(); if ($group_by) { $set = new AA_Set; $set->addSortFromString($group_by); $sort_tmp = $set->getSort(); $slice_info["group_by"] = key($sort_tmp[0]); } elseif ($slice_info['category_sort']) { $tmpobj = $slice->getFields(); $group_field = $tmpobj->getCategoryFieldId(); $grp_odir = (($order==$group_field) AND ($orderdirection!='d')) ? 'a' : 'd'; $sort_tmp[] = array( $group_field => $grp_odir ); } elseif ($slice_info['group_by']) { switch( (string)$slice_info['gb_direction'] ) { // gb_direction is number case '1': $gbd = '1'; break; // 1 (1)- ascending by priority case 'd': // d - descending - goes from view (iview) settings case '8': $gbd = 'd'; break; // d (8)- descending case '9': $gbd = '9'; break; // 9 (9)- descending by priority (for fields using constants) default: $gbd = 'a'; // 2 (2)- ascending; } $sort_tmp[] = array($slice_info['group_by'] => $gbd); } $sort_tmp = array_merge($sort_tmp, getSortFromUrl($sort)); if ($order) { add2sort($sort_tmp, array($order => (strstr('aAdD19',$orderdirection) ? $orderdirection : 'a'))); } // time order the fields in compact view add2sort($sort_tmp, array('publish_date....' => (($timeorder == "rev") ? 'a' : 'd'))); $sort = $sort_tmp; //mlx stuff if ($mlxslice = MLXSlice($slice)) { if (!$mlxView) { $mlxView = new MLXView($mlx); } $mlxView->preQueryZIDs($mlxslice,$conds); } $zids = QueryZIDs( ($slices ? $slices : array($slice_id)), $conds, $sort, "ACTIVE", $neverAllItems, 0, $defaultCondsOperator ); if ($mlxslice) { $mlxView->postQueryZIDs($zids,$mlxslice,$slice_id); } if (!is_object($scr)) { $sess->register('scr'); $scr_url_param = get_url(($scr_url ? $sess->url("$scr_url") : MyUrl($encap, $scr_url)), is_array($als) ? array('als'=>$als) : ''); $scr = new easy_scroller( 'scr', $scr_url_param, $slice_info['d_listlen'], $zids->count()); } // display 'All' option in scroller if ($all_scr) { $scr->setShowAll($all_scr); } // change number of listed items if ($listlen) { $scr->setMetapage($listlen); } // default start page = 1 if (!$scr_go) { $scr_go = 1; } // $scrl comes from easy_scroller if ($scrl) { $scr->update(); } /** Add scroller aliases - page number, listlen */ $scr_aliases['_#PAGE_NO_'] = GetAliasDef( 'f_s:'. $scr->current, '', _m('number of current page (on pagescroller)')); $scr_aliases['_#PAGE_LEN'] = GetAliasDef( 'f_s:'. $scr->metapage, '', _m('page length (number of items)')); // aliases array have two form (quite stupid - will be changed in future - TODO) // depending on listing for one slice or many slices if (!is_array($slices)) { array_add($scr_aliases, $aliases); } else { foreach ($slices as $sid) { // hack for searching in multiple slices. This is not so nice part // of code - we mix there $aliases[] with $aliases[][] // it is needed by itemview::set_column() (see include/itemview.php3) array_add($scr_aliases, $aliases[q_pack_id($sid)]); } } if ( !$scrl ) { $scr->current = $scr_go; } if ( !$srch AND !$encap AND !$easy_query ) { $cur_cats=GetCategories($db,$p_slice_id); // get list of categories pCatSelector($sess->name, $sess->id, MyUrl($encap, $scr_url), $cur_cats,$scr->filters['category_id']['value'], $slice_id, $encap); } if ($zids->count() > 0) { $itemview = new itemview($slice_info, '', $aliases, $zids, $scr->metapage * ($scr->current - 1), ($group_n ? -$group_n : $scr->metapage), // negative number used for displaying n-th group MyUrl($encap, $scr_url) ); echo $itemview->get_output_cached("view"); if (($scr->pageCount() > 1) AND !$no_scr AND !$group_n) { $scr->pnavbar(); } } else { // test if the the noitem_msg is filled (be carefull - "0" should be considered as filled) echo (isset($slice_info['noitem_msg']) AND (strlen($slice_info['noitem_msg']) > 0)) ? // is keyword for removing 'no item message' str_replace( '', '', AA_Stringexpand::unalias($slice_info['noitem_msg'])) : ("

"._m("No item found") ."
"); } if ($searchlog) { PutSearchLog(); } if ($debug) { $timeend = microtime(true); $time = $timeend - $slice_starttime; echo "

Page generation time: $time"; } ExitPage(); ?>
Creative Commons: Some Rights Reserved
Ciertos derechos reservados

Monitor de Políticas TIC en América Latina y el Caribe (ALC) de la
Asociación para el Progreso de las Comunicaciones (APC) desde 2001

Apoyado por HIVOS