but now i'm getting more errors about undefined junk and i feel it has something to do with includes which are coming from another file and not expecting to be inside the extensions folder:
Notice: Undefined property: Dictionary in (my folder)/library/Framework/Framework.Class.Context.php on line 102
Warning: array_key_exists(): The second argument should be either an array or an object in (my folder)/library/Framework/Framework.Class.Context.php on line 102
another stupid question- $Menu->AddTab("Files", "Files", "extensions/FilesTab/default.php?PostBackAction=FTPList", "FilesTab", '', '4', '1');
why doesn't this add the tab at the right end? grrr
By the way, just for the record, the page manager dosn't edit settings.php file. What you're probably seeing is it reading in the extension file to it can include the other extensions behind it before building the page and exiting.
in fact there are no more errors - there is only one small problem. i need the charset for this page only to be iso-8859-1. it was working in the old page because i could set $Configuration['CHARSET'] immediately after including appg/settings.php and before appg/init_vanilla.php.
however, when the custom page is loaded from index.php, those 2 appg files are included before the extension loads, and so the charset in the http header is set to utf-8. when i change $Configuration['CHARSET'] = 'iso-8859-1' in this page, it is changed in the xml declaration only, and that is not good enough for firefox. it's still utf-8 in the header.
can you think of any way around this without adding a conditional (if page is my custom page, change charset) to appg/init_vanilla.php?
I believe you can just stick a second header() call in right before the class declaration and it'll override the previous Content-Type header set in headers.php. Worked with php5.
Well I wasn't saying it should rely on it, I was just under the (wrong) impression that he was saying he might release the page creation part of it as an extension, and was pointing out it might be somewhat redundant to have two extensions for the same purpose.
Comments
$Context->Session->Check($Context);
in there.<?php /* Extension Name: Files Tab Extension Extension Url: http://www.htmlephant.com/ Description: Adds a Files tab to the menu, which diaplays a list of files from an FTP server along with a request system. Will not display without proper permissions. Version: 1.0 Author: ithcy (based upon Trabus's Namewhore Tab extension) Author Url: http://www.htmlephant.com [isdir] => 1 [perms] => drwxr-xr-x [number] => 2 [owner] => xxxxxxxx [group] => xxxxxxxx [size] => 4096 [month] => Feb [day] => 9 [time/year] => 10:30 [name] => xxxxxxxx */ if (!@$Context) { include_once("../../appg/settings.php"); include_once("../../appg/init_vanilla.php"); } $Context->Session->Check($Context); // You should cut & paste this language definition into your conf/your_language.php file // (replace "your_language" with your chosen language, of course): $Context->Dictionary['FilesTabPageTitle'] = 'Files'; $Qualified = (in_array($Context->Session->UserID, array("1","31","2031"))) ? true : false; if ($Qualified && (in_array($Context->SelfUrl, array("index.php", "categories.php", "comments.php", "search.php", "post.php", "account.php", "settings.php")))) { // running from one of the other tabs $Menu->AddTab("Files", "Files", "extensions/FilesTab/default.php?PostBackAction=FTPList", "FilesTab", '', 4, true); } elseif ($Qualified && ($Context->SelfUrl == "default.php")) { // running from the Files tab $Menu->AddTab("Files", "Files", "extensions/FilesTab/default.php?PostBackAction=FTPList", "FilesTab", '', 4, true); $Menu->CurrentTab = "Files"; $Panel->CssClass = "FilesPanel"; $Panel->BodyCssClass = "Files"; $Context->PageTitle = $Context->GetDefinition("FilesTabPageTitle"); require("FTPsettings.php"); class FTPList extends Control { function FTPList(&$Context) { $this->Name = 'FTPList'; $this->Control($Context); } function Render() { if ($this->PostBackAction == 'FTPList') { global $ftp_settings; global $Context; $ftp_path = $ftp_settings['root']; $path = ""; if (isset($_GET['p'])) { $unsafe_path = urldecode($_GET['p']); $safe_path = preg_replace("/;.+/","",$unsafe_path); $path .= $safe_path; $ftp_path .= $safe_path; }; $conn_id = ftp_connect($ftp_settings['host']); $login_result = ftp_login($conn_id, $ftp_settings['user'], $ftp_settings['pass']); if($ftp_settings['passive_mode']) { ftp_pasv ($conn_id, true); } ftp_chdir($conn_id, $ftp_path); $raw_contents = ftp_rawlist($conn_id, "."); $parsed = array(); $i = 0; foreach ($raw_contents as $current) { $split = preg_split("[ ]", $current, 9, PREG_SPLIT_NO_EMPTY); if ($split[0] != "total") { $parsed[$i]['isdir'] = $split[0]{0} === "d"; $parsed[$i]['perms'] = $split[0]; $parsed[$i]['number'] = $split[1]; $parsed[$i]['owner'] = $split[2]; $parsed[$i]['group'] = $split[3]; $parsed[$i]['size'] = $split[4]; $parsed[$i]['month'] = $split[5]; $parsed[$i]['day'] = $split[6]; $parsed[$i]['time/year'] = $split[7]; $parsed[$i]['name'] = $split[8]; $i++; } } $FileList = "Path: $path<br />\n<br />\n"; foreach($parsed as $line) { $link = $line['name']; $ulink = urlencode($path . "/" . $link); if ($line['isdir']) { $link = "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=$ulink&PostBackAction=FTPList\">$link</a>"; } else { $link = "<a href=\"ftp://${ftp_settings['user']}:${ftp_settings['pass']}@${ftp_settings['host']}${ftp_path}/$link\">$link</a>\n"; } $FileList .= "$link<br />\n"; } $FileList .= ""; echo($FileList); } } } $FTPList = $Context->ObjectFactory->NewContextObject($Context, "FTPList"); $Page->AddRenderControl($Head, $Configuration['CONTROL_POSITION_HEAD']); $Page->AddRenderControl($Menu, $Configuration['CONTROL_POSITION_MENU']); $Page->AddRenderControl($Panel, $Configuration['CONTROL_POSITION_PANEL']); $Page->AddRenderControl($FTPList, $Configuration['CONTROL_POSITION_BODY_ITEM']); $Page->AddRenderControl($Foot, $Configuration['CONTROL_POSITION_FOOT']); $Page->AddRenderControl($PageEnd, $Configuration['CONTROL_POSITION_PAGE_END']); $Page->FireEvents(); } else { header("location:".GetUrl($Configuration, "index.php")); } ?>
it is working, tentatively. (see below)
Notice: Undefined property: Dictionary in (my folder)/library/Framework/Framework.Class.Context.php on line 102
Warning: array_key_exists(): The second argument should be either an array or an object in (my folder)/library/Framework/Framework.Class.Context.php on line 102
another stupid question-
$Menu->AddTab("Files", "Files", "extensions/FilesTab/default.php?PostBackAction=FTPList", "FilesTab", '', '4', '1');
why doesn't this add the tab at the right end? grrr
in fact there are no more errors - there is only one small problem.
i need the charset for this page only to be iso-8859-1. it was working in the old page because i could set $Configuration['CHARSET'] immediately after including appg/settings.php and before appg/init_vanilla.php.
however, when the custom page is loaded from index.php, those 2 appg files are included before the extension loads, and so the charset in the http header is set to utf-8. when i change $Configuration['CHARSET'] = 'iso-8859-1' in this page, it is changed in the xml declaration only, and that is not good enough for firefox. it's still utf-8 in the header.
can you think of any way around this without adding a conditional (if page is my custom page, change charset) to appg/init_vanilla.php?
again, thanks, your method has helped immensely.
Eg.
this is a handy extension, so when i add a few more features i'll post it here.