Skip to content

Commit

Permalink
widgets ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilnapsis committed Sep 18, 2016
1 parent ce2b2ba commit 34334d9
Show file tree
Hide file tree
Showing 52 changed files with 4,396 additions and 87 deletions.
7 changes: 4 additions & 3 deletions admin/core/app/action/processlogin-action.php
Expand Up @@ -4,12 +4,13 @@
// include("core/controller/Database.php");

if(Session::getUID()=="") {
$user = $_POST['email'];

$user = $_POST['username'];
$pass = sha1(md5($_POST['password']));

$base = new Database();
$con = $base->connect();
$sql = "select * from user where (email= \"".$user."\" or username= \"".$user."\") and password= \"".$pass."\" and is_active=1";
$sql = "select * from user where ( (email!=\"\" and (email= \"".$user."\" and password= \"".$pass."\")) or (username!=\"\" and (username= \"".$user."\" and password= \"".$pass."\") )) and is_active=1";
//print $sql;
$query = $con->query($sql);
$found = false;
Expand All @@ -32,7 +33,7 @@
}

}else{
print "<script>window.location='index.php?view=home';</script>";
print "<script>window.location='./';</script>";

}
?>
8 changes: 8 additions & 0 deletions admin/core/app/action/processlogout-action.php
@@ -0,0 +1,8 @@
<?php

unset($_SESSION["user_id"]);
session_destroy();

Core::redir("./");

?>
31 changes: 31 additions & 0 deletions admin/core/app/action/widgets-action.php
@@ -0,0 +1,31 @@
<?php

if(isset($_GET["opt"])){
if($_GET["opt"]=="add"){
$cat = new WidgetData();
$cat->title = $_POST["title"];
$cat->func = $_POST["func"];
$cat->params = $_POST["params"];
$cat->ord = $_POST["ord"];
$cat->add();
Core::redir("./?view=widgets");
}
else if($_GET["opt"]=="update"){
$cat = WidgetData::getById($_POST["id"]);
$cat->title = $_POST["title"];
$cat->func = $_POST["func"];
$cat->params = $_POST["params"];
$cat->status = $_POST["status"];
$cat->ord = $_POST["ord"];
$cat->update();
Core::redir("./?view=widgets");
}
else if($_GET["opt"]=="del"){
$cat = WidgetData::getById($_GET["id"]);
$cat->del();
Core::redir("./?view=widgets");
}
}


?>
48 changes: 18 additions & 30 deletions admin/core/app/layouts/layout.php
Expand Up @@ -72,7 +72,7 @@
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-right">
<a href="./logout.php" class="btn btn-default btn-flat">Salir</a>
<a href="./?action=processlogout" class="btn btn-default btn-flat">Salir</a>
</div>
</li>
</ul>
Expand Down Expand Up @@ -126,6 +126,21 @@
<li><a href="./index.php?view=galery"><i class='fa fa-picture-o'></i> <span>Galeria</span></a></li>
<li><a href="./index.php?view=comments"><i class='fa fa-comments'></i> <span>Comentarios</span></a></li>
<li><a href="./index.php?view=msgs"><i class='fa fa-envelope-o'></i> <span>Mensajes</span></a></li>

<li class="treeview">
<a href="#">
<i class="fa fa-paint-brush"></i>
<span>Apariencia</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li><a href="./?view=widgets"><i class="fa fa-circle-o"></i> Widgets</a></li>
</ul>
</li>


<li><a href="./index.php?view=users"><i class='fa fa-user'></i> <span>Usuarios</span></a></li>
<li><a href="./index.php?view=generalcfg"><i class='fa fa-cogs'></i> <span>Configuracion</span></a></li>

Expand Down Expand Up @@ -153,39 +168,13 @@
<strong>Copyright &copy; 2016 <a href="http://evilnapsis.com/" target="_blank">Evilnapsis</a></strong>
</footer>
<?php else:?>
<?php if(isset($_GET["view"]) && $_GET["view"]=="clientaccess"):?>
<div class="login-box">
<div class="login-logo">
<a href="./"><b>ZARD</a>
</div><!-- /.login-logo -->
<div class="login-box-body">
<center><h4>Cliente</h4></center>
<form action="./?action=processloginclient" method="post">
<div class="form-group has-feedback">
<input type="text" name="username" required class="form-control" placeholder="Usuario"/>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" name="password" required class="form-control" placeholder="Password"/>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">

<div class="col-xs-12">
<button type="submit" class="btn btn-primary btn-block btn-flat">Acceder</button>
<a href="./" class="btn btn-default btn-block btn-flat"><i class="fa fa-arrow-left"></i> Regresar</a>
</div><!-- /.col -->
</div>
</form>
</div><!-- /.login-box-body -->
</div><!-- /.login-box -->
<?php else:?>
<div class="login-box">
<div class="login-logo">
<a href="./"><b>ZARD</a>
</div><!-- /.login-logo -->
<div class="login-box-body">
<center><h4>Admin</h4></center>
<center><h4>Welcome to Zard CMS</h4></center>
<form action="./?action=processlogin" method="post">
<div class="form-group has-feedback">
<input type="text" name="username" required class="form-control" placeholder="Usuario"/>
Expand All @@ -199,13 +188,12 @@

<div class="col-xs-12">
<button type="submit" class="btn btn-primary btn-block btn-flat">Acceder</button>
<a href="./?view=clientaccess" class="btn btn-default btn-block btn-flat">Acceso al cliente <i class="fa fa-arrow-right"></i> </a>
</div><!-- /.col -->
</div>
</form>
</div><!-- /.login-box-body -->
</div><!-- /.login-box -->
<?php endif;?>

<?php endif;?>


Expand Down
6 changes: 6 additions & 0 deletions admin/core/app/model/CommentData.php
Expand Up @@ -91,6 +91,12 @@ public static function getMessages(){
return Model::many($query[0],new CommentData());
}

public static function getApproveds($n){
$sql = "select * from ".self::$tablename." where kind=1 and post_id is not NULL and is_public order by created_at limit $n";
$query = Executor::doit($sql);
return Model::many($query[0],new CommentData());
}


public static function getApprovedByPostId($id){
$sql = "select * from ".self::$tablename." where post_id=$id and is_public order by created_at";
Expand Down
4 changes: 2 additions & 2 deletions admin/core/app/model/PostData.php
Expand Up @@ -68,8 +68,8 @@ public static function getPages(){
}


public static function getLast10(){
$sql = "select * from ".self::$tablename." where is_public=1 and kind=1 order by created_at desc limit 10";
public static function getLast($n){
$sql = "select * from ".self::$tablename." where status=1 and kind=1 order by created_at desc limit $n";
$query = Executor::doit($sql);
return Model::many($query[0],new PostData());
}
Expand Down
65 changes: 65 additions & 0 deletions admin/core/app/model/WidgetData.php
@@ -0,0 +1,65 @@
<?php
class WidgetData {
public static $tablename = "widget";


public function WidgetData(){
$this->title = "";
$this->content = "";
$this->image = "";
$this->user_id = "";
$this->is_public = "0";
$this->created_at = "NOW()";
}

public function add(){
$sql = "insert into ".self::$tablename." (title,func,params,ord) ";
$sql .= "value (\"$this->title\",\"$this->func\",\"$this->params\",$this->ord)";
Executor::doit($sql);
}

public static function delById($id){
$sql = "delete from ".self::$tablename." where id=$id";
Executor::doit($sql);
}
public function del(){
$sql = "delete from ".self::$tablename." where id=$this->id";
Executor::doit($sql);
}

// partiendo de que ya tenemos creado un objecto WidgetData previamente utilizamos el contexto
public function update(){
$sql = "update ".self::$tablename." set title=\"$this->title\",func=\"$this->func\",params=\"$this->params\",status=\"$this->status\",ord=\"$this->ord\" where id=$this->id";
Executor::doit($sql);
}

public static function getById($id){
$sql = "select * from ".self::$tablename." where id=$id";
$query = Executor::doit($sql);
return Model::one($query[0],new WidgetData());
}



public static function getAll(){
$sql = "select * from ".self::$tablename;
$query = Executor::doit($sql);
return Model::many($query[0],new WidgetData());
}

public static function getPublics(){
$sql = "select * from ".self::$tablename." where status=1 order by ord";
$query = Executor::doit($sql);
return Model::many($query[0],new WidgetData());
}

public static function getLike($q){
$sql = "select * from ".self::$tablename." where title like '%$q%' or content like '%$q%'";
$query = Executor::doit($sql);
return Model::many($query[0],new WidgetData());
}


}

?>
5 changes: 5 additions & 0 deletions admin/core/app/view/comments-view.php
Expand Up @@ -34,6 +34,8 @@
<th>Nombre</th>
<th>Email</th>
<th>Post</th>
<th>Estado</th>
<th>Fecha</th>
<th></th>
</tr>
</thead>
Expand All @@ -48,6 +50,9 @@
<td><?=$post->name;?></td>
<td><?=$post->email;?></td>
<td><?php if($post->comment_id==null){ echo "<a href='../?view=post&id=".$thepost->id."'>".$thepost->title."</a>";}?></td>
<td><?=$post->is_public==1?"<span class='label label-primary'>Aprobado</span>":"<span class='label label-warning'>Pendiente<span>";?></td>
<td><?=$post->created_at;?></td>

<td style="width:120px;">
<?php if(!$post->is_public):?>
<a href="./?action=aprovecomment&id=<?=$post->id;?>" class="btn btn-xs btn-primary"><i class="fa fa-thumbs-up"></i></a>
Expand Down

0 comments on commit 34334d9

Please sign in to comment.