-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
I think it's because MS has gotten too big. Imagine a totem pole with 1000 levels and there's like 800 levels above marketing and anybody on any of those 800 levels can be like "I wanna see this" and they have to do it because they're one of the million "bosses" in the company, even if the "boss" doesn't know a gd thing about marketing. I mean come on I kind of find it hard to believe that a company who revenues billions of dollars cannot afford a decent marketing dept. That makes no sense. What does make sense is internally some idiot upper management wanting to waste the money they spend on said marketing dept to push their own idea of what's cool.
-
IMO that commercial was weak. My words destroy planets.
-
so you made a membership system and an email system but don't know how to do a count query?
-
google for a page hit counter tutorial (you know, like the ones that say "this page was viewed x times"). aside from the form part, which i'm sure you can easily figure out, a page hit counter tutorial is essentially the same thing.
-
I would not classify him as a troll. Trolls purposely say stupid shit with the goal to cause a ruckus. They are looking for entertainment. Which everybody does that, so it boils down to a matter of what we constitute entertainment. This guy is just an ass who thinks the world revolves around him. Which IMO is worse than a troll, so you should probably apologize to the trolls out there.
-
you have them as two separate captures.
-
coding-wise, you would use z just like x and y, except you would include x and y in the z formula as an offset.
-
yes. That function looks at settings in the db to determine what/how to escape (things).
-
foreach ($numberMaps as $num) { $num = substr($num,0,; if ($t[$num]) { echo "match found"; break; } else { $t[$num] = ''; } }
-
or if this is not a "remember me" value, you would store the data in a flatfile or database, if you're looking for a server-side solution.
-
that error means just what it says: you are listing x amount of columns to insert and y amount of values and those 2 numbers don't match. Example that would produce that error: insert into table (column1,column2,column3) values ('a','b') uh oh, you have 3 columns listed but are only providing 2 values...
-
have your script check if info exists in db already, before you run your insert. pseudo code: select * from table where name = '$uname' or email = '$email' if (mysql_num_rows > 0) { echo "you already registered!" } else { insert ... }
-
that does nothing to validate contextual/semantic data. For example, if you have a phone number form field and your db column is a number type column but user enters in letters, you're going to have problems.
-
Get all links from a website script help! (recursive)
.josh replied to byte1918's topic in PHP Coding Help
I was working on something like this a while back. I never got around to completing it. I remember it mostly kind of sort of worked. Lot of stuff missing like doing something about relative links that use ../ or removing link from master list if cURL returns false, etc... May or may not inspire something other than a bowel movement... <form name='getPageForm' action='' method='post'> Domain (example: http://www.mysite.com/ note: currently only works with root domain name (no starting at xyz folder): <br/> <input type = 'text' name='pageName' size='50' /><br /> Number of links <input type = 'text' name='numLinks' size='2' value='50' /> (will not be exact. will return #+ whatever extra on current page iteration)<br /> <input type='submit' name='getPage' value='load' /> </form> <?php class scraper { var $linkList; // list of data scraped for current page var $rootURL; // root domain entered in from form var $maxLinks; // max links from form var $masterLinkList; // master list of links scraped /* function __construct: constructor, used to do initial property assignments, based on form input */ function __construct($rootURL,$max) { $this->rootURL = $rootURL; $this->maxLinks = $max; $this->masterLinkList[] = $this->rootURL; } // end function __construct /* function scrapePage: goal is to scrape the page content of the url passed to it and return all potential links. problem is that not all links are neatly placed inside a href tags, so using the php DOM will not always return all the links on the page. Solution so far is to assume that regardless of where the actual link resides, chances are its within quotes, so idea is to grab all things that are wrapped in quotes. */ function scrapePage($url) { $linkList = array(); $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; // make the cURL request to $url $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $file = @curl_exec($ch); if (!$file) { $this->linkList = $linkList; } else { // assume everything inside quotes is a possible link preg_match_all('~[\'"]([^\'"]*)[\'"]~',$file,$links); // assign results to linkList $this->linkList = $links[1]; } } // end function getLinks /* function filterLinks: goal is to go through each item in linkList (stuff pulled from scrapePage) and try to validate it as an internal link. So far we use basename to look for a valid page extension (specified in $validPageExt). Need to add ability for user to enter in valid page extensions for the target domain. We also attempt to filter out external links by checking if element starts with 'http' and if it does, if element starts with rootURL. We also assume that if there's a space somewhere in the element that its not valid. Yes that's not 100% because you can technically have a link with spaces in it, but most people don't actually code that way, and it filters out a lot of stuff between quotes, so the benefits far outweigh the cost. */ function filterLinks() { // remove all elements that do not have valid basename extensions $validPageExt = array('htm','html','php','php4','php5','asp','aspx','cfm'); foreach ($this->linkList as $k => $v) { $v = basename($v); $v = explode('.',$v); if (!in_array($v[1],$validPageExt)) unset($this->linkList[$k]); } // end foreach linkList // remove external links, convert relatives to absolute foreach ($this->linkList as $k => $v) { // if $v starts with http... if (substr($v,0,4) == "http") { // if absolute link is not from domain, delete it if (!preg_match('~^'.rtrim($this->rootURL,'/').'~i',$v)) unset($this->linkList[$k]); } else { // if not start with http, assume it is relative, add rootURL to it $this->linkList[$k] = rtrim($this->rootURL,'/') . '/' . ltrim($this->linkList[$k],'/'); } // end else } // end foreach linkList // assume that if there's a space in there, it's not a valid link foreach ($this->linkList as $k => $v) { if (strpos($v,' ')) unset($this->linkList[$k]); } // end foreach linkList // filter out duplicates and reset keys $this->linkList = array_unique($this->linkList); $this->linkList = array_values($this->linkList); } // end function filterLinks /* function addLinksToMasterLinkList: goal here is once data is retrieved from current link and filtered, we will add the link to the master link list. Also we remove dupes from the master list and reset keys. This function can probably be put inside filterLinks (and it was initially...); I couldn't decide whether it deserved its own function or not so I ended up going for it. */ function addLinksToMasterLinkList() { // add each link to master link list foreach ($this->linkList as $v) $this->masterLinkList[] = $v; // filter out duplicates on master link list and reset keys $this->masterLinkList = array_unique($this->masterLinkList); $this->masterLinkList = array_values($this->masterLinkList); } // end function addLinksToMasterLinkList /* function getLinks: basically the main engine of this bot. Goal is to go down the master link list and call each of the other functions until we've passed max links specified. It's not coded to stop at exactly maxLinks; it's coded so if the count is less than max, it scrapes another page. So the end result will be the count before the last iteration, plus whatever is on the last page. So for example if max is 50 and so far we're at 45 links, another page gets scraped. Well if that page has 10 links on it, then the end result will be 55, not 50 links. Also, we make sure to break out of the while loop if there's no more links on the master link list to grab data from. This is for if the site only has a total of like 20 links and you set the number of links to like 100, it will break out of the loop. */ function getLinks() { // start at first element $x = 0; // while there are less links in the master link list than the max allowed... while ((count($this->masterLinkList) < $this->maxLinks)) { // break out of loop and end scraping if there are no more links on the master list if (!$this->masterLinkList[$x]) break; // scrape current page in the master link list $this->scrapePage($this->masterLinkList[$x]); // filter results from the scrape $this->filterLinks(); // add filtered results to master list $this->addLinksToMasterLinkList(); // move to next link in master link list $x++; } // end while count < max }// end function getLinks /* function dumpLinkList: simple function to dump out results. mostly a debugging thing */ function dumpLinkList () { echo "<pre>";print_r($this->masterLinkList); echo "</pre>"; } // end function dumpLinkList } //*** end class scraper // if user enters url... if ($_POST['pageName']) { // create object $scraper = new scraper($_POST['pageName'],$_POST['numLinks']); // grab links $scraper->getLinks(); // dump out results $scraper->dumpLinkList(); } // end if $_POST ?> -
thread closed. refer to sticky already mentioned in this thread.
-
Why bother with something so undependable? It takes all of 2 seconds to delete cookies.
-
There are plenty of good shopping cart systems out there, both free and not. Why reinvent the wheel? You are going to be hard-pressed to find any tutorial about this, let alone a decent tutorial about this. Why? Because tutorials are usually like building blocks. You're asking for a whole building.
-
put exit(); right after all of your header(..);
-
No, the file function takes a file and uses the carriage return (\n) as a delimiter to make an array out of each "line" in the file. I think you meant to say that that's what explode does, which is what I said in my previous post. I explained that in my previous post. A space char and a tab char look the same to us visually, but they are not the same thing. Explode is a simple function that will take one thing and explode the string using that one thing as the delimiter. Since spaces and tabs are different, and you specified space, it did exactly what you told it to do: explode at the space. Since it only found the one space, so you ended up with 2 elements of the array. A forward slash will match a forward slash. preg_split is a regular expression (regex) function. That is, it works by using regular expressions. The very short explanation of regex is pattern matching using various degrees of rules and "wild cards." For instance, if you've ever played poker and jokers are wild, that's regex in principle. Or for example, if I have the string "bob bib bab" and I want to match for "bob" I would literally specify "bob" in the pattern. But if I wanted to for instance match any word that starts with 'b' and ends with 'b' I could make my pattern "b.b" because the dot is a "wild card" which stands for any 1 character (bit more complex than that but that's the gist of it). The ~ ~ on either end is the pattern delimiter. It tells preg_split (or any other regex function) what the start and end of the pattern is. You can use a lot of different things as delimiters, as long as you escape them if you need to use that particular character in the pattern. As far as resources for this stuff goes: There is a sub-forum of this php help forum dedicated to regex (which btw this thread will be moved to it). There are stickies in that forum for resources.
-
image link is not perfect. quick change of the body bg in firebug shows it has a white bg
-
foreach checkbox insert state (checked not cheked) into mysql
.josh replied to makoshark's topic in PHP Coding Help
the way you have your form right now, only the ones that are checked will be posted. If you want to be able to see that ones are non-checked, you need to explicitly specify element positions for question[] in your form. example: question[0] question[1] question[2] That way, if the user does not check for instance, "OutOfStock", the 3rd element will still be posted, but be empty You would then have your foreach loop and ... beyond that, you need to be more clear about what it is you're trying to do. -
okay I think this is what you're looking for (I commented out the php since those vars don't exist on my server): <div id="content" style="float: left;"> <p style="padding: .5em; border-bottom: 1px solid #808000;"><span class="title_text">"<?php //echo "$game_title"; ?>" profile for <?php //echo $werb->getusername($_SESSION['member_id']); ?></span><br> On this page you can edit anything in regards to your account settings. You can also add and delete characters from your profile.</p> <div style="width: 100%; background-color: green;position:relative;"> <div style="float: left; width: 40%;"> <b>BUILDERS</b><br> <ul> <li><a href="res_tools-modbuilder.php">Module Builder</a></li> <li><a href="res_tools-pcbuilder.php">Player Character Builder</a></li> <li><a href="res_tools-npcbuilder.php">Non-Player Character Builder</a></li> </ul> <b>USER TOOLS</b><br> <ul> <li>TEST</li> </ul> </div> <div style="float: right; width: 40%; height:120px;padding: 1em; border: 2px solid #2F4F4F;"> <b>Your chatacters</b><br> <?php //$werb->list_pcs($_SESSION['member_id']); ?> </div> <div style="clear:both;"></div> </div> <div style="width: 100%; background-color: blue;">TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST</div> </div> <div id="roundedBox" class="roundedBox" style="float: right; width: 200px; padding: 0 1em 0 1em";> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr><th style="border-bottom: 2px groove #F0FFF0;">TEMP HOLDER</th></tr> <tr valign="top"><th> </th></tr> </table> <div class="corner topLeft"></div> <div class="corner topRight"></div> <div class="corner bottomLeft"></div> <div class="corner bottomRight"></div> </div> 1) you were missing a ; after the width in one of your divs 2) since you were specifying a height in your left floating div, the contents were overflowing out of it. You either need to remove the height from that (which is what I did) or specify an overflow option. 3) since you are floating things, in order to get the blue bar to appear under them, you need to clear them. You can do this by a dummy div with 'clear: both'