Example #1
0
	/**
	  * renders a SitePage and stores output in a file in $c["cachepath"]
	  *
	  * @param integer SPID of the SitePage to render
	  * @param integer Variation-ID of the SitePage to render
	  * @param string Additional Parameters of URL.
	  */
	function renderSitePage($spid, $variation, $addparam="") {
		global $c, $db;		
		if ($c["renderstatichtml"] && !checkCC($spid)) {
			global $cc, $deploy;
			array_push($cc, $spid);
			$template = getTemplate($spid);

			if ($template != "") {
				$filename = $c["livepath"] . $template;

				$content_array = file($filename);
				$content_string = implode("", $content_array);
				forceDirectories ($c["cachepath"]);
				$full_url = $c["hostlivedocroot"] . $template . "?page=" . $spid . "&v=" . $variation.$addparam;
				$fp = fopen($full_url, "r");
				if ($fp != "") {
					while (!feof($fp)) $content .= fgets($fp, 128);
					fclose ($fp);
					
					$menuId = getDBCell("sitepage", "MENU_ID", "SPID=".$spid);
	    			$short = getPageURL($menuId, $variation);
					if (substr($short, 0, 1) == "/")
						$short = substr($short, 1);

						$allDir = $c["livepath"];
						// ensure that path exists
						$directories = explode("/", $short);

						if (count($directories) > 0) {
							for ($i = 0; $i < count($directories); $i++) {
								$thisDir = $directories[$i];

								if ($thisDir != "") {
									if (!is_dir($allDir . $thisDir)) {
										mkdir($allDir . $thisDir, 0755);
									}
									$allDir = $allDir . $thisDir . "/";
								}
							}

							// delete old index file
							@nxDelete ($allDir , "index.html");	    			
							@nxDelete ($allDir , "index.php" );
						}
	    			
	    			
	    			$index_file = fopen($allDir . "index.html", "w");
					fwrite($index_file, $content);
					fclose ($index_file);
				}
			}
			return true;
		}
	}
		/**
		   * 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) {
			// query for content
			global $db, $c;
			$destinationPath = $c["livefilespath"];
			$columns = $this->_getColumns($newid);
		
			nxDelete($destinationPath,  $columns["newfile"]);
			nxDelete($destinationPath, "t" . $columns["newfile"]);
			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);
		}
Example #3
0
	/**
	 * Places an empty page on the path and displays a text that the page ist no longer live.
	 *
	 * @param string Path to on server
	 */
	function clearShortURL($short) {
		global $c;

		if (substr($short, 0, 1) == "/")
			$short = substr($short, 1);

		$allDir = $c["livepath"];
		// ensure that path exists
		$directories = explode("/", $short);

		if (count($directories) > 0) {
			for ($i = 0; $i < count($directories); $i++) {
				$thisDir = $directories[$i];

				if ($thisDir != "") {
					$allDir = $allDir . $thisDir . "/";
				}
			}

			// delete old index file 
			if (file_exists($allDir . "index.php")) {
				nxDelete ($allDir, "index.php");
			}

			// create new index-file...
			global $c;
			$index = 'html>';
			$index .= '<head>';
			$index .= '<title>Page does not exist</title>';
			$index .= '<meta name="generator" content="N/X WCMS">';
			$index .= '</head>';
			$index .= '<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">';
			$index .= '<center>';
			$index .= '<font face="VERDANA" size="2">';
			$index .= 'The URL you entered is not available at present.<br>';
			$index .= 'Please try again later or go to <a href="' . $c["livedocroot"] . '">Startpage</a>.';
			$index .= '</font>';
			$index .= '</center>';
			$index .= '</body>';
			$index .= '</html>';

			// write to disk 
			$index_file = fopen($allDir . "index.php", "w");
			fwrite($index_file, $index);
			fclose ($index_file);
		}
	}
Example #4
0
		/**
		   * 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;
		}
 /**
  * Delete necessary files. Internally used only.
  */
 function _remove_files()
 {
     global $c;
     $files = $this->getInstallationFiles();
     $error = false;
     for ($i = 0; $i < count($files); $i++) {
         nxDelete($c["livepath"] . "sys/", $files[$i]);
         if (!unlink($c["devpath"] . "sys/" . $files[$i])) {
             $error = true;
         }
     }
     if ($error == true) {
         echo "Warning: The files could not be removed!";
     }
 }
Example #6
0
/**
 * Clear the page with URL-Path
 * 
 * @param integer SitepageId of the page
 * @param integer VariationId of the page
 */
function clearArticleURL($articleId, $variation)
{
    global $c;
    $short = getArticleURL($articleId, $variation);
    $cat = getDBCell('channel_articles', 'CH_CAT_ID', "ARTICLE_ID = " . $articleId);
    $spid0 = getDBCell('channel_categories', 'PAGE_ID', 'CH_CAT_ID=' . $cat);
    $spid = getDBCell("state_translation", "OUT_ID", "IN_ID={$spid0} AND LEVEL=10");
    if (substr($short, 0, 1) == "/") {
        $short = substr($short, 1);
    }
    $allDir = $c["livepath"];
    // ensure that path exists
    $directories = explode("/", $short);
    if (count($directories) > 0) {
        for ($i = 0; $i < count($directories); $i++) {
            $thisDir = $directories[$i];
            if ($thisDir != "") {
                $allDir = $allDir . $thisDir . "/";
            }
        }
        // delete old index file
        if (file_exists($allDir . "index.php")) {
            nxDelete($allDir, "index.php");
        }
        // create new index-file...
        global $c;
        $index = 'html>';
        $index .= '<head>';
        $index .= '<title>Page does not exist</title>';
        $index .= '<meta name="generator" content="N/X WCMS">';
        $index .= '</head>';
        $index .= '<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">';
        $index .= '<center>';
        $index .= '<font face="VERDANA" size="2">';
        $index .= 'The URL you entered is not available at present.<br>';
        $index .= 'Please try again later or go to <a href="' . $c["livedocroot"] . '">Startpage</a>.';
        $index .= '</font>';
        $index .= '</center>';
        $index .= '</body>';
        $index .= '</html>';
        // write to disk
        $index_file = fopen($allDir . "index.php", "w");
        fwrite($index_file, $index);
        fclose($index_file);
    }
}
/**
 * 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;
}