Jump to content

localhost

Members
  • Posts

    152
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

localhost's Achievements

Member

Member (2/5)

0

Reputation

  1. EmperorJazzy, is there anyway you could provide the code for your method?
  2. Back into php after about 6 months, trying to re learn alot, started making a quick program that just creates a random math problem, addition or multiplication with numbers 1-9 to verify wether it's a bot or not. So far I've got it generating random math problems with those variables as seen here: http://74.70.230.229/verification/verify.php Now I know I can make it so they must enter the answer and have it verify it, except for the part where I'm trying to figure out the answer to the question myself! In order to display the images for the numbers, I made the variable $keyone equal to images/filename.gif. Now I'm trying to convert it back to the number and then do the math, with horrible failure, wondering if anyone could give any advice. Before you look at the code, I know it is EXTREMELY inefficient and awful, just something to get me back into the programming mindset. Code: <?php function randkey($length) { $pattern = "123456789"; for($i=0;$i<$length;$i++) { if(isset($key)) $key .= $pattern{rand(0,9)}; else $key = $pattern{rand(0,}; } return $key; } $keyone = randkey(1); $keytwo = randkey(1); // determine if its + or * $func_id = rand(0,1); if ($func_id==0) { $function = "+"; $function = "images/plus.gif"; } else { $function = "*"; $function = "images/multiply.gif"; } // end of + or * // convert the number into the number image if ($keyone=="1") { $keyone = "images/one.gif"; } elseif ($keyone=="2") { $keyone = "images/two.gif"; } elseif ($keyone=="3") { $keyone = "images/three.gif"; } elseif ($keyone=="4") { $keyone = "images/four.gif"; } elseif ($keyone=="5") { $keyone = "images/five.gif"; } elseif ($keyone=="6") { $keyone = "images/six.gif"; } elseif ($keyone=="7") { $keyone = "images/seven.gif"; } elseif ($keyone=="8") { $keyone = "images/eight.gif"; } elseif ($keyone=="9") { $keyone = "images/nine.gif"; } if ($keytwo=="1") { $keytwo = "images/one.gif"; } elseif ($keytwo=="2") { $keytwo = "images/two.gif"; } elseif ($keytwo=="3") { $keytwo = "images/three.gif"; } elseif ($keytwo=="4") { $keytwo = "images/four.gif"; } elseif ($keytwo=="5") { $keytwo = "images/five.gif"; } elseif ($keytwo=="6") { $keytwo = "images/six.gif"; } elseif ($keytwo=="7") { $keytwo = "images/seven.gif"; } elseif ($keytwo=="8") { $keytwo = "images/eight.gif"; } elseif ($keytwo=="9") { $keytwo = "images/nine.gif"; } // end of number to number image conversion // display in image the problem - x (+or*) x echo "<img src=\"$keyone\"> <img src=\"$function\"> <img src=\"$keytwo\"> <br />"; // end of display ?>
  3. My registration script is only showing one error if there is one or more errors. this is the script, thanks for any help you can provide: [code] <?php define("IN_OMEGA", true); $omega_root_path = "./"; include($omega_root_path."base.php"); if (isset($_POST['submit'])) { $username = htmlspecialchars(trim($_POST['username'])); $password = md5(crypt(htmlspecialchars(trim($_POST['password'])), strlen($_POST['password']))); $confpass = md5(crypt(htmlspecialchars(trim($_POST['confpass'])), strlen($_POST['confpass']))); $email = htmlspecialchars(trim($_POST['email'])); $errors = array(); if (empty($username)) { $errors[] = "Username field is empty"; } elseif (empty($password)) { $errors[] = "Password field is empty"; } elseif ($password!=$confpass) { $errors[] = "Passwords do not match"; } elseif (empty($email)) { $errors[] = "E-Mail Address field is empty"; } $error_count = sizeof($errors); $error_phrase = (($error_count)==1) ? "<strong>There was a problem with your registration attempt:</strong><br />" : "<strong>There were some problems with your registration attempt:</strong><br />"; if (($error_count)==0) { $create_user = sql_query("INSERT INTO " . USERS_TABLE . " (`user_groupid`, `username`, `password`, `email`, `login_key`, `reg_date`, `reg_ip`, `user_lastactivity`) VALUES ('" . $sitedata['default_ugid'] . "', '" . $username . "', '" . $password . "', '" . $email . "', '" . crypt($username, rand(15,3648)) . "', '" . mktime() . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . mktime() . "')"); } else { echo $error_phrase; foreach ($errors as $error) { echo "-" . $error . "<br />"; } } } $template = new template("templates/" . $sitedata['template_dir'] . "/register.tpl"); $template->output(); ?> [/code]
  4. I want to secure these two as best as possible, for $_POST I am using htmlspecialchars, and trim. I want to refrain from using addslashes/stripslashes. What else should I use?
  5. you mean like... [code] <?php session_start(); if ($_SESSION['name']) { include('incfile'); } else { include('otherincfile'); $_SESSION['name'] = "value"; } ?> [/code] ???
  6. I was hoping someone could help me out with this, it is pretty self-explanatory. [code] $sentence = "i wanna make the beginning letter capital only."; // $words is now an array $words = explode(" ", $sentence); foreach ($words as $word) { $word = strtoupper(substr($word, 1, 1)); echo $word; } [/code] This outputs: AAHEEAN Thanks for any help you can give.
  7. Basically, I know there are tons of free things where you put in your html and it encodes it with javascript so it still works but makes it ridiculously difficult for others to edit. Well...I need this to work with a php function, so I can do encodehtml($input); and have it return the input encoded. Any help? Thanks!
  8. I want to know how to secure my scripts from as much as I possibly can... for $_GET $_POST so far for POST I use htmlentities and mysql real escape string...and for $_GET i have nothing. thanks -dan
  9. my users online script is only displaying one user even if two are active in the past 5 minutes...any ideas? script: [code=php:0]$FiveMinutes = time()-300; $UsersOnline = Query("Select * From `users` Where `LastActive` >= '" . $FiveMinutes . "'"); while ($FetchUsers = FetchArray($UsersOnline)) { $User = array($FetchUsers['Username']); } $Template = new Template("templates/ForumStatistics.tpl"); $Template->Tags(array( 'MemberCount' => "$MemberCount", 'ThreadCount' => "$ThreadCount", 'PostCount' => "$PostCount", 'UsersOnline' => "" . implode(", ", $User) . "")); $Template->Display(); [/code] thanks!
  10. that is the exact code and i still get the error for input().
  11. class_core.php [code=php:0] class Omega { var $Omega; function Omega() { function Query($Query) { $Result = @mysql_query($Query); if (!$Result) { echo mysql_error(); return false; } else { return $Result; } } function FetchArray($SelectQuery) { $Result = @mysql_fetch_array($SelectQuery); if (!$Result) { echo mysql_error(); return false; } else { return $Result; } } function NumRows($Query) { $Result = @mysql_num_rows($Query); if (!$Result) { echo mysql_error(); return false; } else { return $Result; } } function Input($PostInput) { $Output = mysql_real_escape_string(htmlentities($PostInput)); if (!empty($PostInput)) { return $Output; } else { echo 'OmegaInput(): Invalid or no string specified.'; exit(); } } } } ?> [/code] text.php [code=php:0] <?php require('include/class_core.php'); $Omega = new Omega(); $text = $Omega->Input($_POST['text']); echo $text; ?> <form action="<?php $PHP_SELF; ?>" method="post"> texT: <input type="text" name="text" /> </form> [/code] I get the error: Fatal error: Call to undefined function: input() I want to be able to use that clsas core file and have $Omega->Function functions.... any ideas? i know it can be done i just forget how :P
  12. well basically, the strlen stuff, and the $error array isnt working! i have no idea why....sorry about not posting inside the code thing, i did but then i editted it to show updated code.
×
×
  • 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.