Пример #1
0
<?php

include "../model/msgdb.php";
include "../model/likedb.php";
if ($_POST['method'] == "insert") {
    insert_message();
}
if ($_POST['method'] == "getall") {
    get_messages();
}
if ($_POST['method'] == "like") {
    insert_like();
}
if ($_POST['method'] == "getlike") {
    get_likes();
}
Пример #2
0
<?php

include 'core.php';
session_start();
if (isset($_SESSION['user_id'])) {
    $user_id = $_SESSION['user_id'];
    if (isset($_POST['term_id'])) {
        $term_id = $_POST['term_id'];
    }
    $act = $_POST['act'];
    echo $act;
    //yoxluyurug user like edib ya yox
    if (!previously_liked($user_id, $term_id)) {
        $inserted = insert_like($user_id, $term_id);
        if ($inserted) {
            echo "Success";
        } else {
            echo "Fail";
        }
        $updated = update_num_of_likes($term_id);
    } else {
        echo "You have already liked it";
    }
} else {
    echo "You must first log in to like";
}
?>
	
Пример #3
0
 if ($act === "like") {
     $table_name = "termin_like";
     $opposite_table = "termin_dislike";
     $table_column = "ter_num_like";
     $opposite_column = "ter_num_dislike";
 } else {
     if ($act === "dislike") {
         $table_name = "termin_dislike";
         $opposite_table = "termin_like";
         $table_column = "ter_num_dislike";
         $opposite_column = "ter_num_like";
     }
 }
 //yoxluyurug user like edib ya yox
 if (!previously_liked($user_id, $term_id, $table_name)) {
     $inserted = insert_like($user_id, $term_id, $table_name);
     if ($inserted) {
         $data['result'] = "Success";
     } else {
         $data['result'] = "Fail";
     }
     //yoxluyurug eger bundan evvel eks action atilibsa (eger user like edibse
     //baxirig evvelden dislike olunub ve eksine)
     if (previously_liked($user_id, $term_id, $opposite_table)) {
         //table-dan evvel atdigim addimi sil
         change_status_like($user_id, $term_id, $opposite_table);
         //(dis)like-in sayini azalt
         decrease_num_of_likes($term_id, $opposite_column);
         //buradan mueyyenleshdire bilecem ki men neyin sayini deyishdim
         //yeni sehifede hemchinin like ve ya dislike azaltmaliya
         $data['attr_changed'] = $opposite_column;