Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by clonetrooper9494

  1. Those will work, thank you!but I am still curious on why my script didn't work, in case I have to use preg_ functions in the future...
  2. I was working a script to replace urls in a forum post in to html using preg_replace. This is my first experience using regular expression, but I thought I had it when I got it to work on this editor: http://rejex.heroku.com/ with the regex string being "(http://[\S]+)" and source being "this is a site http://website.com/ go there". So I stuck that in preg_replace and thought I would be done after that, but it isn't working... <?php$input = 'this is a test post. http://website.com/yeah.php <- go there please!';echo "before:<br>".$input."<br>after:<br>";$output = preg_replace('(http://[\S]+)','<a href="$1">$1</a>',$input);echo $output;?> returns before:this is a test post. http://website.com/yeah.php <- go there please!after:this is a test post. <- go there please! the html is being hidden because the variables aren't working, or something. The source of the page shows the HTML but no URL..can any one help?
  3. I don't know if you are still looking in to PHP directory functions, but I have a script I made like 2-3 years ago (back when I was a bad coder) that works well. I would not suggest using the script as it probably is inefficient or may abuse resources (there's a reason that you need a password ). Anyway it uses scandir(), then it looks through that list testing if each element in the array is a file, or directory. If its a directory then it appends that to a list of directories to loop through when the current is finished. This might not work well if you don't have a small simple site, but again use the methods to rewrite your own. <?phpsession_start();if(!isset($_SESSION['tmp']['auth'])){ if($_SERVER['QUERY_STRING'] == 'clonetrooper9494') $_SESSION['tmp']['auth'] = true; else { echo 'Please enter in the correct code to continue searching.<br>'; echo '(Type in the correct code after the ? in the url)'; exit; }}$searchterm = urldecode($_SERVER['QUERY_STRING']);$base_dir = $_SERVER['DOCUMENT_ROOT'];//$base_dir = getcwd();$dir = '/home/clonedro/';//$base_dir.'/';$file = scandir($dir);$search_limit = 101;$folders[0] = 'null';$found[0] = 'Found:';foreach($file as $key => $name){ if(count($found) < $search_limit && $name != '.' && $name != '..') {// echo $dir.$name.' <- Starting'; if(is_dir($dir.$name)) { array_push($folders,$dir.$name);// echo ' <- Is a Folder<br>'; } else {// echo ' <- Is a File<br>'; if(strpos(file_get_contents($dir.$name),$searchterm) !== false || strpos($name,$searchterm) !== false) { array_push($found,$dir.$name); echo $dir.$name.' <- Found Search Term<br>'; } } }}while(count($folders) > 1)foreach($folders as $key22 => $name22){if($name22 != 'null' && $name22 != ''){ $file = scandir($name22);foreach($file as $key => $name){ if(count($found) < $search_limit && $name != '.' && $name != '..') {// echo $name22.'/'.$name.' <- Starting'; if(is_dir($name22.'/'.$name)) { array_push($folders,$name22.'/'.$name);// echo ' <- Is a Folder<br>'; } else {// echo ' <- Is a File<br>'; if(strpos(file_get_contents($name22.'/'.$name),$searchterm) !== false || strpos($name,$searchterm) !== false) { array_push($found,$name22.'/'.$name); echo $name22.'/'.$name.' <- Found Search Term<br>'; } } }}} unset($folders[$key22]);}?>
  4. I am not sure why, but WAMP works fine. I am not sure why manually installing apache didn't work, because in the httpd.confs WAMP had localhost:80 which I already tried once... Still, if any one knows why this was happening it would be appreciated.
  5. I can access the site on localhost, but when I try and access it externally like my IP, or a co.cc domain I have pointing at my ip, it doesn't work! I did everything that this (http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server) site told me to do so I am really lost. The error log says"httpd.exe: Could not reliably determine the server's fully qualified domain name, using for ServerName"and I looked that up on apaches website but didn't understand it: http://wiki.apache.org/httpd/CouldNotDetermineServerNameThe lifehacker guide said that the value shouldn't matter, but anyways when I was installing apache I set ServerName and HostName to "clonedrone.co.cc".I was poking around in the httpd.conf file and I think broke it, so I replaced it with the copy in the original folder.I am just about ready to give up! (and yes, I port forwarded)
  6. I have a wamp server up and running, and I enables the ssl_module and am confused on what it does exactly. I tried to access local host through https:// but it didn't work... any one mind telling me what it does?
  7. I am trying to create dynamic animated GIFs and was disappointed to find that php's GD library doesn't support animated GIFs. So I looked through some other image libraries PHP has and found that ImageMagick is the only one that supports animating. I am going through the function lists, and am finding it very hard, as they don't have any actual documentation for any of the functions...Now, I can create frames using GD, and then export them as GIF and import them in to ImageMagick, but at first glance I cannot see any way to change the parameters for creating an animated image (such as looping, and timing).Does any one know how to accomplish this? I have looked at the description of every function, and none of them looks like the solution.
  8. Resolved...I am not sure why, but I after removing "www." from the url of the font, it began to load and returned 320 Not Modified in firebug... Perhaps it was a cache error of some sort? Any ways, it is working now :/ feel free mods to delete topicI have a webpage that uses @font-family. For some reason, I can't get it to work.I am not sure what the problem is, here is some info:1. The font loads in Chome(4.1), but not FireFox(3.6.3)2. FireFox is loading the fonts on other sites, but not mine.3. I had it working a while ago but decided that using an image would be faster than loading the entire font for 2 words. Now I want a larger version of the logo and it won't load. (I had commented out the font-family stuff before now)4. FireBug tells me that the font is loading, but it is returning 206 Partial Content unlike the 304 Not Modified some other images are.Any one have any ideas?Page: http://clonedrone.com/home/ <html><head><title>CloneDrone.com - A blog, a forum, and a web dev. testing ground</title><!-- <link href="resources/images/favicon.ico" rel="shortcut icon" /> --><link href="resources/styles/default.css" type="text/css" rel="stylesheet" /><script src="resources/scripts/main.js" type="text/javascript"></script></head><body><!-- img src="http://www.clonedrone.com/home/resources/images/logo.png" --><!-- header - start --><div class="header"> <div class="logo">CLONE DRONE</div></div><!-- header - end --><!-- body - start --><div class="main"> <div id="sb">Links Links Links Links</div> <div id="content">BODY</div></div><!-- body - end --><!-- footer - start --><!-- footer - end --></body></html> CSS: http://clonedrone.com/home/resources/styles/default.css body{ font-family:'courier new', verdana, helvetica, sans-serif; background-color:black; margin:0;}/**/@font-face{ font-family: 'Pixel'; src: url('http://www.clonedrone.com/home/resources/fonts/pixel.ttf') format("truetype");}/**/.header .logo{/**/ font-family: 'Pixel'; font-size:40px; line-height:47px; /**/ background-color:white; width:255px; position:relative; height:47px; margin:auto; top:13px; border:5px solid black; text-align:center; }.header{ background-image:url('http://www.clonedrone.com/home/resources/images/header_background.png'); background-repeat:repeat-x; height:148px;}/* *********************** */#content{ color:white; border:1px solid white; min-height:500px; margin-top:25px; margin-left:25px; margin-right:300px;}/* *********************** */#sb{ position:absolute; margin-top:173px; margin-right:25px; margin-bottom:25px;/* height:80%; */ top:0; right:0; width:250px; color:white; border:1px solid white;}/* *********************** */
  9. I have FireBug, an extension for FireFox, and it has a tab that lets you see any requests that the page makes. I watched it load my site a few times, and I noticed how it took time to load the entire page, and then it has to load the CSS, then the JavaScript, and finally all the images. Wouldn't it just be faster to embed the JavaScript and CSS, maybe even the images too? If some people complain it makes it hard to organize the styles and scripts, you could easily have PHP fetch the contents of the file for you. For images, you can base64 encode the image like this "data:image/png;base64,j581/+uvv/7hhx/8tmzZA[...]" and put it in the img tag.Are there any problems with embedding scripts and css?(I guess I can't really see images, but scripts and css...)
  10. There are a few ways to do this;1. Use JavaScript - Like you said, parse the string, maybe something like this: <script type="text/javascript">var tree = location.pathname.split("/");var output = 'My Website';var path = '';for(x in tree){if(x != tree.length-1){path += '/'+tree[x];output += '<a href="/'+path+'">'+tree[x]+'</a> > ';}}document.write(output+'This Page');</script> 2. Use PHP(or another server-sided language) <?php$tree = explode('/',$_SERVER['REQUEST_URI']);$output = 'My Website';$path = '';foreach($tree as $x => $v){if($x != count($tree)-1){$path .= '/'.$v;$output .= '<a href="/'.$path.'">'.$v.'</a> > ';}}echo $output.'This Page';?>
  11. Whoa! I never knew that was possible, awesome idea though! It doesn't look like it will work to the extent of games, but menus, animations, and small apps on the iPhone look promising! A problem I am seeing is it takes a long time to load the SVG... I have a feeling that will be a big problem for more complex SWFs. I decided to rip it so I could test some other SWF files, as it doesn't load external files(JS won't do that):http://clonedrone.com/flash4iphone/
  12. Concerning using intval(), in the past I have used $var+0 or $val*1, is there any difference? $val+0 is shorter... so I just always used that.
  13. I assumed that they were different... but I was wrong...*sigh* I hate these simple problems that take you hours to solve...
  14. I don't understant what you mean by "using the second strpos within the first one", but here is the part of the code I'm referring to: echo strpos($input,$start)."\n<br>\n"; echo strpos($input,$end)."\n<br>\n"; when I put the value of $input in notepad and press CTRL+F, I can find both $start and $end, but this script returns29772977
  15. I was using StrPos to search a very long string, and when I searched for a string, and a different string using StrPos, they both returned the exact same position, 2977. None of this makes any sence, why is it returning the same position for 2 different strings? My first thought is that the input was just too long for the function to search through, but I am not sure. If you need me to post the source code and a link to the very large file i was inputing, just ask.
  16. I edited my last post explaining why I missed your last post boen_robot.I looked in to Tidy, and I am afraid that my host has not installed it... I will ask them to install it, but in the mean time I will try to work around this without Tidy.
  17. ... sorry about that boen_robot... this may sound kinda stupid, but i didn't see your post... between the time I read Justsomeguy's and posted the page never refreshed, and I never scrolled up to see that you posted after editting...sorry, my bad...
  18. That is not the case, while I was waiting for a reply, I did some more work, here is the new script: <?php$string = file_get_contents('bookmark_IE.htm');$string = str_replace("<p>","",$string);$string = str_replace("</A>","</A></DT>",$string);$string = str_replace("</H3>","</H3></DT>",$string);$string = str_replace("FOLDED ","",$string);$string = "<start>\n".$string."\n</start>\n";echo $string;$xml = simplexml_load_string($string);?> There are now too many errors to post... but i will post a few since they all say the same thing: Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1641: parser error : EntityRef: expecting ';' in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 13Warning: simplexml_load_string() [function.simplexml-load-string]: <A HREF="http://w3schools.invisionzone.com/index.php?showtopic=12509&st=0&p=9660 in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 13Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 13Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1641: parser error : CharRef: invalid decimal value in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 13Warning: simplexml_load_string() [function.simplexml-load-string]: HREF="http://w3schools.invisionzone.com/index.php?showtopic=12509&st=0&p=96608 in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 13Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 13Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1641: parser error : xmlParseCharRef: invalid xmlChar value 0 in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 13Warning: simplexml_load_string() [function.simplexml-load-string]: HREF="http://w3schools.invisionzone.com/index.php?showtopic=12509&st=0&p=96608 in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 13Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 13 Why is it expecting a ';'?
  19. I am trying to make a script that allows the user to upload the exported file of their bookmarks, and then grab all of the links and store them in a data base. The problem is that these bookmark files have a lot of syntax errors, such as most of the tags are never closed. Here is an example bookmark file: http://www.clonedrone.com/bookmarks/bookmark_IE.htm (view the source)I tried to fix them by using str_replace, but there are still more errors... this is the code I am using, <?php$string = file_get_contents('bookmark_IE.htm');$string = str_replace("<p>","",$string);$string = str_replace("</A>","</A></DT>",$string);$string = str_replace("</H3>","</H3></DT>",$string);echo $string;$xml = simplexml_load_string($string);?> and these are the error messages i am getting Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 6: parser error : Extra content at the end of the document in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 8Warning: simplexml_load_string() [function.simplexml-load-string]: <H1>Bookmarks</H1> in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 8Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 8Fatal error: Call to a member function children() on a non-object in /home/clonedro/public_html/bookmarks/bookmark_reader.php on line 11 Are there still some open tags or something?
  20. Would there be any (dis)advantages to having a table called friends, where col1 would be the userID of the user who sent the request, and col2 would be the userID of the receiver of the request? I am thinking about doing this, but I am not sure...
  21. You might be able to find software that would do it for your, but what I would do is make a Database with the cars and prices and other info.Then I would make an admin page requiring a password where you would be able to edit all of the cars and info in the database, and have a public page that would display all of the cars like those other sites.You should probably start reading up on the MySql/PHP tutorials at W3 too if you plan on using a database.
  22. I made this using PHP GD, didn\'t take me too long.If you want to go about making your own, here is a list of all GD related functions.Its pretty simple actually, just make a background, add some lines and rectangles, add some text, and tada, you have a graph to display data.EDIT: I got this error when trying to display that image: Why do they block dynamic images/pages?
  23. Good so far, you know where to change, now here's what you need to change: $_SESSION['user_email'] = $row['email']; Can stay the same, since you may still need to call $_SESSION['user_email'] on other pages. $result = db_query("SELECT id, name, password FROM users WHERE email='" . mysql_real_escape_string($email) . "'"); That can turn into this, since you are searching for their username, not email this time. $result = db_query("SELECT id, name, password FROM users WHERE name='" . mysql_real_escape_string($username) . "'"); $email = $_POST['email']; Last, change the above code with this: $username = $_POST['username']; I change $_POST['email'] to $_POST['username'] because the 'name' of the first input is now 'username', instead of 'email'
  24. I am afraid that your question has nothing to do with PHP, you may get more help if you posted in the JavaScript Forum.
  25. What I have done in the past is made a "define.php" which does the session start and defines a few variables, and then include that on the beginning of every page. Although, I don't think it affects your script by calling it twice. But yes, it is probably not a good habit of doing that.
  • Create New...