How to Change Pagination into Infinite Scroll in codeigniter - php

I want to change this pagination page into infinite scroll. I'm using codeigniter. I had already search about jquery and ajax but i don't really understand how to implement it in my code. So please help me to edit my pagination code into infinite scroll. . . I had struggle for days. I will be so grateful if u can hep me.
Thank you :)
HomeController.php
public function list_voucher($page=NULL, $orderBy=NULL)
{
if($this->session->userdata('logged_in'))
{
$session_data = $this->session->userdata('logged_in');
$data['nama'] = $session_data['nama'];
$data['id'] = $session_data['id_user'];
$data['tipeUser'] = $session_data['tipe_user'];
}
else{
$data['nama'] = "";
$data['id'] = "0";
$data['tipeUser']="";
}
$data['url_image'] = $this->imageUrl;
$data['notif'] = '';
$config['base_url'] = base_url().'/home_controller/list_voucher/';
$data['jmlh_rows'] = $this->voucher->getAllDeals();
$total_row = $data['jmlh_rows']->num_rows();
$config["total_rows"] = $total_row;
$config["per_page"] = 8;
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
$str_links = $this->pagination->create_links();
$data["links"] = explode(' ',$str_links );
$data['dataAllDeals'] = $this->voucher->getAllDealsPerPage($config["per_page"], $page, $orderBy);
$data['no']=$this->uri->segment(3);
$data['data_kategori'] = $this->jenismakanan->Getjenismakanan();
$this->load->view('listalldeals', $data);
}
View
<!DOCTYPE html>
<html>
<head>
<title>deals</title>
<link href="<?php echo base_url();?>css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="<?php echo base_url();?>js/jquery.min.js"></script>
<!-- Custom Theme files -->
<!--theme-style-->
<link href="<?php echo base_url();?>css/style.css" rel="stylesheet" type="text/css" media="all" />
<!--//theme-style-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Food shop Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!--fonts-->
<link href='http://fonts.googleapis.com/css?family=Rokkitt:400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Lobster+Two:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
<!--//fonts-->
<script type="text/javascript" src="<?php echo base_url();?>js/move-top.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>js/easing.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
});
});
</script>
<link href="<?php echo base_url();?>css/index.css" rel="stylesheet" type="text/css" media="all" />
<link rel="stylesheet" href="<?php echo base_url();?>css/imgslider.css" type="text/css" media="screen" />
<script src="<?php echo base_url();?>js/slideout.min.js"></script>
<script src="<?php echo base_url();?>js/jquery.wmuSlider.js"></script>
<script src="<?php echo base_url();?>js/jquery.wmuGallery.js"></script>
</head>
<body>
<nav id="menu">
<h1 style="color:white">Menu</h1>
<hr style="color:white;">
<ul>
<?php if($tipeUser=="user"){?>
<li><h4>Home</h4></li>
<li><h4 style="color:white">Welcome <?php echo $nama;?></h4></li>
<li><h4>My Voucher</h4></li>
<li><h4>Profile</h4></li>
<li><h4>Logout</h4></li>
<?php } else if($tipeUser=="restoran"){ ?>
<li><h4>Home</h4></li>
<li><h4 style="color:white">Welcome <?php echo $nama;?></h4></li>
<li><h4>Dashboard</h4></li>
<li><h4>Voucher Management</h4></li>
<!-- <li><h4>Reedem Voucher</h4></li> -->
<li><h4>Logout</h4></li>
<?php } else if($tipeUser==""){ ?>
<li><h4>Home</h4></li>
<li><h4>Login / Register</h4></li>
<li><h4>Voucher</h4></li>
<li><h4>Restaurants</h4></li>
<?php
if($data_kategori->num_rows()>0)
{
foreach ($data_kategori->result() as $rows)
{ ?>
<li><h4><a href="<?php echo base_url();?>home_controller/Type/<?php echo $rows->id_jenis_makanan; ?>" style="color:white"><?php echo $rows->nama_jenis_makanan;?>
</a></h4></li>
<?php } } ?>
<?php } ?>
</ul>
</nav>
<main id="panel">
<header>
<!--header-->
<div class="header-in">
<div class="container">
<!---->
<div class="header-bottom">
<div class="col-xs-1">
<button class="toggle-button"></button>
</div>
<div class="col-xs-11">
<?php echo form_open('home_controller/search_bar');?>
<div class="search">
<form>
<input type="text" id= "input-keyword" name="input-keyword" placeholder="Search ..." value="<?php echo set_value('input-keyword')?>" >
<input type="submit" value="">
</form><?php echo form_close(); ?>
</div>
</div>
<div class="clearfix"> </div>
</div>
<!---->
</div>
</div>
<!---->
<div class="container">
<div class="specials">
<h2>List All Vouchers</h2>
<hr></hr>
<?php
if($dataAllDeals->num_rows()>0)
{ $j=0;
$f=$no;
foreach ($dataAllDeals->result() as $rowAllDeals){ $j++;
if($j%5==0 || $j==1){
?>
<?php } ?>
<div class="col-xs-6">
<a href="<?php echo base_url();?>home_controller/Details/<?php echo $rowAllDeals->id_restoran;?>" ><img src="<?php echo $url_image;?>restaurant/<?php echo $rowAllDeals->id_restoran;?>/deals/<?php echo $rowAllDeals->gambar_voucher;?>" class="img-responsive-search" alt="">
</a>
<center>
<h3 style="font-size: 4vw;text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"><b><?php echo $f+1;?>. <?php echo $rowAllDeals->nama_restoran?></b></h3>
<h3 style="font-size: 3vw;text-overflow: ellipsis; overflow: hidden; white-space: nowrap;">Valid until : <?php $date=date_create($rowAllDeals->masa_berlaku); echo date_format($date, "d-M-Y"); ?></h3>
</center>
<?php
if($rowAllDeals->sisa_voucher > 0) {
?>
<h4 style="font-size: 2vw;text-overflow: ellipsis; overflow: hidden; white-space: nowrap;" align="center">AVAILABLE (<?php echo $rowAllDeals->sisa_voucher. ' Voucher'?> from <?php echo $rowAllDeals->jumlah_voucher. ' Voucher'?>)</h4>
<?php }
else{ ?>
<h4 align="center" style="color:red; font-size: 3vw;text-overflow: ellipsis; overflow: hidden; white-space: nowrap;">NOT AVAILABLE <br></h4>
<?php }
?>
<?php if($tipeUser=="user" || $tipeUser==""){ ?>
<div class="actions">
<?php
if($rowAllDeals->sisa_voucher > 0) {
?>
<center><i class="icon-shopping-cart icon-white"></i>Get Voucher</center><br>
<?php
}
else{ ?>
<center><i class="icon-shopping-cart icon-white"></i>Get Voucher</center><br>
<?php }
?>
</div> <?php } ?>
</div>
<?php if($j%4==0){?><?php } ?>
<?php $f++; }
} ?>
</div>
</div></div>
<div class="container">
<div class="col-md-12">
<p style="height:10px"></p>
<div id="pagination" align="center" class="pagination-wrapper">
<ul class="tsc_pagination pagination" align="center">
<!-- Show pagination links -->
<?php foreach ($links as $link) {
echo "<li>". $link."</li>";
} ?></ul>
</div>
</div></div>
<!---->
</header>
</main>
<?php if($this->session->flashdata('message')) :
echo "<script>alert('". $this->session->flashdata('message')."')</script>";
endif; ?>
</body>
<script>
var slideout = new Slideout({
'panel': document.getElementById('panel'),
'menu': document.getElementById('menu'),
'padding': 190,
'tolerance': 70
});
// Toggle button
document.querySelector('.toggle-button').addEventListener('click', function() {
slideout.toggle();
});
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if( userAgent.match( /iPad/i ) || userAgent.match( /iPhone/i ) || userAgent.match( /iPod/i ) )
{
slideout.disableTouch();
}
slideout.disableTouch();
// auto close
slideout.on('open', function() {
$( "#panel" ).click(function() {
return false;
});
$( "#panel" ).click(function() {
slideout.close();
});
});
slideout.on('close', function() {
$( "#panel" ).unbind('click');
});
</script>
<script>
$('.gallery').wmuSlider();
</script>
</html>
Model
public function getAllDeals(){
$this->db->select();
$this->db->from('voucher v');
$this->db->join('restoran r', 'r.id_restoran = v.id_restoran');
//$this->db->where('r.fitur_premium', 'y');
$this ->db -> where('v.masa_berlaku >', date('Y-m-d'));
$this ->db -> where('v.is_aktif', '1');
//$this->db->limit(8,0);
$query = $this->db->get();
return $query;
}
public function getAllDealsPerPage($num,$page, $orderBy){
$this->db->select();
$this->db->from('voucher v');
$this->db->join('restoran r', 'r.id_restoran = v.id_restoran');
//$this->db->where('r.fitur_premium', 'y');
$this ->db -> where('v.masa_berlaku >', date('Y-m-d'));
$this ->db -> where('v.is_aktif', '1');
if($orderBy == NULL){
$this->db->order_by('id_voucher', 'asc');
}
else{
if($orderBy == "scName"){
$orderBy = 'nama_voucher';
$order ='asc';
}
else if($orderBy == "scNew"){
$orderBy = 'id_voucher';
$order ='desc';
}
$this->db->order_by($orderBy, $order);
}
//$this->db->limit(8,0);
$query = $this->db->get('', $num, $page);
return $query;
}

Related

Codeigniter Infinite Scroll error

I try to make infinite scroll pagination in my codeigniter project. I'am using this tutorial http://www.mostlikers.com/2016/05/codeigniter-pagination-infinite-scroll.html to make it. But this is what i get
View
<!DOCTYPE html>
<html>
<head>
<title>deals</title>
<link href="<?php echo base_url();?>css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="<?php echo base_url();?>js/jquery.min.js"></script>
<!-- Custom Theme files -->
<!--theme-style-->
<link href="<?php echo base_url();?>css/style.css" rel="stylesheet" type="text/css" media="all" />
<!--//theme-style-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Food shop Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!--fonts-->
<link href='http://fonts.googleapis.com/css?family=Rokkitt:400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Lobster+Two:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
<!--//fonts-->
<script type="text/javascript" src="<?php echo base_url();?>js/move-top.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>js/easing.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
});
});
</script>
<link href="<?php echo base_url();?>css/index.css" rel="stylesheet" type="text/css" media="all" />
<link rel="stylesheet" href="<?php echo base_url();?>css/imgslider.css" type="text/css" media="screen" />
<script src="<?php echo base_url();?>js/slideout.min.js"></script>
<script src="<?php echo base_url();?>js/jquery.wmuSlider.js"></script>
<script src="<?php echo base_url();?>js/jquery.wmuGallery.js"></script>
</head>
<body>
<nav id="menu">
<h1 style="color:white">Menu</h1>
<hr style="color:white;">
<ul>
<?php if($tipeUser=="user"){?>
<li><h4>Home</h4></li>
<li><h4 style="color:white">Welcome <?php echo $nama;?></h4></li>
<li><h4>My Voucher</h4></li>
<li><h4>Profile</h4></li>
<li><h4>Logout</h4></li>
<?php } else if($tipeUser=="restoran"){ ?>
<li><h4>Home</h4></li>
<li><h4 style="color:white">Welcome <?php echo $nama;?></h4></li>
<li><h4>Dashboard</h4></li>
<li><h4>Voucher Management</h4></li>
<!-- <li><h4>Reedem Voucher</h4></li> -->
<li><h4>Logout</h4></li>
<?php } else if($tipeUser==""){ ?>
<li><h4>Home</h4></li>
<li><h4>Login / Register</h4></li>
<li><h4>Voucher</h4></li>
<li><h4>Restaurants</h4></li>
<?php
if($data_kategori->num_rows()>0)
{
foreach ($data_kategori->result() as $rows)
{ ?>
<li><h4><a href="<?php echo base_url();?>home_controller/Type/<?php echo $rows->id_jenis_makanan; ?>" style="color:white"><?php echo $rows->nama_jenis_makanan;?>
</a></h4></li>
<?php } } ?>
<?php } ?>
</ul>
</nav>
<main id="panel">
<header>
<!--header-->
<div class="header-in">
<div class="container">
<!---->
<div class="header-bottom">
<div class="col-xs-1">
<button class="toggle-button"></button>
</div>
<div class="col-xs-11">
<?php echo form_open('home_controller/search_bar');?>
<div class="search">
<form>
<input type="text" id= "input-keyword" name="input-keyword" placeholder="Search ..." value="<?php echo set_value('input-keyword')?>" >
<input type="submit" value="">
</form><?php echo form_close(); ?>
</div>
</div>
<div class="clearfix"> </div>
</div>
<!---->
</div>
</div>
<!---->
<div class="container">
<div class="specials">
<ol> <div id="results"></div></ol>
</div>
</div></div>
<div class="container">
<div class="col-md-12">
<p style="height:10px"></p>
<div id="pagination" align="center" class="pagination-wrapper">
<ul class="tsc_pagination pagination" align="center">
<!-- Show pagination links -->
<!-- <?php foreach ($links as $link) {
echo "<li>". $link."</li>";
} ?></ul> -->
<!-- </div> -->
</div></div>
<!---->
</header>
</main>
<?php if($this->session->flashdata('message')) :
echo "<script>alert('". $this->session->flashdata('message')."')</script>";
endif; ?>
</body>
<script>
var slideout = new Slideout({
'panel': document.getElementById('panel'),
'menu': document.getElementById('menu'),
'padding': 190,
'tolerance': 70
});
// Toggle button
document.querySelector('.toggle-button').addEventListener('click', function() {
slideout.toggle();
});
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if( userAgent.match( /iPad/i ) || userAgent.match( /iPhone/i ) || userAgent.match( /iPod/i ) )
{
slideout.disableTouch();
}
slideout.disableTouch();
// auto close
slideout.on('open', function() {
$( "#panel" ).click(function() {
return false;
});
$( "#panel" ).click(function() {
slideout.close();
});
});
slideout.on('close', function() {
$( "#panel" ).unbind('click');
});
</script>
<script>
$('.gallery').wmuSlider();
</script>
</html>
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var total_record = 0;
var total_groups = <?php echo $total_data; ?>;
$('#results').load("<?php echo base_url() ?>Home_controller/load_more",
{'group_no':total_record}, function() {total_record++;});
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height())
{
if(total_record <= total_groups)
{
loading = true;
$('.loader_image').show();
$.post('<?php echo site_url() ?>Home_controller/load_more',{'group_no': total_record},
function(data){
if (data != "") {
$("#results").append(data);
$('.loader_image').hide();
total_record++;
}
});
}
}
});
});
</script>
Model
public function get_allDeal_count()
{
$sql = "SELECT COUNT(*) as tol_records FROM voucher v join restoran r on v.id_restoran = r.id_restoran";
$result = $this->db->query($sql)->row();
return $result;
}
public function get_allDeal_content($start,$content_per_page)
{
$sql = "SELECT * FROM voucher v join restoran r on v.id_restoran=r.id_restoran WHERE LIMIT $start,$content_per_page";
$result = $this->db->query($sql)->result();
return $result;
}
Controller
public function list_voucher()
{
if($this->session->userdata('logged_in'))
{
$session_data = $this->session->userdata('logged_in');
$data['nama'] = $session_data['nama'];
$data['id'] = $session_data['id_user'];
$data['tipeUser'] = $session_data['tipe_user'];
}
else{
$data['nama'] = "";
$data['id'] = "0";
$data['tipeUser']="";
}
$data['notif'] = '';
$config['base_url'] = base_url().'/home_controller/list_voucher/';
$data['data_kategori'] = $this->jenismakanan->Getjenismakanan();
$total_data = $this->voucher->get_allDeal_count();
$content_per_page = 5;
$data['total_data'] = ceil($total_data->tol_records/$content_per_page);
$this->load->view('listalldeals', $data,FALSE);
// $this->load->view('listalldeals', $data);
}
public function load_more()
{
$group_no = $this->input->post('group_no');
$content_per_page = 5;
$start = ceil($group_no * $content_per_page);
$all_content = $this->voucher->get_allDeal_content($start,$content_per_page);
if(isset($all_content) && is_array($all_content) && count($all_content)) :
foreach ($all_content as $key => $content) :
echo '<li>'.$content->id_restoran.'</li>';
echo '<p>'.$content->nama_restoran.'</p>';
endforeach;
endif;
}
That's all the code that I used. I don't know what should I do to fix it.

How to add 3 attempts in a login page

hello everyone i just wanna ask on how to add three attempts in my login page here is the code
<?php
include 'connect.php';
?>
<?php
if(isset($_POST) && !empty($_POST))
{
session_start();
include("config_DB.php"); //including config.php in our file
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = mysql_real_escape_string(stripslashes(md5($_POST['password'])));
$user_type= $_GET['user_type'];
$match = "select * from $table where username = '".$username."' and password = '".sha1($password)."';";
$qry = mysql_query($match);
$row=mysql_fetch_array($qry);
$num_rows = mysql_num_rows($qry);
if($num_rows >= 1){
$_SESSION['user']= $_POST["username"];
$_SESSION['name'] = $row['empName'];
$_SESSION['position'] = $row['empPosition'];
$_SESSION['user_type'] = $row['user_type'];
header("location:index.php/index_controller/home");
} else {
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = mysql_real_escape_string(stripslashes($_POST['password']));
include("config_DB.php"); //including config.php in our file
$match = "select * from $table where username = '".$username."' and password = '".sha1($password)."';";
$qry = mysql_query($match);
$row=mysql_fetch_array($qry);
$num_rows = mysql_num_rows($qry);
$attemps =0;
if($num_rows <= 0){
echo
"<script type=\"text/javascript\">".
"window.alert('Invalid username/password!');".
'window.location.href="index.php";'.
"</script>";
exit;
}
$_SESSION['user']= $_POST["username"];
$_SESSION['name'] = $row['empName'];
$_SESSION['position'] = $row['empPosition'];
$_SESSION['user_type'] = $row['user_type'];
header("location:index.php/index_controller/home");
}
}else{
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>City Planning and Development Office--Login</title>
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/bootstrap.min.css"/>
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/login-style.css"/>
<link rel="stylesheet/less" href="<?php echo base_url();?>assets/less/icons.less"/>
<!-- Load JavaScript Libraries -->
<script src="<?php echo base_url();?>assets/js/jquery/jquery-1.11.1.min.js"></script>
<script src="<?php echo base_url();?>assets/js/jquery/jquery-ui.js"></script>
<script src="<?php echo base_url();?>assets/js/jquery/jquery.widget.min.js"></script>
<!-- Load Metro JavaScript -->
<script src="<?php echo base_url();?>assets/js/load-metro.js"></script>
<script src="<?php echo base_url();?>assets/js/metro.min.js"></script>
<script src="<?php echo base_url();?>assets/js/metro-calendar.js"></script>
<script src="<?php echo base_url();?>assets/js/metro-datepicker.js"></script>
<!-- Load Bootstrap JavaScript -->
<script src="<?php echo base_url();?>assets/js/bootstrap.min.js"></script>
<script src="<?php echo base_url();?>assets/js/validate.js"></script>
<script src="<?php echo base_url();?>assets/js/condition.js"></script>
<!-- Login parallax -->
<style type="text/css">
body{
background:#000;
}
input.info{
color:#000 !important;
}
.vertical-offset-100{
padding-top:100px;
}
.login{
background:#ed1c24;
color:#fff;
}
body{
background: url(img/back.png);
background-color: #444;
background: url(/cpdo_ci/assets/images/pinlayer2.png),url(/cpdo_ci/assets/images/pinlayer1.png),url(/cpdo_ci/assets/images/back.png);
}
.vertical-offset-100{
padding-top:100px;
}
</style>
</head>
<body>
<script src="<?php echo base_url();?>assets/js/TweenLite.min.js"></script>
<div class="container" >
<div class="row vertical-offset-100">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading">
<div class="row-fluid user-row">
<center><img src="/cpdo_ci/assets/images/malolos.png" height="200" width="200" alt="CPDO"></center>
</div>
</div>
<div class="panel-body">
<form accept-charset="UTF-8" id="login" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" name="login" class="form-signin" role="form">
<fieldset>
<div class="form-group">
<input class="form-control info" placeholder="Username" name="username" id="username" required type="text">
</div>
<div class="form-group">
<input class="form-control info" placeholder="Password" name="password" id="password" required type="password" value="">
</div>
<label>
<div style=" font-size:90%" >
</div>
</label>
<input class="btn btn-lg btn-success btn-block" type="submit" value="Login">
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$(document).mousemove(function(e){
TweenLite.to($('body'),
.5,
{ css:
{
backgroundPosition: ""+ parseInt(event.pageX/8) + "px "+parseInt(event.pageY/'12')+"px, "+parseInt(event.pageX/'15')+"px "+parseInt(event.pageY/'15')+"px, "+parseInt(event.pageX/'30')+"px "+parseInt(event.pageY/'30')+"px"
}
});
});
});
</script>
</body>
<?php
}
?>
</html>
</html>
Try this to the back-end which receives the login parameters.
if($_POST["password"]) !== $password_stored_in_db) {
if($attempts == 3) {
header('Location: login.php?max_attempt=exceeded');
}
} else if (isset($attempts)) {
$attempts = ++ $attempts;
} else {
$attempts = 0;
}
header('Location: login.php?attempt=' . $attempts);
Also add this to login.php to determine if user has exceeded max attempts:
Make sure that login.php is set to check for max_attempt=exceeded by adding:
if(isset($_GET["max_attempt"])) {
if($_GET["max_attempt"] == "exceeded") {
// Error message
// Use $_SESSION to record the time and to stop user from trying again for a while because if you use cookies, it maybe overridden or re-set.
}
}
You really should store the information of attempts on the DB, but some quick hack by storing the data on the session would be
<?php
include 'connect.php';
if(isset($_POST) && !empty($_POST))
{
session_start();
include("config_DB.php"); //including config.php in our file
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = mysql_real_escape_string(stripslashes(md5($_POST['password'])));
$user_type= $_GET['user_type'];
$match = "select * from $table where username = '".$username."' and password = '".sha1($password)."';";
$qry = mysql_query($match);
$row=mysql_fetch_array($qry);
$num_rows = mysql_num_rows($qry);
if($num_rows >= 1){
$_SESSION['attemps'] = 0;
$_SESSION['user']= $_POST["username"];
$_SESSION['name'] = $row['empName'];
$_SESSION['position'] = $row['empPosition'];
$_SESSION['user_type'] = $row['user_type'];
header("your_home_page");
} else {
$_SESSION['attemps'] ||= 0;
$_SESSION['attemps'] += 1;
if ($_SESSION['attemps'] > 3) {
header("location:/access_denied.php");
}
$display_warning = true;
}
}else{
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>City Planning and Development Office--Login</title>
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/bootstrap.min.css"/>
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/login-style.css"/>
<link rel="stylesheet/less" href="<?php echo base_url();?>assets/less/icons.less"/>
<!-- Load JavaScript Libraries -->
<script src="<?php echo base_url();?>assets/js/jquery/jquery-1.11.1.min.js"></script>
<script src="<?php echo base_url();?>assets/js/jquery/jquery-ui.js"></script>
<script src="<?php echo base_url();?>assets/js/jquery/jquery.widget.min.js"></script>
<!-- Load Metro JavaScript -->
<script src="<?php echo base_url();?>assets/js/load-metro.js"></script>
<script src="<?php echo base_url();?>assets/js/metro.min.js"></script>
<script src="<?php echo base_url();?>assets/js/metro-calendar.js"></script>
<script src="<?php echo base_url();?>assets/js/metro-datepicker.js"></script>
<!-- Load Bootstrap JavaScript -->
<script src="<?php echo base_url();?>assets/js/bootstrap.min.js"></script>
<script src="<?php echo base_url();?>assets/js/validate.js"></script>
<script src="<?php echo base_url();?>assets/js/condition.js"></script>
<!-- Login parallax -->
<style type="text/css">
body{
background:#000;
}
input.info{
color:#000 !important;
}
.vertical-offset-100{
padding-top:100px;
}
.login{
background:#ed1c24;
color:#fff;
}
body{
background: url(img/back.png);
background-color: #444;
background: url(/cpdo_ci/assets/images/pinlayer2.png),url(/cpdo_ci/assets/images/pinlayer1.png),url(/cpdo_ci/assets/images/back.png);
}
.vertical-offset-100{
padding-top:100px;
}
</style>
</head>
<body>
<script src="<?php echo base_url();?>assets/js/TweenLite.min.js"></script>
<div class="container" >
<div class="row vertical-offset-100">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading">
<div class="row-fluid user-row">
<center><img src="/cpdo_ci/assets/images/malolos.png" height="200" width="200" alt="CPDO"></center>
</div>
</div>
<div class="panel-body">
<form accept-charset="UTF-8" id="login" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" name="login" class="form-signin" role="form">
<fieldset>
<div class="form-group">
<input class="form-control info" placeholder="Username" name="username" id="username" required type="text">
</div>
<div class="form-group">
<input class="form-control info" placeholder="Password" name="password" id="password" required type="password" value="">
</div>
<label>
<div style=" font-size:90%" >
</div>
</label>
<input class="btn btn-lg btn-success btn-block" type="submit" value="Login">
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
<?php if defined($display_warning) : ?>
window.alert('Invalid username/password!');
<?php endif; ?>
$(document).mousemove(function(e){
TweenLite.to($('body'),
.5,
{ css:
{
backgroundPosition: ""+ parseInt(event.pageX/8) + "px "+parseInt(event.pageY/'12')+"px, "+parseInt(event.pageX/'15')+"px "+parseInt(event.pageY/'15')+"px, "+parseInt(event.pageX/'30')+"px "+parseInt(event.pageY/'30')+"px"
}
});
});
});
</script>
</body>
</html>
</html>

Remove sidebar on some pages on Wordpress

I am trying to edit a Worpress template. Everything work as as expected except that I wish to have a page without sidebar - which is not included in that template.
To achieve this I went to the template's folder, duplicated the "page.php" and named it page-nosidebar.php. Over there I deleted the get_sidebar call script. Here is how it looks like now:
<?php /*
Template Name: No Sidebars
*/ ?>
<?php get_header(); ?>
<div id="single_cont">
<div class="single_left">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1 class="single_title"><?php the_title(); ?></h1>
<div class="single_inside_content">
<?php the_content(); ?>
</div><!--//single_inside_content-->
<br /><br />
<?php //comments_template(); ?>
<?php endwhile; else: ?>
<h3>Sorry, no posts matched your criteria.</h3>
<?php endif; ?>
</div><!--//single_left-->
<div class="clear"></div>
</div><!--//single_cont-->
<?php get_footer(); ?>
After this, I went to the page editor and assigned this new template to the page I wanted to have no sidebar. Problem? Sidebar still shows up.
How should I do? Thanks in advance!
UPDATE
footer.php
<div class="clear"></div>
<div id="footer">
<div class="footer_text"> <?php echo date("Y"); ?> Company. Powered by Company</div>
</div><!--//footer-->
</div><!--//main_container-->
<?php wp_footer(); ?>
</body>
</html>
header.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <link href='http://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Raleway:400,100,200' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Cabin:700' rel='stylesheet' type='text/css'> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title> <?php wp_head(); ?> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> <!--[if lt IE 9]> <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script> <![endif]--> <!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>--> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-latest.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/scripts.js"></script> <script src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.infinitescroll.js" type="text/javascript" charset="utf-8"></script> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" title="no title" charset="utf-8"/> <script type="text/javascript"> $(document).ready( function($){ $('#content_inside').infinitescroll({
navSelector : "div.load_more_text",
// selector for the paged navigation (it will be hidden)
nextSelector : "div.load_more_text a:first",
// selector for the NEXT link (to page 2)
itemSelector : "#content_inside .home_post_box"
// selector for all items you'll retrieve },function(arrayOfNewElems){
$('.home_post_box').hover( function() { $(this).find('.home_post_text').css('display','block'); }, function () { $(this).find('.home_post_text').css('display','none'); } );
//$('.home_post_cont img').hover_caption();
// optional callback when new content is successfully loaded in.
// keyword `this` will refer to the new DOM content that was just added.
// as of 1.5, `this` matches the element you called the plugin on (e.g. #content)
// all the new elements that were found are passed in as an array
}); } ); </script> </head> <body> <?php $shortname = "neue"; ?> <?php if(get_option($shortname.'_background_image_url','') != "") { ?> <style type="text/css"> body { background-image: url('<?php echo get_option($shortname.'_background_image_url',''); ?>'); } </style> <?php } ?> <div id="main_container"> <div id="header"> <div class="left"> <?php if(get_option($shortname.'_custom_logo_url','') != "") { ?>
<img src="<?php echo stripslashes(stripslashes(get_option($shortname.'_custom_logo_url',''))); ?>" class="logo" /> <?php } else { ?>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/logo.jpg" class="logo" /> <?php } ?> </div>
<div class="right"> <div class="head_social">
<?php if(get_option($shortname.'_twitter_link','') != "") { ?>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/twitter-icon.png" />
<?php } ?>
<?php if(get_option($shortname.'_facebook_link','') != "") { ?>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/facebook-icon.png" />
<?php } ?>
<?php if(get_option($shortname.'_google_plus_link','') != "") { ?>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/google-plus-icon.png" />
<?php } ?>
<?php if(get_option($shortname.'_dribbble_link','') != "") { ?>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/dribbble-icon.png" />
<?php } ?>
<?php if(get_option($shortname.'_pinterest_link','') != "") { ?>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/pinterest-icon.png" />
<?php } ?>
<div class="clear"></div> </div><!--//head_social-->
<div class="header_menu"> <!--
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li>CATEGORIES
<ul>
<li>Wordpress Themes</li>
<li>Create Plugins</li>
<li>Wordpress Themes</li>
<li>Create Plugins</li>
</ul>
</li>
<li>BLOG</li>
<li>CONTACT</li>
</ul>-->
<?php wp_nav_menu('menu=header_menu&container=false&menu_id='); ?>
<div class="clear"></div> </div><!--//header_menu-->
<div class="clear"></div> </div> <div class="clear"></div> <div class="tagline"> <?php echo get_option($shortname.'_header_text','Use Neue Theme Settings to update this text...') ?> </div><!--//tagline-->
</div><!--//header-->

Hacked Joomla 3.1 administrator login page

My website was hacked, and i can see login page on my joomla administrator login page
here is the url of login page:
http://societ.us/administrator/index.php
the hacker was add code (at line 13-15):
<style type="text/css">
html { display:none }
</style>
Do you know how to remove that code?
I have checked few file below (and many more), and i haven't found it
in /home/societ/societ.us/administrator/templates/isis/login.php
<?php
/**
* #package Joomla.Administrator
* #subpackage Templates.isis
*
* #copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* #license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$lang = JFactory::getLanguage();
// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');
JHtml::_('bootstrap.tooltip');
// Add Stylesheets
$doc->addStyleSheet('templates/' .$this->template. '/css/template.css');
// Load optional RTL Bootstrap CSS
JHtml::_('bootstrap.loadCss', false, $this->direction);
// Load specific language related CSS
$file = 'language/' . $lang->getTag() . '/' . $lang->getTag() . '.css';
if (is_file($file))
{
$doc->addStyleSheet($file);
}
// Detecting Active Variables
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$task = $app->input->getCmd('task', '');
$itemid = $app->input->getCmd('Itemid', '');
$sitename = $app->getCfg('sitename');
// Check if debug is on
$config = JFactory::getConfig();
$debug = (boolean) $config->get('debug');
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<jdoc:include type="head" />
<script type="text/javascript">
window.addEvent('domready', function ()
{
document.getElementById('form-login').username.select();
document.getElementById('form-login').username.focus();
});
</script>
<style type="text/css">
/* Responsive Styles */
#media (max-width: 480px) {
.view-login .container {
margin-top: -170px;
}
.btn {
font-size: 13px;
padding: 4px 10px 4px;
}
}
<?php if ($debug) : ?>
.view-login .container {
position: static;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
}
.view-login .navbar-fixed-bottom {
display: none;
}
<?php endif; ?>
</style>
<!--[if lt IE 9]>
<script src="../media/jui/js/html5.js"></script>
<![endif]-->
</head>
<body class="site <?php echo $option . " view-" . $view . " layout-" . $layout . " task-" . $task . " itemid-" . $itemid . " ";?>">
<!-- Container -->
<div class="container">
<div id="content">
<!-- Begin Content -->
<div id="element-box" class="login well">
<img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/images/joomla.png" alt="Joomla!" />
<hr />
<jdoc:include type="message" />
<jdoc:include type="component" />
</div>
<noscript>
<?php echo JText::_('JGLOBAL_WARNJAVASCRIPT') ?>
</noscript>
<!-- End Content -->
</div>
</div>
<div class="navbar navbar-fixed-bottom hidden-phone">
<p class="pull-right">© <?php echo $sitename; ?> <?php echo date('Y');?></p>
<a class="login-joomla" href="http://www.joomla.org" class="hasTooltip" title="<?php echo JHtml::tooltipText('TPL_ISIS_ISFREESOFTWARE');?>">Joomla!®</a>
<i class="icon-share icon-white"></i> <?php echo JText::_('COM_LOGIN_RETURN_TO_SITE_HOME_PAGE') ?>
</div>
<jdoc:include type="modules" name="debug" style="none" />
</body>
</html>
in /home/societ/societ.us/administrator/templates/isis/index.php
<?php
/**
* #package Joomla.Administrator
* #subpackage Templates.isis
* #copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* #license GNU General Public License version 2 or later; see LICENSE.txt
* #since 3.0
*/
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$lang = JFactory::getLanguage();
$this->language = $doc->language;
$this->direction = $doc->direction;
$input = $app->input;
$user = JFactory::getUser();
// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');
$doc->addScript('templates/' .$this->template. '/js/template.js');
// Add Stylesheets
$doc->addStyleSheet('templates/' . $this->template . '/css/template.css');
// Load optional RTL Bootstrap CSS
JHtml::_('bootstrap.loadCss', false, $this->direction);
// Load specific language related CSS
$file = 'language/' . $lang->getTag() . '/' . $lang->getTag() . '.css';
if (is_file($file))
{
$doc->addStyleSheet($file);
}
// Detecting Active Variables
$option = $input->get('option', '');
$view = $input->get('view', '');
$layout = $input->get('layout', '');
$task = $input->get('task', '');
$itemid = $input->get('Itemid', '');
$sitename = $app->getCfg('sitename');
$cpanel = ($option === 'com_cpanel');
$showSubmenu = false;
$this->submenumodules = JModuleHelper::getModules('submenu');
foreach ($this->submenumodules as $submenumodule)
{
$output = JModuleHelper::renderModule($submenumodule);
if (strlen($output))
{
$showSubmenu = true;
break;
}
}
// Logo file
if ($this->params->get('logoFile'))
{
$logo = JUri::root() . $this->params->get('logoFile');
}
else
{
$logo = $this->baseurl . "/templates/" . $this->template . "/images/logo.png";
}
// Template Parameters
$displayHeader = $this->params->get('displayHeader', '1');
$statusFixed = $this->params->get('statusFixed', '1');
$stickyToolbar = $this->params->get('stickyToolbar', '1');
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<jdoc:include type="head" />
<?php
// Template color
if ($this->params->get('templateColor'))
{
?>
<style type="text/css">
.navbar-inner, .navbar-inverse .navbar-inner, .dropdown-menu li > a:hover, .dropdown-menu .active > a, .dropdown-menu .active > a:hover, .navbar-inverse .nav li.dropdown.open > .dropdown-toggle, .navbar-inverse .nav li.dropdown.active > .dropdown-toggle, .navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle, #status.status-top
{
background: <?php echo $this->params->get('templateColor');?>;
}
.navbar-inner, .navbar-inverse .nav li.dropdown.open > .dropdown-toggle, .navbar-inverse .nav li.dropdown.active > .dropdown-toggle, .navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle{
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .25), inset 0 -1px 0 rgba(0, 0, 0, .1), inset 0 30px 10px rgba(0, 0, 0, .2);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .25), inset 0 -1px 0 rgba(0, 0, 0, .1), inset 0 30px 10px rgba(0, 0, 0, .2);
box-shadow: 0 1px 3px rgba(0, 0, 0, .25), inset 0 -1px 0 rgba(0, 0, 0, .1), inset 0 30px 10px rgba(0, 0, 0, .2);
}
</style>
<?php
}
?>
<?php
// Template header color
if ($this->params->get('headerColor'))
{
?>
<style type="text/css">
.header
{
background: <?php echo $this->params->get('headerColor');?>;
}
</style>
<?php
}
?>
<!-- Sidebar background color -->
<?php if ($this->params->get('sidebarColor')) : ?>
<style type="text/css">
.nav-list > .active > a, .nav-list > .active > a:hover
{
background: <?php echo $this->params->get('sidebarColor'); ?>;
}
</style>
<?php endif; ?>
<!--[if lt IE 9]>
<script src="../media/jui/js/html5.js"></script>
<![endif]-->
</head>
<body class="admin <?php echo $option . " view-" . $view . " layout-" . $layout . " task-" . $task . " itemid-" . $itemid . " ";?>" <?php if ($stickyToolbar) : ?>data-spy="scroll" data-target=".subhead" data-offset="87"<?php endif;?>>
<!-- Top Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<?php if ($this->params->get('admin_menus') != '0') : ?>
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<?php endif; ?>
<a class="brand" href="<?php echo JUri::root(); ?>" title="<?php echo JText::sprintf('TPL_ISIS_PREVIEW', $sitename);?>" target="_blank"><?php echo JHtml::_('string.truncate', $sitename, 14, false, false);?> <i class="icon-out-2 small"></i></a>
<?php if ($this->params->get('admin_menus') != '0') : ?>
<div class="nav-collapse">
<?php else : ?>
<div>
<?php endif; ?>
<jdoc:include type="modules" name="menu" style="none" />
<ul class="<?php if ($this->direction == 'rtl') : ?>nav<?php else : ?>nav pull-right<?php endif; ?>">
<li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php echo $user->name; ?> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class=""><?php echo JText::_('TPL_ISIS_EDIT_ACCOUNT');?></li>
<li class="divider"></li>
<li class=""><?php echo JText::_('TPL_ISIS_LOGOUT');?></li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</nav>
<!-- Header -->
<?php
if ($displayHeader):
?>
<header class="header">
<div class="container-fluid">
<div class="row-fluid">
<div class="span2 container-logo">
<a class="logo" href="<?php echo $this->baseurl; ?>"><img src="<?php echo $logo;?>" alt="<?php echo $sitename; ?>" /></a>
</div>
<div class="span10">
<?php if (isset($app->JComponentTitle)) : ?>
<h1 class="page-title"><?php echo JHtml::_('string.truncate', $app->JComponentTitle, 0, false, false);?></h1>
<?php else : ?>
<h1 class="page-title"><?php echo JHtml::_('string.truncate', '', 0, false, false);?></h1>
<?php endif; ?>
</div>
</div>
</div>
</header>
<?php
endif;
?>
<?php
if ((!$statusFixed) && ($this->countModules('status'))):
?>
<!-- Begin Status Module -->
<div id="status" class="navbar status-top hidden-phone">
<div class="btn-toolbar">
<jdoc:include type="modules" name="status" style="no" />
</div>
<div class="clearfix"></div>
</div>
<!-- End Status Module -->
<?php
endif;
?>
<?php
if (!$cpanel):
?>
<!-- Subheader -->
<a class="btn btn-subhead" data-toggle="collapse" data-target=".subhead-collapse"><?php echo JText::_('TPL_ISIS_TOOLBAR');?> <i class="icon-wrench"></i></a>
<div class="subhead-collapse collapse">
<div class="subhead">
<div class="container-fluid">
<div id="container-collapse" class="container-collapse"></div>
<div class="row-fluid">
<div class="span12">
<jdoc:include type="modules" name="toolbar" style="no" />
</div>
</div>
</div>
</div>
</div>
<?php
else:
?>
<div style="margin-bottom: 20px"></div>
<?php
endif;
?>
<!-- container-fluid -->
<div class="container-fluid container-main">
<section id="content">
<!-- Begin Content -->
<jdoc:include type="modules" name="top" style="xhtml" />
<div class="row-fluid">
<?php if ($showSubmenu) : ?>
<div class="span2">
<jdoc:include type="modules" name="submenu" style="none" />
</div>
<div class="span10">
<?php else : ?>
<div class="span12">
<?php endif; ?>
<jdoc:include type="message" />
<?php
// Show the page title here if the header is hidden
if (!$displayHeader):
?>
<h1 class="content-title"><?php echo JHtml::_('string.truncate', $app->JComponentTitle, 0, false, false);?></h1>
<?php
endif;
?>
<jdoc:include type="component" />
</div>
</div>
<?php if ($this->countModules('bottom')) : ?>
<jdoc:include type="modules" name="bottom" style="xhtml" />
<?php endif; ?>
<!-- End Content -->
</section>
<?php if (!$this->countModules('status') || (!$statusFixed && $this->countModules('status'))) : ?>
<footer class="footer">
<p align="center">
<jdoc:include type="modules" name="footer" style="no" />
© <?php echo $sitename; ?> <?php echo date('Y');?></p>
</footer>
<?php endif; ?>
</div>
<?php if (($statusFixed) && ($this->countModules('status'))) : ?>
<!-- Begin Status Module -->
<div id="status" class="navbar navbar-fixed-bottom hidden-phone">
<div class="btn-toolbar">
<div class="btn-group pull-right">
<p><jdoc:include type="modules" name="footer" style="no" />
© <?php echo $sitename; ?> <?php echo date('Y');?></p>
</div>
<jdoc:include type="modules" name="status" style="no" />
</div>
</div>
<!-- End Status Module -->
<?php endif; ?>
<jdoc:include type="modules" name="debug" style="none" />
<?php if ($stickyToolbar) : ?>
<script>
(function($){
// fix sub nav on scroll
var $win = $(window)
, $nav = $('.subhead')
, navTop = $('.subhead').length && $('.subhead').offset().top - <?php if ($displayHeader || !$statusFixed) : ?>40<?php else:?>20<?php endif;?>
, isFixed = 0
processScroll()
// hack sad times - holdover until rewrite for 2.1
$nav.on('click', function ()
{
if (!isFixed) setTimeout(function () { $win.scrollTop($win.scrollTop() - 47) }, 10)
})
$win.on('scroll', processScroll)
function processScroll()
{
var i, scrollTop = $win.scrollTop()
if (scrollTop >= navTop && !isFixed)
{
isFixed = 1
$nav.addClass('subhead-fixed')
} else if (scrollTop <= navTop && isFixed)
{
isFixed = 0
$nav.removeClass('subhead-fixed')
}
}
})(jQuery);
</script>
<?php endif; ?>
</body>
</html>
Thank You In Advance
It might be injected into <jdoc:include type="head" />.
Try removing this line, for debugging purposes and see if the 'malicious' CSS is still present.
If not, then the code is infact injected into this Joomla include. To edit that file being called by Joomla, head over to:
/libraries/joomla/document/html/renderer/head.php
and try searching for anything out of the ordinary.
If you for some reason don't want to manually fix this problem, try re-installing Joomla onto the already existing website (be-careful not to overwrite your current configs, database and template), which I'm sure will fix this problem.
If you can't see it in the files, neither can we...
There are hundreds of files that the hacker may have altered.
It seems as if it is something within the template, but it could be as simple as a plugin for the administrator.
Use the Inspect Element in Firefox or Chrome, and remove the HTML style. Login to your administrator, and keep on manually removing the HTML style, until you find out what the hacker did.

jQuery Loading Content into a Div with CodeIgniter

I am trying to dynamically load content from my database into a div in my view called dynamic. I have a grid of products to the left of the dynamic div and when a user clicks on one of them I want the dynamic div to be populated with details on the product that they clicked on. Additionally, I would like the page to load with the first product selected and displayed automatically. I have tried to follow several tutorials on how to do this, but all I have done is run in circles. Any help is appreciated. My code is below:
Controller (category.php):
public function product() {
$product_id = $_POST['product_id'];
$data['product'] = $this->Category_model->getOneProduct($product_id);
}
Model (Category_model.php):
public function getOneProduct($id) {
$result = $this->db->query("SELECT *
FROM product
WHERE product_id = ?", array($id));
return $result->row_array();
}
View (category_view.php):
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $page['page_title']; ?></title>
<meta charset="utf-8">
<meta name="keywords" content="<?php echo $page['page_meta_keywords']; ?>"/>
<meta name="description" content="<?php echo $page['page_meta_description']; ?>"/>
<link rel="stylesheet" href="<?php echo base_url(); ?>css/style.css" type="text/css" media="all">
<link rel="stylesheet" href="<?php echo base_url(); ?>css/menu.css" type="text/css" media="all">
<link rel="stylesheet" href="<?php echo base_url(); ?>css/bgstretcher.css" type="text/css" media="all"; />
<link href='http://fonts.googleapis.com/css?family=Didact+Gothic:regular' rel='stylesheet' type='text/css' />
[removed][removed]
[removed][removed]
[removed][removed]
[removed]
$(document).ready(function(){
$('body').bgStretcher({
images: ['<?php echo base_url(); ?>images/background.jpg']
});
$('#slideshowHolder').jqFancyTransitions({
delay: 5000,
width: 483,
height: 573,
});
});
[removed]
</head>
<body>
<div id="main">
<div>/div>
<?php $this->load->view('menu_view'); ?>
<div id="content">
<div id="left">
<div id="slideshowHolder">
<?php foreach ($rotators as $rotator) { ?>
<img src="<?php echo base_url(); ?>images/<?php echo $rotator['rotator_photo']; ?>" width="100%" alt="">
<?php } ?>
</div>
</div>
<div id="right">
<div>
<table width="50%" cellpadding="5" >
<tr>
<?php $sql_endRow = 0;
$sql_columns = 3;
$sql_hloopRow1 = 0;
foreach ($products as $product) {
if($sql_endRow == 0 && $sql_hloopRow1++ != 0) { ?>
<tr>
<?php } ?>
<td align="center">
<a href="">
<img src="<?php echo base_url(); ?>products/<?php echo $product['product_thumbnail']; ?>" />
</a>
</td>
<?php $sql_endRow++;
if($sql_endRow >= $sql_columns) { ?>
</tr>
<?php $sql_endRow = 0;
}
}
if($sql_endRow != 0) {
while ($sql_endRow < $sql_columns) { ?>
<td> </td>
<?php $sql_endRow++;
} ?>
</tr>
<?php }?>
</table>
</div>
<div id="dynamic">
<?php //print_r($one_product); ?>
</div>
</div>
<div>/div>
</div>
</div>
</body>
</html>
</code>
In product(), Make the product_id come from GET instead of POST so that your links will work without javascript.
$product_id = $_GET['product_id'];
In getOneProduct($id):
return json_encode($result->row_array());
HTML:
<table width="50%" cellpadding="5" id="product-grid">
<!-- snip -->
<a href="/your/url/product?product_id=<?php echo $product['product_id']; ?>" data-product-id="<?php echo $product['product_id']; ?>">
<img src="<?php echo base_url(); ?>products/<?php echo $product['product_thumbnail']; ?>" />
</a>
example javascript (jquery):
$('#product-grid a').click(function(e){
e.preventDefault();
$.ajax({
type: "GET",
url: "/your/url/product",
data: "product_id=" + $(this).attr('data-product-id'),
success: function(msg){
var product_data = jQuery.parseJSON(msg);
// do something with product_data
$('#dynamic').html('New product: ' + product_data.product_id);
}
});
});

Categories