File indexing completed on 2025-01-26 05:26:00
0001 <?php 0002 0003 include("gfx3/lib.php"); 0004 0005 $aResponse['error'] = false; 0006 $aResponse['message'] = ''; 0007 0008 0009 if(isset($_POST['action'])) 0010 { 0011 if(htmlentities($_POST['action'], ENT_QUOTES, 'UTF-8') == 'rating') 0012 { 0013 $id = intval($_POST['idBox']); 0014 $rate = floatval($_POST['rate']); 0015 0016 $postdata = array( 0017 "vote" => $rate 0018 ); 0019 0020 $client = new OCSClient(); 0021 $client->set_auth_info(EUser::nick(),EUser::password()); 0022 $client->set_post_data($postdata); 0023 $result = $client->post("v1/content/vote/$id"); 0024 0025 if($result["ocs"]["status"]=="ok"){ 0026 $success = true; 0027 } else { 0028 $success = false; 0029 } 0030 0031 0032 // json datas send to the js file 0033 if($success) 0034 { 0035 $aResponse['message'] = 'Your rate has been successfuly recorded. Thanks for your rate :)'; 0036 0037 echo json_encode($aResponse); 0038 } 0039 else 0040 { 0041 $aResponse['error'] = false; 0042 $aResponse['message'] = $client->get_last_raw_result(); 0043 0044 0045 echo json_encode($aResponse); 0046 } 0047 } 0048 else 0049 { 0050 $aResponse['error'] = true; 0051 $aResponse['message'] = '"action" post data not equal to \'rating\''; 0052 0053 0054 echo json_encode($aResponse); 0055 } 0056 } 0057 else 0058 { 0059 $aResponse['error'] = true; 0060 $aResponse['message'] = '$_POST[\'action\'] not found'; 0061 0062 0063 echo json_encode($aResponse); 0064 }