הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   אתגר TrubleShooting - מס' #1 בסדרה - הזוכה ... (https://hosts.co.il/forums/showthread.php?t=50582)

Tomer 24-07-07 23:21

אתגר TrubleShooting - מס' #1 בסדרה - הזוכה ...
 
והמנצח לאתגר זה הוא omercnet ו mlnn שזכה במקום השני :)

יפה מאוד (:

DCB 24-07-07 23:27

מזל טוב!

מס' 1 בסדרה?
יהיו עוד אתגרי תיקון טעויות אתה מתכוון בזה?

Tomer 24-07-07 23:47

ציטוט:

נכתב במקור על ידי DCB (פרסם 528928)
מזל טוב!

מס' 1 בסדרה?
יהיו עוד אתגרי תיקון טעויות אתה מתכוון בזה?

כמובן שיהיו, וגם אתגרים מסוגים שונים.

mlnn 25-07-07 00:06

נזכה לראות את הקוד?
עריכה:
מסתבר שגם אני זכיתי ;P

SHeDoN 25-07-07 00:29

מזל טוב,
תהנו מהירוק לשבועיים (:
(שניכם עסק רשום סגולים עדיין, וזה לא יפגע בכם להציע הצעות)

Elad-A 25-07-07 14:04

מזל טוב לכם :)

חיים 25-07-07 14:07

מזל טוב חח יש מצב שראות מה לא היה טוב בקוד של אלו שלא זכו?או לראות את הקודים הזוכים ?;P

omercnet 25-07-07 21:04

כל הכבוד לכל המשתתפים,
הקוד שלי:
PHP קוד:

<?php
error_reporting
(0);

function 
secure_array($array) { # Recursivly dig in an array and secure it.
  
if ( is_array($array) ) {
    
array_map('secure_array'$array);
  } else {
      
mysql_escape_string($array);
      
stripslashes($array);
  }
  return 
$array;
}

session_start(); /* Session must start before any headers are sent */

/* First check if we've seen this dude before, and only then set the session/cookie */
if ($_SESSION['IwasHere'] || $_COOKIE['IwasHere'] ) {
  if ( !isset(
$_POST['Username'] ) { # Make sure we don't block the user after posting the form.
      
die("You have already visited the site. Access denied, you can't view the site.");
  } else {
    
$_SESSION['IwasHere'] = true;
    
setcookie("IwasHere"true ,time() + 3600); # Make sure the cookie will expire in 1 hour from now, instead of deleting it :)
  
}
}

?>
<p>
Hello, welcome to my system. 
You are a new programmer at Hosts.co.il, your employer wants you to check his code and fix the errors. 
He doesn't have any server with PHP installed, so you are allowed to use your eyes only!<br />
<br />
Good luck.</p>
<?php
/* Remove any badly formed vars ($-Database-Username, $Database-Hostname) and sort all db related info into an array */
$db = array();
$db['user']   = "root";
$db['pass']   = "xyzPassWord";
$db['host']   = "localhost";
$db['dbase']  = "hosts";

/* Make sure we don't have any problems connecting to database */
if ( !$db['Connect'] = mysql_connect($db['host'], $db['user'], $db['pass']) ) { die("<b>DB Err:</b> ".mysql_error()); }
if ( !
$db['SelectDB'] = mysql_select_db($db['dbase']) ) { die("<b>DB Err:</b> ".mysql_error()); }

$_POST secure_array($_POST); # Secure all POST information before we handle it.

if ( isset($_POST['Username']) ) {
  
$db['Query'] = mysql_query("SELECT * FROM `tblUsers` WHERE `Username`=\"{$_POST['Username']}\" AND `Password`=\"{$_POST['Password']}\"");
  echo ( 
mysql_num_rows($db['Query']) != "Invalid user and/or password<br />" "User exist and password correct!" );
} else {
  
?>
<FORM METHOD=POST ACTION="">
  Usrname: <INPUT TYPE="text" NAME="Username"><br />
  Password: <INPUT TYPE="password" NAME="Password"><br />
  <INPUT TYPE="submit">
</FORM>
  <?
}
?>


Meir 25-07-07 23:38

מזל טוב לכם, ד"א רק אני לא הבנתי את האתגר ועשיתי בכלל קובץ מרוחק שבודק את התחביר של הPHP?8-*

בניה 25-07-07 23:57

בהתחלה חשבתי שצריך לכתוב משהו בPHP שצריך להריץ את הקוד PHP
|חחח קטן|


כל הזמנים הם GMT +2. הזמן כעת הוא 07:53.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ