Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Location

MMDE's Achievements


Member (2/5)



  1. Okay. I've never used FluxBB. I once programmed for some other forum software, and you will have to read and study a little bit to understand exactly how to make an add-on for FluxBB. Should be some kind of documentation somewhere. Most likely will the add-on system support installation and uninstallation, so you should program both. In your case... I would make the installation script alter and add an extra column in the user table in the database. I would add some extra menu for changing color or adding some extra options at the end of some option page that already exists. It would simply be a form where you select a color and then when saving it would save it to the database. Make sure to also either use some already existing validation script in the server or create one yourself. It is very important you validate the data to be safe to use against the database. You also need to make the script add the color to each user when avatar and username etc is loaded. Simply extend the sql query to get the extra column and output it along with the username just inside some html font tag or something or styling of some sort. Just remember to make it so you can later remove it. To uninstall the script, make sure it can remove everything you've added. Like dropping the extra column from the user table (make sure to not drop the entire table). etc I recommend creating a test forum and play around with it first. Read the forum's code and try to understand it. :s Alternatively you can try to pay someone to do it for you.
  2. You need to specify a name attribute for the input tags... <form action="eatnlocal_validate.php" method="post"> <P> Name: <input type="text" id="name" name="name"><br> Restaurant name: <input type="text" id="restaurant" name="restaurant"><br> Email: <input type="text" id="email" name="email"><br> <input type="submit" value="Submit" name="submit"> </P> </form> and you don't really need to use id, unless it has something to do with your CSS or something...
  3. Got no idea what kind of forum software you use. Have you programmed it yourself? (Kind of doubt it since you are asking this question). Does it support add-ons? If it supports add-ons, I would think you could write one. If it does not have an add-on system you will have to edit the forum code.
  4. We don't see your code, how should we know? Please post it! My tip is to trace it all the way back to where you think you get it from and echo it all the way from there to wherever you lose it.
  5. <?php function get_data($url, $post=null, $header=false, $cookie=null, $ref=null, $ssl=false){ $ch = curl_init($url); if($post){ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } if($cookie) curl_setopt($ch, CURLOPT_COOKIE, $cookie); if($ref) curl_setopt($ch, CURLOPT_REFERER, $ref); curl_setopt($ch, CURLOPT_HEADER, $header); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $ssl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); return curl_exec($ch); } function add_postfields($data, &$post){ $site = new DOMDocument(); @$site->loadHTML($data); $inputs = $site->getElementsByTagName('input'); foreach($inputs AS $input){ if($input->hasAttribute('name')){ switch($input->getAttributeNode('name')->value){ case 'nl.marktplaats.xsrf.token': $post['nl.marktplaats.xsrf.token'] = $input->getAttributeNode('value')->value; return; } } } } function get_cookies($data){ preg_match_all('|Set-Cookie: (.*);|U', $data, $matches); return implode('; ', $matches[1]); } function marktplaats($url, $username, $password){ $post = array( 'j_username' => $username, 'j_password' => $password, 'remember_me' => true ); $data = get_data('https://vernieuwd.marktplaats.nl/account/login.html', null, true, null, null, false); add_postfields($data, $post); $cookies = get_cookies($data); $cookie = get_cookies( get_data( 'https://vernieuwd.marktplaats.nl/account/securityCheck.html', http_build_query($post), true, $cookies, 'https://vernieuwd.marktplaats.nl/account/login.html', false ), $post ); return get_data($url, null, false, $cookie); } $url = 'http://vernieuwd.marktplaats.nl/'; $username = 'username'; $password = 'password'; $data = marktplaats($url, $username, $password); echo $data; ?> If you want the activity to seem a bit more "legit", then you could add: curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0');
  6. To further extend upon what Christian F. said... You can easily write a script that makes a regex which will make preg_match return true if at least one of the words in the input are in the string. word1|word2|word3 etc You can also make preg_match return true if one of the words input are found as a whole word in the script, and not the part of a word: ((\W|^)word1(\W|$))|((\W|^)word2(\W|$))|((\W|^)word3(\W|$)) The hard part comes when you want it to contain all the inputted words in one regex pattern... Then you get a very long permutated string, which I totally don't recommend (might be there is some way around it I don't know about). In this case I think a better option would be to loop through all the words and make sure you find them all in the string. function match_input($input, $string){ $one_match = false; $words = explode(' ', $input); $wc = count($words); for($i=0; $i<$wc; i++){ if(preg_match('/\A\s\Z/', $words[$i])){ continue; } if(!preg_match('/(\W|^)'.$words[$i].'(\W|$)/', $string)){ return false; }else{ $one_match = false; } } if($one_match){ return true; } return false; } Sorry, did a couple of typos, but I think I've fixed 'em all now! I also just added another small change to one of my codes, to check if the $words[$i] only contained white-space characters, and to ignore those, and also to return false if no words was actually found in the string.
  7. Do you check if $_GET is set before you use it? Though, I only get Undefined index: no, when I don't set it. <?php $string = 'some text test'; if (preg_match('/'. urldecode($_GET['no']) . '/i', $string)) echo 'TRUE: '.$_GET['no']; else echo 'FALSE '.$_GET['no'] ?> ^ Worked as expected for me. results: TRUE: test TRUE: text FALSE string TRUE: some FALSE some text string TRUE: some text test etc BUT watch out for special characters like (, ) and many others: Warning: preg_match() [function.preg-match]: Compilation failed: unmatched parentheses at offset 4 FALSE some) Warning: preg_match() [function.preg-match]: No ending delimiter '/' FALSE some\ Warning: preg_match() [function.preg-match]: Unknown modifier '/' FALSE some/ I would strongly suggest not using user input in the regex pattern, unless you are very sure you've tested it to be safe already.
  8. The problem is you are not giving the server what it wants. Different sites use all kinds of strange ways to verify various data, sometimes there are redirects and then there's sessions/cookies etc. I recommend usin Live HTTP headers, an add-on for firefox, to catch all the header data that is sent. You will need to try to replicate it. Send me a test account in PM and I could try to help you later tonight or tomorrow or something like that, but try some on your own first please. I recently did tumblr for someone here, and while that was fun, it took a little while.
  9. If I am to understand this correctly, arrays in PHP is hash maps? If that is the case, the worst case time it takes to find something in an array is O(log(n)), right? Shouldn't there then be cases where foreach could be faster to loop through an array with? Imagine the case of a huge array of integers, maybe some thousands. Would it use the same time accessing each of the entries in the array with foreach as a normal for loop? If that is not the case, what if it is a huge array filled with arrays of integers, and you use more than one or two of the values in each array you loop through the giant one? I understand there is quite a huge advantage of using a for loop because you have more control of exactly what key you use against the array. Thoughts?
  10. Do you want to do this because of bandwidth to the server? If this is not the case, then you can use HTML and CSS for this. http://dev.w3.org/ht...markup/img.html If you really want to re-size it to save bandwidth, then you need to use one of the image processing libraries in PHP, here's a good list of some of them: http://www.php.net/m...lspec.image.php I've only really used GD: http://www.php.net/m.../book.image.php I know it can do what you are asking for and there should be lots of tutorials for it online.
  11. What part of "Just for fun... ;o" did you not understand? It was never meant as a robust re-usable component or anything like that, just to show the idea behind the code. Which is also why I wrote 5 different ones. It's just meant as examples and things to continue work on for him. I'm not here to do his work. This is what I react to: ^ You are not correcting me at any point here, you're being nothing but a jerk. Your "points" are lost in the way you write it. It seems you are more eager to tell me I'm wrong and insult me than actually trying to write something useful for the user.
  12. Also, it seems I didn't use the same regex in both the edits... I made a small adjustment: '/1000|[1-9][0-9]{1,2}|[1-9]/' It looks for matches in this order: 1000 (1000) OR first character is between 1 and 9, the second and maybe third is between 0-9 (10-999) OR first character is between 1 and 9 (1-9) preg_match($input, $regex, $matches); Looks for matches of the regex pattern in the input. Stores them in $matches Stops after finding one match. Returns the number of matches. // if any matches if(preg_match($input, $regex, $matches)){ echo $matches[0]; // the first and only match }
  13. Without changing the class: <?php class Person { private $name; function __construct($name) { $this->name = $name; } function setName($newName) { $this->name = $newName; } function getName() { return $this->name; } } class Person2 extends Person{ public function nameLength(){ return strlen($this->getName()); } } $person = new Person2('the name'); echo $person->nameLength(); ?> <?php class Person { private $name; function __construct($name) { $this->name = $name; } function setName($newName) { $this->name = $newName; } function getName() { return $this->name; } } $person = new Person2('the name'); echo strlen($this->getName()); ?>
  14. I wrote 5 similar functions to show 5 different stand-alone functions. I did not try to use them at the same time, and they are not supposed to do so either. I suppose I could have written a way to compare these, that simply by putting them all in the same loop. They way of guessing was the variation. All I did was copy/paste them quickly. I suppose the last one I posted is not good enough either to verify the data is a number, just to see if it is in range if it is a number. With the code I wrote, it would never happen.... There would be no SQL injections. Read it, don't just act like a jerk. It takes only what matches the regex, only numbers. It doesn't care about the rest of the input from the user, because it doesn't use it. Neither is there any SQL connection in my code. I think the biggest problem is this site's way of formatting code. I guess this is a problem caused by me. I made the check dependent on regex. You need to understand what it does before you change it. o.O It takes the first number that matches the pattern. The pattern is 1000 OR first character 1-9 the next two 0-9 OR first 1-9 the next one 0-9 OR the first is 1-9.
  15. I think it's more when it comes to reading you got much to learn... It's like you didn't read the code at all... >_> 1. There are 5 functions so the person can see the different variations and see how they perform. No need for callback. Using callback here is very wrong when all I'm doing is showing him the 5 different variations. 2A. That would never happen... if(!empty($_POST['guess']) && preg_match('/[0-9]{1,3}/', $_POST['guess'], $match)){ $number = $match[0]; I know he asked for between 1 and 1000, but again, just for test purposes, I wrote the regex to match between 0 and 999, hence why I used that in the code as well. The functions could easily be adjusted thereafter. No need to prevent when it will never happen, while not completely wrong to do what you are saying, it's pointless. EDIT: I believe this regex would suffice what he wants: '/1000|[1-9][0-9]{1,2}|[1-9][0-9]|[1-9]{1}/' 2B. I don't get what you are talking about here, but I implemented what he request in the 3rd variant. First it guesses a random number. Then it gets to know if its lower or higher. If it's higher then we know the number we are looking for is minimum the number we guessed +1. We then take max-((max-min)/2) and round it. This will end because of +1 and -1 with the max and min value. function computer_guesses($number){ $min = 0; $max = 999; $guess = rand($min,$max); for($guesses=1; $guess!=$number; $guesses++, $guess=round($max-(($max-$min)/2))){ if($number<$guess) $max = $guess-1; else $min = $guess+1; } echo 'Computer guessed the number '.$number.' in '.$guesses.' guesses!<br>'; } ^ It can be done as simple as that. It doesn't verify the number, it just assumes it is between 0 and 999. You can do this instead if you want it to verify all data and be more dynamic: EDIT: I made it like it was request, between 1 and 1000. function computer_guesses($number, $min=1, $max=1000){ if($number>$max || $number<$min){ echo 'The number is too '.($number>$max ? 'large' : 'small').'.<br />'; } $guess = rand($min,$max); for($guesses=1; $guess!=$number; $guesses++, $guess=round($max-(($max-$min)/2))){ if($number<$guess) $max = $guess-1; else $min = $guess+1; } echo 'Computer guessed the number '.$number.' in '.$guesses.' guesses!<br>'; } if(!empty($_POST['guess']) && preg_match('/1000|[1-9][1-9]{1,2}|[1-9]{1}/', $_POST['guess'], $match)){ computer_guesses($match[0]); } ^ This one allows for the user to have typed in something else than just a number, but will only take the first valid number it finds.
  • 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.