-->-->-->-->-->-->-->-->-->-->-->-->--> include "/home/waggacwc/public_html/refurb/RETRO-GLOBALS.php"; //test1 include_once "$LIBRARYPATH/RETROVOX-CONSTANT-VARIABLES.php"; include_once "$LIBRARYPATH/fnRetrovoxStartHtml.php"; include_once "$LIBRARYPATH/fnStartHtml.php"; include_once "$LIBRARYPATH/fnSwitchFileSelect.php"; include_once "$LIBRARYPATH/fnNumericHtmlSelect.php"; include_once "$LIBRARYPATH/fnDebugArray.php"; include_once "$LIBRARYPATH/fnDirectoryListing.php"; include_once "$LIBRARYPATH/fnFillWebTemplate.php"; include_once "$LIBRARYPATH/fnMessageToHtml.php"; include_once "$LIBRARYPATH/fnListBlockToHtml.php"; include_once "$LIBRARYPATH/fnCodeBlockToHtml.php"; include_once "$LIBRARYPATH/fnJournalToHtml.php"; include_once "$LIBRARYPATH/fnFaqToHtml.php"; include_once "$LIBRARYPATH/fnHyperlinkPlainText.php"; //echo realpath('/apache2/ideas/product-data/lib'); //echo "The realpath of / is ".realpath('/'); $bNewFile = false; $sFilePath = ''; $sFileContents = ''; $aaTextLines = ''; $sWebPathPrefix = '/ideas'; $bChmodSucceeded = false; //-- if php can make the file writeable $aaTextLines = file($ERRORTEMPLATE); $sErrorTemplateContents = implode('', $aaTextLines); $aaTextLines = file($ADMINTEMPLATE); $sAdminTemplateContents = implode('', $aaTextLines); $sConfigurationFilePath = "$WEBDOCUMENTROOT/refurb/manage/notepad/retrovox-notepad.conf"; if (file_exists($sConfigurationFilePath)) { $aaEditorSettings = parse_ini_file($sConfigurationFilePath); $iEditorFontSize = $aaEditorSettings['editor-font-size']; $iEditorColumns = $aaEditorSettings['editor-columns']; $iEditorRows = $aaEditorSettings['editor-rows']; //fnDebugArray($aaEditorSettings); } //-- Convert all file path indicators to forward slashes since this is the //-- easiest format for PHP to deal with. Otherwise it is necessary to 'escape' //-- all the MS Windows backslashes. //$sFilePath = stripslashes($_GET['file']); $sFilePath = $_GET['file']; $sFilePath = str_replace('\\', '/', $sFilePath); $sFilePath = preg_replace('#[/]+#', '/', $sFilePath); // if (substr($sFilePath, 0, 1) != "/") // { // $sFilePath = "/$sFilePath"; // } $sFilePathEncoded = htmlspecialchars($sFilePath); $sFilePathUrlEncoded = htmlspecialchars(urlencode($sFilePath)); $sWebFilePathEncoded = htmlspecialchars(str_replace($WEBDOCUMENTROOT, "", $sFilePath)); $sFileName = basename($sFilePath); $sFileNameEncoded = htmlspecialchars($sFileName); $sFileNameUrlEncoded = htmlspecialchars(urlencode($sFileName)); $debug = ""; if ($debug == "true") { echo "
sFilePath=$sFilePath
sFileName=$sFileName
sCurrentDirectory=$sCurrentDirectory
sCurrrentWebDirectory=$sCurrentWebDirectory
sWebFilePathEncoded=$sWebFilePathEncoded
";
//exit;
} //--if
$iEditorColumnsRequest = $_REQUEST['cols'];
$iEditorRowsRequest = $_REQUEST['rows'];
$bStripSlashes = $_REQUEST['stripslash'];
$iEditorFontSizeRequest = $_REQUEST['fontsize'];
$bSaveConfiguration = $_REQUEST['save'];
if ($bSaveConfiguration == 'true')
{ $bSaveConfiguration = true; }
else
{ $bSaveConfiguration = false; }
//-- if, else save config settings
//-- Editor settings set through request variables have
//-- precedence to those set through the configuration file
if (!is_numeric($iEditorFontSize))
{
if (is_numeric($iEditorFontSizeRequest))
{
$iEditorFontSize = $iEditorFontSizeRequest;
}
else
{
$iEditorFontSize = "15";
}
}
else
{
if (is_numeric($iEditorFontSizeRequest))
{
$iEditorFontSize = $iEditorFontSizeRequest;
}
} //-- if no font size in config file
if (!is_numeric($iEditorColumns))
{
if (is_numeric($iEditorColumnsRequest))
{
$iEditorColumns = $iEditorColumnsRequest;
}
else
{
$iEditorColumns = "15";
}
}
else
{
if (is_numeric($iEditorColumnsRequest))
{
$iEditorColumns = $iEditorColumnsRequest;
}
} //-- if no rows in config file
if (!is_numeric($iEditorRows))
{
if (is_numeric($iEditorRowsRequest))
{
$iEditorRows = $iEditorRowsRequest;
}
else
{
$iEditorRows = "15";
}
}
else
{
if (is_numeric($iEditorRowsRequest))
{
$iEditorRows = $iEditorRowsRequest;
}
} //-- if no rows number in config file
if ($bSaveConfiguration)
{
$sConfigurationData = "\n".
"editor-font-size=$iEditorFontSize\n".
"editor-columns=$iEditorColumns\n".
"editor-rows=$iEditorRows\n";
$fileHandler = fopen($sConfigurationFilePath, "w");
fwrite($fileHandler, $sConfigurationData);
fclose($fileHandler);
} //-- if save settings
if (!file_exists($sFilePath))
{
//-- old
if (file_exists($WEBDOCUMENTROOT.$sFilePath))
{
$sFilePath = $WEBDOCUMENTROOT.$sFilePath;
}
elseif (file_exists($WEBDOCUMENTROOT."/".$sFilePath))
{
$sFilePath = $WEBDOCUMENTROOT."/".$sFilePath;
}
else
{
$sPageTitle = "Web Notepad: the file doesn't exist";
$sPageContent = "
= Web Notepad: the file doesn't exist
The file-name $sFilePathEncoded which you just specified doesn't
exist.
'Re-enter the file name'
link://retrovox-notepad-choose-file.php?file=$sFilePathUrlEncoded
'Jump to a different folder'
link://$MANAGEMENTWEBFOLDER/select-folder.php
";
$sPageContent = fnMessageToHtml($sPageContent);
$sOutputPage = fnFillWebTemplate(
$sAdminTemplateContents, $sPageContent, $sPageTitle);
echo $sOutputPage;
exit;
} //-- if, else web-relative path
} //-- if file doesn't exist
if (is_dir($sFilePath))
{
if (substr($sFilePath, -1) != "/")
{
$sFilePath = "$sFilePath/";
}
$sPageTitle = "Web Notepad: the path is a directory";
$sPageContent = "
= Web Notepad: the path is a directory
The file-name $sFilePathEncoded which you just specified is a
'directory' or 'folder' on the web-server.
a- 'Jump to a different folder'
link://$MANAGEMENTWEBFOLDER/select-folder.php
- 'Re-enter the file name'
link://retrovox-notepad-choose-file.php?file=$sFilePathUrlEncoded
- 'Find a file on the server'
link://$MANAGEMENTWEBFOLDER/find-file-form.php?file=$sFilePathUrlEncoded
Select a file in the directory $sFilePathEncoded
";
$sPageContent = fnMessageToHtml($sPageContent);
$sPageContent = $sPageContent.fnDirectoryListing(
$sFilePath,
false,
"$NOTEPADWEBFOLDER/retrovox-notepad.php?file",
"$NOTEPADWEBFOLDER/retrovox-notepad.php?file",
"$MANAGEMENTWEBFOLDER/move-file-form.php?file",
"$NOTEPADWEBFOLDER/retrovox-notepad.php?file",
$WEBDOCUMENTROOT);
$sOutputPage = fnFillWebTemplate(
$sAdminTemplateContents, $sPageContent, $sPageTitle);
echo $sOutputPage;
exit;
} //-- if file is a directory
if (!is_writable($sFilePath))
{
//$bChmodSucceeded = chmod($sFilePath, 0407);
copy($sFilePath, "$sFilePath-temp");
rename("$sFilePath-temp", $sFilePath);
if (!is_writable($sFilePath))
{
$sPageTitle = "Web Notepad: the file is not writable";
$sPageContent = "
= Web Notepad: the file is not writable
The file-name [$sFilePathEncoded] which you just specified has its permissions
set so that is cannot be edited (updated or modified in any way).
You may be able to overcome this problem by typing
chmod a+w $sFilePath
if you can log into the web-server (assuming that it is a Unix variant
server). This sometimes works. Another trick is to rename or copy the
file to a different name and then rename it back again to its original name.
The purpose of this is to make you, or the web-server the owner of the file,
however, the current script has just attempted that trick and it FAILED.
Nevertheless, you may have better luck if you can telnet or ssh into the
Web-server.
'Re-enter the file name'
link://retrovox-notepad-choose-file.php?file=$sFilePathUrlEncoded
'Copy the file (to try to make it editable)'
link://$MANAGEMENTWEBFOLDER/move-file-form.php?file=$sFilePathUrlEncoded
'Jump to a different folder'
link://$MANAGEMENTWEBFOLDER/select-folder.php
";
$sPageContent = fnMessageToHtml($sPageContent);
$sOutputPage = fnFillWebTemplate(
$sAdminTemplateContents, $sPageContent, $sPageTitle);
echo $sOutputPage;
exit;
}
else
{
$bRenameFileTrick = true;
} //-- if renaming file trick was successful
} //-- if file not writeable
$aaTextLines = file($sFilePath);
$sFileContents = implode('', $aaTextLines);
$bNewFile = false;
if ($bStripSlashes != '')
{
$sEditorContents = stripslashes(htmlspecialchars($sFileContents));
}
else
{
$sEditorContents = htmlspecialchars($sFileContents);
}
//--<--<--<--<--<--<--<--<--<--<--<--<--<--<
?>