*/ // Check we have the bits if (!isset($_POST['textcontent'])) { print 'error:No content supplied.'; exit; } else { if (!isset($_POST['sourcefile'])) { print 'error:No source text file name supplied.'; exit; } else { $sourceFile = pathFromID($_POST['sourcefile']); $fileContent = $_POST['textcontent']; } } $mode = isset($_POST['mode']) ? $_POST['mode'] : false; if (isPageTemplate($sourceFile)) { $mode = 'pagetemplate'; } elseif (getFileExtension($sourceFile) == "php") { $mode = 'page'; } /* If a child include, save file to pv location, and save live copy if live not present or empty If a page, just save to pv location, and save live copy if not present or empty, PLUS correct the general-include call (for the LIVE version!) If a free include, save to pv location, and save live copy if not present or empty If a Page Template, simply save to PTs folder */ switch ($mode) { case "ptchildinclude": // ???????????????? $previewFile = pathFromID($_POST['sourcefile']); $liveFile = False;
// DEBUG echo $_GET['file'] ; exit ; if (!isset($_GET['file'])) { echo 'error:No file name provided.'; exit; } /* Get details of file itself (Page/FI) */ $matchStatus = false; $liveFile = pathFromID($_GET['file']); /* If $liveFile starts with "pagetemplates/"... it's a PT In which case, get the LCIs from pagetemplates/ptname/ */ // echo 'error:' . $isPT ; exit ; if (isPageTemplate($liveFile)) { $xmlr = '<xml>'; $xmlr .= '<file>' . $_GET['file'] . '</file>'; $xmlr .= '<filestatus>0</filestatus>'; getPTChildIncludes($liveFile); } else { $previewFile = getPreviewFileFromLive($liveFile); $matchStatus = matchFiles($previewFile, $liveFile); $xmlr = '<xml>'; $xmlr .= '<file>' . $_GET['file'] . '</file>'; $xmlr .= '<filestatus>' . $matchStatus . '</filestatus>'; /* If it's a page, we need details on all LCIs */ if (getFileExtension($liveFile) == "php") { $xmlr .= '<localchildincludes>';
if (!file_exists($killFile)) { print 'error:filedoesnotexist - ' . $_GET['file']; exit; } // Delete primary File if (False === @unlink($killFile)) { print 'error:deletefilefailed - ' . $killFile; exit; } // DEBUG print ('error:' . $killFile); exit ; if (strstr($killFile, '_cms_files/')) { // We have a LCI. Get the live file from preview // Note: Use a generic function for this...!!! $killFile2 = str_replace('_cms_files/cms_preview/', '_cms_files/cms_live/', $killFile); } else { if (isPageTemplate($killFile)) { // PT name is strip slash, add ".php" $killFile2 = false; $includesDir = stripFileExtension($killFile) . '/'; } else { // Must be a page or Free Include, so find the corresponding Live file??? = $killFile2 if (strstr($killFile, '../')) { $killFile2 = getPreviewFileFromLive($killFile); } if (getFileExtension($killFile) == "php") { // File is a PAGE, try to delete its local folders too $includesDir = stripFileExtension(getPreviewFileFromLive($killFile)) . '_cms_files'; clearstatcache(); } } }
$newFilePath = pathFromID($_POST['newfilepath']) . '.set'; } if (!isset($_POST['template'])) { print 'error:No set template supplied'; exit; } define("DIR", dirname($_POST['newfilepath'])); // Read in template $templateArray = @unserialize(file_get_contents(STDIR . $_POST['template'])); $newArray = array(); $newArray[0] = $_POST['template']; $newArray[1] = $newArray[0]; $newArray[2] = $templateArray['cols']; // If it's going to belong to a PT, there's only one copy! if (isset($_POST['parentpage'])) { if (isPageTemplate(pathFromID($_POST['parentpage']))) { // strip the .php and append a / $newPreviewFilePath = stripFileExtension(pathFromID($_POST['parentpage'])) . '/' . $_POST['newfilepath'] . '.set'; $newLiveFilePath = False; $successReturnValue = $newPreviewFilePath; } else { $includesRoot = getLCIRootFolderFromPagePath(pathFromID($_POST['parentpage'])); makeSureFoldersExist($includesRoot); $newPreviewFilePath = $includesRoot . '/cms_preview/' . $_POST['newfilepath'] . '.set'; $newLiveFilePath = getLiveLCIFromPreview($newPreviewFilePath); $successReturnValue = $_POST['parentpage'] . '/' . $_POST['newfilepath'] . '.set'; // Note: Simpler line below works in new text... // $returnFile = $_GET['parentpage'] . '/' . $fileName ; } } else { // FREE INCLUDE: there are also 2 copies (i.e. parentpage not set)
if (!file_exists($filePath)) { echo 'error:Original file not found.'; exit; } if (!isset($_GET['newFileName'])) { echo 'error:No new file name sent'; exit; } else { $newFileName = $_GET['newFileName']; } $dir = dirname($filePath); $ext = getFileExtension($filePath); /* If it's a SET TEMPLATE ??? */ if (isPageTemplate($filePath)) { // PAGE TEMPLATE --- rename it and its LCI folder $newFilePath = $dir . '/' . $newFileName . '.' . $ext; if (False === @rename($filePath, $newFilePath)) { echo 'error:Failed to rename Page Template: ' . $filePath . ' >>> ' . $newFilePath; exit; } if ($ext == 'php') { $originalLCIFolder = stripFileExtension($filePath); $newLCIFolder = stripFileExtension($newFilePath); if (False === @rename($originalLCIFolder, $newLCIFolder)) { echo 'error:Failed to rename Page Template includes folder: ' . $originalLCIFolder . ' >>> ' . $newLCIFolder; exit; } } echo 'pt';