Jump to content
xisto Community

TavoxPeru

Members
  • Content Count

    865
  • Joined

  • Last visited

Everything posted by TavoxPeru

  1. Hi there, your problem is caused by the title tag in your main news page, simply replace with </title> your close tag. <html><head><title>JoVolKa Unofficial News</title><link rel="stylesheet" type="text/css" href="../style.css" /></head><body>... Best regards,
  2. Thanks for the share, is a nice tool. Very simple and effective, so i just add it to my arsenal of tools. In relation to url2jpeg, i try it too but definitely i prefer url2bmp, because the last one includes the same functionality and its free. best regards,
  3. Wow, this is really very cool and demostrates the power of the mix of HTML, CSS and Javascript, i just try it with IE 6 and it shows an alert window because, Internet Explorer, doesn't understand these basic concepts correctly and does not render PNGs correctly. So, i open it with Firefox and works and looks very fine, but i think it has an error, because the default background image shows incomplete.Best regards,
  4. Yes, beginners MUST learn first HTML, it would help in many ways, especially when you work with software like FRONTPAGE, DREAMWEAVER and alike, that include a lot of extra and unnecessary HTML code, now, with the use of templates you can achieve easily and quickly very good results but always you must edit your HTML code, and sometimes this templates are a bit difficult to edit. BTW, i still use my text editor -editplus- to make quick changes to my work. Best regards,
  5. Ferant DHTML Studio Lite is a free browser-based wizard that may be used to create DHTML windows or pop-us in 3 easy steps: Choose a template. Customize properties and methods. Copy some javascript code and some images if needed. It's written in Javascript and the scripts are compatible with most browsers, including Internet Explorer, Netscape Navigator, Mozilla, and Opera, so you only need a browser to run it It offers twelve different templates with 79 customizable properties, such as dragging ability, resizability, colors, and fonts. Unfortunately this software is a bit older and seems like the creator simply disappear because i don't find any update available and it's website simply redirecting to another website. You can download from here Best regards,
  6. Hi, I agree with The Gimp, A few months ago i started to use it and i like it very much, is a very good software, configurable in many ways, with lots of add-ons and of course IT IS FREE.Best regards,
  7. Hi, i just visit this website and its very cool and complete, thanks for share with us. best regards,
  8. Yes, it is possible to do, the only thing to care about is that you must set write priviligies to this folder with CHMOD 777. To add new news to your table you only need a page with a FORM with a TEXTAREA field for the news and other page to process the submited data. FormNews.htm:Page with the form, i only put the form elements <form action="addnews.php" method="post">News: <textarea rows="3" name="news" cols="100"></textarea><br /><br /><input name="cmdAdd" type="submit" value="Add News" /></form> addnews.php:Page that process the submited data to insert into the database.<?phpfunction safeEscapeString($string){ if (get_magic_quotes_gpc()) { return $string; } else { return mysql_real_escape_string($string); // return mysqli_real_escape_string($string); }}include ("connectdb.php"); // connect and select your database$news=safeEscapeString($_POST["news"]);mysql_query("insert into news(news) values ('$news')") or die (mysql_errno(). ": " . mysql_error() );mysql_close();Header("Location: FormNews.htm");exit();?>In your news.php your select statement include the LIMIT clause like this:<?phpinclude ("connectdb.php"); // connect and select your database$query_rsNews = "SELECT * FROM news ORDER BY id DESC LIMIT 20";$rsNews = mysql_query($query_rsNews) or die(mysql_error());while($row_rsNews = mysql_fetch_array($rsNews)) { echo $row_rsNews["id"] . $row_rsNews["news"];}?>For moderators will be the same thing. Best regards,
  9. Another way to do this is by setting the image width and height as 100 percent inside the <img> tag. The browser then resizes the image according to the window's size, and with Javascript by using document.body.clientWidth and document.body.clientHeight that returns the width and height of the active window, and one function for the On_Load event which sets the image width and height and other to the onresize event which refresh the page. BTW, i dont test this with Firefox but i guess it will work. Best regards,
  10. Hi I use the following code to resize images of any size to the size that i need.<?php//$width: image width//$height: image height//$target: target image width or heightfunction imageResize($width, $height, $target) {if ($width > $height) { $percentage = ($target / $width);} else { $percentage = ($target / $height);}$width = round($width * $percentage);$height = round($height * $percentage);return " width=\"$width\" height=\"$height\"";}// source image$photo="images/anyphoto.jpg";// populate attributes obtained from the image $PropImg = array(0,0,0,"");$PropImg = GetImageSize($photo);if (isset($PropImg[0])) $nW = $PropImg[0];else $nW = 100;if (isset($PropImg[1])) $nH = $PropImg[1];else $nH = 100;// generate html img tag$Img="<img border='0' hspace='3' align='left'";$Img.=" src=\"" . $photo . "\"" . imageResize($nW,$nH, 220) . ">";// show the imgecho $Img;?> Very simple but function very well Best regards,
  11. You are right, and that happens with a lot of functions in the Php Manual. BTW, i read that post too and i finish very disapointed Excellent info, very useful especially this last paragraph. I have a question, how and where i use the Reply-to function??? best regards,
  12. I dont know if via HTTP Headers you can do it, i think that a simple way will be by using an array with all the titles of the web pages that you need or may be by using a template engine. best regards,
  13. login.php: trivia's login file. <?phprequire 'config.php';if($logged_in == 1) { die('You are already logged in, '.$_SESSION['nickname'].'. <a href="logout.php">Click here to logout</a>.');}?><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Trivia - Login</title><style type="text/css"><!--body { margin:10;background-color:#131313; font-family:Verdana, Arial; font-weight:bold; font-size:9px; color:#FFFFFF; }.register_box { border: 1px solid #323232; background-color: #202020; font-family: Verdana, Arial; font-weight: bold; font-size: 9px; color: #FFFFFF; } P { font-family:Verdana, Arial; font-size:11px; color:white; text-align:justify }background-color: #009900; cursor: pointer; }.legend {font-family: Verdana, Arial; font-size:8pt; font-weight:bold; color:white; width:50%; text-align:right; padding-left:2px; padding-bottom:3px; padding-top:3px }.title { font-family: Verdana, Arial; font-size:14pt; font-weight:bolder; color:white; text-align:center; width:100%; padding:10px }.field {font-family: Verdana, Arial; font-size:8pt; color:white; text-align:left; width:50%; padding-left:2px; padding-right:2px; padding-bottom:3px; padding-top:3px }//--></style></head><body><?phpif (isset($_POST['submit'])) { // if form has been submitted /* check they filled in what they were supposed to and authenticate */ if(!$_POST['nname'] || !$_POST['passwd']) { die('You did not fill in a required field.'); } // authenticate. if (!get_magic_quotes_gpc()) { $_POST['nname'] = addslashes($_POST['nname']); } $Sqlcheck="SELECT nickname, password, last_login, test_day FROM registration WHERE nickname='" . $_POST["nname"] . "'"; $check=mysql_query($Sqlcheck) or die(mysql_error()); if(mysql_num_rows($check)<1) { die("That nickname does not exist in our database. Please <a href=\"registration.php\">click here</a> to register and try again"); } $info = mysql_fetch_array($check); // check passwords match $_POST['passwd'] = stripslashes($_POST['passwd']); $info['password'] = stripslashes($info['password']); $_POST['passwd'] = md5($_POST['passwd']); if ($_POST['passwd'] != $info['password']) { die('Incorrect password, please try again.'); } // if we get here username and password are correct, // check last login date and set last login date, number of plays // update database and register session variables. $date=date("Y-m-d",strtotime("now")); $times_play=0; //number of tests played today $last=$date; // default last login date $last_login_date = $info['last_login']; // user's last login date if($last_login_date == $date) { $times_play=$info['test_day']; $last = $last_login_date; } $update_login = "UPDATE registration SET last_login =now(), test_day=".$times_play. " WHERE nickname = '".$_POST['nname']."'"; mysql_query($update_login) or die(mysql_error()); $_POST['nname'] = stripslashes($_POST['nname']); $_SESSION['nickname'] = $_POST['nname']; $_SESSION['password'] = $_POST['passwd']; $_SESSION['tests_count'] = $times_play; mysql_close(); // check number of test played by the user if ($_SESSION['tests_count']==5) { $template = "template4.html"; if(!$output = file($template)) die("Couldn't open the template file ($template). Please check and make sure that this file is where it's supposed to be."); $output = implode("\n", $output); $output = str_replace("%%NICKNAME%%", $_SESSION['nickname'], $output); echo $output; exit(); }?><h1>Logged in</h1><p>Welcome back <?php echo $_SESSION['nickname']; ?>, you are logged in and ready to play our <a href="trivia.php">TRIVIA</a>.<br /><br /><a href="logout.php">Click here to logout</a>.</p><?php} else { // if form hasn't been submitted?><div align="center"> <center> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table align="center" border="0" width="60%" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" class="title">LOGIN</td> </tr> <tr> <td class="legend">Nickname</td> <td class="field"><input class="register_box" TYPE="TEXT" NAME="nname" SIZE="10" MAXLENGTH="15" tabindex="1"></td> </tr> <tr> <td class="legend">Password</td> <td class="field"><input class="register_box" TYPE="PASSWORD" NAME="passwd" SIZE="10" MAXLENGTH="32" tabindex="2"></td> </tr> <tr> <td width="100%" colspan="2" align="center" style="padding-top:3px;padding-bottom:3px"> <input class="register_box" type="submit" value="Login" name="submit" tabindex="3" > <input class="register_box" type="reset" value="Reset" tabindex="4"> </td> </tr> </table> </form> </center></div></body></html><?php}?> trivia.php: The Trivia's main file where we show the questions and its corresponding result using a simple html template file that include a script in javascript to control the time.<?phprequire("config.php"); if ($logged_in == 0) { die('Sorry you are not logged in, this area is restricted to registered members. <a href="login.php">Click here</a> to log in.');}# check number of plays per dayif ($_SESSION['tests_count']==5) { $template = "template5.html"; if(!$output = file($template)) die("Couldn't open the template file ($template). Please check and make sure that this file is where it's supposed to be."); $resultoutput=""; $formoutput=""; $output = implode("\n", $output); $output = str_replace("%%RESULT%%", $resultoutput, $output); $output = str_replace("%%NICKNAME%%", $_SESSION['nickname'], $output); $output = str_replace("%%FORM%%", $formoutput, $output); echo $output; exit();}# check number of questions per playif (!isset($_SESSION['questions_count'])) { $_SESSION['questions_count']=1;} else { if($_SESSION['questions_count']<$questions_test) { $_SESSION['questions_count']++; } else { unset($_SESSION['questions_count']); $update_login = "UPDATE registration SET test_day=test_day+1 WHERE nickname = '".$_SESSION['nickname']."'"; mysql_query($update_login) or die(mysql_error()); $SqlTestcheck="SELECT test_day FROM registration WHERE nickname='" . $_SESSION["nickname"] . "'"; $Testcheck=mysql_query($SqlTestcheck) or die(mysql_error()); $Testinfo = mysql_fetch_array($Testcheck); $_SESSION['tests_count'] = $Testinfo["test_day"]; $template = "template3.html"; if(!$output = file($template)) die("Couldn't open the template file ($template). Please check and make sure that this file is where it's supposed to be."); $resultoutput=""; $formoutput=""; $output = implode("\n", $output); $output = str_replace("%%RESULT%%", $resultoutput, $output); $output = str_replace("%%NICKNAME%%", $_SESSION['nickname'], $output); $output = str_replace("%%PLAYSLEFT%%", ($total_tests - $_SESSION['tests_count']), $output); $output = str_replace("%%FORM%%", $formoutput, $output); echo $output; mysql_close(); exit(); }}#$template is the template file the script will use to#format the form. $template = "formtemplate.html";#load the template fileif(!$output = file($template)) die("Couldn't open the template file ($template). Please check and make sure that this file is where it's supposed to be.");$output = implode("\n", $output);#calculate number of questions in the database$SqlTotalQuestions=mysql_query("select max(id) as total from question");$RowTotalQuestions=mysql_fetch_array($SqlTotalQuestions);$TotalQuestions=$RowTotalQuestions["total"];#Pick a random question$RandomQuestion=rand(1,$TotalQuestions);$SqlQuestionSelected=mysql_query("select id, question from question where id=$RandomQuestion") or die ("Error... Cant select a valid question");#populate the random question$RowQuestionSelected=mysql_fetch_array($SqlQuestionSelected);$TheQuestion = htmlspecialchars($RowQuestionSelected["question"]);$IdTheQuestion = $RowQuestionSelected["id"];#select/populate choices array$SqlA = "SELECT * from answer where answer.idq=$IdTheQuestion";$regA=mysql_query($SqlA) or die(mysql_error());$j=0;while($Answers = mysql_fetch_array($regA) ) { $IdChoices[$j]=$Answers["id"]; $Choices[$j]=$Answers["answer"]; $j++;}#build form output for CHOICES$nChoices=sizeof($Choices);$choiceoutput="";$Text="";for($i=0; $i<$nChoices; $i++) { $Text='<input type="radio" name="answer" value="' . $IdChoices[$i] . '"'; if($i==0) { $First=" CHECKED "; $Text.=$First; } $Text.="> ". $Choices[$i] . "</input>"; $choiceoutput.= $Text."<br />";}#close the database connection, we just dont need anymoremysql_close();$time = time();$formoutput ="<input type=\"hidden\" name=\"question\" value=\"" . $TheQuestion . "\">";$formoutput .="<input type=\"hidden\" name=\"idquestion\" value=\"" . $IdTheQuestion . "\">";$formoutput .="<input type=\"hidden\" name=\"time\" value=\"" . $time . "\">";$formoutput .= $choiceoutput;$resultoutput=($_REQUEST["resultoutput"]=="") ? "" : $_REQUEST["resultoutput"];$output = str_replace("%%RESULT%%", $resultoutput, $output);$output = str_replace("%%NUMQUESTION%%", $_SESSION['questions_count'], $output);$output = str_replace("%%QUESTION%%", $TheQuestion, $output);$output = str_replace("%%FORM%%", $formoutput, $output);echo $output;exit();?> trivia1.php: File that judge the user's answer.<?phprequire("config.php"); if ($logged_in == 0) { die('Sorry you are not logged in, this area is restricted to registered members. <a href="login.php">Click here</a> to log in.');}#$progressive determines whether the user is given another#random question after answering a question. If $progressive#is set to 0, the script will only display the results from#the previous question. If set to 1, it will display the#results along with another question. Because questions are#chosen in random order, it's possible that the same question#will appear twice in a row during a progressive game.$progressive = 1;$result="";$Points=1;#Judge the user's answer, if one was submittedif(isset($_POST["question"])) { if($_POST["question"]) { #Remove slashes that came through as submitted data $question=stripslashes($_POST["question"]); $idquestion=$_POST["idquestion"]; if($_POST["answer"]) { #Find the if the answer submitted is the correct choice of the relevant question $SqlA = "SELECT * from answer where answer.idq=$idquestion and answer.id=" . $_POST["answer"]; $regA=mysql_query($SqlA) or die(mysql_error()); $RowA = mysql_fetch_array($regA); if ($RowA["correct"]==1) { # update user stats and display if its a correct answer $result="Correct!"; } else { $result="Incorrect!"; $Points=-1; } } $update_points = "UPDATE registration SET points=points+$Points WHERE nickname = '".$_SESSION['nickname']."'"; mysql_query($update_points) or die(mysql_error()); #close the database connection, we just dont need anymore mysql_close(); #Should we show another question? if(!$progressive) exit(); } else { $result = ""; }}else { $result = "";}$Url2Go="trivia.php?resultoutput=$result";Header("Location: $Url2Go");exit();?>That's all the php code required, the following are the html templates files to run correctly the trivia timed test: formtemplate.html: template file that include the script to control the time. <html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>::Trivia::</title></head><body bgcolor="#99CCCC"><form name="form" method="POST" action="trivia1.php"><h3 align="center"><font color="#993300">Trivia!</font></h3><table width="90%" border="0" align="center" bgcolor="#000000" cellpadding="0" cellspacing="1"> <tr> <td> <table width="100%" border="0" bgcolor="#FFFFFF"> <tr> <td style="text-align:center;font-size:10pt;font-family:Verdana;font-weight:bold; text-decoration:underline">%%RESULT%% </td> </tr> <tr> <td style="text-align:left;font-size:10pt;font-family:Verdana, Arial;">Question #%%NUMQUESTION%%: <span style="font-weight:bold;color:#FF0000;font-size:12pt">%%QUESTION%%</span> </td> </tr> <tr> <td style="text-align:left;font-size:10pt;font-family:Verdana, Arial;">Which answer looks the best? </td> </tr> <tr> <td style="text-align:left;font-size:10pt;font-family:Verdana, Arial;padding-left:20px">%%FORM%% </td> </tr> <tr> <!-- countdown script --> <td style="text-align:left;font-size:10pt;font-family:Verdana, Arial;">Time Left: <input type="text" name="seconds" size="3"> <script language="javascript" type="text/javascript"> var myTime = 20; function countDown() { document.form.seconds.value = myTime; if (myTime == 0) { location.href="trivia1.php"; } else if (myTime > 0) { myTime--; setTimeout("countDown()",1000); } } countDown(); </script> </td> </tr> <tr> <td style="text-align:center"><input type="submit" value="Answer" name="submit"> </td> </tr> </table> </td> </tr></table></form><p align="center"><a href="logout.php"><font size="2" face="Verdana, Arial">Click here to Logout</font></a></p></body></html> template4.html: Template file used in the login.php file if the user complete his number of tests per day.<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>::Trivia::</title></head><body bgcolor="#99CCCC"><h2 align="center"><font color="#FFFFFF">Trivia!</font></h2><table width="90%" border="0" align="center" bgcolor="#000000" cellpadding="0" cellspacing="1"> <tr> <td> <table width="100%" border="0" bgcolor="#131313"> <tr> <td> <p><font size="2" face="Verdana, Arial">Sorry, but today you can not play our Trivia again, because you complete all your plays, please try again tomorrow.</p> <p><font size="2" face="Verdana, Arial">Thanks to play our Trivia %%NICKNAME%%. <a href="logout.php"><font size="2" face="Verdana, Arial">Click here to Logout</font></a>.</p> </td> </tr> </table> </td> </tr></table></body></html> template5.html: Template file used in the trivia.php file if the user complete his number of tests per day.<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>::Trivia::</title></head><body bgcolor="#99CCCC"><h3 align="center"><font color="#993300">Trivia!</font></h3><table width="90%" border="0" align="center" bgcolor="#000000" cellpadding="0" cellspacing="1"> <tr> <td> <table width="100%" border="0" bgcolor="#ffffff"> <tr> <td> <p><font size="2" face="Verdana, Arial">Thanks to play our Trivia %%NICKNAME%%</p> <p><font size="2" face="Verdana, Arial">Sorry, but today you can not play our Trivia again, because you complete all your plays, please try again tomorrow.</p> </td> </tr> </table> </td> </tr></table><p align="center"><a href="logout.php"><font size="2" face="Verdana, Arial">Click here to Logout</font></a>.</p></body></html> template3.html: Template file used in the trivia.php file if the user complete all the questions of the test.<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>::Trivia::</title></head><body bgcolor="#99CCCC"><h3 align="center"><font color="#993300">Trivia!</font></h3><table width="90%" border="0" align="center" bgcolor="#000000" cellpadding="0" cellspacing="1"> <tr> <td> <table width="100%" border="0" bgcolor="#FFFFFF"> <tr> <td> <p align="center"><font size="2" face="Verdana, Arial"><b><u>%%RESULT%%</u></b></font></p> <p><font size="2" face="Verdana, Arial">Thanks to play our Trivia %%NICKNAME%%</p> <p><font size="2" face="Verdana, Arial">You can play our Trivia %%PLAYSLEFT%% more time(s).</p> </td> </tr> </table> </td> </tr></table><p align="center"><a href="logout.php"><font size="2" face="Verdana, Arial">Click here to Logout</font></a> or <a href="trivia.php"><font size="2" face="Verdana, Arial">Click here to Play again</font></a>.</p></body></html>Well, as you can see there are a lot of improvements to do and i must do when i have some time in the near future i hope, so please feel free to PM me if you have any question. Best regards,
  14. Hi, you have a lot of good websites to learn php. I recomend you to first download php from the oficial website: PHP Download Page, then read the simple tutorial here: PHP: A simple tutorial and finally i suggest to download the official php help file: PHP Documentation. BTW, dont forget to visit frecuently this forum you will find a lot of good examples and many people that can help you . Best regards,
  15. Well, as i promised in my last post yesterday here is the code of the script, it is not complete yet because i will make some improvements but the basical functioning is complete. Today is my happybirthday so i only post the database tables and the config files: DB Tables Files: CREATE TABLE registration ( id int(10) unsigned NOT NULL auto_increment, name varchar(45) NOT NULL default '', email varchar(100) NOT NULL default '', nickname varchar(15) NOT NULL default '', password varchar(32) NOT NULL default '', is_activated char(1) NOT NULL default '0', activation_code varchar(25) NOT NULL default '', regdate date NOT NULL default '0000-00-00', last_login date NOT NULL default '0000-00-00', test_day tinyint(1) unsigned NOT NULL default '0', points int(10) NOT NULL default '0', PRIMARY KEY (id) ) TYPE=MyISAM COMMENT='Trivia Users'; CREATE TABLE question ( id smallint(5) unsigned NOT NULL auto_increment, question varchar(255) NOT NULL default '', PRIMARY KEY (id) ) TYPE=MyISAM COMMENT='Trivia Questions'; CREATE TABLE answer ( idq smallint(5) unsigned NOT NULL default '1', id tinyint(3) unsigned NOT NULL auto_increment, answer varchar(255) NOT NULL default '', correct tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (idq,id) ) TYPE=MyISAM COMMENT='Trivia Answers' ; config.php: general configuration file <?php$db_user = "your_db_user"; $db_password = "your_db_userpassword";$database = "your_db";$server = "localhost";$questions_test=5; // number of questions per test$total_tests=5; // number of tests per day// connect to servermysql_connect($server, $db_user, $db_password) or die ("Could not connect to the Server!" . mysql_errno() . ": " . mysql_error() );// select databasemysql_select_db($database) or die ("Could not select the Database!" . mysql_errno() . ": " . mysql_error() );include('check_login.php');?> check_login.php: user checking configuration file<?php/* check login script, included in config.php. */session_start();if (!isset($_SESSION['nickname']) || !isset($_SESSION['password'])) { $logged_in = 0; return;} else { // remember, $_SESSION['password'] will be encrypted. if(!get_magic_quotes_gpc()) { $_SESSION['nickname'] = addslashes($_SESSION['nickname']); } // addslashes to session username before using in a query. $pass=mysql_query("SELECT password FROM registration WHERE nickname='".$_SESSION['nickname']."'"); if(mysql_num_rows($pass) != 1) { $logged_in = 0; unset($_SESSION['nickname']); unset($_SESSION['password']); // kill incorrect session variables. } $db_pass = mysql_fetch_array($pass); // now we have encrypted pass from DB in //$db_pass['password'], stripslashes() just incase: $db_pass['password'] = stripslashes($db_pass['password']); $_SESSION['password'] = stripslashes($_SESSION['password']); //compare: if($_SESSION['password'] == $db_pass['password']) { // valid password for username $logged_in = 1; // they have correct info in session variables. } else { $logged_in = 0; unset($_SESSION['nickname']); unset($_SESSION['password']); // kill incorrect session variables. }}// clean upunset($db_pass['password']);$_SESSION['nickname'] = stripslashes($_SESSION['nickname']);?> To be continued... Best regards,
  16. Thanks, i do something like that with no goods results in the timer, so i follow your advice and redirect to XX page and THAT'S IT . I will post all the code tomorrow. CLICK HERE TO PLAY TRIVIA Best regards,
  17. Well, after some days i return to this script -i'm very busy with a lot of work- so, i just upload the new version, it works but i have some trouble with the 20s time counter, the problem is that the form.submit() function doesnt work when the time is over. Here's the problematic code: $formoutput = "<form name=\"form\" method=\"POST\" action=\"".$_SERVER["PHP_SELF"]."\"><input type=\"hidden\" name=\"question\" value=\"" . $TheQuestion . "\">";$formoutput .= "Time Left: <input type=\"text\" name=\"seconds\" size=\"3\"><br /><br />\n" ."<script type=\"text/javascript\">\n" ."var myTime = 20;\n" ."function countDown() { \n" ."\tdocument.form.seconds.value = myTime; \n" ."\tif (myTime == 0) { \n" ."\t\t// http://forums.xisto.com/no_longer_exists/; ."\t\t//clearTimeout(timer1);\n" ."\t\t//document.form.submit()\n" ."\t\tlocation.href ='" . $_SERVER["PHP_SELF"]. "';\n" ."\t}\n" . "\telse if (myTime > 0) { \n" ."\t\tmyTime--; \n" ."\t\tsetTimeout(\"countDown()\",1000); \n" ."\t}\n" ."}\n\n" ."countDown();\n" ."</script>"; $formoutput .= $choiceoutput;$formoutput .= "<br><input type=\"submit\" value=\"Answer\" name=\"submit\"></form>"; Best regards,
  18. I dont know if this the correct way to post this enhancement so to the admins please let me know if im wrong ok???. In my previous post i drop a question related to how to implement a login counter attempts, for example 3 login attempts. Well, i go ahead and finish the script to support this behavior. So, if you want to implement this you only need to insert before line 2 of the chksec.php script the following code: session_start();if (!isset($_SESSION['access_count'])) { $_SESSION['access_count']=1;}else { $_SESSION['access_count']++;}if($_SESSION['access_count']>3) { unset($_SESSION['access_count']); $_SESSION = array(); // reset session array session_destroy(); // destroy session. die( 'You exceed the maximum number of login attempts.' );}That's it Best regards,
  19. Thanks mastercomputers great code. I go ahead and implement your changes to my script and works fine and also i include the use of the defined() and define() functions to allow direct access to the included file only by the parent script as discussed here:CMS103 - Securing Your Website. The new chksec.php: <?phpdefined( 'MY_ACCESS_CODE' ) or die( 'Direct Access to this location is not allowed.' );function_exists('valid_user') || require('htpasswd.inc.php'); $userpass = load_htpasswd();if(!isset($_SERVER['PHP_AUTH_USER'])){ Header("WWW-Authenticate: Basic realm=\"Restricted Access\""); Header("HTTP/1.1 401 Unauthorized"); echo "Authorization Required."; exit();}if(!valid_user($userpass,$_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'])){ Header("WWW-Authenticate: Basic realm=\"Restricted Access\""); Header("HTTP/1.1 401 Unauthorized"); echo "Authorization Required."; exit();}?>This is the new test file:<?phpdefine( "MY_ACCESS_CODE", true );include("chksec.php");echo "Welcome back " . $_SERVER['PHP_AUTH_USER'];?>I have a couple of questions, how do you do to implement a counter of login attempts??? for example only allow 3 login attempts, and do you have the method to write an .htpasswd file and generate a hash for the password??? If its true please post it to complete the script. Best regards,
  20. Yes you are right, i know that limitation and if you know the name of the txt file you get the user/password information and your security is fall down, if you do and post the code for the encryption method i think every body will very grateful. regards,
  21. Hi, there is sometimes that you need to password protect a directory in your site but you dont have access to a database or you dont need it because only a few users will access this directory, well the following script i develop will help in this situation. With only 2 files you can implement a basic security, the first file is a simple txt file where you store your users information and the second file is the php script. You can name the files whatever you want and can be used in any site with php support. The users.txt file: In this file simply put one line at the time your users information like this: username1|userpassword1 username2|userpassword2 . . usernamen|userpasswordn The chksec.php file: This file is the one that implements the basic security, here is the code: <?phpif(!isset($_SERVER['PHP_AUTH_USER'])){ Header("WWW-Authenticate: Basic realm=\"Restricted Access\""); Header("HTTP/1.1 401 Unauthorized"); echo "Authorization Required."; exit();}$theFile=file("users.txt");$nUsers=sizeof($theFile);$i=0;$validated=FALSE;while ($i<$nUsers && !$validated){ $aFields=explode("|",$theFile[$i]); if (($_SERVER['PHP_AUTH_USER']==$aFields[0])&&($_SERVER['PHP_AUTH_PW']==chop($aFields[1]))) $validated=TRUE; $i++;}if(!$validated){ Header("WWW-Authenticate: Basic realm=\"Restricted Access\""); Header("HTTP/1.1 401 Unauthorized"); echo "Authorization Required."; exit();}?> Thats it, to work you just need to include this file in another php file. For example: <?phpinclude("chksec.php");echo "Welcome back " . $_SERVER['PHP_AUTH_USER'];?>Best regards,
  22. Hi, I got the same problem every time im trying to login to my cpanel with internet explorer or with firefox, i really dont care about this and simply i press the yes button to the alert window and accept. Also, this window appears before the login window of my cpanel account.best regards,
  23. Yes, the combination offered by the Gtalk and Gmail make these services a step forward within other services, is an excellent tool to stay in touch with your contacts, clients, friends, etc. and at the same time you can read your mail. Of course, this only works if you configure your gmail view to standard with chat, that is very easy to do by simply click an hyperlink at the bottom of the page. best regards,
  24. Hi, i agree with the post of vujsa, you forgot to finish your statements with a semicolon, thats your problem, also your connect variable is not strictly necessary, you can decide to use it or not. A suggestion, always include in your database functions the mysql error number and string like this: $connect = mysql_connect($server, $user, $sqlpass) or die("Could not connect to the database!" . mysql_errno() . ": " . mysql_error() );mysql_select_db($db, $connect) or die("Could not select database! Does it exist?" . mysql_errno() . ": " . mysql_error() ); Are very helpful to solve a lots of problems. Best regards,
  25. Thanks for the tips, i have this problem a time ago and never realize that the solution is too simple. best regards,
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.