-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
renfley this is your 2nd thread looking for a way to advertise sale of your domains on phpfreaks. To be clear, we do not allow advertising on our board, with the exception of 1) Offering or asking for freelance services in the freelance forum. 2) Small, unobtrusive message in your sig. Example: make a page on a site you host where you offer your domains, and in your sig you can put something like "I have some domains for sale, click here!"
-
You cannot do this with the ftp commands (except possibly by using file manipulation commands like fopen/fseek/fread through ftp_raw, if permissions allow, which most likely not..also, I'm not entirely sure you can actually use those commands). You will have to retrieve the file as a whole, and then search through it. You may (with proper permissions local and remotely) be able to do it with sockets though with limitations. (Sockets would in theory allow you to run arbitrary shell commands on the remote server, so for instance you could run php remotely and use the file reading functions, or use shell commands). Either way... None of the file reading commands (whether done locally or through a socket allows you to just grab x through y lines unless the lines are by convention all a fixed number of char length (padded if shorter), and then you can use fseek to jump to the line based on $x * $length. If the lines are not fixed length, you will have to either make a loop and just continue until $x (and then break at line $y), or put the file in its entirety into an array (like with file - not advisable unless the filesize is always expected to be relatively small). edit: nevermind looks like you actually can't even use ftp_exec or ftp_raw. ftp_exec only returns a status code or false, no info, so even if the remote server allowed it, it would be useless. ftp_raw only (assuming permissions allow for it) only do raw ftp commands, not php commands!
-
Okay, I know the DOM object is complex and scary at first, so I'll give you some more examples. After that, you are on your own...follow the provided link, RTFM! <?php // example content to parse. You didn't post that part of your script, but you probably got this from a file_get_contents call or something. $content = <<<EOF <html> <head></head> <body> <a href="site/user/36" title="Vinodkumar">Vinodkumar 36</a> <a href="site/user/37" title="Vinodkumar">Vinodkumar 37</a> <a href="site/user/38" title="Vinodkumar">Vinodkumar 38</a> <a href="site/user/39" title="Vinodkumar">Vinodkumar 39</a> <a href="somepage.php">some page</a> </body> </html> EOF; // create a new DOM object $doc = new DOMDocument(); // load the html content to be parsed $doc->loadHTML($content); // get all the anchor tags $links = $doc->getElementsByTagName('a'); // for each anchor tag... foreach ($links as $k => $link) { // output the full, raw link tag. // wrapped in htmlentities() for display purposes $rawTag = $doc->saveXML($link); echo htmlentities($rawTag) . "<br/><br/>"; // output the innerHTML of the link echo "link value : " . $link->nodeValue . "<br/><br/>"; // alternative way to output the innerHTML of the link echo "link value : " . $link->textContent . "<br/><br/>"; // output a specified attribute echo "href : " . $link->getAttribute('href') . "<br/><br/>"; // output all of the attrib='value' in the current link // (first it is put into an associative array for convenience) $link_attributes = array(); foreach($link->attributes as $attribute) { $link_attributes[$attribute->name] = $attribute->value; } echo "<pre>";print_r($link_attributes); echo "</pre>"; echo "<hr>"; } // end foreach anchor tag ?> output: <a href="site/user/36" title="Vinodkumar">Vinodkumar 36</a> link value : Vinodkumar 36 link value : Vinodkumar 36 href : site/user/36 Array ( [href] => site/user/36 [title] => Vinodkumar ) <a href="site/user/37" title="Vinodkumar">Vinodkumar 37</a> link value : Vinodkumar 37 link value : Vinodkumar 37 href : site/user/37 Array ( [href] => site/user/37 [title] => Vinodkumar ) <a href="site/user/38" title="Vinodkumar">Vinodkumar 38</a> link value : Vinodkumar 38 link value : Vinodkumar 38 href : site/user/38 Array ( [href] => site/user/38 [title] => Vinodkumar ) <a href="site/user/39" title="Vinodkumar">Vinodkumar 39</a> link value : Vinodkumar 39 link value : Vinodkumar 39 href : site/user/39 Array ( [href] => site/user/39 [title] => Vinodkumar ) <a href="somepage.php">some page</a> link value : some page link value : some page href : somepage.php Array ( [href] => somepage.php )
-
We actually at one point in time in the past did have a separate "Author" group, where you pretty much just had to be a registered member and ask for it. That was available for like a year and in all that time only like 3 people joined, didn't post anything on the main site, and eventually removed themselves from the Author group. So we just ditched that group. But right now, what you said... that is more or less how the current restrictions effectively are. When a member has been around a while, has x+ posts, and gives decent advice, not being a complete asshat in the community...someone in Guru+ can nominate that member to become a Guru and other Guru+ can vote yay or nay and if the yay's win, they become a Guru, which gives them access to make blogs/tutorials. So...so far IMO there isn't much reason to just give open access to regular members; trying that in the past did not generate the interest we had hoped for, and putting restrictions on it like that..we already do that. IOW my personal vote is to keep it as-is.
-
FYI any guru+ member already has the ability to add a blog or tutorial to main site right now.
-
sowna, judging by the code you posted, it looks like you are working with an html document, perhaps retrieved from a file_get_contents or cURL call, and you are trying to extract the user id from links on the page. When trying to parse html, it is safer to use a DOM Parser than regex. example: // example content to parse. You didn't post that part of your script, but you probably got this from a file_get_contents call or something. $content = <<<EOF <html> <head></head> <body> <a href="site/user/36" title="Vinodkumar">Vinodkumar 36</a> <a href="site/user/37" title="Vinodkumar">Vinodkumar 37</a> <a href="site/user/38" title="Vinodkumar">Vinodkumar 38</a> <a href="site/user/39" title="Vinodkumar">Vinodkumar 39</a> <a href="somepage.php">some page</a> </body> </html> EOF; // create a new DOM object $doc = new DOMDocument(); // load the html content to be parsed $doc->loadHTML($content); // get all the anchor tags $links = $doc->getElementsByTagName('a'); // for each anchor tag... foreach ($links as $link) { // get the href attribute $href = $link->getAttribute('href'); // if href is the right link ... if ( stripos($href,'/user/')!==false ) // user id is the last / delimited value in $href, grab it and put into array of found user ids $user_ids[] = array_pop(explode('/',$href)); } // end foreach anchor tag // example showing output of found user ids echo "<pre>"; print_r($user_ids); echo "</pre>"; output: Array ( [0] => 36 [1] => 37 [2] => 38 [3] => 39 )
-
He can't get the value from the server superglobal...that only contains info about the request url. He is trying to extract a url from a string of html code. My question is, what has he tried? I ask because we are here to help people in their efforts, because our goal is to teach people how to do stuff, not just do their work for them.
-
what have you tried?
-
So today's father's day google logo animation features a letter-child "e" giving its letter-father "l" a cup of coffee via remote control. So, which letter is the mom? If we are to go by color, then all of "Goog" is the mom. Notice that the "g" in "Goog" is conspicuously missing the bottom half of its font stroke, making it look like the "g" is standing on 2 legs...as if "mom" is standing on two legs, bent over in front of "dad", offering up her father's day gift as well. Hey, check out the oo's on that milf...giggity giggity
-
well to be fair, back then, literally every byte counted...
-
I've only poked at perl like once or twice, but doesn't perl do that sort of thing?
-
preg_match that checks for lower/upper case letters, numbers, spaces, etc.
.josh replied to Shockdot's topic in Regex Help
yes, show the code where you receive the posted info, and where you are matching it. Also, put this somewhere: echo "<pre>"; print_r($_POST); echo "</pre>"; and post what is echoed out. -
There isn't case-sensitive and case-insensitive comparison operators of other types, so why would there be here? Well yes, that is half my point. For that half, I agree, the point is that when it comes to current operators, case-sensitivity isn't really relevant. But for proposed operators for things like "begins with.." and "ends with.." case-sensitivity is a common issue and therefore becomes relevant. IOW sure, you can just have $= be case-sensitive but there will be enough situations and people wanting it to sometimes be insensitive that people will want a way to specify, which means a separate operator will have to be made. But since all the other operators don't consider case, having two separate operators for these proposed things would disjoint them from the spirit of other operators. So therefore my argument is that in order to accommodate case, it wouldn't make sense to have operators like this, it's better to stick with functions. In other words, operators are "lower level functions" where things like case should not be considered. There are no conditions involved. Core functions are "higher level functions" where things like that are considered (passing as arguments). There are conditions involved, that allow for variance based on circumstance. Since "begins with..." and "ends with.." will often want to consider case, they should not be expressed as operators, because situations will often demand for variance in behavior. Or another way to put it, in principle, it is essentially the same argument people make for bitching about loosely typed languages.
-
preg_match that checks for lower/upper case letters, numbers, spaces, etc.
.josh replied to Shockdot's topic in Regex Help
This would be odd. Doesn't magic_quotes only affect userland data? In which cases would this happen? Curious for my own debugging Well, yes. But the OP did not specify where the data is coming from. It could be for matching against posted data. Like I said, random shot in the dark. -
preg_match that checks for lower/upper case letters, numbers, spaces, etc.
.josh replied to Shockdot's topic in Regex Help
random shot in the dark: perhaps you are testing with ' and I wonder if your server automatically escapes those to make the value \' and since \ doesn't match, the regex is failing... -
Interesting idea...not sure how I feel about that. Right now you can easily do stuff like that with for instance strpos or using regex. Not sure how useful those operators would be though. How would case-sensitivity (vs. non) be handled? That's common enough that it would have to be considered, and IMO it would be kinda lame to have two separate operators for that.. would be better as a function. On that note...perhaps cleaning up the functions in regards to stuff like case comparison.. for instance, there's no reason why there needs to be a separate strpos vs. strpos, or even strrpos and strripos .. all 4 of those could be combined to a single function.
-
Google Analytics is a popular tracking system. Alternatively, if you are looking to host your own solution, Piwik is pretty comprehensive.
-
preg_match that checks for lower/upper case letters, numbers, spaces, etc.
.josh replied to Shockdot's topic in Regex Help
if ( preg_match('~^[-a-z0-9_:%$.,!]+$~i',$string) ) { // valid } else { // invalid } -
All by itself, I'm not seeing anything wrong with the code you've posted, you'll have to post more. 1) I'm not 100% but I don't think browsers default to a radio button being selected, so if it is "defaulting" to "Male" then I'm pretty sure either that's what you selected or you have other code (not posted) that's setting $gender. I don't see it defaulting to "Male" in the latest FF, Chrome and IE anyways... 2) Dunno what to tell you on this count since near as I can tell, you didn't post relevant code for that 3) Again, you didn't post relevant code for that (the query string and query insert code)
-
Really? That simple? Debbie I've noticed that things tend to get "buggy" sometimes when php tags are embedded inside html tags like that; it's pretty hard to accurately parse (I've seen this in other IDEs too, and if you look at your posted code, you can see even smf's syntax highlighter is buggin') I messed that up. Does this look better... <input id="female" type="radio" name="gender" value="F" <?php echo ((isset($gender) && $gender == "F") ? 'checked="checked"' : ''); ?> /> <label for="female">Female</label> <input id="male" type="radio" name="gender" value="M" <?php echo ((isset($gender) && $gender == "M") ? 'checked="checked"' : ''); ?> /> <label for="male">Male</label> Debbie looks okay to me
-
only thing i think is technically wrong is I think in your label tag, I think the for attribute is supposed to point to an element id not, name.
-
looks okay to me.. I guess netbeans is buggin'
-
I also agree with ManiacDan: that statement is more for like if you were wanting to setup some kind of communication system with someone, you would be adding an extra layer (php) into the mix, thus opening up more possibilities for potential attacks. It's the same working principle that the more hoops you have to jump through, more points you have to go through to get from sender to receiver, the more opportunity to find and exploit a hole. So that statement isn't really applicable for wanting to hash a password to be stored. ...
-
could also take a look at hash() it doesn't offer bcrypt but it does offer a lot of other algorithms (you can use hash_algos to see a list of available)