Jump to content

gish

Members
  • Posts

    92
  • Joined

  • Last visited

    Never

Posts posted by gish

  1. I have just been given some code that is live on a web site. I pulled it down to my local linux machine and the php will not run. I have worked out the issue

    the php tags are <? scripting ?> it is missing the php.

     

    I have a couple of questions how do I get my local linux  machine get <? scripting ?>  this to work and I have a lot of code that is like this and I am sure

    that it is no longer secure is this right?

  2. I am trying to create a tally by using the get function this is the code so far

     

    page one

    						<?php	
    						   if ($_GET['t'] == ''){
    							 	  $_GET['t'] = 0;				
    							}
    
    							if ($_GET['q'] == 1){
    								$answer = "While she is tried.";
    							} else if  ($_GET['q'] == 2){
    								$_GET['t'] = $_GET['t']+1;
    								$tally = $_GET['t'];
    								$answer = "While she is tried.";
    							} else if ($_GET['q'] == 3){
    								$answer = "While she is tried.";
    							}else {
    						   	echo '<a href="QuestionOne.php" name="question_one">
    						   	        Oops you did not select an answer please try again</a>';
    
    							}	
    						?>
    

     

    <a href="QuestionTwo.php?t=<?php echo $tally;?>" name="question_two">Question Two</a>
    

     

    This works fine when I send it to QuestionTwo.php i will get 0 or a 1 in the url bar

    Then I have to ask a question. When the form submits to The next page it does not take the t variable with it.

     

    How do I do this?

  3. Hi phpfreaks

     

    I need to know how to create a database that will give me the operation of a calander. I want an example. I have looked around the web but can't seem to find anything that will explain what they are doing. I don't want a script.

     

    Any assistance would be great thanks gish

  4. this function when called will elevate the month or decrease the month depending on the link you press. I know what the issue is

     

    date("m") +  $_SESSION //works fine

     

    date("m") - $_SESSION  //this works very very badly

     

    does anyone know how to fix it? =)

     

    function GetMonth(){
    		$Name = $_GET['m']; //this needs to be a session
        		switch($Name) {
            		case b: 
            		  $_SESSION ['calendar']--; 
      				  return mktime(0, 0, 0, 	date("m") - $_SESSION ['calendar'], date("d"), date("y"));
            		break;
            		case f: 
            		  $_SESSION ['calendar']++; 
    			  return mktime(0, 0, 0, 	date("m") + $_SESSION ['calendar'] , date("d"), date("y"));
            		break;
           		default:
           		  $_SESSION ['calendar']= 0; 
       			  return mktime(0, 0, 0, 	date("m"), date("d"), date("y"));
       			}
    
    }
    echo date("d/m/Y", GetMonth()); 
    

  5. Thanks that is what I was looking for.

    One quick question I have been looking at this date

    function.

     

      [mday]    => 17

     

    I understand this tells me the day of the month 

    How do I find out how many  days that are in a  month?

     

  6. I mean some think like this

     

    $right_now = mktime(0, 0, 0, date("m"), date("d"), date("y"));
    echo "Current date: ".date("m/d/y", $right_now); 
    

     

    The output would be 6/2/2009

     

    then you press a link <href>

     

    Then the output would be 6/3/2009

     

    In Australia is d/m/y

  7. I am creating a online calender, I found a small scripted pulled it apart to find out how it works. now i am trying to create a calender will show three months two months in advance. My problem is I can't the  date[mon] to increment up.

     

    Does anyone know what I am doing wrong?

     

     

        $monthOne['mon']= $monthOne['mon']+ 1; 
        echo $monthOne['mon'];
    
        $monthTwo['mon']= $monthOne['mon']+ 2;
        echo $monthTwo['mon'];
    
    

     

        // current month
        $today    = getdate();
        $firstDay = getdate(mktime(0,0,0,$today['mon'],1,$today['year']));
        $lastDay  = getdate(mktime(0,0,0,$today['mon']+1,0,$today['year']));
        
        //month one
        $monthOne    = getdate();  
        $monthOne['mon']= $monthOne['mon']+ 1; 
        echo $monthOne['mon'];
        $monthOnefirstday = getdate(mktime(0,0,0,$monthOne['mon'],1,$monthOne['year']));
        $monthOnelastDay  = getdate(mktime(0,0,0,$monthOne['mon']+1,0,$monthOne['year']));
        
        //month two
        $monthTwo    = getdate();
        $monthTwo['mon']= $monthOne['mon']+ 2;
        echo $monthTwo['mon'];
        $monthTwofirstday = getdate(mktime(0,0,0,$monthTwo['mon'],1,$monthTwo['year']));
        $monthTwolastDay  = getdate(mktime(0,0,0,$monthTwo['mon']+1,0,$monthTwo['year']));
    
    

     

    Gish

  8. thanks

    The to answer your question is the  file include("inc/login.inc");has three headers to chose from. The problem is that when I run the script it gets sent to include("inc/error.inc"); automatically. I need preg_match to recognizes  empty strings so that I can stop the error.

     

    how do I do that? I googled and can't find anything?

  9. I am using preg_match to protect my scripts.

    I have two questions,

    One Is this going to protect the server?

    Two As it enters the script it sees that the username and password are empty. but I need them to be empty. So how do I get preg_match to let empty strings through.

     

    <?phps
    include("inc/security.inc");
    //object security this test to see if the login script is has any scripting issues
    $script_protector = new security($_POST['username'] , $_POST['password']);
    $script_protector ->preg_match_0to9($_POST['username'] , $_POST['password']);
    //security needs to return a 1 to enable the next function
    if ($script_protector->security_checked() == 1){
    include("inc/login.inc");
    } else {
    //needs to return to last figures
    $_SESSION['information']['error']= 2;
    include("inc/error.inc");
    }
    ?>
    

     

    <?php
    class security
    {
    private $username;
    private $password;
    private $past_string;	
    // this method(function) is setup for numbers only 0 to 9 and a maxium of 40 numbers	
      public function preg_match_0to9 ($username , $password){
    		if (( preg_match('/^[A-Za-z0-9]+$/',$username) ) or (preg_match('/^[A-Za-z0-9]+$/',$password)) ){ 
    		//this is make sure the string is not to long
    				strlen($username); strlen($password); 
    				if (($username >= 40) or ($password >= 40) ){
    					$this->past_string = 0;
    					//the security test is incorrect
    					} else { 
    					$this->past_string = 1;
    					//the security test is correct
    					}
    		} else { 
    		$this->past_string = 0;
    		//the security test is incorrect
    		}			
    }
    // this is function is a return value for the method (function) called   
       public function security_checked() {
                return $this->past_string;        
       }
    }
    ?>
    
    

  10. When writing session variables into your script is it better for the web servers security, speed and resource  to  have the following,

     

    $_SESSION['login']= 0;

    $_SESSION['username']= $username_variable;

    $_SESSION['address']=  $address;

    $_SESSION['phone']= $phone;

     

    or

     

    $_SESSION['information'] = array();

    $_SESSION['information]['username'] =$username_variable; ;

    $_SESSION['information']['address']=  $address;

    $_SESSION['information']['phone']= $phone;

     

    The reason I am asking is I am about to start a large personal project and it has to have quite a few session variables and I don't want to cause an issue. After looking at the plan I have in place most of them could go into a single array. But I am not sure if that is of any advantage.

     

    Gishaust

  11. hi there is nothing wrong with the code except

     

      public function missed_return(){

          return  $this->$Missed;

      }

      public function yes_return(){     

          return  $this->$Yes;

      } 

      public function no_return(){ 

          return  $this->$No;     

      }

      public function unsure_return(){     

          return  $this->$Unsure; 

      }

     

     

    the variables need to be

    return  $this->Unsure; 

    and so on

×
×
  • 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.