Jump to content

Mehdi

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Mehdi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Tested browsers: firefox 3.6.16 chromium 10.0.648.133 IE 8 The content of index.php. <?php include_once 'Webshop.php'; // class Webshop include_once 'InputChecker.php'; // static class InputChecke include_once 'LayoutMaker.php'; // static class LayoutMaker session_start (); // check for the first visit if (!isset ($_SESSION ['webshop'])) $_SESSION ['webshop'] = new Webshop (); // handels all input from $_POST include_once 'postChecker.php'; if (InputChecker::getPageAction ($_GET ['p']) == PageAction::LOGOUT) $_SESSION ['webshop'] -> setRole (Role::VISITOR); if (InputChecker::isInputCorrect ($_GET ['c'], $_GET ['s'], $_GET ['b'], $_GET ['p'], $_SESSION ['webshop'] -> getCategories (), $_SESSION ['webshop'] -> getBrands ())) { echo LayoutMaker::getTop (); echo LayoutMaker::getPageWithPointers ($_GET ['c'], $_GET ['s'], $_GET ['b'], $_GET ['a'], $_GET ['p'], $_SESSION ['webshop'] -> getRole (), $_SESSION ['webshop'] -> getCategories (), $_SESSION ['webshop'] -> getBrands ()); echo LayoutMaker::getBottom ($_SESSION ['webshop'] -> getRole ()); } else { echo LayoutMaker::getTop (); echo LayoutMaker::getPageWithoutPointers ($_SESSION ['webshop'] -> getCategories ()); echo LayoutMaker::getBottom (); } ?> Content of postChecker.php: <?php require_once '/someWhere/loginInfoSite.php'; // contains username and password if (isset ($_POST ['username']) && isset ($_POST ['password']) && $_POST ['username'] == $username && $_POST ['password'] == $password) $_SESSION ['webshop'] -> setRole (Role::ADMIN); ?>
  2. Hi, My php application works abnormal. The used code to mange session is: include_once "classesFiles"; session_start (); // check for the first visit if (!isset ($_SESSION ['anObject'])) $_SESSION ['anObject'] = new Object (); $username = "xxx"; $password = "yyy"; if (isset ($_POST ['username']) && isset ($_POST ['password']) && $_POST ['username'] == $username && $_POST ['password'] == $password) $_SESSION ['anObject'] -> setRole (Role::ADMIN); if (InputChecker::getPageAction ($_GET ['p']) == PageAction::LOGOUT) $_SESSION ['anObject'] -> setRole (Role::VISITOR); ... I tested the code as follow: 1- go to the site 2- log in 3- make a new tab in the same browser 4- go to the site from the new tab (I am already logged in) 5- log out from the new tab 6- go to the first tab 7- refresh the tab. I am still logged in (I find this behavior abnormal) The second test: 1- go to the site 2- log in 3- make a new tab in the same browser 4- go to the site from the new tab (I am already logged in) 5- go to the first tab 6- log out 7- go to the second tab 8- refresh the tab. I am logged out (I find this normal) The order of tabs from which I log out is important. Does anyone have an idea why the first test dose not work normal? Thanks,
  3. At the first line, the characters &, " and ' have to convert to entities, don't they?
  4. Hi, I work on an ubuntu system with php 5.2.1. The next code doesn't convert my string to entities! Could you guide me please? <html> <head> <title>Text including html</title> </head> <body> <?php echo phpinfo(); $str= <<<TEXT Einstürzende Neubauten and Marya's & Mother and again "test". TEXT; $code=htmlentities($str, ENT_QUOTES); $code1=htmlspecialchars($str); echo $code,"<br>",$code1; ?> </body> </html>
  5. Mehdi

    calendar

    Yes I work with Linux. Thanks for the guide.
  6. Mehdi

    calendar

    Hello, My calendar program shows only the date from 1902 until 2037. Could you say me why the program cannot shows the calendar of the years after 2037? Thanks,
  7. Hello, I've written a script that has to show a bar chart with horizontal line of the name of companies en vertical line of amount of money that each company has payed. But it doesn't work. I think it have to work well. Could you check it, and tell me where the error is, please? Thanks, [code] <?php header("Content-type: image/png"); class simpelbar{ private $margin=20; //The margin around of chart private $marginverticalline=20; //place of vertical line private $marginhorizentalline=40;//place of horizontal line private $barmargin=10; //distance between two cells private $inputwidth; //inserted width private $inputheight; //inserted height private $cells=array(); //array for the companies information private $font="luxisri.ttf"; //font function __construct($width,$height){   $this->inputwidth=$width;   $this->inputheight=$height; } function addbar($company,$money){   $this->cells[$company]=$money; } private function fontadjust($widthbar){   $fontsize=$widthbar;   foreach($this->cells as $key=>$val){   while(true){     $textsize=imageTTFbbox($fontsize,0,$this->font,$key);     if(abs($textsize[2])<$widthbar){     break;     }     $fontsize--;   }   } return $fontsize; } function draw(){   $realwidth=$this->inputwidth-$this->margin*2; //the width of image   $realheight=$this->inputheight-$this->margin*2; //the height of image   $ystarthorizentalline=$realheight-$this->marginhorizentalline; // the begging y-point of horizontal line   $xendhorizentalline=$realwidth-$this->margin; //the end x-point of horizontal line   $max=max($this->cells); //the maximum amount of the money   $totalbars=count($this->cells); //total cells of the chart   $verticallinelong=$ystarthorizentalline-$this->margin; //the height of the vertical line   $widthbar=(int)(($realwidth-(2*$this->margin)-($this->barmargin*($totalbars+1)))/$totalbars); //the width of  a cell   $text_size=$this->fontadjust($widthbar); //the text size   $image=imagecreate($realwidth,$realheight);   $red=imagecolorallocate($image,255,0,0);   $blue=imagecolorallocate($image,0,0,255);   $black=imagecolorallocate($image,0,0,0);   imageline($image, $this->margin,$ystarthorizentalline,$this->margin,$this->margin,$black);   imageline($image,$this->margin,$ystarthorizentalline,$xendhorizentalline,$ystarthorizentalline,$black);   $xbar=$this->margin+$this->barmargin; //the x-point of the first cell   foreach($this->cells as $key=>$val){   $ybar=$ystarthorizentalline-(int)($val/$max*$verticallinelong); // the y-point of first cell   $nextxbar=$xbar+$widthbar;// the second x-point of the cell   $nextybar=$this->marginhorizentalline;// the second y-point of the cell   imagefilledrectangle($image,$xbar,$ybar,$nextxbar,$nextybar,$blue);   $box=imageTTFbbox($text_size,0,$this->font,$key);   $xstartfont=$xbar+(int)(($widthbar-abs($box[2]))/2); //the begging of the text under the cells   imageTTFtext($image,35,0,$xstartfont,$realheight-5,$black,$this->font,$key);   $xbar=$nextxbar+$this->barmargin;//counting of the x-point of the next cell   }   imagepng($image); } } $test=new simpelbar(400,300); $test->addbar("Shell",300); $test->addbar("Philips",200); $test->addbar("CCC",400); $test->draw(); ?>[/code]
  8. [quote author=HuggieBear link=topic=113440.msg460993#msg460993 date=1162372581] The function in your class is called aadbar (notice the two 'a') and you call is using addbar (notice the two 'd'). Regards Huggie [/quote] Thanks
  9. Hi, The below script doesn't run. If I run it I get the error message of "The image cannot be displayed". Could you tell me where the error is? [code]<?php header("Content-type: image/png"); class simpelbar{ private $margin=20; private $marginverticalline=20; private $marginhorizentalline=40; private $barmargin=10; private $inputwidth; private $inputheight; private $cells=array(); private $font="luxisri.ttf"; function __construct($width,$height){   $this->inputwidth=$width;   $this->inputheight=$height; } function aadbar($company,$money){   $this->cells[$company]=$money; } private function fontadjust($widthbar){   $fontsize=$this->marginhorizentalline;   foreach($this->cells as $key=>$val){   while(true){     $textsize=imageTTFbbox($fontsize,0,$this->font,$key);     if(abs($textsize[2])<$widthbar){     break;     }     $fontsize--;   }   } return $fontsize; } function draw(){   $realwidth=$this->inputwidth-$this->margin*2;   $realheight=$this->inputheight-$this->margin*2;   $ystarthorizentalline=$realheight-$this->marginhorizentalline;   $xendhorizentalline=$realwidth-$this->margin;   $max=max($this->cells);   $totalbars=count($this->cells);   $verticallinelong=$ystarthorizentalline-$this->margin;   $widthbar=(int)($realwidth-(2*$this->margin)-($this-barmargin*($totalbars+1))/$totalbars);   $text_size=$this->fontadjust($widthbar);   $image=imagecreate($realwidth,$realheight);   $red=imagecolorallocate($image,255,0,0);   $blue=imagecolorallocate($image,0,0,255);   $black=imagecolorallocate($image,0,0,0);   imageline($image, $this->margin,$ystartborizentalline,$this->margin,$this->margin,$black);   imageline($image,$this->margin,$ystarthorizentalline,$xendhorizentalline,$ystarthorizentalline,$black);   $xbar=$this->margin+$this->barmargin;   foreach($this->cells as $key=>$val){   $ybar=$ystarthorizentalline-(int)(($val/$max)*$verticallinelong);   $nextxbar=$xbar+$widthbar;   $nextybar=$this->marginhorizentalline;   imagefilledrectangle($image,$xbar,$ybar,$nextxbar,$nextybar,$blue);   $box=imageTTFbbox($text_size,0,$this->font,$key);   $xstartfont=$xbar+(int)(($widthbar-$box[2])/2);   imageTTFtext($image,35,0,$xstartfont,$realheight-5,$black,$this->font,$key);   $xbar=$nextxbar+$this->barmargin;   }   imagepng($image); } } $test=new simpelbar(400,300); $test->addbar("Shell",300); $test->addbar("Philips",200); $test->addbar("CCC",400); $test->draw(); ?>[/code]
  10. Hello, The next script cann't send a message to a mail addresse by "Yahoo" (someone@yahoo.com) but wel to a mail addresse by google (someone@gmail.com). [code]<html> <head> <title>Exercise 14.2</title> </head> <body> <div> <form method="post" action="<?=$_SERVER['PHP_SELF']?>"> <p> Insert your mail address: <input type="text" name="mail"> </p> <p> Insert the subject: <input name="subject" type="text"> </P> <p> <textarea name="message" row="50px" col="70px"> </textarea> </p> <p> <input type="submit" value="Submit"> </p> </form> </div> <?php $to="someone@yahoo.com"; $from=$_REQUEST['mail']; $subject=$_REQUEST['subject']; $message=$_REQUEST['message']; if (!empty($from) && !empty($subject) && !empty($message)){ mail($to, $subject, $message, "From: $from\r\n") or die("Couldn't send mail"); print "Browser: ".$_SERVER['HTTP_USER_AGENT']."<br>IP address: ".$_SERVER['REMOTE_ADDR']; } else { print "You haven't filled in the form completely!"; } ?>[/code] Could you help me please? Thanks,
×
×
  • 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.