/** * moves cached files from temporary cache-dir to their final destination * */ function launchCache($spid, $variation) { global $c; if ($c["renderstatichtml"]) { forceDirectories ($c["tmpcachepath"]); $spname = getSPNameUrlSafe($spid); nxCopy($c["tmpcachepath"] .$spname ."_" . $spid . "_v" . $variation . ".html", $c["cachepath"], $spname."_". $spid . "_v" . $variation . ".html"); @unlink ($c["tmpcachepath"]. $spname ."_" . $spid . "_v" . $variation . ".html"); } }
function copyRecord($newid) { // query for content global $db, $c; $destinationPath = $c["devfilespath"]; $columns = $this->_getColumns($newid); if ($columns["suffix"] != "") { nxCopy($c["devfilespath"] . $columns["filename"], $destinationPath , $columns["newfile"]); if (file_exists($c["devfilespath"] . "t" . $columns["filename"]) ) nxCopy($c["devfilespath"] . "t" . $columns["filename"], $destinationPath , "t" . $columns["newfile"]); } return $this->_getCreateSQL($columns); }
/** * Create the sql-code for a version of the selected object * @param integer ID of new Version. * @returns string SQL Code for new Version. */ function createVersion($newid, $copy = false) { // query for content global $db, $c; $destinationPath = $c["livefilespath"]; if ($copy) $destinationPath = $c["devfilespath"]; $querySQL = "SELECT * FROM $this->management_table WHERE $this->pk_name = $this->fkid"; $query = new query($db, $querySQL); $query->getrow(); $filename = $query->field("FILENAME"); $description = addslashes($query->field("DESCRIPTION")); $filetype = $query->field("FILETYPE"); $location = $query->field("LOCATION"); $name = $query->field("NAME"); $query->free(); // copy image to new version $fileparts = explode(".", $filename); $suffix = strtolower($fileparts[(count($fileparts) - 1)]); $newfile = $newid . "." . $suffix; if (!$copy) { nxDelete ($destinationPath , $newfile); } if ($suffix != "") { nxCopy($c["devfilespath"] . $filename, $destinationPath , $newfile); } $sql = "INSERT INTO $this->management_table ($this->pk_name, NAME,FILENAME, FILETYPE, LOCATION, DESCRIPTION) VALUES ($newid, '$name', '$newfile', '$filetype', '$location', '$description')"; return $sql; }
/** * Copy necessary files for plugin installation. Interally used only */ function _copy_files() { global $c; $files = $this->getInstallationFiles(); $error = false; for ($i = 0; $i < count($files); $i++) { nxCopy($c["path"] . "plugin/" . strtolower($this->name) . "/" . $files[$i], $c["livepath"] . "sys/", $files[$i]); if (!copy($c["path"] . "plugin/" . strtolower($this->name) . "/" . $files[$i], $c["devpath"] . "sys/" . $files[$i])) { $error = true; } } if ($error == true) { echo "Warning: The files could not be copied!"; } }
/** * determine the size of the image. write size to the database. * copy file to local folder */ function process() { global $c; $delete = $_POST["REMOVE".$this->fkid]; if ($delete) { addUpdate("pgn_image", "FILENAME", "", "FKID = ".$this->fileId, "TEXT"); addUpdate("pgn_image", "WIDTH", 0, "FKID = ".$this->fileId, "NUMBER"); addUpdate("pgn_image", "HEIGHT", 0, "FKID = ".$this->fileId, "NUMBER"); } else { // check, if upload. if ($this->suffix != "") { $image = $_FILES[$this->name]['tmp_name']; $image_name = $_FILES[$this->name]['name']; //determine image size $size = getimagesize($image); $width = $size[0]; $height = $size[1]; $oldfilename = getDBCell("pgn_image", "FILENAME", "FKID = " . $this->fileId); $filename = $this->fileId . "." . $this->suffix; // updating the database addUpdate("pgn_image", "FILENAME", $filename, "FKID = " . $this->fileId, "TEXT"); addUpdate("pgn_image", "WIDTH", $width, "FKID = " . $this->fileId, "NUMBER"); addUpdate("pgn_image", "HEIGHT", $height, "FKID = " . $this->fileId, "NUMBER"); // loading up new item. if ($oldfile != "") unlink ($c["devfilespath"] . $oldfilename); move_uploaded_file($image, $c["devfilespath"] . $filename); nxCopy($c["devfilespath"] . $filename, $c["devfilespath"], "orig_".$filename); // setting variables for further filtering $this->filename = $filename; $this->width = $width; $this->height = $height; // try creating thumbnails if ($c["useimagemagick"]) { $thumb = new NXImageApi($c["devfilespath"].$filename, $c["devfilespath"]."t".$filename); $thumb->resizeAbsolute(120, 120); $thumb->gravity = "Center"; $thumb->drawText("Preview"); $thumb->save(); $this->applyAutoMod($filename); } else { $thumb = new Img2Thumb($c["devfilespath"].$filename, 120, 120, $c["devfilespath"]."t".$filename); } //determine image size $size = getimagesize($c["devfilespath"] . $filename); $width = $size[0]; $height = $size[1]; $oldfilename = getDBCell("pgn_image", "FILENAME", "FKID = " . $this->fileId); $filename = $this->fileId . "." . $this->suffix; // updating the database addUpdate("pgn_image", "FILENAME", $filename, "FKID = " . $this->fileId, "TEXT"); addUpdate("pgn_image", "WIDTH", $width, "FKID = " . $this->fileId, "NUMBER"); addUpdate("pgn_image", "HEIGHT", $height, "FKID = " . $this->fileId, "NUMBER"); } } }
/** * Launch a Sitepage-MAster * @param integer SPM_ID to launch * @param integer ID of the level to launch to. * @param integer ID of the variation to launch. * @returns integer Translated ID after launch */ function launchSitepageMaster($in, $level, $variation) { global $db; $out = translateState($in, $level, false); $sql = "SELECT * FROM sitepage_master WHERE SPM_ID = {$in}"; $query = new query($db, $sql); $query->getrow(); $clt = $query->field("CLT_ID"); $type = $query->field("SPMTYPE_ID"); $name = addslashes($query->field("NAME")); $desc = addslashes($query->field("DESCRIPTION")); $path = addslashes($query->field("TEMPLATE_PATH")); $cltTrans = launchClusterTemplate($clt, $level, $variation); $sql = "DELETE FROM sitepage_master WHERE SPM_ID = {$out}"; $query = new query($db, $sql); $sql = "INSERT INTO sitepage_master (SPM_ID, NAME, DESCRIPTION, TEMPLATE_PATH, CLT_ID, SPMTYPE_ID, DELETED, VERSION) VALUES "; $sql .= "({$out}, '{$name}', '{$desc}', '{$path}', {$cltTrans}, {$type}, 0, {$level})"; $query = new query($db, $sql); $query->free(); // copy template physically. global $c; if (file_exists($c["devpath"] . $path)) { nxDelete($c["livepath"], $path); nxCopy($c["devpath"] . $path, $c["livepath"], $path); } launchSPMVariations($in, $level); return $out; }