/** * upload a preview picture of a content * @param string $format * @param string $contentid * @param string $previewid * @return string xml/json */ private function contentpreviewupload($format, $contentid, $previewid) { $user = $this->checkpassword(true); $this->checktrafficlimit($user); $content = addslashes($contentid); $preview = addslashes($previewid); // fetch data $con = new OCSContent(); if ($preview == 1 or $preview == 2 or $preview == 3) { if ($con->load($content) and $con->is_owned(OCSUser::id())) { if (isset($_FILES['localfile']['name']) and isset($_FILES['localfile']['name']) and ($_FILES['localfile']['name'] != '' and $_FILES['localfile']['name'] != 'none' and $_FILES['localfile']['tmp_name'] != '' and $_FILES['localfile']['tmp_name'] != 'none')) { if ($con->previewadd($content, 'localfile', $preview)) { $txt = $this->generatexml($format, 'ok', 100, ''); } else { ELog::error("previewadd crashed lol!"); } } else { $txt = $this->generatexml($format, 'failed', 101, 'localfile not found'); } } else { $txt = $this->generatexml($format, 'failed', 102, 'no permission to change content'); } } else { $txt = $this->generatexml($format, 'failed', 103, 'preview must be 1, 2 or 3'); } echo $txt; }