Jump to content

Zhadus

Members
  • Posts

    376
  • Joined

  • Last visited

    Never

Everything posted by Zhadus

  1. If (condition1) echo '<img src="1.jpg" />'; else echo '<igm src="2.jpg" />';
  2. Submit the form to itself to do the checking, or change this redirect: if(!$resp->is_valid) { header("location:captcha_error.html"); die(); As far as saving the values if you navigate OFF of the page, you'll need to either store them in a database until they return and reload them, or if the information doesn't need to be secure, you can pass it back through the URL and use a $_GET request.
  3. I agree with Ken2k7 that a database would be optimal, but this saves on queries to the database, and there are very few people who would rather decode a URL than just click the link. Here are the two functions I use: function getLink($matches) { if (preg_match('/^www\./', $matches[2])) $link = 'http://' . $matches[2]; else $link = $matches[2]; $link = base64_encode($link); $result = $matches[1] . 'link.php?url=' . $link. $matches[3]; return $result; } function linkMask($text) { $pattern = '/(<a href=["|\'])(.*?)?(["|\']>)/'; $text = preg_replace_callback($pattern, "getLink", $text); return $text; } I can't guarantee it's bug free. You'll want to run whatever text you have through the linkMask() function and it will do the rest. It also fixes links incase you mistakenly type www.blah.com instead of using the http://. To use it, the links are just in normal "a href" format that it checks for. On my link.php page, it looks like this: $target = base64_decode($_GET['url']); header ("Location: $target"); Mine has a lot more features, but that's the basic jist and I think you're knowledgeable to modify it to your needs.
  4. If you used mine instead of his, I'm an idiot $url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $arr = array("dog", "cat"); $find = ''; foreach($arr as $key => $val) { $find = strstr($url, $val); echo $find; } Also, what exactly are you expecting and what are you getting?
  5. gevans made the fix, but you do realize you're overwriting $find if it finds 'dog' anyway, right? Try this: $url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $arr = array("dog", "cat"); $find = ''; foreach($arr as $key =>) { $find = strstr($url, $key); echo $find; }
  6. I'd recommend using a different type of system so you don't need to manually add in all the links you want to do that to. I personally use base64 encoding of my urls, and send them a link.php page with the encoded url. Then I decode and use a header to redirect. It's easy and clean, and has the same affect.
  7. $newcode = preg_replace('%{sls}(.*){/sle}%s', $replacewith, $input);
  8. If CountProfiles returns a value, you can just do this: echo '<span id="stats">'. CountProfiles() .'</span>';
  9. I'd recommend putting anything that you use more than once in a library as you never know what may use them again in the future. Also as long as you are doing some reworking, take a look at some other functions, you may be able to combine a few that do similar things.
  10. You're right for a slow load. Could have it round to the closest 2 minute interval. Just as you said, it doesn't need to be completely secure, just so that the general script kiddy won't have access basically. Just manipulate the date() command to factor it with your hash variable.
  11. Well it certainly wouldn't be easy, but it does depend on the variables and how many of them would differ from time to time. If you make your hash variable related to the current time, it would be much more difficult to brute force/experiment.
  12. How secure do you need it? If you can decrypt it, someone else can too.
  13. I guess I'm not the only one that doesn't have a clue for what you're trying to do. How is your database setup and what exactly are you trying to do?
  14. Yeah, I didn't read through it as well as I should have, instead of forgetting the escape, should have just removed it completely.
  15. Forgot to escape the first double quote before the username variable. <?php echo "<b><font color=\"$color\"><a href='../profile.php?id=\"$username\"'></b></td>"; ?>
  16. As previous people have stated, please post the code. If you just don't have the right permissions set, go to your MySQL database and give yourself the right permissions, otherwise change the code in the admincp to check for different permissions that you have set.
  17. I understand you don't have access to the classes, but what is getName() structured like?
  18. The variable $utilsavelink only exists within the function. If you adjust things a little bit, you can better the usability of your function. Instead of 'echo'ing the result in the function, have it 'return' a value. Like this: <?php // -------- GENERATE UTIL SAVINGS LINK -------- function utilsave_link($model_id, $homeormodel = 'model', $linktext = 'View Photos'){ $path_to_photo_folder = HM_ASSETS_PATH.$homeormodel.'s/'.$model_id.'/utilsave/'; $photoinfo = dirList($path_to_photo_folder); $i = 6; foreach($photoinfo as $photo){ if($i > 6){$nameit = '';}else{$nameit = $linktext;} $utilsavelink .= '<a href="/hm_assets/'.$homeormodel.'s/'.$model_id.'/utilsave/'.$photo.'" rel="lytebox" title="Energy Savings">'.$nameit.'</a>'; $i++; } return $utilsavelink; } ?> Now in your display page, set it up like this: <?php $utilsavelink = utilsave_link($modelsubmodel[base]->id, 'model', 'Click here'); if ($utilsavelink != null) {?> <div class="utilsave"><?php echo $utilsavelink ?> to view the <?php echo $modeltitle; ?>'s utility savings. </div> <?php }?>
  19. Is this code: <?php if($utilsavelink == null) echo 'style="display:none;"'; ?> On the display page or in the function?
  20. What you need to do is modify the following: <?php // Get key day informations. // We need the first and last day of the month and the actual day $today = getdate(); $firstDay = getdate(mktime(0,0,0,$today['mon'],1,$today['year'])); $lastDay = getdate(mktime(0,0,0,$today['mon']+1,0,$today['year'])); ?> That code loads the first and last day of the month according to todays date. Passing a global variable and drawing it using $_GET will allow you to manipulate that portion. We can quite simply just do this if we pass "month" and "year" though the address bar: <?php $next[0] = $today['mon'] + 1; if ($next[0] > 12) { $next[0] = 1; $next[1] = $today['year'] + 1; } $prev[0] = $today['mon'] - 1; if ($prev[0] < 1) { $prev[0] = 12; $prev[1] = $today['year'] - 1; } $link[0] = 'calendar.php?month=' . $next[0] . '&year=' . $next[1]; $link[1] = 'calendar.php?month=' . $prev[0] . '&year=' . $prev[1]; ?>
  21. If DB is not an option, perhaps use a flatfile (textfile) to save the information. Otherwise for your question trying to draw the cookie value, it's: $variable = $_COOKIE['origTime'];
  22. I'd recommend going about it differently. Anyone can disable cookies and then send multiple emails. Why don't you store the information in a database. You can track the user by their email or by their IP address (The latter being less useful to you). From that you can just use a timestamp for when the email was sent.
  23. <?php if (isset($_GET['id'])) { // Show Page } else { // Don't Show Page or Redirect } ?> Like that?
×
×
  • 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.