ztealmax
Members-
Posts
157 -
Joined
-
Last visited
Never
About ztealmax
- Birthday 03/19/1974
Contact Methods
-
MSN
martin@ztealmax.se
-
Website URL
http://demo.premierguild.com
Profile Information
-
Gender
Male
-
Location
Sweden
ztealmax's Achievements
Member (2/5)
0
Reputation
-
[ HELP! ] exclude file endings and file start!?!
ztealmax replied to ztealmax's topic in PHP Coding Help
cheers m8 -
[ HELP! ] exclude file endings and file start!?!
ztealmax replied to ztealmax's topic in PHP Coding Help
well as i see the code you have to know what filename it is before, and as i dont know that until its done $string = "dragons.about.news"; states its a file name that exists right? but ofc i could get it to get names from filelisting and yes im new to this thats why im trying to get hints and tips how to do things. -
[ HELP! ] exclude file endings and file start!?!
ztealmax replied to ztealmax's topic in PHP Coding Help
problem is that the filename isnt allways "dragons.about.news" the name is diferent since its created when a new news post is created, any other way to acomplis this? //Cheers Martin -
Hello again forum, i have a question that i hope you think is simple: Have this code that excludes file endings that ends with .news Is it possible to get it to exclude anything after first filename for example if the filename is: dragons.about.news and when i use the script i want it only to show dragons (dragons could be anyname i was hoping i could use like * or something however if i modify this script further i would like to get it to show the following about and this could be anything also so i would like it to show whatever is written between first text and last text here is my small code <?php $dir = "news/"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $excludenews = '/\.news$/'; if(preg_match($excludenews,$filename)) { /* You can proceed because the file has the extension .zip */ $filename = ereg_replace($dir, "", "$filename"); $filename = ereg_replace(".news", "", "$filename"); echo "<a href='?content=read&contents=".$dir."Catogory.".$filename.".desc'>" . $filename . "</a><br>"; } } ?> Does this make any sense? Ask me if you dont understand what im asking or if you want to know more about how im thinking Cheers Martin
-
ok i cant find whats wrong or where to change it demo site is: demo.premierguild.com ftp is the same as a messaged you about register globals is on as far as iknow! what this code should do is somehow get the real path of the link i clicked, does it make any sence? //Cheers Martin
-
im checking tru the code get back to you soon
-
path thats assigned in news_catogories.php is "news/" but when i click a link within "news/" it should become the new path for "news.php" for example i click info so the new path should now be "news/info" let me know if im bad at explaining! //martin
-
hmm where would i turn that on? damn im such a noob at this /Martin
-
yes it should be the complete scripts
-
still need some help here
-
news_catogories.php <?php $path = "news"; // path to the dir you want to scan foreach(glob("$path/*", GLOB_ONLYDIR) as $catdir) { // catogories start $catogories = ("".$catdir.".description"); $catfile = fopen($catogories, 'r') /*or die('Could not open file!')*/; $catdata = fread($catfile, filesize($catogories)) /*or die('Could not read file!')*/; fclose($catfile); $catdir = ereg_replace("news/", "", "$catdir"); echo "<a href='".$_SERVER['PHP_SELF']."?content=news'><b>".$catdir."</b></a> ".$catdata."<br>"; } ?> news.php <?php function in_dir ($file, $in_dir) { $dir = realpath ($file); $in_dir = realpath ($in_dir); if (!is_dir ($file)) { $dir = dirname ($file); } do { if ($dir === $in_dir) { $is_in_dir = TRUE; break; } } while ($dir !== ($dir = dirname ($dir))); return (bool) @$is_in_dir; } $dir = $path; echo $dir; echo $path; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $pattern = '/\.news$/'; if(preg_match($pattern,$filename)) { /* You can proceed because the file has the extension .news */ $filename = ereg_replace($dir, "", "$filename"); $filename = ereg_replace(".news", "", "$filename"); echo "<a href='?content=read&contents=".$dir."".$filename.".news'>" . $filename . "</a><br>"; } } ?> this is my index.php <?php // language start $language = ("config/language.cfg"); $lanfile = fopen($language, 'r') /*or die('Could not open file!')*/; $landata = fread($lanfile, filesize($language)) /*or die('Could not read file!')*/; fclose($lanfile); include("languages/$landata.php"); // language end ?> <?php // sitename start $sitename = ("config/sitename.cfg"); $sitenamefile = fopen($sitename, 'r') /*or die('Could not open file!')*/; $sitenamedata = fread($sitenamefile, filesize($sitename)) /*or die('Could not read file!')*/; fclose($sitenamefile); define('sitename',$sitenamedata.""); // sitename end ?> <?php // welcome start $welcome = ("config/welcome.cfg"); $welcomefile = fopen($welcome, 'r') /*or die('Could not open file!')*/; $welcomedata = fread($welcomefile, filesize($welcome)) /*or die('Could not read file!')*/; fclose($welcomefile); define('welcome',$welcomedata.""); // welcome end ?> <?php // sitetag start $sitetag = ("config/sitetag.cfg"); $sitetagfile = fopen($sitetag, 'r') /*or die('Could not open file!')*/; $sitetagdata = fread($sitetagfile, filesize($sitetag)) /*or die('Could not read file!')*/; fclose($sitetagfile); define('sitetag',$sitetagdata.""); // sitetag end ?> <?php // disclaimer start $disclaimer = ("config/disclaimer.cfg"); $disclaimerfile = fopen($disclaimer, 'r') /*or die('Could not open file!')*/; $disclaimerdata = fread($disclaimerfile, filesize($disclaimer)) /*or die('Could not read file!')*/; fclose($disclaimerfile); define('disclaimer',$disclaimerdata.""); // disclaimer end ?> <?php // theme start $theme = ("config/theme.cfg"); $themefile = fopen($theme, 'r') /*or die('Could not open file!')*/; $themedata = fread($themefile, filesize($theme)) /*or die('Could not read file!')*/; fclose($themefile); $themes = ("themes/"); define('theme',$themes.$themedata."/"); @include_once("$themes/$themedata/theme.php"); // theme end ?> <?php $url = $_SERVER['SERVER_NAME']; define("url", $_SERVER['SERVER_NAME']); ?> <? echo $header ?> <? include("menus/mainmenu.php");?> <?php if(isset($_GET['content'])){ include($_GET['content'].".php"); } else { include($_GET['content'].""); echo "".$welcomedata." "; } ?> <? echo $footer ?>
-
i can give u access to ftp if you would like to check it out first hand? ive sended you a PM with information for ftp
-
hi ok echod path but still got nothing showing still get this message Warning: readdir(): supplied argument is not a valid Directory resource in news.php on line 26
-
the echo was empty didnt show up anything think the fault is in this code while (false !== ($filename = readdir($dh)))[/Code] Warning: readdir(): supplied argument is not a valid Directory resource in news.php on line 26
-
tried it , doesnt work, idont know what im doing wrong :\