sKunKbad
Members-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by sKunKbad
-
[SOLVED] Finding the position of a variable
sKunKbad replied to Sesquipedalian's topic in PHP Coding Help
<?php $string = 'There was a dog who was blue'; $word = 'was'; $text = explode($word,$string); $charnum = (strlen($text[0]) + strlen($word) + strlen($text[1]) + 1); echo $charnum; ?> -
$handle = fopen("ftp://user:password@example.com/somefile.txt", "w"); see the manual http://us.php.net/manual/en/function.fopen.php
-
I have a fairly basic user authentication class that I am working with, but it doesn't do everything I want it to do. It uses a MySQL database for users/passwords. Passwords are encrypted. The session is regenerated for every page. I've been researching security issues and trying to make sure my class is as secure as possible. I want to make sure only one person can be logged in to an account at a time, and have a good idea of how to do it, but I'd like to see some other really good user authentication classes that people are using. Most of the ones I have seen online are too basic and lack any security, and I'm wondering if anyone can point me to a script or two to check out. I know about the PEAR AUTH package, but I'm looking for non-PEAR classes only. Thank you.
-
TinyMCE works with Safari, and I believe FCKeditor does not.
-
Error with website Auth protector?
sKunKbad replied to winmastergames's topic in Third Party Scripts
I downloaded the script and took a look at what you are dealing with. You need to show the code for the page you are trying to protect. At the very top of that page you would have the include: <?php require_once("maxProtector.class.php"); ?> Line 39 of your protect-class.php script is what is causing the problem. Can you post more of the code you are dealing with? BTW...if you are on a server with apache installed, you can do this much easier by using .htaccess / .htpasswd files. The .htaccess / .htpasswd asks for user name and password, and the password is stored in encrypted form, where in this script you are using the password is a plain string. -
Error with website Auth protector?
sKunKbad replied to winmastergames's topic in Third Party Scripts
move <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Please login to access this feature</title> Can someone help? Please? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"><div id="header_left"></div> <div id="header_main">Please login to access this feature</div><div id="header_right"></div></div> <div id="content"> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <center> <label>Password: <input name="passwd" type="password" size="20" /> </label><br/> <label> <input type="submit" name="submitBtn" class="sbtn" value="Login" /> </label> </center> </form> </div> <div id="footer"><a href="http://www.phpf1.com" target="_blank">Powered by Max's Site Protector</a></div> </div> </body> [code] below the php at the bottom of what you showed me and see if it works. [/code] -
Error with website Auth protector?
sKunKbad replied to winmastergames's topic in Third Party Scripts
it has that error message because session_start(); is being called after output to the browser. -
There are a number of ways to do it, but the fast and easy way is to have three divs stacked. Top div holds an image of the top of the box (rounded in this case). Content goes in the second div. Bottom div holds an image of the bottom of the box (rounded in this case).
-
try html_entity_decode(); or if you are using php5 you can use something like this: <?php // Works with php5 only! // KJV verse of the day code starts here ----------------------------------------------------------------------------------------------------------->> print("<div class='greenbox-top'></div> <div class='greenbox-bg'> <h2>Verse Of The Day</h2>"); $feed = simplexml_load_file('http://www.biblegateway.com/usage/votd/rss/votd.rdf?9'); $namespaces = $feed->getNamespaces(true); $content = $feed->channel->item->children($namespaces['content']); $verse = $feed->channel->item->title; echo ("<p>".$verse."<br /><br />".str_ireplace('<br/><br/> Brought to you by <a href="http://www.biblegateway.com">BibleGateway.com</a>. Copyright (C) KJV. All Rights Reserved.','',$content->encoded)."</p>"); print("</div> <div class='greenbox-bottom'></div>"); // KJV verse of the day code ends here -------------------------------------------------------------------------------------------------------------->> ?>
-
try commenting the javascript <!-- javascript --> and or using cdata declaration
-
or use < and > directly echo "<$email>";
-
echo "<" . $email . ">"; //why doesn't this work?
-
I posted the finished code at the original thread
-
OK man, I've got done what you asked for. If you need anything else... buy some books. It's Christmas and I ain't gonna be around for a couple days. <?php /* Each person should be judged by key 1 first. The person with the highest value wins *If there is a tie, then key 2 is checked, and the person with the highest value wins. *If there is still a tie, key3 is checked, and the person with the LOWEST value wins. */ $group = $savedGroup = array( 1 => array ( 0 => 'john' , 1 => 6 , 2 => 5 , 3 => 3 ) , 2 => array ( 0 => 'pat' , 1 => 6 , 2 => 5 , 3 => 3 ) , 3 => array ( 0 => 'mat' , 1 => 9 , 2 => 5 , 3 => 3 ) , 4 => array ( 0 => 'pink' , 1 => 5 , 2 => 5 , 3 => 3 ) , 5 => array ( 0 => 'joey' , 1 => 5 , 2 => 5 , 3 => 3 ) ) ; function sort_keys ($x, $y) { if ($x['1']>$y['1']) return -1; else if ($x['1']<$y['1']) return 1; if ($x['2']>$y['2']) return -1; else if ($x['2']<$y['2']) return 1; if ($x['3']<$y['3']) return -1; else if ($x['3']>$y['3']) return 1; return 0; } uasort ($group, 'sort_keys'); echo '<h3>Who is best?</h3><pre>' . print_r($group, 1) . '</pre>'; $winner = array_shift($group); echo "<h3>The winner is {$winner['0']}</h3>"; /* *Now check if there are people that have the same values */ $confirmed = array(0=>array()); foreach ($savedGroup as $member){ foreach ( $savedGroup as $otherMember ){ if ( $otherMember != $member ) { for ($k=1; $k<=3; $k++){ if ($member["$k"] == $otherMember["$k"]){ //the initial match of stat values $match["$member[0]"]["$otherMember[0]"]["$k"] = 'yes'; //add match confirmation of single value to array if (count($match["$member[0]"]["$otherMember[0]"])== '3'){ //check that all values are matches, indicating a true match for ($m=0; $m<=count($confirmed)-1; $m++){ if(in_array( "$otherMember[0]", $confirmed["$m"] ) || in_array( "$member[0]", $confirmed["$m"] )){ $found = $found +1; } } if( $found == 0 ){ //if no previous matches, make new $confirmed array static $matchGroup = 0; $confirmed["$matchGroup"][] = $member[0]; $confirmed["$matchGroup"][] = $otherMember[0]; $matchGroup++; }else{ //add name as key to existing $confirmed array for($z=0; $z<=count($confirmed)-1; $z++){ if(in_array( "$otherMember[0]", $confirmed["$z"] ) || in_array( "$member[0]", $confirmed["$z"] )){ $confirmed["$z"][] = $member[0]; $confirmed["$z"][] = $otherMember[0]; } } $found = 0; } } } } } } } for($g=0; $g<=count($confirmed)-1; $g++){ $confirmed["$g"] = array_unique($confirmed["$g"]); } $new = array(); for($b=0; $b<=count($confirmed)-1; $b++){ foreach ($confirmed["$b"] as $key => $val){ $new["$b"][] = $val; } } for($r=0; $r<=count($new)-1; $r++){ echo "<h3>The following members had an instance of complete duplicate stats:</h3>"; echo "<div style='width:200px; background-color:yellow;'>"; for($t=0; $t<=count($new["$r"])-1; $t++){ echo $new["$r"]["$t"] . "<br>"; } echo "</div>"; } ?>
-
I think I'm getting a lot closer to having this done, but getting burnt out. Any help is appreciated. Here is the modification that I have, and it's almost working right: for ($m=0; $m<=count($confirmed)-1; $m++){ if(in_array( $otherMember[0], $confirmed["$m"] ) || in_array( $member[0], $confirmed["$m"] )){ $found = $found +1; } } if( $found == 0 ){ //if no previous matches, make new $confirmed array static $matchGroup = 0; $confirmed["$matchGroup"][] = $member[0]; $confirmed["$matchGroup"][] = $otherMember[0]; $matchGroup++; }else{ //add name as key to existing $confirmed array foreach ($confirmed as $z){ if(in_array( $otherMember[0], $z )){ $z[] = $member[0]; $z[] = $otherMember[0]; } } $found = 0; }
-
I like to try to solve people's questions here, and I'm actually working on a solution for another thread. On line 43 starts two foreach loops that should eventually add people with matched values to an array called $confirmed. The people and their values are stored in an array at the top of the script. The guy I'm helping wants his script to show people who have matching values. Why isn't my $confirmed array loading up with arrays of matches? <?php /* Each person should be judged by key 1 first. The person with the highest value wins *If there is a tie, then key 2 is checked, and the person with the highest value wins. *If there is still a tie, key3 is checked, and the person with the LOWEST value wins. */ $group = $savedGroup = array( 1 => array ( 0 => 'john' , 1 => 6 , 2 => 5 , 3 => 3 ) , 2 => array ( 0 => 'pat' , 1 => 6 , 2 => 5 , 3 => 3 ) , 3 => array ( 0 => 'mat' , 1 => 5 , 2 => 5 , 3 => 9 ) , 4 => array ( 0 => 'pink' , 1 => 5 , 2 => 5 , 3 => 9 ) , 5 => array ( 0 => 'joey' , 1 => 5 , 2 => 5 , 3 => 9 ) ) ; function sort_keys ($x, $y) { if ($x['1']>$y['1']) return -1; else if ($x['1']<$y['1']) return 1; if ($x['2']>$y['2']) return -1; else if ($x['2']<$y['2']) return 1; if ($x['3']<$y['3']) return -1; else if ($x['3']>$y['3']) return 1; return 0; } uasort ($group, 'sort_keys'); echo '<h3>Who is best?</h3><pre>' . print_r($group, 1) . '</pre>'; $winner = array_shift($group); echo "<h3>The winner is {$winner['0']}</h3>"; /* *Now check if there are people that have the same values */ $confirmed = array(0=>array()); foreach ($savedGroup as $member){ foreach ( $savedGroup as $otherMember ){ if ( $otherMember != $member ) { for ($k=1; $k<=3; $k++){ if ($member["$k"] == $otherMember["$k"]){ //the initial match of stat values $match["$member[0]"]["$otherMember[0]"]["$k"] = 'yes'; //add match confirmation to array if (count($match["$member[0]"]["$otherMember[0]"])== '3'){ //check that all stats match foreach($confirmed as $possible){ //<<---------- LINE 43 foreach($possible as $matched){ if(!in_array( $otherMember[0], $matched )){ static $matchGroup = 0; $confirmed["$matchGroup"][] = $member[0]; $confirmed["$matchGroup"][] = $otherMember[0]; $matchGroup++; }else{ //add name as key to existing $confirmed array $matched[] = $member[0]; } } } } } } } } } echo "<pre>"; print_r($match); print_r($confirmed); echo "</pre>";
-
Maybe somebody else can help with this. This is what I have so far: <?php /* Each person should be judged by key 1 first. The person with the highest value wins *If there is a tie, then key 2 is checked, and the person with the highest value wins. *If there is still a tie, key3 is checked, and the person with the LOWEST value wins. */ $group = array( 1 => array ( 0 => 'john' , 1 => 4 , 2 => 5 , 3 => 7 ) , 2 => array ( 0 => 'pat' , 1 => 4 , 2 => 5 , 3 => 7 ) , 3 => array ( 0 => 'mat' , 1 => 4 , 2 => 5 , 3 => 7 ) , 4 => array ( 0 => 'pink' , 1 => 4 , 2 => 5 , 3 => 7 ) ) ; function sort_keys ($x, $y) { if ($x['1']>$y['1']) return -1; else if ($x['1']<$y['1']) return 1; if ($x['2']>$y['2']) return -1; else if ($x['2']<$y['2']) return 1; if ($x['3']<$y['3']) return -1; else if ($x['3']>$y['3']) return 1; return 0; } uasort ($group, 'sort_keys'); echo '<h3>Who is best?</h3><pre>' . print_r($group, 1) . '</pre>'; $group2 = $group; $winner = array_shift($group); echo "<h3>The winner is {$winner['0']}</h3>"; /* *Now check if there are three or more people that have the same values */ $count = count($group2) - 2; for ($i=1; $i <= $count; $i++){ $a = $i; $b = $i + 1; $c = $i + 2; $three = array_intersect_assoc( $group2["$a"] , $group2["$b"] , $group2["$c"] ); if (array_key_exists('1', $three) && array_key_exists('2', $three) && array_key_exists('3', $three)){ $nameOne = $group2["$a"]['0']; $nameTwo = $group2["$b"]['0']; $nameThree = $group2["$c"]['0']; echo "All of the value for $nameOne, $nameTwo, and $nameThree are the same<br>"; echo "<pre>"; print_r($three); echo "</pre>"; } } ?> I just want to have the output fixed so that it says "john, pat, mat, and pink all have the same values" instead of how it outputs now.
-
$winner = array_shift($group); echo "<h3>The winner is {$winner['0']}</h3>"; This uasort function is not easily understood by beginners ( and I still consider myself one!). I learned it from a book called "PHP5 Advanced" by Larry Ulman. The uasort function takes a user defined function, which sorts according to the rules set within. $x and $y are simply variables set to the keys that are being sorted at that particular instance. You won't be disappointed with the book I mentioned. Go ahead and buy it!
-
Your queries have odd single quote characters in them. The names of your table and database fields should not be in single quotes. $result = mysql_query("SELECT * FROM `Wallpapers` WHERE `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') AND `approved` = '0' ORDER BY `ID` DESC LIMIT"); You ought to try to test your queries in phpMyAdmin or the MySQL console to make sure they are good before sticking them in your php.
-
Give this a try: <?php $group = array( 1 => array ( 0 => 'john' , 1 => 4 , 2 => 5 , 3 => 6 ) , 2 => array ( 0 => 'pat' , 1 => 5 , 2 => 2 , 3 => 7 ) , 3 => array ( 0 => 'mat' , 1 => 4 , 2 => 6 , 3 => 6 ) , 4 => array ( 0 => 'pink' , 1 => 2 , 2 => 2 , 3 => 10 ) ) ; function sort_keys ($x, $y) { if ($x['1']>$y['1']) return -1; else if ($x['1']<$y['1']) return 1; if ($x['2']>$y['2']) return -1; else if ($x['2']<$y['2']) return 1; if ($x['3']<$y['3']) return -1; else if ($x['3']>$y['3']) return 1; return 0; } uasort ($group, 'sort_keys'); echo '<h3>Who is best?</h3><pre>' . print_r($group, 1) . '</pre>'; ?>
-
If all this is for is pagination, then I think the following code may be getting closer to what you want: if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page=1; }; $start_from = ($page-1) * 20; $sql = "SELECT * FROM Wallpaper WHERE `Category` = '".$id."' OR `Category` IN(SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') AND `approved` = '0' ORDER BY ID DESC LIMIT $start_from, 20"; $rs_result = mysql_query ($sql); $total_records = mysql_num_rows($rs_result); $total_pages = ceil($total_records / 30); for ($i=1; $i<=$total_pages; $i++) { echo "<a href='categories.php?page='.$i.'>'.$i.'</a>"; };
-
It's hard to really see what's wrong without the entire code. Do you see how you are overwriting the value of both your $sql and $rs_result variable. Same as: $x = 1; $x = 5; The first select statement means nothing, and neither does it's result, or at least that is what I get from the supplied code.
-
Where is your mysql_fetch_array, and why have two queries with the same result variable?
-
Barand is right. If there is a chance that you will add categories of articles in the future, you would need to create the array of categories dynamically.