Example #1
0
 public function downloadadd()
 {
     if (!is_dir("content/" . $this->id)) {
         chdir("content");
         if (!mkdir($this->id)) {
             ELog::error("<b>mkdir</b> failed for some reason. Inspect.");
             return false;
         }
         chdir("..");
     }
     $path = "content/" . $this->id . "/";
     //clean evetual additional files
     EFileSystem::clean_all_files_in($path, array("1", "2", "3"));
     //if upload file failed print error. Else add link to content object.
     if (!EFileSystem::move_uploaded_file_in_ext($path)) {
         ELog::error("<b>get_uploaded_file</b> failed! Path: ({$path}) ");
         return false;
     } else {
         $this->downloadlink1 = "http://" . EConfig::$data["ocs"]["host"];
         //retrieve website running server
         $this->downloadlink1 .= "/content/" . $this->id . "/" . EFileSystem::get_uploaded_file_name();
         $this->downloadname1 = EFileSystem::get_uploaded_file_name();
         EDatabase::q("UPDATE ocs_content SET downloadlink1='" . $this->downloadlink1 . "', downloadname1='" . $this->downloadname1 . "' WHERE id=" . $this->id . " LIMIT 1");
         //activity update
         OCSActivity::add(OCSUser::id(), 3, OCSUser::login() . " uploaded a new version of " . $this->name);
         return true;
     }
 }