<?php
/* Ulyxex version 1.6.7.8 ***************/
/* code http://ulyxex.logz.org **********/
/* Andre Lozano http://andre-lozano.org */
//~ this script show one random article from all pages mixed
class ViewPage extends Ulyxex {
public object $h;
public object $t;
public int $pos;
public string $typePage;
public string $Select;
public string $From;
public string $SelectCount;
public string $OrderSort;
public array $Cond;
public string $page_data;
public string $next_pages;
function __construct($pageId=0,$sortStyle=0,$typePage="page"){
$this->h = New Htmlz();
$this->t = New Translate();
$this->pos = isset($_GET['pg'])?$this->h->num($_GET['pg']):0;
$this->Select = SELECT.
ARTICLES.".ID ARTID,".ARTICLES.".CONTENT,".ARTICLES.".DATEPAGE,".ARTICLES.".SUBJECT,".
USERS.".USERNAME,".USERS.".ID IDUSERID";
$this->From = FROM.
ARTICLES.
INNERJOIN.PAGES._ON_.ARTICLES.".PAGEID = ".PAGES.".ID".
INNERJOIN.USERS._ON_.ARTICLES.".USERID = ".USERS.".ID";
$this->SelectCount = SELECT."COUNT(".ARTICLES.".ID) AS NUM";
$this->OrderSort = "";
$this->Cond = array();
$this->typePage = $typePage;
if ($pageId){
$this->page_data = $this->page_data($pageId,$sortStyle);
$this->next_pages = $this->next_pages($pageId);
}
}
public function page_data($pageId=0,$sortStyle=0){
$h = $this->h;$t = $this->t;
$sortOrder = array("DATEPAGE DESC","SUBJECT DESC","DATEPAGE ASC");
$pgPos = ($this->pos)?($this->pos - 1) * ARTICLESPAGE:0;
$this->Cond = array();
$this->Cond[] = ARTICLES.".HIDE = 0";
$this->Cond[] = PAGES.".HIDE = 0";
if (isset($_POST['searchwebsite'])) {
$this->Cond[] = " MATCH(".ARTICLES.".CONTENT) AGAINST('".$h->safe($_POST['searchwebsite'])."') ";
$this->OrderSort = ORDERBY.$sortOrder[$sortStyle]." LIMIT ".$pgPos.",".ARTICLESPAGE;
if (session_status() === PHP_SESSION_ACTIVE) $_SESSION['searchwebsite'] = $h->safe($_POST['searchwebsite']);
} else if (isset($_SESSION['searchwebsite']) && isset($_GET['state'])){
$this->Cond[] = " MATCH(".ARTICLES.".CONTENT) AGAINST('".$_SESSION['searchwebsite']."') ";
$this->OrderSort = ORDERBY.$sortOrder[$sortStyle]." LIMIT ".$pgPos.",".ARTICLESPAGE;
} else {
$this->OrderSort = ORDERBY." RAND() LIMIT 1";
}
$query = $this->Select.$this->From.$this->Where($this->Cond).$this->OrderSort;
$query = $this->q($query);
if ($line = $this->fetch($query)){
$article = $line['CONTENT'];
$article .= $h->nav(
$h->ahref("index.php?k=user&v=".$line['IDUSERID']."&t=".$h->clean_short_url($line['USERNAME']),$line['USERNAME'],$h->alt($t->w("show")." ".$t->wz("user").$line['USERNAME']))
." ".$line['DATEPAGE']." ".
$h->ahref("index.php?k=article&v=".$line['ARTID']."&t=".$h->clean_short_url($line['SUBJECT']),"url",$h->alt($t->wr("open url").$t->wz("article").$line['SUBJECT']))
,$h->v("class","contenturl").$h->v("id",$t->w("article-nav").$line['ARTID']));
$result = $h->article($article,$h->v("id","article_".$line['ARTID']));
while ( $line = $this->fetch($query) ){
$article = $line['CONTENT'];
$article .= $h->nav(
$h->ahref("index.php?k=user&v=".$line['IDUSERID']."&t=".$h->clean_short_url($line['USERNAME']),$line['USERNAME'],$h->alt($t->w("show")." ".$t->wz("user").$line['USERNAME']))
." ".$line['DATEPAGE']." ".
$h->ahref("index.php?k=article&v=".$line['ARTID']."&t=".$h->clean_short_url($line['SUBJECT']),"url",$h->alt($t->wr("open url").$t->wz("article").$line['SUBJECT']))
,$h->v("class","contenturl").$h->v("id",$t->w("article-nav").$line['ARTID']));
$result .= $h->article($article,$h->v("id","article_".$line['ARTID']));
}
return $h->articles($result,$t->w("main-content-articles"));
} else {
return "";
}
}
public function next_pages($pageId=0){
$h = $this->h;$t = $this->t;
$this->Cond = array();
$this->Cond[] = ARTICLES.".HIDE = 0";
$this->Cond[] = PAGES.".HIDE = 0";
if (isset($_POST['searchwebsite']) || (isset($_SESSION['searchwebsite']) && isset($_GET['state'])) ){
$state = "&state=1";
isset($_POST['searchwebsite'])?$search = $h->safe($_POST['searchwebsite']):$search = $_SESSION['searchwebsite'];
$this->Cond[] = " MATCH(".ARTICLES.".CONTENT) AGAINST('".$search."') ";
$query = $this->SelectCount.$this->From.$this->Where($this->Cond);
$query = $this->q($query);
if ($line = $this->fetch($query)){
$this->items = $line['NUM'];
/* total pages */
$pages = $this->items/ARTICLESPAGE;
$pages++;
$result = array();
if ($pages > 2){
for($i=1;$i < $pages;$i++){
$num = $i?strval($i):"0";
if ($i == $this->pos || ($this->pos == 0 && $i == 1)){
$result[] = "[".$h->ahref("index.php?k=".$this->typePage."&v=".$pageId.$state."&pg=".$num,$num,$h->alt($t->w("next pages")))."]";
} else {
$result[] = $h->ahref("index.php?k=".$this->typePage."&v=".$pageId.$state."&pg=".$num,$num,$h->alt($t->w("next pages")));
}
}
}
return implode(" . ",$result);
}
} else {
return "";
}
}
}
?>
page url