laffin
Members-
Posts
1,200 -
Joined
-
Last visited
Everything posted by laffin
-
Well sounds like godaddy is doing something right. What ya see there is an example of bad programming practice Register Globals Which takes uri arguments and makes em a global variable in the script.
-
You are speaking of encryption. not obfusciation. Obfusciated code is unreadable to human eyes, but still executable code. encrypted code, isnt executable without a decrypter module there are plenty of encryptors out there, Zend has one (Zend Guard). and plenty of obfusciators, like this one see bottom for example of obfusciated code.
-
your not treating the am/pm in the if conditionals as strings use 'am' and 'pm'. also you have a neverending loop while ($hour = $_POST["event_time_hh"] + 12) { $event_date = $y."-".$m."-".$d." ".$hour.":".$_POST["event_time_mm"].":00"; } as $hr will never be 0, it will cycle through this loop until php timeout is reached (30 secs is default) you might want to consider using mktime function, to validate the fields. and strftime to place it back into string format.
-
I would avoid cookies for any mid/long term storage, as many users will do housekeeping or use different computers. I would store them into a db instead.
-
This sounds more like an apache redirect/alias system, than a php issue. Although you can do something like this with php, but apache must be configured for PATH_INFO. Apache Alias look at AliasMatch config setting, which will give you general info on how to use it (although you will need some knowledge of regex) but it should be complicated to add
-
udually, id's are primary key with autoincrement on looking at the query I see $sql = "INSERT INTO posts (post_id, title, body) VALUES ('', '$title', '$body')"; if your not setting the id, than take it out $sql = "INSERT INTO posts (title, body) VALUES ('$title', '$body')"; Another problem I see, is that yer not escapting title or body $title = trim($_POST['txtTitle']); $body = trim($_POST['txtBody']); try something like $title = mysql_real_escape_string(trim($_POST['txtTitle'])); $body = mysql_real_escape_string(trim($_POST['txtBody'])); I would throw in some validation to see if title & body do have some form of content as well.
-
Myself, I see line 12 empty on every gamertag that I've tried it on. You do know that the array begins with 0 not 1? so it shouldd be $line[11] that you are looking for. you can verify this by using var_dump($line)
-
Secure pages Sessions vs. Cookies & session_destroy() help
laffin replied to Limeni's topic in PHP Coding Help
1) I wouldnt use sessions to store redundant information, consider them as a temporary variables instead, for quick lookups in the db or other information. I would do something like this in login if(isset($_SESSION['loggedin']) && isset($_SESSION['id']) && $_SESSION['loggedin']) { die("Already logged in"); } // Login form processing here // $_SESSION['loggedin']=true; $_SESSION['id']=$row['id']; // This would be from your database on logout I wud just set $_SESSION['loggedin'] to false any secure pages, just check those two variables, and load the user record from the $_SESSION['id'] -
function / page reloaded after header redirect
laffin replied to juriaan79's topic in PHP Coding Help
The 302 status code - page has moved redirect. Which browser tries to handle, so this does sound like a browser issue. You may consider using your own redirect method function redirect($url,$timeout=1) { if(empty($url)) $url=URL_BASE; echo "<meta http-equiv="refresh" content=\"{$timeout};{$url}\" />"; die(); } -
function / page reloaded after header redirect
laffin replied to juriaan79's topic in PHP Coding Help
Check yer apache log files, if its getting refreshed, it will show the entry twice, its probably the browser. you may also want to check yer php log files. -
tokens/point systems/currency systems/other buy/purchase systems. they are all basicly the same. But your should have a general overview of how the system works before implementing a system. Purchasing/recieving tokens User usage of tokens and so forth but if its just a fifo link system, than you really dont need tokens or other systems. Just have to pop off the link from the stack, when you use the link
-
38 not too bad here is what I used <?php $quote=$text="God is great, God is good, Let us thank him for our food."; $minwin=2; $pos=$cnt=0; $tlen=strlen($text); while($pos<($tlen-$minwin)) { $pos2=$pos+$minwin; $winsize=$minwin; $matchsize=0; while(($pos2+$winsize)<$tlen) { while (substr($text,$pos,$winsize)==substr($text,$pos2,$winsize)) { if($winsize>$matchsize) { $matchpos=$pos; $matchsize=$winsize; } $winsize++; } $pos2++; } if($matchsize) { $match=substr($text,$pos,$matchsize); $matches[$cnt]=$match; $text=str_replace($match,"\\{$cnt}",$text); $pos++; $cnt++; $tlen=strlen($text); } $pos++; } // } echo "Original: {$quote}<br />\n"; echo "Compressed: {$text}<br />\n"; foreach($matches as $key=>$val) { echo " #{$key}=>'{$val}'<br />\n"; } ?> Although some code can be added (returning the biggest array first, not incorporated yet) its almost there reason I used \0 instead of just 1,2,3,4, is so you can find the replacements quickly, but Im shure ya can use other delimeter marks
-
Its quite simple, but ya have to have some wits to it As shown this was output of the code i had created, but this sounds more like a school project than a riddle. To achieve this I use a sliding window mechanism. grab first portion of text with min window, compare against rest of string if a match is found, store the result, increase the window, and try the match again increment the first portion offset and repeat
-
Something like this should work // Setup our paths, 0 is always default $directories = array(0=>'pages',1=>'images'); // Get First parameter, if non-existant or empty, set default to '1' $a=isset($_GET['a'])?(!empty($_GET['a']?$_GET['a']:'1'):'1'; // Get Second parameter, if non-existant or empty, set default to 'php' $b=isset($_GET['b'])?(!empty($_GET['b']?$_GET['b']:'php'):'php'; // Get Third Paramter, if non-existant or empty, set default to 0 // if not in array of pages set default $c=isset($_GET['c'])?(!empty($_GET['c']?(isset($directories[$_GET['c']]?$_GET['c']:0):0):0; // Check if the page exists, if not show error if(!file_exists($page="{$directories[$c]}/{$a}.{$b}")) { echo 'Page you are requesting doesnt exist'; } else { // Otherwise grab the page @include($page); }
-
sounds like a pagination system http://www.phpfreaks.com/tutorial/basic-pagination a tutorial here
-
function / page reloaded after header redirect
laffin replied to juriaan79's topic in PHP Coding Help
I would add more debug information to the error reporting read some about the debug_backtrace, this should provide more than enough information. -
Just a thought, would ya need an empty function set first? $function_code=null than add the extra code to the function $function_code.='echo "hello";'; than just continue adding more code as neccessary. $function_code.='echo " world";'; than just create an anonymous function, $func=create_function('',$a); now the anonymous function can be called anytime with $func(); but if ya want to, I suppose ya can bypass the creation of functions entirely, and use eval instead if you want an immediate return
-
why the forward and back quote marks on the second line? they should look like the first line
-
Efficiency is derived from the implementation of the system. So Sessions is kinda a moot point in saying its efficient on developing a system. A simple database (commonly seen) CREATE Table `users` ( id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(32) NOT NULL DEFAULT '', canadd ENUM ('yes','no') DEFAULT 'no', canmove ENUM ('yes','no') DEFAULT 'no', candelete ENUM ('yes','no') DEFAULT 'no' ) Although this system is easy to develop, edit, and use, its very inefficient. As ToonMariner Suggested, ya may opt in learning BitWIse Operators, this does add a complexity in coding and queries. but it adds to code efficiency. And once learned, its not hard to maintain at all.
-
With MySQL, its called full text search u can find a tutorial here
-
Problem you will encounter is the last row, if the items listed doesnt fall exactly on an end tag. so u will have to add a check for it after the while loop and fill in the extra columns <?php $items=rand(5,20); $cols=rand(2,5); $counter=0; Echo "Items={$items} Columns={$cols}<br>\n"; echo "<table>\n<"; while($counter<$items) { if(!($counter%$cols)) echo "<tr>\n"; echo " <td>$counter</td>\n"; $counter++; if(!($counter%$cols)) echo "</tr>\n"; } if(($counter%$cols)) { while(($counter)%$cols) { echo " <td> </td>\n"; $counter++;} echo "</tr>\n"; } echo "</table>"; ?>
-
Looks like binary sequences, convert to decimal (floats) or hexadecimal or other number base.
-
DATE_FORMAT is used in yer queries to MySQL u can have MySQL return in your format if you use that function. Read the link provided, and play with it the routine I posted, just validates the date in one of two formats (this is for php side of things) mm-dd-yyyy or yyyy-mm-dd and returns FALSE if the date is invalid format or just invalid (as per suggestion by BioBob)
-
Thats kinda silly isnt it. Obviously yer creating a lot more work than is needed, if you would have taken the advice. Which makes perfect sense But now yer doing all these extravagent tricks, which dont work. So Q? Why ask for advice/help if yer intent on sticking with your way? I dont know about the rest, but that seems kinda rude...
-
<?php function datecheck($dat) { if(preg_match('/^(\d{1,2})[-\/](\d{1,2})[-\/](\d{4,4})/',$dat,$pieces)) { $mm=$pieces[1]; $dd=$pieces[2]; $yy=$pieces[3]; } elseif(preg_match('/^(\d{4,4})[-\/](\d{1,2})[-\/](\d{1,2})/',$dat,$pieces)) { $mm=$pieces[2]; $dd=$pieces[3]; $yy=$pieces[1]; } if(isset($mm) && !checkdate($mm,$dd,$yy)) unset($mm); return isset($mm)?"{$mm}-{$dd}-{$yy}":FALSE; } var_dump(datecheck('12-31-20001')); var_dump(datecheck('02-29-20001')); var_dump(datecheck('20001-01-15')); var_dump(datecheck('07-04-20010')); var_dump(datecheck('07-32-20010')); ?> This should work, with both formats and return a valid date in the format yyyy-mm-dd now for sql ya want to read this: DATE_FORMAT() so in yer queries ya wud use DATE_FORMAT($dat,'%Y-%m-%d') instead of $dat or ya could use the routine above to convert from MySQL to yer date format