Jump to content

goocharlton

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Posts posted by goocharlton

  1. I am referring to the following script.

    <?php
    $specialties = array("Variable 1", "Variable 2");
    $i = 0;
    extract($_POST['specialties']);
    foreach($specialties as $value) {                     	
    if (isset($_POST['specialties'])) {
    	$checked = '';
    	if ($specialties[$i] == $value) {
    		$checked = ' checked';
    	}
    }
       echo "<tr><td><input name='specialties[]' type='checkbox' value='$value'$checked /></td><td>$value $i</td></tr>";
       ++$i;                            
    }
    ?>
    

     

    I am creating a list of checkboxes for my form using an array. I have setup the script to check if all fields are filled in before it submits itself. If the validation doesn't pass then the script reloads the form with the field filled with the details the user had entered.

     

    I am trying to also make it so the checkboxes that the user had selected before validation are still checked after they don't pass validation. I have tried doing so using:

    <?php
    if ($specialties[$i] == $value) {
    $checked = ' checked';
    }
    ?>
    

    ...but I am unable to get $specialties[$i] to work correctly. I have tried $specialties[0] and the script works fine for the first checkbox which is of course what I want for the all the checkboxes. That is why I have tried using $i but not successfully.

     

    Is there a better way of doing this? What am I doing wrong?

  2. Thanks but you don't understand what I am asking.

     

    I am defining 'reloadElement' to the HTML tag id that I want it to replace, not the tag id in which it is in.

     

    Using filter('{item}',this.id,this.value) is defining reloadElement to the HTML tag in which it is in, where as using filter('{item}','{reloadElement}',this.value) I am able to define {reloadElement} every time I insert the function.

     

    Do you understand?

  3. I have a function in my PHP script that I use to filter content by HTML tag id when the item changes in the drop down menu as seen below:

    <?php
    echo '...';
    echo '<div id="filter"><form style="padding:0;margin:0;">Filter: <select name="collection" onchange="filter(\'albums\',\'reload\',this.value)">';
    echo '...';
    ?>
    

     

    The javascript variable that I am using for the onchange event is:

    filter('{item}','{reloadElement}',this.value)

    where:

    • {item} = a variable that is used to define what part of the filter.php script to run
    • {reloadElement} = defines what HTML tag by id to reload(using ajax)
    • this.value = just grabs the id that the drop down menu item is holding

     

    For example:

    filter('album','content',this.value)

    The following runs the 'album' part of the filter.php script and used 'this.value' to to grab content from the database then it reloads the HTML tag with id 'content' using AJAX.

     

    The AJAX script that I am using is:

    var xmlHttp
    
    function filter(type,reloadElement,value)
    { 
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    	{
    	alert ("Browser does not support HTTP Request")
    	return
    	}
    var url="filter.php"
    url=url+"?type="+type
    url=url+"&value="+value
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChanged
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    }
    
    function stateChanged() 
    { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    	{ 
    	document.getElementById(reloadElement).innerHTML=xmlHttp.responseText 
    	} 
    }
    
    function GetXmlHttpObject()
    {
    var xmlHttp=null;
    try
    	{
    	// Firefox, Opera 8.0+, Safari
    	xmlHttp=new XMLHttpRequest();
    	}
    catch (e)
    	{
    	//Internet Explorer
    	try
    		{
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    		}
    	catch (e)
    		{
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    		}
    	}
    return xmlHttp;
    }
    

     

    Which then calls filter.php to grab the new content to be reloaded.

     

    My problem is with getting the {reloadElement} to be the tag id that is reloaded by the AJAX script.

    Somehow I need to get:

    .getElementById(reloadElement).

    as seen in the stateChanged function to be defined by the middle variable in the filter funtion.

     

    How do I achieve this?

  4. I have a website that I am trying to get URL rewriting working on it. This scenario is as follows:

     

    The URL in the browser shows .../page/1 and is interpreted by mod_rewrite as .../handler.php?page=1 with the following .htaccess file:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule page/([0-9]+)$ /handler.php?$page=$1
    

     

    I try using the PHP GET function to call the page number. I tried using the following code but it just returned blank:

    <?php
    $page = $_GET['page'];
    echo $page;
    ?>
    

     

    What am i doing wrong?

  5. From what I could understand this is what you are looking for:

    <?php
    $test = file_get_contents('http://game.endless-online.com/playerlist.html');
    //echo $test;
    preg_match_all('|<td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="50"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="100"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="70"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td>|is',$test, $out);
    echo '<table><tr><td>Name</td><td>Title</td><td>Level</td><td>Experience</td><td>Gender</td></tr>';
    foreach ($out[0] as $k => $v){
    echo '<tr><td>', $out[1][$k], '</td><td>', $out[2][$k], '</td><td>', $out[3][$k], '</td><td>', $out[4][$k], '</td><td>',$out[5][$k], "</td></tr>";
    }
    echo '</table>';
    ?>
    

  6. Any ideas on how I can build an application that guesses the number that people are thinking of?

     

    I figured the way to do it it to get the script to ask questions that the user asks yes or no too till it gets to a small enough possibility to get the exact number.

     

    I.e. The script will ask,

    "Is you number 50 or higher?"

    -- if yes "Is your number 75 or higher?

    ---- if yes "Is your number..."

    ---- if no"Is your number..."

    -- if no "Is your number 25 or higher?

    ---- if yes "Is your number..."

    ---- if no"Is your number..."

    ...etc

     

    I can easily run the script in a way that goes through every single possibility and possible path running if and else but that will take days of going through every single possibility, can you think of a better way of doing it?

     

    Possibly using an array to array the possibilities > what are your thoughts?

  7. Here is the code I am trying to use:

                <?php
    		session_start();
    		$result = mysql_query("SELECT username, password FROM user WHERE username='password'");
    		$passwords = mysql_fetch_assoc($result);
    		if ($_POST['password'] == $passwords[$_POST['username']]) {
    			echo "Login Successfull";
    			$_SESSION['auth_username'] = $_POST['username'];
    		} else { ?>
                    <form method="post">
                    	<div class="login-form">
                            Username<?php if(isset($_POST['login']) and !$_POST['username']) { echo "<span style='color:#FF0000;'>*</span>"; } ?><br>
                            <input name="username" type="text">
                        </div>
                        <div class="login-form">
                            Password<?php if(isset($_POST['login']) and !$_POST['password']) { echo "<span style='color:#FF0000;'>*</span>"; } ?><br>
                            <input name="password" type="password">
                        </div>
                        <div class="login-button">
                            <input name="login" type="submit" value="Login" style="width:40px;">
                        </div>
                    </form>
                    <?php } ?>
    

     

    What am I doing wrong?

  8. Probably not. If it is a browser based proxy, you can toss some ajax / iframe code in their to get his real browser to connect, but it's probably a real proxy.

    ....go on. What were you saying about ajax/iframe code, can you explain more about this?

     

    what is the spam?

    Just viagra adds and crap like that.

     

    You could block proxies however, when you block proxies people using AOL also get blocked from your site. I don't have a solution; just thatught I'd say lol

    I'm not fussed with the fact that the hacker got in, I know how he got in and when he got in(nothing special I know) but I just want to try and track him down that's all.

  9. Ok here goes!

     

    I have been hacked numerous times by the same hacker spamming my site. He uploads a file to a directory and then accesses the file through his browser which them edits files on my domain that he specifies. I have just fixed all the pages that were spammed on my site for the 3rd time and it will not happen again because I actually took the effort to close the hole in which he was entering by.

    He(whether in person or from a scheduled program) returns daily to run the script that he had uploaded to re-spam my pages.

     

    He is no noob because he runs it all from behind proxy's so I am unable to track him that I am aware of.

     

    Because he runs this script everyday I am wondering if I can use that against him in some way.

    As he is behind a proxy this will be much harder or impossible but where there is a will there is a way!

     

    I need to know if there is any way to get details of a user through a proxy with php or is there some way I can trick him through it? I can edit the file that he runs off my server every day to whatever I want.

     

    What do you think?

  10. I have a content area with width that varies according to whether there are left or right modules(this is a joomla cms site).

     

    I have written this code but I cant get it to work....

    <div id="content" style="width:<?php
    					if ((mosCountModules( "left" )) < 0):
    						if ((mosCountModules( "right" )) < 0)
    						echo "800";; 
    					elseif ((mosCountModules( "left" )) > 0):
    						if ((mosCountModules( "right" )) > 0)
    						echo "380";;
    					 elseif ((mosCountModules( "left" )) < 0):
    						if ((mosCountModules( "right" )) > 0)
    						echo "590";; 
    					 elseif ((mosCountModules( "left" )) > 0):
    					 	if ((mosCountModules( "right" )) < 0)
    						echo "590";; 
    					endif;
    					?>px">											
    			</div>
    

     

    Can anyone tell me what I am doing wrong, if you dont know anything about Joomla do you know whats wrong with the php i have writen?. I am trying to say that:

    - If there are no modules in the left AND right columns echo a width of 800px.

    - If there are modules in the left AND right columns echo a width of 380px.

    - If there are modules in the right AND not in the left columns echo a width of 590px.

    - If there are modules in the left AND not in the right columns echo a width of 590px.

  11. I have my site 'news-and-press.php' page with this code:

    <?php 
    $page_name = 'News & Press';
    $page_ID = 'newsandpress';
    $heading = 'News & Press';
    $content = include("news-and-press2.php");
    include ('template.php');
    ?>

     

    When I run 'news-and-press.php' the code runs through the list of variables then it runs the include ('template.php'); (this is the page that runs the site template, it asks for the variables above).

     

    My problem is when 'news-and-press.php' is run the $content variables' output displays before the include ('template.php'); is displayed but it is meant to run the include ('template.php'); and then call $content into the template.

     

    The 'news-and-press2.php' file has the following code...

    <?php 
    function GetNews()
    {
    include("news_items.php"); 
    	foreach ($news as $value) {
    		echo "<p>";
    		echo "<b>" .$value[date]. "</b><br>";
    		echo $value[content];
    		echo "<p>";
    	}
    }
    
    echo GetNews()
    ?>

     

    What am I doing wrong?

     

    Preview can be found http://www.tx25.com/news-and-press.php

  12. I am trying to use this code....

    <?php
    include("news_items.php"); 
    			foreach ($news as $value) {
    				echo "<p>";
    				echo "<b>" .$value[date]. "</b><br>";
    				echo $value[content];
    				echo "<p>";
    			}
    ?>
    

    ...inside a simple variable like so...

    <?php
    $variable = include("news_items.php"); 
    			foreach ($news as $value) {
    				echo "<p>";
    				echo "<b>" .$value[date]. "</b><br>";
    				echo $value[content];
    				echo "<p>";
    			}
    ?>
    

     

    As you would already know this doesn't work. How do I achieve this?

  13. My 'news_items.php' file contains:

    <div class="date">June 28, 2007</div>
    <div class="info">Welcome to .......<br>text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text</div>

     

    If news_items.php doesn't contain any PHP you can use $contents = file_get_contents("news_item.php"); and it will assign the contents of news_item.php to $contents.

     

    edit: I still don't understand what you're trying to do really...

     

    Cheers mate. Your my hero. Thats exactly what i was looking for.

  14. My 'news_items.php' file contains:

    <div class="date">June 28, 2007</div>
    <div class="info">Welcome to .......<br>text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text</div>

  15. Hmm. Thanks infid3l but can you recommend any other way of doing what i am trying to achieve. I cannot use the method that you just mentioned because I also use news_items.php called from another file in the following way:

    <?php
    			if (${'left_column_' . $page_ID} == 0)
    				echo "";
    			else
    				include_once ("left_column.php");
                ?>

     

    ..therefore I cannot change the news_items.php in anyway unless I can do it in a way that it can be called by the above code as well.

×
×
  • Create New...

Important Information

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.