|
|
|
$v) {
$kk = AddslashesDeep($v);
}
foreach ($_POST as $k => $v) {
$kk = AddslashesDeep($v);
}
foreach ($_COOKIE as $k => $v) {
$kk = AddslashesDeep($v);
}
}
$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."sliceobj.php3";
require_once AA_INC_PATH."hitcounter.class.php3";
// function definitions:
require_once AA_INC_PATH."slice.php3";
require_once AA_INC_PATH. ($encap ? "locsessi.php3" : "locsess.php3");
$slice_starttime = get_microtime();
//MLX stuff
require_once AA_INC_PATH."mlx.php";
page_open(array("sess" => "AA_SL_Session"));
$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 (($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 ( !eregi("^([0-9a-z_])+(\.[0-9a-z]*)?$", $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 ';
ExitPage();
}
$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 = GetAliasesFromFields($fields);
array_add($add_aliases, $aliases);
} else {
foreach ($slices as $sid) {
list($fields) = GetSliceFields($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)] = GetAliasesFromFields($fields,$als);
array_add($add_aliases, $aliases[q_pack_id($sid)]);
}
}
// fulltext view ---------------------------------------------------------------
if ( $sh_itm OR $x OR $o ) {
// $r_state_vars = StoreVariables(array("sh_itm")); // store in session
if ( $x ) {
$zid = new zids((int)$x, 's');
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, $fields, $aliases, $zid, 0, 1, $sess->MyUrl($slice_id, $encap));
$itemview->print_item();
}
// 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,"", "", $sess->MyUrl($slice_id, $encap), $disc);
$itemview->print_discussion('nocache'); // 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, $fields, $aliases, $zids, 0,$zids->count(), $sess->MyUrl($slice_id, $encap));
$itemview->print_itemlist();
ExitPage();
}
// compact view ----------------------------------------------------------------
if (!is_object($scr)) {
$sess->register('scr');
if ( isset($als) AND is_array($als)) {
$scr_als_param = '&'. htmlentities(HttpGetParameters(array('als'=>$als)));
}
$scr_url_param = ($scr_url ? $sess->url("$scr_url") : $sess->MyUrl($slice_id, $encap)).$scr_als_param."&";
$scr = new easy_scroller( 'scr', $scr_url_param, $slice_info['d_listlen'], 0);
}
// 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)]);
}
}
/* old version of automatiocaly created search form - not used in AA > 1.2
$easy_query .. easy query form
$srch .. bigsrch form ??
*/
if (($easy_query || $srch) AND !(is_array($conds) OR isset($group_by) OR isset($sort))) {
if ($easy_query) { // posted by easy query form ----------------
$r_state_vars = StoreVariables(array("listlen","no_scr","scr_go","srch_fld","srch_from", "srch_to",
"easy_query", "qry", "srch_relev", "mlx")); // store in session, added mlx
$item_ids = GetIDs_EasyQuery($fields, $db, $p_slice_id, $srch_fld, $srch_from, $srch_to, $qry, $srch_relev);
if ( isset($item_ids) AND !is_array($item_ids) ) {
echo " $item_ids ";
}
if ( !$scrl ) {
$scr->current = $scr_go;
}
}
elseif ($srch) { // posted by bigsrch form -------------------
$r_state_vars = StoreVariables(array("listlen","no_scr","scr_go","big","search", "s_col", "mlx")); // store in session
if ( !$big ) {
$search['slice'] = $slice_id;
}
$item_ids = SearchWhere($search, $s_col);
if ( !$scrl ) {
$scr->current = $scr_go;
}
}
elseif ($debug) {
echo "ERROR: This branch should never be entered.";
}
} else {
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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'] );
}
}
// ***** 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) {
$sortorder = new AA_Sortorder;
$sortorder->addSortFromString($order);
$order = reset($sortorder->getOrder()); // 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) {
$sortorder = new AA_Sortorder;
$sortorder->addSortFromString($group_by);
$sort_tmp = $sortorder->getOrder();
$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 (isMLXSlice($slice_info)) {
if (!$mlxView) {
$mlxView = new MLXView($mlx);
}
$mlxView->preQueryZIDs(unpack_id128($slice_info[MLX_SLICEDB_COLUMN]),$conds,$slices);
}
$zids = QueryZIDs( ($slices ? $slices : array($slice_id)), $conds, $sort, "ACTIVE", $neverAllItems, 0, $defaultCondsOperator, true );
if (isMLXSlice($slice_info)) {
$mlxView->postQueryZIDs($zids,unpack_id128($slice_info[MLX_SLICEDB_COLUMN]),$slice_id, $conds, $sort, $slice_info['group_by'],"ACTIVE", $slices, $neverAllItems, 0, $defaultCondsOperator,$nocache);
}
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,$sess->MyUrl($slice_id, $encap, true),$cur_cats,$scr->filters[category_id]['value'], $slice_id, $encap);
}
if ($zids->count() > 0) {
$scr->countPages( $zids->count() );
$itemview = new itemview($slice_info, $fields, $aliases, $zids, $scr->metapage * ($scr->current - 1),
($group_n ? -$group_n : $scr->metapage), // negative number used for displaying n-th group
$sess->MyUrl($slice_id, $encap) );
$itemview->print_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( '', '', $slice_info['noitem_msg']) : (""._m("No item found") ." ");
}
if ($searchlog) {
PutSearchLog();
}
if ($debug) {
$timeend = get_microtime();
$time = $timeend - $slice_starttime;
echo "
Page generation time: $time";
}
ExitPage();
?>
|
|
|
FECCAPLU - Federación
de Criadores de Camélidos de la Provincia de La Unión
- PERÚ
geronimo@aedes.com.pe
©Portal La Unión - Reserva Paisajística de la
Subcuenca del Cotahuasi
Email: info@cotahuasiarequipa.com Página Web: www.cotahuasiarequipa.com
Webmaster: webmaster@aedes.com.pe |
|