Jump to content

iarp

Members
  • Posts

    326
  • Joined

  • Last visited

Everything posted by iarp

  1. $looponce = 1; foreach ($this->info as $k => $v) { if ( (($k == 'subject') && ($v['required'])) && (!$this->settings['customSubject'])) { for ($i = 0; $i <= 0; $i++) { $output[] = $this->display_errors('error_system_subject'); } } if ( (($k == 'name') && (!$v['required'])) || ((!array_key_exists("name", $this->info)) && ($looponce == 1)) ) { $output[] = $this->display_errors('error_system_name'); $looponce++; } } That is my loop that i check things in. What i'm more interested in is the name if statement. If currently checks for a name key in an array(below) and makes sure that it is set to required. If it's not set to required, print out a system error and die()'s. I'm looking for ways to remove the need for program errors and just change them to what is needed to run. What i know how to do is, get into the inner array, what i don't know is how to edit the data and put it back exactly as it was given to me. The inner array data can be put back in any order, but the outer array must be in exact order as it was given. above code $this->info = $formdata; $formdata = array( 'name' => array('name'=>"Full Name", 'required'=>false, 'type'=>'text'), # This needs to be required=>true, but i can't trust the user, which is why i have the error. 'telephone' => array('name'=>"Telephone", 'required'=>false, 'type'=>'phone'), ); Any help is greatly appreciated, also am i doing the foreach loop in the code above in an efficient manner or is there another way?
  2. What errors are you getting with .htaccess ? When i was attempting to make something, i made use of wordpress' htaccess below, and then everything is grab-able with REQUEST_URI. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
  3. Just being sent in an email, no database work here.
  4. My current function for checking over user inputs is below, email and phone numbers work just fine. I'm more worried about the insufficiency of text and textarea, this isn't being used live anywhere atm while i remake it and i'm out of ideas on how to scan general data. Fields passing through text, textarea might be full names, addresses, subjects basically general things. I've been stumbling on ideas of what would be best practice to do this. Any ideas? # $tbc = data to be cleaned # $type = email, phone, text, textarea function escape_data($tbc, $type='text') { switch($type) { case 'email': if(preg_match('/(\w+\.)*\w+@(\w+\.)*\w+(\w+\-\w+)*\.\w+/', $tbc)){ $op = $tbc; } else { $op = false; } break; case 'phone': if (!empty($tbc)) { preg_match_all('/[0-9\(\)+.\- ]/s', $tbc, $cleaned); foreach($cleaned[0] as $k=>$v) { $ready .= $v; } if ((strlen($ready) > 10) && (strlen($ready) <=25)) { $op = $ready; } else { $op = false; } } else { $op = false; } break; case 'text': case 'textarea': if (!empty($tbc)) { $op = strip_tags($tbc); } else { $op = false; } break; default: $op = false; } return $op; }
  5. This is the code i used when i made a registration page, it checked length first which can easily be removed. Mod to your needs. escape_data() was a function i made that made sure it was clean to be inserted into myself database.. if (strlen($_POST['email']) <= 40) { if (eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['email'])))) { $e = escape_data($_POST['email']); } else { $e = FALSE; echo '<p><font color="red" size="+1">Please enter a valid email address!</font></p>'; } } else { $e = FALSE; echo '<p>The email address you provided exceeds maximum length of 40 letters</p>'; }
  6. Eithor change: .style10 { to .style10 a { or move the class="style10" to the <a> itself and not the span. Although if you really need the span for some odd reason, then just do the .style10 a {
  7. <?php if($_GET['cmd'] == 'delete') # If i change the $_GET['cmd'] to $cmd this won't work... at least it doesn't work on my xampp installation. { echo "Deleted: " . $_GET['id']; } for($i=0; $i<10; $i++) { ?> <br/> <a href='<?php echo $_SERVER['PHP_SELF'];?>?cmd=delete&id=<?php echo $i; ?>'>Record #<?php echo $i; ?></a> <?php } ?> ^^ Comments. What i'm refering to is their checking if $cmd is not set and then echoing out the delete link. $cmd is never initialized anywhere, nowhere does it say $cmd = something-here meaning the link would never been shown as long as something is contained in $cmd. With your example i was getting the Deleted: # message but as soon as i made the change thats in my comments it stops working. In the end, the (!isset($cmd) is a waste unless it's being use to determine some type of administration level to stop annonymous people from using it.
  8. It doesn't make sence for it to pass $cmd(through URL's) and $_GET['cmd'] unless PHP makes an automatic assumption that if $cmd isn't assigned it attempts to use a $_GET or a $_POST?
  9. <?php mysql_connect("localhost", "removed", "removed") or die(mysql_error()); mysql_select_db("something_removed") or die(mysql_error()); if($_GET['cmd'] == 'delete') { $id = mysql_real_escape_string($_GET['id']); $sql = "DELETE FROM news WHERE id = $id"; $result = mysql_query($sql) or die(mysql_error()); if($result) { echo "Row deleted!"; } else { echo "There was an error deleting."; } } $data = mysql_query("SELECT * FROM stealth") or die(mysql_error()); Print "<table border='1' cellpadding='3'>"; Print "<th>Url:</th><th>Link:</th><th>Clicks:</th>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td>".$info['folder_name'] . " </td>"; Print "<td>".$info['url'] . " </td>"; Print "<td>".$info['visits'] . "</td>"; if(!isset($cmd)) { echo "<td><a href='delete.php?cmd=delete&id={$info['id']}'>Delete</a></td>"; } Print "</tr>"; } Print "</table>"; ?> Try that, the mysql connection should've come before the deletion process. Whats with the $cmd? I don't see it ever being used (refering to the if(!isset($cmd)) statement) unless thats initialized on another page to determine admin?
  10. $var = "C:/www/Poj/acc/"."acc_namn"; Look like your trying to append acc_namn from a line or two above it. Should've been $var = "C:/www/Poj/acc/" . $acc_namn;
  11. make sure the password column is something like varchar(32). Currently the column looks to only be storing up to 10 characters and not 32.
  12. Made a few changes, quick edits as its late and i'm heading to bed. It may or may not work as i can't test it. Changed AND from the query to && and added brackets around both WHERE clauses removed a space between md5 and ( <?php // Open a connection to the DB $conn = mysql_connect('localhost', 'root', '') or die(mysql_error()); mysql_select_db('Sumeru Skills', $conn); // Start the session (DON'T FORGET!!) session_start(); // Check if user wants to login (GET info) if(isset($_GET['try'])) { // That's nice, user wants to login. But lets check if user has filled in all information if(empty($_POST['username']) || empty($_POST['password'])) { // User hasn't filled it all in! echo 'Please fill in all the required fields!'; } else { // User filled it all in! // Make variables save with addslashes and md5 $username = $_POST['username']; $password = md5($_POST['password']); // Search for a combination $query = mysql_query("SELECT login_id FROM login WHERE (username = '" . $username . "' && password = '" . $password . "') ") or die(mysql_error()); // Save result list($user_id) = mysql_fetch_array($query); // If the user_id is empty no combination was found if(empty($user_id)) { echo 'No combination of username and password found.'; } else { // the user_id variable doesn't seem to be empty, so a combination was found! // Create new session, store the user id $_SESSION['user_id'] = $user_id; // Redirect to userpanel.php header('location: userpanel.php'); } } } ?> <form action="login.php?try=true" method="post"> Username: <input type="text" name="username"><br> <br> Password: <input type="password" name="password"><br> <br> <input type="submit" value="Login!"> </form>
  13. Wheres the code that does the comparison? Is it using proper number of equal signs(==)... etc.
  14. Add this to your $headers $header = "MIME-Version: 1.0" . "\r\n"; $header .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
  15. Besides being able to name your own, is there any real benefit to naming your own sessions rather then using it's own naming scheme?
  16. This is the file <?php $L['base'] = '/lemon/'; class systemsettings { function base() { return $L['base']; } } ?> but "return $L['base'];" inside the class isn't able to access the originating $L at the very start of the script.
  17. without global $L at the top. It says undefined variable on line 51 and line 51 is within the class using $L['base']
  18. I'm having trouble with variables and accessing them within classes. I have $L['base'] = '/home/'; at the start of my script and i need to access it within a class i've built a bit furthur down the page. Parse error: parse error, expecting 'T_FUNCTION' in <LOCATION> on line 3 Line 3 pertains to <?php class systemsettings { global $L; ...etc etc... } ?>
  19. Have you tried changing define("SOCK_PORT", 8080); to straight 80 and leaving 127.0.0.1(my last post) the same?
  20. It seems like you've tried storing the image itself in the database. That or something else has gone wrong that i cant think of. You can't store the image itself in the database, you can store a name value and then refer to it on the servers location like http://www.exa mple.com/images/img.jpg
  21. <?php // Bind Socket to SOCK_PORT on '0.0.0.0' //socket_bind( $sock, '0.0.0.0', SOCK_PORT ) or die(socket_strerror(socket_last_error($sock))); ## Comment out this line socket_bind( $sock, '127.0.0.1', SOCK_PORT ) or die(socket_strerror(socket_last_error($sock))); ## Uncomment this line ?> Future Use: The original uncommented line was trying to use the ip address 0.0.0.0 instead of loopback 127.0.0.1 (as per the commented line)
  22. I think there should or (or already is) a law named for these situations. As soon as i'll paste some troublesome code to a friend over IM.... i'll figure out wtf's wrong as soon as i hit enter.
  23. I always thought you put "or die("Error")" after items to see whats wrong rather then wrapping it around potentially working items... isn't die() only activated on PHP errors
  24. I've never used PHPNuke before, but if it works as i think it does, edit your home page and edit it back to whatever you had before. Someone's gone and copied the source code to a youtube page and pasted part of it on the home page screwing everything up.
  25. Looking at your source code, it seems that just below a youtube embedded video is a <script> that is not closed properly with </script> and it also looks like the script isn't properly finished. <script type="text/javascript"> var MSG_Hide = 'Hide'; var MSG_Show = 'Show'; var MSG_Login = 'Please sign in to perform this operation.'; var MSG_Loading = 'Loading...'; var MSG_ShowingAll = 'Showing All Videos'; var MSG_LoginFavorites = 'You must be logged in to add this video to your favourites'; var MSG_LoginAddPlaylist = 'You must be logged in to add this video to a playlist.'; var MSG_LoginReportConcern = 'You must be logged in to report a concern.'; var MSG_FlagDefault = 'Select a Reason'; var swfUrl = canPlayV9Swf() ? 'http://s.ytimg.com/yt/swf/watch-vfl89162.swf' : 'http://s.ytimg.com/yt/swf/watch_v8-vfl89162.swf'; var swfArgs = {"usef": 0, "fexp": "903900,902904", "vq": null, "video_id": "BarcpvrlWoI", "l": 487, "sk": "UWn-vv5BSO_gLzUponUBBqmU4AW8bpdlC", "fmt_map": "5/0/7/0/0", "t": "v</font></td> ############ The line above this comment is the problem, it isn't closed properly (or finished for that matter) </tr> </table></td> </tr> </table></td> As well, a bit above that section you have <link rel="stylesheet" href="http://s.ytimg.com/yt/cssbin/www-core-vfl89818.css" type="text/css"> corect me if i'm wrong but that needs to be closed as well <link rel="stylesheet" href="http://s.ytimg.com/yt/cssbin/www-core-vfl89818.css" type="text/css" />
×
×
  • 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.