connect('127.0.0.1',6379); $user_id = null; if (isset($_COOKIE['uid'])) { $user_id = $_COOKIE['uid']; } if (isset($_GET['id'])) { $id = $_GET['id']; $res_penulis = mysql_query("select oleh, user_type from webref.referensi where id='$id'"); $penulis = mysql_fetch_array($res_penulis); $oleh = $penulis['oleh']; $user_type = $penulis['user_type']; } $color_tombol_trust = "#009900"; $color_tombol_distrust = "#CC0000"; if (isset($_GET['id'])) { if (isset($_GET['act']) && $_GET['act']=="trust") { if (!isset($user_id)) { echo ""; exit; } //jika belum ngasih trust if ($redis->get("trust:ref:$id:user:$user_id")=="") { $redis->set("trust:ref:$id:user:$user_id", "1"); //jika rekomendasi baru pertama kali dikasih trust if ($redis->get("trust:ref:$id")=="") { $redis->set("trust:ref:$id", "1"); }else{ //tambah trust rekomendasi $redis->incr("trust:ref:$id"); } if ($redis->get("distrust:ref:$id")>0 and $redis->get("distrust:ref:$id:user:$user_id")!="") { $redis->decr("distrust:ref:$id"); } if ($user_type==0) { //kalo penulisnya belum pernah dapat trust if ($redis->get("trust:user_profile:$oleh")=="") { $redis->set("trust:user_profile:$oleh", "1"); }else{ //tambah kredit trust penulis $redis->incr("trust:user_profile:$oleh"); } //kurangi kredit distrust penulis if ($redis->get("distrust:user_profile:$oleh")>0 and $redis->get("distrust:ref:$id:user:$user_id")!="") { $redis->decr("distrust:user_profile:$oleh"); } } $redis->set("distrust:ref:$id:user:$user_id", ""); } } if (isset($_GET['act']) && $_GET['act']=="distrust") { if (!isset($user_id)) { echo ""; exit; } //jika belum ngasih distrust if ($redis->get("distrust:ref:$id:user:$user_id")=="") { $redis->set("distrust:ref:$id:user:$user_id", "1"); //jika rekomendasi baru pertama kali dikasih trust if ($redis->get("distrust:ref:$id")=="") { $redis->set("distrust:ref:$id", "1"); }else{ //tambah distrust rekomendasi $redis->incr("distrust:ref:$id"); } //kurangi jumlah trust if ($redis->get("trust:ref:$id")>0 and $redis->get("trust:ref:$id:user:$user_id")!="") { $redis->decr("trust:ref:$id"); } if ($user_type==0) { //kalo penulisnya belum pernah dapat distrust if ($redis->get("distrust:user_profile:$oleh")=="") { $redis->set("distrust:user_profile:$oleh", "1"); }else{ //tambah kredit distrust penulis $redis->incr("distrust:user_profile:$oleh"); } //kurangi kredit trust penulis if ($redis->get("trust:user_profile:$oleh")>0 and $redis->get("trust:ref:$id:user:$user_id")!="") { $redis->decr("trust:user_profile:$oleh"); } } $redis->set("trust:ref:$id:user:$user_id", ""); } } $total_trust_ref = $redis->get("trust:ref:$id"); $total_distrust_ref = $redis->get("distrust:ref:$id"); $total_trust_oleh = $redis->get("trust:user_profile:$oleh"); $total_distrust_oleh = $redis->get("distrust:user_profile:$oleh"); $total_trust_level = $total_trust_oleh - $total_distrust_oleh; if ($redis->get("trust:ref:$id:user:$user_id")=="") { $tombol_trust = ""; $src_button_useful = "images/useful.png"; }else{ $tombol_trust = "disabled"; $you_and = "You and "; $color_tombol_trust = "#999999"; $src_button_useful = "images/useful-ed.png"; } if ($redis->get("distrust:ref:$id:user:$user_id")=="") { $tombol_distrust = ""; $src_button_useless = "images/useless.png"; }else{ $tombol_distrust = "disabled"; $you_and_2 = "You and "; $color_tombol_distrust = "#999999"; $src_button_useless = "images/useless-ed.png"; } if ($total_trust_level > 10000) { $level = 5; }else if ($total_trust_level > 2000) { $level = 4; }else if ($total_trust_level > 100) { $level = 3; }else if ($total_trust_level > 10) { $level = 2; }else if ($total_trust_level > 0) { $level = 1; }else if ($total_trust_level < 0) { $level = -1; }else if ($total_trust_level < -10) { $level = -2; }else if ($total_trust_level < -100) { $level = -3; }else if ($total_trust_level < -2000) { $level = -4; }else if ($total_trust_level < -10000) { $level = -5; } if (isset($_GET['act']) && ($_GET['act']=="trust" or $_GET['act']=="distrust" and $user_type==0)) { mysql_query("update webref.user_profile set trust_level = '$level' where user_id='$oleh'") or die(mysql_error()); } } $trust_count = $redis->get("trust:ref:$id"); $distrust_count = $redis->get("distrust:ref:$id"); ?>
/>
/>
1) { if ($tombol_trust=="disabled") { echo "You and ". ($trust_count - 1) . " other people(s) feel this is useful."; }else{ echo $trust_count . " peoples feel this is useful."; } }else if ($trust_count == 1) { if ($tombol_trust=="disabled") { echo "You feel this is useful."; }else{ echo "One person feel this is useful."; } } echo "
"; ?> 1) { if ($tombol_distrust=="disabled") { echo "You and ". ($distrust_count - 1) . " other people(s) feel this is useless."; }else{ echo $distrust_count . " peoples feel this is useless."; } }else if ($distrust_count == 1) { if ($tombol_distrust=="disabled") { echo "You feel this is useless."; }else{ echo "One person feel this is useless."; } } // echo "
"; // echo "
"; // echo "
"; // echo "Total trust: $total_trust_oleh
"; // echo "Total distrust: $total_distrust_oleh"; ?>
set("trust:user_profile:653411650", 50000); $redis->set("trust:user_profile:1148193857", 50000); $redis->set("trust:user_profile:655976325", 50000); $redis->set("trust:user_profile:667651483", 50000); $redis->set("trust:user_profile:1050098421", 50000); $redis->set("trust:user_profile:653411299", 50000); $redis->set("trust:user_profile:773633750", 50000); $redis->set("trust:user_profile:709657827", 50000); $redis->set("trust:user_profile:712874502", 50000); $redis->set("trust:user_profile:563279880", 50000); $redis->set("trust:user_profile:1068201970", 50000); $redis->set("trust:user_profile:100000338757411", 50000);*/ ?>