File indexing completed on 2024-05-12 17:26:19

0001 <?php
0002 class UserPanelModel extends EModel {
0003     public function upload () {
0004         $name = EHeaderDataParser::secure_post("inputTitle");
0005         $type = EHeaderDataParser::secure_post("type");
0006         $downloadname1 = EHeaderDataParser::secure_post("inputDownloadName");
0007         $downloadlink1 = EHeaderDataParser::secure_post("inputDownloadLink");
0008         $description = EHeaderDataParser::secure_post("inputDescription");
0009         $summary = EHeaderDataParser::secure_post("inputSummary");
0010         $version = EHeaderDataParser::secure_post("inputVersion");
0011         $changelog = EHeaderDataParser::secure_post("inputChangelog");
0012         $personid = OCSUser::login();
0013 
0014         $postdata = array(
0015             "name" => $name,
0016             "type" => $type,
0017             "downloadname1" => $downloadname1,
0018             "downloadlink1" => $downloadlink1,
0019             "description" => $description,
0020             "summary" => $summary,
0021             "version" => $version,
0022             "changelog" => $changelog,
0023             "personid" => $personid
0024             );
0025 
0026     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
0027     $client->set_auth_info($personid,EHeaderDataParser::get_cookie("password"));
0028     $check = $client->post("v1/content/add",$postdata);
0029      //print_r($_FILES);
0030      //print_r($_FILES['localfile']['tmp_name']);
0031         $id = "";
0032     if($check["ocs"]["meta"]["statuscode"]=="100"){
0033       
0034       $id = $check["ocs"]["data"]["content"][0]["id"];
0035       
0036       $client = new OCSClient(EConfig::$data["ocs"]["host"]);
0037       $client->set_auth_info($personid,EHeaderDataParser::get_cookie("password"));
0038             if(!empty($_FILES['inputDownloadFile'])){
0039                 $client->set_upload_file($_FILES['inputDownloadFile']['tmp_name']);
0040                 $result = $client->post("v1/content/uploaddownload/$id");
0041             }
0042             if(!empty($_FILES['inputScreenshot1'])){
0043           $client->set_upload_file($_FILES['inputScreenshot1']['tmp_name']);
0044           $result = $client->post("v1/content/uploadpreview/$id/1");
0045             
0046                 if(!empty($_FILES['inputScreenshot2'])){
0047                     $client->set_upload_file($_FILES['inputScreenshot2']['tmp_name']);
0048                     $result = $client->post("v1/content/uploadpreview/$id/2");
0049                 
0050                     if(!empty($_FILES['inputScreenshot3'])){
0051                         $client->set_upload_file($_FILES['inputScreenshot3']['tmp_name']);
0052                         $result = $client->post("v1/content/uploadpreview/$id/3");
0053                         if($result["ocs"]["meta"]["statuscode"]=="100"){
0054                             //cosa fare se va a buon fine
0055                             
0056                         } 
0057                     }
0058                 }
0059             } //else {ELog::pd($result);}
0060     } header("Location: /plasmastore/app_description/show/$id/$name");
0061   }
0062 
0063     public function edit ($args) {
0064         $id= $args;
0065         $name = EHeaderDataParser::secure_post("inputTitle");
0066         $type = EHeaderDataParser::secure_post("type");
0067         $downloadname1 = EHeaderDataParser::secure_post("inputDownloadName");
0068         $downloadlink1 = EHeaderDataParser::secure_post("inputDownloadLink");
0069         $description = EHeaderDataParser::secure_post("inputDescription");
0070         $summary = EHeaderDataParser::secure_post("inputSummary");
0071         $version = EHeaderDataParser::secure_post("inputVersion");
0072         $changelog = EHeaderDataParser::secure_post("inputChangelog");
0073         $personid = OCSUser::login();
0074 
0075         $postdata = array(
0076             "name" => $name,
0077             "type" => $type,
0078             "downloadname1" => $downloadname1,
0079             "downloadlink1" => $downloadlink1,
0080             "description" => $description,
0081             "summary" => $summary,
0082             "version" => $version,
0083             "changelog" => $changelog,
0084             "personid" => $personid
0085             );
0086 
0087     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
0088     $client->set_auth_info($personid,EHeaderDataParser::get_cookie("password"));
0089     $check = $client->post("v1/content/edit/$id",$postdata);
0090 
0091     if($check["ocs"]["meta"]["statuscode"]=="100"){
0092             $client = new OCSClient(EConfig::$data["ocs"]["host"]);
0093             $client->set_auth_info($personid,EHeaderDataParser::get_cookie("password"));
0094             if(!empty($_FILES['inputDownloadFile'])){
0095                 $client->set_upload_file($_FILES['inputDownloadFile']['tmp_name']);
0096                 $result = $client->post("v1/content/uploaddownload/$id");
0097             }
0098             if(!empty($_FILES['inputScreenshot1'])){
0099                 $client->set_upload_file($_FILES['inputScreenshot1']['tmp_name']);
0100                 $result = $client->post("v1/content/uploadpreview/$id/1");
0101                 ELog::pd($result);
0102             
0103                 if(!empty($_FILES['inputScreenshot2'])){
0104                     $client->set_upload_file($_FILES['inputScreenshot2']['tmp_name']);
0105                     $result = $client->post("v1/content/uploadpreview/$id/2");
0106                 
0107                     if(!empty($_FILES['inputScreenshot3'])){
0108                         $client->set_upload_file($_FILES['inputScreenshot3']['tmp_name']);
0109                         $result = $client->post("v1/content/uploadpreview/$id/3");
0110 
0111                         if($result["ocs"]["meta"]["statuscode"]=="100"){
0112                             //ELog::pd($check); //cosa fare se va a buon fine
0113                             
0114                         } 
0115                     }
0116                 }
0117             } //else {ELog::pd($result);}
0118         //cosa fare se va a buon fine
0119         header("Location: /plasmastore/app_description/show/$id");
0120     }
0121 }
0122 } 
0123 ?>