Jump to content

laffin

Members
  • Posts

    1,200
  • Joined

  • Last visited

Everything posted by laffin

  1. there is no need for an else. die/exit end the script right there.
  2. DOH, Good point, that shudda fixed it for ya
  3. Your example program worked fine here. Maybe it did error out and u didn;t know it? check apache log for any errors. most likely u got a headers already sent error message.
  4. If yer data is in csv format, than ur in luck fgetscsv CSV isn't hard to break down, if u know what each field header is. even if u dunno each one, just the ones that are important to you. (fopen/fgetscsv/fclose) if it's not a text file, there is no tips and tricks for it. you will most likely view it thru a hex editor looking for patterns in the data, than with pencil in hand write down offset / length and what kind of data it is. once you are able to figure out the pattern, u can use fopen in binary mode, to extrapulate the data. (fopen/fread/fseek/fclose)
  5. I used something like this in another post $page = (!is_null($page = isset($_GET['page'])?(preg_match("@[^/.\s]@",$_GET['page'])?(file_exists($_GET['page'].'html')?$_GET['page']:null):null):null) ?$page:"home") . ".html"; the preg_match just prevents users using . or / in the page reference.
  6. <?php $level = isset($_GET['level'])?(preg_match("@[^/.\s]@",$_GET['level'])?$_GET['level']:''):''; $course = isset($_GET['course'])?(preg_match("@[^/.\s]@",$_GET['course'])?$_GET['course']:''):''; $page= (!empty($level)? ("pages/$level" . (!empty($course) ? "/$course":"") . ".htm") : "main.htm"); if(!file_exists("$page")) include("error.htm"); echo "page=$page"; ?> whoops a missing paren. but whats a missing delimeter between coders.
  7. number_format]http://us2.php.net/number_format]number_format
  8. in my post above, just realized that that code puts main.htm in pages make following changes $page= (!empty($level)? ("pages/$level" . (!empty($course) ? "/$course":"") . ".htm") : "main.html"; if(!file_exists($page)) include("error.htm"); and yer done
  9. Nope, no real reason to have it coded that way <? $level = isset($_GET['level'])?(preg_match("@[^/.\s]@",$_GET['level'])?$_GET['level']:''):''; $course = isset($_GET['course'])?(preg_match("@[^/.\s]@",$_GET['course'])?$_GET['course']:''):''; $page= (!empty($level)? ("$level" . (!empty($course) ? "/$course":"") . ".htm") : "main.html"; if(!file_exists($page="pages/$page")) include("error.htm"); echo "page=$page"; ?> the builk of the action as u can see is taken care of here $page= (!empty($level)? ("$level" . (!empty($course) ? "/$course":"") . ".htm") : "main.html"; again using boolean operations to build the page. if built with if statements wud look like if(!empty($level)) $page = "$level" if(!empty($level) && !empty($course)) $page="$page/$course"; if(!empty($page)) $page="$page.htm" else $page= "main.html";
  10. its not all that hard. but you will need to know how the file can be broken down. if you got this much you can do pretty much anything with the data. importing to a db, or making your own interface. again not all that hard but may take time.
  11. i think, question is how to create subdomains for user accounts.
  12. $body_of_textarea=preg_replace("\s"," ",$body_of_textarea); those ^M are \n newlines \s in a preg_ statement is whitespace spaces, tabs, newlines, and carriage returns.
  13. $level = variable assignment isset($_GET['level']) isset returns true if variable exists, so we are checking if variable level passed on url ? the boolean operator, based on expression above, if true returns first set, otherwise return 2nd set (preg_match("@[^/.\s]@",$_GET['level'])?$_GET['level']:'') our first set, uses preg_match to check that 'level' from url dusnt contain . or / in it, if it dusn return it, otherwise return empty string (notice it uses another boolean operation in here) : our seperator from first and second set '' our 2nd set, is an empty string ;
  14. U have to check if yer server supports PATH_INFO, if not ya may have to edit .htaccess to make a ReWrite Rule
  15. Even using that wont remove the 1995 from current pages. either, use a text editor that can do a search & replace over multiple files (UltraEdit is what I use) or create a script to make these changes for u. this can be done with php, and if the dates are in the same format, a preg_match/replace function to add in the new custom footer/code. if ya need it done today, go with option 1 if it can wait a couple of days, consider option 2 (then u have a new tool in yer box)
  16. depends on preference really. MySQL, XML files, FlatFile DB, FlatFiles plenty of ways ya can go about doing something like this. Just really depends how many features u wud like on such a script. I prefer using MySQL, but it may be a bit hard for someone new to setup. if thats the case using FlatFiles will be the way to go for the time being.
  17. after this: header("Location: index.php?page=acchome"); add this exit(); I dun think u want to continue processing the script when u reach this point, you want it to go to that page. But php dusn know this and continues processing the script, thus the error headers already sent.
  18. nope, look it's probably mysql based. u have to check the files for mysql_connect or similar db connection strategies with.
  19. And sometimes they give answers that are much more complex than expected, but the complexity sometimes is a welcome bit of coding. seen some of the users here, post some great code, which i'm picking up and adding to my own tricks toolbox.
  20. Use what I use Expresso Regex Developement tool even if ya dun understand regex completely, this tool helps a lot
  21. no not a stored url usually it has the base path for pics set $picdir="/images"; than in the db the only thing stored is the filename <A IMG SRC="$picdir/$smilie[0]"> that's what cooldude is saying, not storing the image in the db itself. but renaming the uploaded image file, to something sensible (this shud also prevent naming conflicts). thus if ya was user 1, cooldude 2, and myself 3. ya wud have a uploaded images folder with 0001_0001.jpg 0001_0002.gif 0002_0001.jpg 0002_0002.jpg 0002_0003.jpg 0003_0001.png with a db structure as TABLE images ( id integer unsigned primary key autoincrement, filename varchar(80) not null default '', userid integer unsigned not null default '0' ); u can quickly build the url with this info alone.
  22. $string=preg_replace('@<a .*href=[\'\"]([^\s]+)[\'\"].*>.*</a>@im','$1',$string);
  23. preg_replace works perfect here, not shure how u tested it. <?php $string = '<a href="http://link.com/">Link</a> <a href="http://link2.com/">Link2</a> <a href="http://link3.com/">Link3</a> <a href="http://link4.com/">Link4</a>'; $string=preg_replace('@<a href=[\'\"]([^\s]+)[\'\"]>.*</a>@im','$1',$string); echo "<pre>$string</pre>"; ?>
  24. heh nice and easy way there cooldude, usually i go with a md5 hash or similar. but than naming conventions dun make sense, i like the method u describe cuz ya can visually see who has a lot of image uploads. Not only that, u can lookup the user from the filename.
  25. Just have to modify yer code a bit if flag dusn exist. reason i used the if statement. otherwise it will return FALSE, and substr will wipe out the whole string
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.