Got rid of MySQL, fixed bugs in text module
This commit is contained in:
parent
98a80154e9
commit
402a66900e
6 changed files with 62 additions and 265 deletions
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php global $session;
|
||||
/**
|
||||
* Project: BeCast WebEngine - simple site engine
|
||||
* File: /modules/text/text.output.php
|
||||
|
@ -32,60 +32,59 @@ $session->page_begin("Text Module", FALSE);
|
|||
|
||||
class text extends module{
|
||||
|
||||
function output(){
|
||||
global $module,$config,$db,$log,$core,$error;
|
||||
$textid=0;
|
||||
$url="";
|
||||
if(Isset($this->get["textid"]) || Isset($this->post["textid"])){
|
||||
if(Isset($this->get["textid"])){
|
||||
$textid = intval($this->get["textid"]);
|
||||
}else{
|
||||
$textid = intval($this->post["textid"]);
|
||||
function output()
|
||||
{
|
||||
global $module, $config, $db, $log, $core, $error;
|
||||
$textid = 0;
|
||||
$url = "";
|
||||
if (isset($this->get["textid"]) || isset($this->post["textid"])) {
|
||||
if (isset($this->get["textid"])) {
|
||||
$textid = intval($this->get["textid"]);
|
||||
} else {
|
||||
$textid = intval($this->post["textid"]);
|
||||
}
|
||||
$result = $db->query("SELECT a.`id` a.`text`, a.`title`, u.`username`, eu.`username` as edituser, a.`date`, a.`edittime`, a.`eid` FROM `" . $config["prefix"] . "article` a LEFT JOIN `".$config["prefix"]."users` eu on a.`eid` = eu.`uid` LEFT JOIN `".$config["prefix"]."users` u on a.`author` = u.`uid` WHERE a.`id`='".$textid."' AND a.`active`='true'") or die($db->error());
|
||||
}elseif(Isset($this->get["url"]) || Isset($this->post["url"])){
|
||||
If(Isset($this->get["url"])){
|
||||
$url=preg_replace( '/\.html($|\?)/i', "$1", $this->get["url"] );
|
||||
}else{
|
||||
$url=preg_replace( '/\.html($|\?)/i', "$1", $db->escape_string($this->post["url"]));
|
||||
}
|
||||
$result = $db->query("SELECT a.`id`, a.`text`, a.`title`, u.`username`, eu.`username` as edituser, a.`date`, a.`edittime`, a.`eid` FROM `" . $config["prefix"] . "article` a LEFT JOIN `".$config["prefix"]."users` eu on a.`eid` = eu.`uid` LEFT JOIN `".$config["prefix"]."users` u on a.`author` = u.`uid` WHERE a.url='".$url."' AND a.`active`='true'");
|
||||
$result = $db->query("SELECT a.`id` a.`text`, a.`title`, u.`username`, eu.`username` as edituser, a.`date`, a.`edittime`, a.`eid` FROM `" . $config["prefix"] . "article` a LEFT JOIN `" . $config["prefix"] . "users` eu on a.`eid` = eu.`uid` LEFT JOIN `" . $config["prefix"] . "users` u on a.`author` = u.`uid` WHERE a.`id`='" . $textid . "' AND a.`active`='true'") or die($db->error());
|
||||
} elseif (isset($this->get["url"]) || isset($this->post["url"])) {
|
||||
if (isset($this->get["url"])) {
|
||||
$url = preg_replace('/\.html($|\?)/i', "$1", $this->get["url"]);
|
||||
} else {
|
||||
$url = preg_replace('/\.html($|\?)/i', "$1", $db->escape_string($this->post["url"]));
|
||||
}
|
||||
$result = $db->query("SELECT a.`id`, a.`text`, a.`title`, u.`username`, eu.`username` as edituser, a.`date`, a.`edittime`, a.`eid` FROM `" . $config["prefix"] . "article` a LEFT JOIN `" . $config["prefix"] . "users` eu on a.`eid` = eu.`uid` LEFT JOIN `" . $config["prefix"] . "users` u on a.`author` = u.`uid` WHERE a.url='" . $url . "' AND a.`active`='true'");
|
||||
|
||||
|
||||
}else{
|
||||
} else {
|
||||
return $error->http_error("404");
|
||||
|
||||
}
|
||||
$fid="";
|
||||
$fid.=$textid;
|
||||
$fid.=$url;
|
||||
if($db->num_rows($result) > 0){
|
||||
if(!$this->tpl->isCached('textview.tpl',"textview".$fid)) {
|
||||
$row = $db->fetch_array($result);
|
||||
$cresult = $db->query("SELECT * FROM `" . $config["prefix"] . "article_categorys` c LEFT JOIN `" . $config["prefix"] . "article_category` s ON c.`id`=s.`c_id` WHERE s.`a_id`='".$row["id"]."'");
|
||||
while($c=$db->fetch_array($cresult)){
|
||||
if(!$cat){
|
||||
$cat=$c["categoryname"];
|
||||
}else{
|
||||
$cat.=", ".$c["categoryname"];
|
||||
}
|
||||
$fid = "";
|
||||
$fid .= $textid;
|
||||
$fid .= $url;
|
||||
if ($db->num_rows($result) > 0) {
|
||||
if (!$this->tpl->isCached('textview.tpl', "textview" . $fid)) {
|
||||
$row = $db->fetch_array($result);
|
||||
$cresult = $db->query("SELECT * FROM `" . $config["prefix"] . "article_categories` c LEFT JOIN `" . $config["prefix"] . "article_category` s ON c.`id`=s.`c_id` WHERE s.`a_id`='" . $row["id"] . "'");
|
||||
while ($c = $db->fetch_array($cresult)) {
|
||||
if (!$cat) {
|
||||
$cat = $c["categoryname"];
|
||||
} else {
|
||||
$cat .= ", " . $c["categoryname"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$editdate = date("d.m.Y, H:i", $row["edittime"]);
|
||||
$date = date("d.m.Y, H:i", $row["date"]);
|
||||
$this->tpl->assign('article', $row);
|
||||
$this->tpl->assign('cat', $cat);
|
||||
$this->tpl->assign('editdate', $editdate);
|
||||
$this->tpl->assign('date', $date);
|
||||
}
|
||||
$this->titleaddon=$row['title'].' - ';
|
||||
$core->add_navbit($row['title']);
|
||||
return $this->tpl->fetch('textview.tpl',"textview".$fid);
|
||||
}else{
|
||||
}
|
||||
$this->titleaddon = $row['title'] . ' - ';
|
||||
$core->add_navbit($row['title']);
|
||||
return $this->tpl->fetch('textview.tpl', "textview" . $fid);
|
||||
} else {
|
||||
return $error->http_error("404");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue