Jump to content

linuxdream

Members
  • Posts

    124
  • Joined

  • Last visited

    Never

Everything posted by linuxdream

  1. What code do you have so far? Would be helpful to post.
  2. Hard to tell what you want to keep unless we know how the form is being processed/reloaded. I usually do something like this: [code] <?php echo "<select name='something'>"; foreach($options as $value=>$option){     //Set this variable depending on what is selected and how...result from DB lookup, POST to this page, etc...     if(!empty($sql_result)){         $selected = "selected='selected'";     }else{         $selected = '';     }     echo "<option value=$value $selected>$option</option>"; } echo "</select>"; ?> [/code]
  3. Why don't you echo out the $cms_root_path to see the absolute file system path. That way you can be sure that the login_result.php is in that path. Is probably just off by a directory or two.
  4. Depending on how you get the file, you could just check the time stamp or atime of the files. Might be a little easier than comparing the filenames...but not by that much.
  5. You could run multiple instances of Apache and MySQL each using different config information. For instance, one Apache process could be config'd to run php4 with mysql4 or something like that for as many instances as your hardware could support. Additionally, you could specify what domain each instance would be responsible for. But I am only familiar with Linux. I know it can be done in Linux, Windows might be another story. Maybe google for "running multiple instances of apache in Windows" or something like that. Might get you closer.
  6. Sorry, I forgot to include the *...so: $variable = '/AO_photogallery_cat #([0-9]*)\b/is';
  7. The content can be whatever you want it to be. No regex stuff needed. The first and last "/" are delimiters that tell preg_match that the content within the /'s is to used in the expression. The ( )'s capture the content within them and they get placed in the $matches array, hence $matches[1]. So in this case it captures the numbers only, that way you don't have to substr() or whatever after to get just what you want. The \b says that it should end with a word boundary. Could have just been a \s or space but they both should work in this case.
  8. Your $variable sould be something like: $variable = '/AO_photogallery_cat #([0-9])\b/'; then $matches[1] would contain the number.
  9. So each checkbox would be name="id[]" value="recordid" Then in your processing script... [code] foreach($_POST['id'] as $selected){   $db->query('INSERT INTO table SELECT * FROM oldtable WHERE id = $selected'); } [/code] Something like that.
  10. Don't forget that if it's your own server, your ISP may not let you send anything with a destination port of 25...which would be any email. That's why I can't send email anyway... Just though I would mention it. B
  11. I must be really off today, this should be a very easy thing. Try this: $query = "INSERT INTO facility_cameras (facilityid, cameraid, miscid) VALUES ('{$_POST['nt']}', '{$_POST['nt1']}', '{$_POST['nt2']}')"; I usually filter my POST and GET variables thus changing the name so I don't have to deal with so many "s and 's..I've forgotten how to deal with them. The curly braces tell PHP that the enclosed data is a variable and it should replace everything with the proper values before it gets to MySQL. Give it a shot, if not, then I must be completely off the deep end today. If MySQL still complains, then ditch the {} and the 's inside the $_POST variable. Technically you are supposed to have them (or "s) but it will work without them.
  12. Thanks ShogunWarrior. That's a pretty freaking cool function(s). So my basic layout right now is like so: [code] <?php $host = "http://www.somesite.com/"; foreach($tagAttributes as $tag=>$attribute){     $pattern="/<$tag([^>]*)$attribute=[\"']?(?!https?:|ftp:|javascript:)([^\"'\s>]+)(?(2)\\2)/is";     $html =  preg_replace_callback($pattern, 'preg_callback', $html);     }     function preg_callback($matches){     global $tag, $attribute;     $url = $this->abs_url($host, $matches[2], 1); //abs_url is included into the class as a private method below     $replace = "<$tag\${1}$attribute=\"$url\${3}\"";     return $replace; } echo $html; //Should output corrected links, src's, etc. but doesn't. Just outputs the same input, so basically nothing matches. ?>[/code] But it's still not replacing the proper full name. I'm sure it's because I'm not using the callback function properly...any corrections you see? The output is simply the same as the input thus nothing is matching. I have ZERO experience with preg's callback, I didn't even know it existed until effigy pointed it out. The doc's says to return the replace value thus this should be working. Thanks, B
  13. Sorry I forgot to remove the "$" from within the $_POST[] variable. Remove those $'s and it should be good. So: $query = 'INSERT INTO facility_cameras (facilityid, cameraid, miscid) VALUES ("$_POST["nt"]", "$_POST["nt1"]", "$_POST["nt2"]")'; If it still doesn't work, then check you error log file to see the exact error. If you are *nix: tail /var/log/messages should do it. Sorry, just woke up, still not thinking clearly yet!!! Notice I changed the " and ' in the statement as well. B
  14. Also, it would help by telling us what line number/statement was generating the errors. The errors will tell you the line#
  15. The only way to do it is if: 1) you have an account on the same system as the page you wish to view and the permissions on that system are relaxed enough (either through command line or through a PHP script) 2) The programmers of the page makes a mistake and names the extension .htm or something like that 3) The web server (or sys admin) screws something up and doesn't enable the PHP module thus making every PHP page downloadable. Situation 1 is the most probable. PHP was designed so that people can't read the code, hence it being a server side processing language. B
  16. It's simply used to fill the main content portion of the page around head and footer templates (in the URL you provided anyway). Expanding on what the others were saying. The value of the ?do= is probably a filename or other signifier in the site that contains the main page contents. It's basically an easy way to manage template and content through PHP. For instance, you have your main page: [code] <html> <body> Hello everyone!!!! You are now on page: <?php //Used to display main content within template framework $contentfile = $_GET['do'] . ".php"; include_once('$contentfile'); ?> <br /> Thanks for visiting </body> </html> [/code] B
  17. Your Insert statement is incorrect. The statement should look something like: $query = "INSERT INTO facility_cameras (facilityid, cameraid, miscid) VALUES ("$_POST['nt']", "$_POST['$nt1']", "$_POST['$nt2']")"; PHP cannot process form data unless it was submitted from a previous request since all its processing is server side. Also, You should think about separating the form and processing pages or at least throw a conditional in there or else you will be making an empty INSERT request every time the page loads when you only want that happening when someone submits a page. B
  18. If you need specific answers you really need to post at least the main portions of your code. Or else how can we help?
  19. What's the output of a print_r($row) on your first page? Make sure the $row['userrank'] value is actually getting set right. Then you will know if it is either the MySQL query or the session that is bad. Brandon C.
  20. I think you could do this a few ways: 1) Make the link a small form that does a POST request. That way there's no URL data. 2) Make a JavaScript function that basically creates and submits a form POST style. 3) Design your register page so that it automatically redirects after processing the data. Of all the ways, method1 is, I believe, the most common and easiest.
  21. Thanks for the quick response, effigy. Works real well when the host is a base url with no other directories after it (ie. change $host to www.phpreaks.com/links/ and a link to /myimage.gif should read www.phpfreaks.com/myimage.gif, not www.phpfreaks.com/links/myimage.gif), so my only other question is about the host/baseurl that get substituted. Towards the top of the method, I set both a $host, which is simply the host address part of the url passed into the function to be used for a document root link (/myweb/mypage.htm), and a $baseUrl which is use when there is no absolute link (myweb/mypage.htm). So my question is, since the root address can be different depending on if the link is relative or is a document root link, how do I test for that and place the right value in there? I tried working with preg's if/else (which I saw you so elegantly use in your solution) but unfortunately my knowledge of that special feature is rather limited. Can you think of anything similar to this? I know the replace expression can't use regex, but I'm hoping you get what I mean: [code]<?php $pattern="/<$tag([^>]*)$attribute=([\"'])?(?!https?:|ftp:|javascript:)(\/)([^\"'\s>]+)(?(2)\\2)/is"; $replace="<$tag\${1}$attribute=\"(?(3)$host|$baseUrl)\${4}\""; [/code] Thanks again for your help and ideas. Brandon C.
  22. Hello all, Thanks in advance for your help. I have been having some problems trying to fix all relative links within HTML pulled from various web sites. I have written a class called RipCURL that makes web parsing and extracting of data quick and easy. However, the original method I used to fix the relative links did not work for all types of links allowed (single, double or no quote after the =, etc.). For instance, with my class you can do something like this: [code] <?php $url = "http://www.google.com"; $html = $rip->ripRun($url, 1); echo $html; ?> [/code] and the output would be the HTML provided by the $url. However, I'm having a problem with the preg_replace(). Here is the actual method that takes the base url to fix all inks with (or overrides it if there is a <BASE> tag in the document, as well as the actual HTML to parse. It returns that parsed data as well as sets a class variable with the clean HTML: [code] <?php public function fixLinks($baseUrl, $html = null){     if(is_null($html)){ $html = $this->rawHtml;     } $tagAttributes=array(       'table'=>'background',       'td'=>'background',       'tr'=>'background',       'th'=>'background',       'body'=>'background',       'a'=>'href',       'link'=>'href',       'area'=>'href',       'form'=>'action',       'script'=>'src',       'img'=>'src',       'iframe'=>'src',       'frame'=>'src',       'embed'=>'src');         //Get hostname for relative URL's     $host = parse_url($baseUrl);     $host = $host['scheme'] . "://" . $host['host'] . "/";           if(preg_match('/<base(?:.*?)href=["\']?([^\'"\s]*)[\'"\s]?/is', $html, $base)){     $baseUrl = $base[1];     $host = $baseUrl;     }             // Append a trailing slash to the url if it doesn't exist     if (substr($baseUrl, -1, 1) !='/'){       $baseUrl.='/';     }     //Works for everything but relative paths like href="someimage.jpg"     foreach($tagAttributes as $tag=>$attribute){     $pattern="/<$tag([^>]*)$attribute=[\"']*(?!http:|ftp:|https:|javascript:)\/([^\"'\s>]*)[\"']?/is";     $replace="<$tag\${1}$attribute=\"$host\${2}\""; $html=preg_replace($pattern, $replace, $html);     }     //This was added recently to make the direct paths work...but i don't know it doesn't match???     //Does not work for direct paths like href=someimage.jpg     foreach($tagAttribute as $tag=>$attribute){         $pattern="/<$tag([^>]*)$attribute=[\"']*(?!http:|ftp:|https:|javascript:)([^\"'\s>]*)[\"']?/is";         $replace="<$tag\${1}$attribute=\"$baseUrl\${2}\"";         $html=preg_replace($pattern, $replace, $html);     } $this->rawHtml = $html; return $html;   } ?>[/code] Now I know it's not the most efficient way but at this point I'm just trying to get it work, then I'll work on efficiency. The problem is that any relative path never seems to match the second regex. So everything like href=/mydir/image.gif and /newfile.php always works and gets replaced with the proper href=http://www.mysite.com/mydir/image.gif, etc. But relative ones don't. They simply remain relative without the added host or base url. Any ideas would be a great help. This project is on Sourceforge.org if anyone is interested. http://sourceforge.net/projects/ripcurl/ Again, thanks a lot. This is one of the last little things that has been really bugging me with this project. Brandon C.
  23. Not sure you can dissable it without JS. Perhaps you could simply hide the rest of the elements with a "display: none" style....but actually, you would have to use a one liner of JS in the checkbox to see when it gets checked... doh!!
  24. Wow, that could get really confusing. Though looking at the example, I don't see why class two couldn't extend class one. It would greatly reduce the confusion and shorten typing time. I think that's what classes are for anyway, to easily manage a group of similar items. If class one and two are referencing the same items, why not combine/extend them? But I can assume there are other methods that might prevent this from happening easily??? Aside form that fact that you probably already have a bunch of code using it this way. Sorry man, I'm not sure if there is a better practice aside from combining the two classes.
×
×
  • 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.