예제 #1
0
 public function listFriends($id)
 {
     $client = new OCSClient();
     $self = new OCSUser();
     $client->set_auth_info($self->login(), EHeaderDataParser::get_cookie("password"));
     return $client->get("/v1/friend/data/{$id}");
 }
예제 #2
0
 public function getUserInfo($id)
 {
     $user = new OCSClient();
     $pw = $_COOKIE["password"];
     $name = $_COOKIE["login"];
     $user->set_auth_info($name, $pw);
     return $user->get("v1/person/data/{$id}");
 }
예제 #3
0
 public function edit($args)
 {
     $id = $args;
     $name = EHeaderDataParser::secure_post("inputTitle");
     $type = EHeaderDataParser::secure_post("type");
     $downloadname1 = EHeaderDataParser::secure_post("inputDownloadName");
     $downloadlink1 = EHeaderDataParser::secure_post("inputDownloadLink");
     $description = EHeaderDataParser::secure_post("inputDescription");
     $summary = EHeaderDataParser::secure_post("inputSummary");
     $version = EHeaderDataParser::secure_post("inputVersion");
     $changelog = EHeaderDataParser::secure_post("inputChangelog");
     $personid = OCSUser::login();
     $postdata = array("name" => $name, "type" => $type, "downloadname1" => $downloadname1, "downloadlink1" => $downloadlink1, "description" => $description, "summary" => $summary, "version" => $version, "changelog" => $changelog, "personid" => $personid);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info($personid, EHeaderDataParser::get_cookie("password"));
     $check = $client->post("v1/content/edit/{$id}", $postdata);
     if ($check["ocs"]["meta"]["statuscode"] == "100") {
         $client = new OCSClient(EConfig::$data["ocs"]["host"]);
         $client->set_auth_info($personid, EHeaderDataParser::get_cookie("password"));
         if (!empty($_FILES['inputDownloadFile'])) {
             $client->set_upload_file($_FILES['inputDownloadFile']['tmp_name']);
             $result = $client->post("v1/content/uploaddownload/{$id}");
         }
         if (!empty($_FILES['inputScreenshot1'])) {
             $client->set_upload_file($_FILES['inputScreenshot1']['tmp_name']);
             $result = $client->post("v1/content/uploadpreview/{$id}/1");
             ELog::pd($result);
             if (!empty($_FILES['inputScreenshot2'])) {
                 $client->set_upload_file($_FILES['inputScreenshot2']['tmp_name']);
                 $result = $client->post("v1/content/uploadpreview/{$id}/2");
                 if (!empty($_FILES['inputScreenshot3'])) {
                     $client->set_upload_file($_FILES['inputScreenshot3']['tmp_name']);
                     $result = $client->post("v1/content/uploadpreview/{$id}/3");
                     if ($result["ocs"]["meta"]["statuscode"] == "100") {
                         //ELog::pd($check); //cosa fare se va a buon fine
                     }
                 }
             }
         }
         //else {ELog::pd($result);}
         //cosa fare se va a buon fine
         header("Location: /plasmastore/app_description/show/{$id}");
     }
 }
예제 #4
0
 public function leaveComment($id)
 {
     $type = "1";
     $content = $id;
     $content2 = "1";
     $parent = "";
     $subject = EHeaderDataParser::secure_post("inputSubject");
     $message = EHeaderDataParser::secure_post("inputMessage");
     $postdata = array("type" => $type, "content" => $content, "content2" => $content2, "parent" => $parent, "subject" => $subject, "message" => $message);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info(EHeaderDataParser::get_cookie("login"), EHeaderDataParser::get_cookie("password"));
     $check = $client->post("v1/comments/add", $postdata);
     if ($check["ocs"]["meta"]["statuscode"] == "100") {
         //cosa fare se va a buon fine
         header("Location: /plasmastore/app_description/show/{$id}");
     } else {
         echo $check["ocs"]["meta"]["statuscode"];
     }
 }
예제 #5
0
파일: addScore.php 프로젝트: KDE/ocs-server
<?php

include "gfx3/lib.php";
$aResponse['error'] = false;
$aResponse['message'] = '';
if (isset($_POST['action'])) {
    if (htmlentities($_POST['action'], ENT_QUOTES, 'UTF-8') == 'rating') {
        $id = intval($_POST['idBox']);
        $rate = floatval($_POST['rate']);
        $postdata = array("vote" => $rate);
        $client = new OCSClient();
        $client->set_auth_info(EUser::nick(), EUser::password());
        $client->set_post_data($postdata);
        $result = $client->post("v1/content/vote/{$id}");
        if ($result["ocs"]["status"] == "ok") {
            $success = true;
        } else {
            $success = false;
        }
        // json datas send to the js file
        if ($success) {
            $aResponse['message'] = 'Your rate has been successfuly recorded. Thanks for your rate :)';
            echo json_encode($aResponse);
        } else {
            $aResponse['error'] = false;
            $aResponse['message'] = $client->get_last_raw_result();
            echo json_encode($aResponse);
        }
    } else {
        $aResponse['error'] = true;
        $aResponse['message'] = '"action" post data not equal to \'rating\'';
예제 #6
0
 public function test()
 {
     $total_time = 0;
     EStructure::view("header");
     ETime::measure_from();
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     echo '<h3>Sanity OCS test</h3>';
     echo '<p>config..........';
     $check = $client->get("v1/config");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/check..........';
     $postdata = array("login" => "test", "password" => "password");
     $check = $client->post("v1/person/check", $postdata);
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/add..........';
     $postdata = array("login" => "cavolfiore", "password" => "cavolfiore", "email" => "*****@*****.**", "firstname" => "cavolf", "lastname" => "chiappe");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $check = $client->post("v1/person/add", $postdata);
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/data..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/person/data");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/data?name=cavol&page=1&pagesize=10..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/person/data?name=cavol&page=1&pagesize=10");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/data/[login]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/person/data/cavolfiore");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/self..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/person/self");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/add..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $postdata = array("name" => "esempio", "type" => "0", "downloadname1" => "downloadname1", "downloadlink1" => "downloadlink1", "description" => "description", "summary" => "summary", "version" => "version", "changelog" => "changelog", "personid" => "test");
     $client->set_auth_info("test", "password");
     $check = $client->post("v1/content/add", $postdata);
     $contentid = $this->example_contentid = $check['ocs']['data']['content'][0]['id'];
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/categories..........';
     $check = $client->get("v1/content/categories");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/licenses..........';
     $check = $client->get("v1/content/licenses");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/data..........';
     $check = $client->get("v1/content/data");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/data?search=esem..........';
     $check = $client->get("v1/content/data?search=esem");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/data/[contentid]..........';
     $check = $client->get("v1/content/data/{$contentid}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/download/[contentid]/1..........';
     $check = $client->get("v1/content/download/{$contentid}/1");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/vote/[contentid]..........';
     $id = intval($contentid);
     $rate = floatval(1);
     $postdata = array("vote" => $rate);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/content/vote/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/edit/[contentid]..........';
     $postdata = array("name" => "esempiomod", "summary" => "summarymod", "downloadname1" => "downloadname1mod", "downloadlink1" => "downloadlink1mod", "description" => "descriptionmod", "version" => "versionmod", "changelog" => "changelogmod");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/content/edit/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>[get] activity..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/activity");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>[post] activity..........';
     $postdata = array("message" => "coding is fun");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/activity");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>fan/add..........';
     $postdata = array("idcontent" => $contentid);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/fan/add/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>fan/data/[contentid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/fan/data/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>fan/status/[contentid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/fan/status/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>fan/remove..........';
     $postdata = array("idcontent" => $contentid);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/fan/remove/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>comments/add..........';
     $postdata = array("type" => "1", "content" => $id, "content2" => "1", "parent" => "0", "subject" => "subject", "message" => "message");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/comments/add");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>comments/data/[type]/[contentid1]/[contentid2]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     //$client->set_auth_info("test","password");
     $check = $client->get("v1/comments/data/1/{$id}/1&page=1&pagesize=10");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     //deleting content used for tests
     echo '<p>content/delete/[contentid]..........';
     $postdata = array("contentid" => $id);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/content/delete/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     /*
      * TODO: add to OCS specs more returncodes than just 100
      */
     echo '<p>friend/data/[personid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/friend/data/cavolfiore");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     /*
      * TODO: add to OCS specs more returncodes than just 100
      */
     echo '<p>friend/receivedinvitations..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/friend/receivedinvitations");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     /*
      * TODO: add to OCS specs more returncodes than just 100
      */
     echo '<p>friend/invite/[personid]..........';
     $postdata = array("message" => "would you be my friend?");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/friend/invite/cavolfiore ");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>friend/approve/[personid]..........';
     $postdata = array("message" => "would you be my friend?");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("cavolfiore", "cavolfiore");
     $client->set_post_data($postdata);
     $check = $client->post("v1/friend/approve/test");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>friend/decline/[personid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("cavolfiore", "cavolfiore");
     $check = $client->post("v1/friend/decline/test");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>friend/cancel/[personid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("cavolfiore", "cavolfiore");
     $check = $client->post("v1/friend/cancel/test");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )<br>";
     echo "This OCS test took: {$total_time}";
     EStructure::view("footer");
 }