-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
thats because foreach ($rooms[$position] as $key => $value) { should be foreach ($rooms[$_SESSION['position']] as $key => $value) {
-
See my previous post, I don't see a problem with using get as it will only show 0 to X (x being the door, not the room) From the foreach loop its $roomid variable
-
1. SAPI module specific location * PHPIniDir directive in Apache 2 * -c command line option in CGI and CLI * php_ini parameter in NSAPI * PHP_INI_PATH environment variable in THTTPD 2. The PHPRC environment variable (Before PHP 5.2.0 this was checked after the registry key mentioned below.) 3. HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry location) 4. Current working directory (for CLI) 5. The web server’s directory (for SAPI modules) 6. Directory of PHP (If Windows) 7. Windows directory (C:\windows or C:\winnt) 8. –with-config-file-path compile time option The path in which the php.ini file is looked for can be overridden using the -c argument in command line mode. (cgi) /home/user1/htdocs/cgi-bin/php.cgi -c /home/user1/php.ini the PHPRC is a system environment variable
-
change eval( $code ); echo $souvik; to htmlentities( $code ); this will "display" the code not execute it
-
If you look at the last code I posted, it has the loop your use, here's a revised version <?php session_start(); $rooms = array( 0 => array(30, 1, 29, 28, 31), 1 => array(0, 1), /*more stuff*/ 29 => array(44, 32) ); if(empty($_SESSION['pos'])) { $_SESSION['pos'] = 0; }else{ $_SESSION['pos'] = $rooms[$_SESSION['pos']][$_GET['number']]; } if(!isset($rooms[$_SESSION['pos']])) { echo "Room error!";//attempting to bypass rooms will cause this exit; } foreach ($rooms[$_SESSION['pos']] as $K=>$roomid) { //$roomid isn't used but its the room your going into //you may use this later !! echo "<a href=\"?number=$K\"><img src=\"door.png\" boarder=\"0\"></a>"; } ?>
-
Can anyone else smell cow? or or it maybe ball!
-
[SOLVED] OnSelect or OnChange code help needed.
MadTechie replied to acctman's topic in Javascript Help
Your welcome..! -
[SOLVED] OnSelect or OnChange code help needed.
MadTechie replied to acctman's topic in Javascript Help
Your question is too general, here's some code (basic ajax) but I added an option to view the set session as it seams pointless to set it an do nothing with it! <?php session_start(); if(!empty($_GET['session'])) { $_SESSION['session'] = $_GET['session']; exit(); } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Set session</title> </head> <body> <script language="javascript"> function ajaxFunction(session) { var loaderphp = "<?php echo $_SERVER['PHP_SELF'] ?>"; var xmlHttp; try { xmlHttp=new XMLHttpRequest(); }catch(e){ try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.open("GET", loaderphp+"?session="+session,true); xmlHttp.send(null); } </script> <form action="" method="post" enctype="multipart/form-data"> <select name="folder" onchange="javascript:ajaxFunction(this.value);"> <option value="" selected="selected">Select</option> <option value="1">Public</option> <option value="2">Mobile</option> <option value="3">Private</option> </select> </form> <a href="?show=true">Show set session</a> <?php if(!empty($_GET['show'])) echo "Your session is set to {$_SESSION['session']}"; ?> </body> </html> Using a cookie would work just as well and won't need to make a server call, and would be very short and simple code but without more detail I can't make any real suggestions! -
[SOLVED] OnSelect or OnChange code help needed.
MadTechie replied to acctman's topic in Javascript Help
see any Ajax example, or use cookies -
[SOLVED] OnSelect or OnChange code help needed.
MadTechie replied to acctman's topic in Javascript Help
yes -
Uploading photos... pre-upload verification?
MadTechie replied to LordLanky's topic in PHP Coding Help
As PHP is server side, the file will need to be uploaded before PHP can touch it, You can tell the server to stop accepting files over X size by reducing the upload_max_filesize and post_max_size directives in the PHP.INI file, for example if they are set to 2Mb then after 2Mb's are sent the upload is aborted. If you want a client side validation, you maybe want to look at something like SWFuploader, EDIT: Note: AJAX is JavaScript, and can't touch client files for security reasons -
okay the code I submitted.. get the current position and their selection (room number 0 - X) i then check the array and get the new room number and set that to my position so for this example i am going use this maze array $rooms = array( 0 => array(30, 1, 29, 28, 31), 1 => array(0, 1), /*more stuff*/ 29 => array(44, 32), ); I start at 0 my new doors are $rooms[0] and i have 5 options 0, 1, 2, 3, 4 keep in mind that in room 0 0=30 1=1 2=29 etc (the user only selects a number 0, 1, 2, 3 or 4) the user select 2 the code get the maze array and looks up $rooms[0][2] this returns my new position which is 29 my new doors are $rooms[29] and i have 2 options 0, 1 keep in mind that in room 29 0=44 1=32 (the user only selects a number 0 or 1) etc etc now i never reveal any room numbers just the index number always 0 to X and i then lookup the next room by getting what door (array key) was selected and what room i was in
-
don't confuse obscurity with security, just because you hide the number, anyone who looks at the html could just enter sequential numbers until they get a hit, Personally I could try to keep the maze built into an array and work form their somthing like this <?php session_start(); $rooms = array( 0 => array(30, 1, 29, 28, 31), 1 => array(0, 1) ); $_SESSION['pos'] = $rooms[$_SESSION['pos']][$_POST['number']]; foreach ($rooms[$_SESSION['pos']] as $K=>$aaa) { echo "<input type=\"text\" name=\"$K\" src=\"door.png\""; } ?>
-
[SOLVED] Pass control to another php file ...
MadTechie replied to binderman's topic in PHP Coding Help
OOP is the better route but most start with procedural, breaking down the code into resuable functions it always a good start -
[SOLVED] Pass control to another php file ...
MadTechie replied to binderman's topic in PHP Coding Help
correct, its like you copied and pasted that code into that place, but if you create function you can call them when needed, breaking your large script into smaller functions should help.. then you could put all the database functions into database.php and all the display functions into display.php, once you get used to that then Look at OOP Okay header() controls the Page header (who would of guessed) the Location: prefix tell the browser to goto another page. its basically a redirect.. but unlike javascript or metatags you can't have anything displayed on the page -
[SOLVED] Pass control to another php file ...
MadTechie replied to binderman's topic in PHP Coding Help
okay a simple way to think of if is like actions for example heres my main page (with menu) <a href="?action=home">home</a><br /> <a href="?action=contact">contact</a><br /> <?php switch($_GET['action']) { case "home": include "home.php"; break; case "contact": include "contact.php"; break; } ?> and heres my pages <?php echo "contect page"; ?> <?php echo "home page"; ?> Now thats kinda basic.. you could also create a file with functions ie <?php function getUserList() { //..code return array(); } function getUserDetails($UserID) { //..code return array(); } ?> and include that into another file to use the functions -
[SOLVED] Pass control to another php file ...
MadTechie replied to binderman's topic in PHP Coding Help
do you mean include a file and why do you want to close file that calls it ? What "controls" do you wish to pass ? -
<?php if (preg_match('/\b(https?:\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$])/i', $_POST['comment'], $regs)) { echo "url {$regs[1]} found"; } ?>
-
You know someone paypaled me lunch money, that was kinda funny. when i saw it!
-
Cool again this was my third option, create an adapter, please note I am very new to WP (as in about an hour new) so it may not cover everything but from an overview I think it should cover the main part (getting the post) things like comments etc are not included but can be added. i hope it works for you
-
okay new idea, try this <?php $WPdir = dirname(__FILE__)."/content"; chdir($WPdir); require_once("adapter.php"); echo getPost(95); echo getPost(228); ?> adapter.php must be in the WP folder <?php require('wp-config.php'); mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); mysql_select_db(DB_NAME); function getPost($id) { $vars = mysql_query(sprintf("SELECT post_content FROM wp_posts WHERE post_status = 'publish' AND ID = %d", $id) ); $row = mysql_fetch_assoc($vars); return $row['post_content']; } ?>
-
Yes P=228 is $_GET['p'] = 228 WP has code that stops it loading twice,, the old code connects to itself by going out then back in, and opens 2 connections, where as a normal include doesn't go out, *thinking of options* Let me install WP on my local PC and I'll have a look
-
you could just pass N,S,E,W to the GET and hold the X in a session. ie switch($_GET['action']) { case "N": $_SESSION['X']=$_SESSION['X']-5; break; case "S": $_SESSION['X']=$_SESSION['X']+5; break; case "E": $_SESSION['X']=$_SESSION['X']+1; break; case "W": $_SESSION['X']=$_SESSION['X']-1; break; } $X = $_SESSION['X'];
-
So are you trying to pull more than one include ?
-
if your at room 22 and their a north door and the 22_north.jpg file exist it will display it if that file doesn't exist it displays north.jpg this allows you to add some extra doors with minimal code updates, as for the target that depends on how your going to code it, if you look at the 5x5 then the all you need to do is workout what room is in that direction So West is X-1 East is X+1 North is X-5 South is X+5 if your passing this via Get then you would something like <?php $X = $_GET['X']; $maze = array(/*maze details here*/); if(strpos($maze[$x],"N"))//if N is found { echo "<a href=\"?X=".($X-5)."\">"; if(file_exists($x."_north.jpg")) { //display image echo "<img src=\"".$x."_north.jpg\">"; }else{ //display image echo "<img src=\"north.jpg\">"; } echo "</a>"; } if(strpos($maze[$x],"S"))//if S is found { echo "<a href=\"?X=".($X+5)."\">"; if(file_exists($x."_south.jpg")) { //display image echo "<img src=\"".$x."_south.jpg\">"; }else{ //display image echo "<img src=\"_south.jpg\">"; } echo "</a>"; } if(strpos($maze[$x],"E"))//if E is found { echo "<a href=\"?X=".($X+5)."\">"; if(file_exists($x."_east.jpg")) { //display image echo "<img src=\"".$x."_east.jpg\">"; }else{ //display image echo "<img src=\"_east.jpg\">"; } echo "</a>"; } if(strpos($maze[$x],"W"))//if W is found { echo "<a href=\"?X=".($X+5)."\">"; if(file_exists($x."_west.jpg")) { //display image echo "<img src=\"".$x."_west.jpg\">"; }else{ //display image echo "<img src=\"_west.jpg\">"; } echo "</a>"; } ?> please note this is all untested and I haven't written any real designs for this..