مشکل در اجرای json

shz_furion

کاربر عضو
سلام.دوستان مشکلی دارم که قبلا نداشتم.قبلا هیچ مشکلی توی اجرای json نبوده،اما الان با این مشکل عجیب رو به رو شدم.دیروز سرور لایت اسپید همراه با بسته امنیتی رو روی سرور نصب کردم و از همون موقع مشکل توی اجرای کد به وجود اومده.تابع توی لوکال جواب رو بر می گردونه اما روی سرور هیچی برگردونده نمیشه.

اینم کد که بخواین امتحان کنید.کد مشکلی نداره:


کد:
<?php
$uid = $_POST['uid'];
$page = $_POST['page'];
$page=strtolower($page);
$page=str_replace('www.','',$page);
$page=str_replace('http://','',$page);
$page=str_replace('https://','',$page);
$ip = $_SERVER['REMOTE_ADDR'];

$error = false;

//Let's check to see if we have the proper variables coming in from the ajax post request
//If not lets load and array with an error and a message
if(!$uid=='themeviews-like')
{
    $json = array("error"=>true, "message"=>"Could not find uid.powered by themeviews.ir!");
    $error = true;
}elseif(!$page)
{
    $json = array("error"=>true, "message"=>"Error: Could not find page.powered by themeviews.ir!");
    $error = true;
}else if(!$ip)
{
    $json = array("error"=>true, "message"=>"Error: Could not find ip.powered by themeviews.ir!");
    $error = true;
}

//If we do not have an error, lets go ahead and start cleaning the variables
if(!$error)
{
    //Include your mysql connection file
    include 'mysql_conf.php';

    $ip = mysql_real_escape_string( $ip );
    $page = mysql_real_escape_string( $page );
    $uid = mysql_real_escape_string( $uid );

    //Lets see if the user / ip address has already liked the article on this page
    $query = mysql_query("SELECT * FROM ip WHERE u_ip = '".$ip."' AND u_page = '".$page."' LIMIT 1");
    $count = mysql_num_rows( $query );

    //If the user hasn't then let's go ahead and add the like to the likes table
    //If there is an error lets output an error message, else lets go ahead and output a success message
    if(!$count)
    {
    $query = mysql_query("SELECT * FROM vote WHERE u_page = '".$page."' LIMIT 1");
    $row = mysql_fetch_assoc( $query );
    if(!$row){
    $plus=$row['u_plus'];
    $Plus=$row['u_plus']+1;
    $query=mysql_query("INSERT INTO vote VALUES('','".$page."','".$Plus."')");
    $Query = mysql_query("SELECT * FROM vote WHERE u_page = '".$page."' LIMIT 1");
    $row = mysql_fetch_array( $Query );        

        if($query)//add record to table
        {
            $json = array("error"=>false, "message"=>"Successfully liked.powered by themeviews.ir!", "count"=>$Plus, "icon"=>dislike);
        }else
        {
            $json = array("error"=>true, "message"=>"Error: Could not process like.powered by themeviews.ir!");
        }
    }
    else{
    $plus=$row['u_plus'];
    $Plus=$row['u_plus']+1;
    $query=mysql_query("SELECT * FROM vote WHERE u_page = '".$page."' LIMIT 1");
    $row = mysql_fetch_array($query);

    $edit = mysql_query ("UPDATE vote SET `u_page` = '".$row['u_page']."', `u_plus` = '".$Plus."' WHERE `url` = '".$row['url']."' LIMIT 1");    

        if($edit)//add record to table
        {
            $json = array("error"=>false, "message"=>"Successfully liked.powered by themeviews.ir!", "count"=>$Plus, "icon"=>dislike);
        }else
        {
            $json = array("error"=>true, "message"=>"Error: Could not process like.powered by themeviews.ir!");
        }    


    }
    $query=mysql_query("INSERT INTO ip VALUES('','".$page."','".$ip."',NULL)");
    }
    else{
        //This means we already have a like for this article on this page
    $query = mysql_query("SELECT * FROM vote WHERE u_page = '".$page."' LIMIT 1");
    $row = mysql_fetch_assoc( $query );
    $minus=$row['u_plus'];
    $minus=$minus-1;
    $edit = mysql_query ("UPDATE vote SET `u_page` = '".$row['u_page']."', `u_plus` = '".$minus."' WHERE `url` = '".$row['url']."' LIMIT 1");
    $query = mysql_query("delete FROM ip WHERE u_ip = '".$ip."' AND u_page = '".$page."' LIMIT 1");

    if($edit && $query)//add record to table
        {
            $json = array("error"=>false, "message"=>"Successfully disliked.powered by themeviews.ir!", "count"=>$minus, "icon"=>like);
        }else
        {
            $json = array("error"=>true, "message"=>"Error: Could not process like.powered by themeviews.ir!");
        }
    }
}
//Kill all the processes and output the array in json format
echo json_encode( $json );
 
بالا