S
stew

  • Mar 12, 2006
  • Joined Dec 4, 2002
  • I work for a company that specialises in exactly this...

    we can process pretty much any CV in any format and over a few languages and extract the relavent information and stick it in XML.

    let me know if you are at all interested in this.

    oh, but it isn't free.

    • hey there...

      I just launched an application for testing and i've allowed users to upload images to a public photo gallery. however, when something is being uploaded the response of the rest of the site is REALLY slow....

      is there anything that can be down to prevent this or minimise the effect?

      • preg_match("/^([0-9]+|MAX)$/",$volume);
        

        hey there,

        the above regular expression is supposed to match any positive number or the string "MAX", however it fails when $volume = "MAX";

        any ideas?

        • sorry I just excluded the lines for class definitions so that there was less code... they were there in the file!

          i've tried changing the code to

          require_once("StockGame.class.php");
          require_once("stockItem.class.php");
          require_once("StockItemList.class.php");
          
          
          session_start();
          
          $game = null;
          
          print_r($_SESSION);
          
          if($_SESSION["game"] == null)
          {
              $game = new StockGame();
              $game->buildGame();
              $_SESSION["game"] = $game;
              print_r($_SESSION["game"]);
          }
          
          
          //print_r($game);
          
          if(!$_SESSION["game"]->checkGameComplete())
          {
               $_SESSION["game"]->nextGo();
               print_r($_SESSION["game"]);
          }
          else
          {
              print "destroying game";
              session_destroy();
          }
          
          print_r($_SESSION["game"]);
          $left = $_SESSION["game"]->getTurnsRemaining();
          //print_r($game);
          print_r($_SESSION["game"]);
          
          
          
          print "<br /><br /><a href=\"test_item.php\">next</a> || you have ".$left." remaining";
          
          print_r($_SESSION["game"]);
          
          

          and everything appears as it should when I dump the objects... but when I click the link at the bottom or refresh the page, the $_SESSION["game"] is again null.

          ???

          • session_start();
            
            $game = null;
            
            print_r($_SESSION);
            
            if(!isset($_SESSION["game"]))
            {
                $game = new StockGame;
                $game->buildGame();
            }
            else
            {
                $game = unserialize($_SESSION["game"]);
            }
            
            print_r($game);
            
            if(!$game->checkGameComplete())
            {
                 $game->nextGo();
            }
            else
            {
                session_destroy();
                print "destroying game";
            }
            
            $left = $game->getTurnsRemaining();
            
            print_r($game);
            
            $_SESSION["game"] = serialize($game);
            
            

            Hey there guys the above code doesn't appear to be saving the $game as a session variable ( i have cookies enabled!!). also the print_r($_SESSION), prints an array with the 'game' key being null/not set.

            I know that you need to serialise objects when storing them as session variables so i can't really see why the above script isn't working.

            Also I know that the session destroy function isn't being called as nothing is being printed.

            any ideas?

            stew

            •    $parentID = null;
                  $parentType = null;
                  $user;
                  if(!isLoggedIn())
                  {
                      header("Location: ".$this->getHeader("community","login",null,null,null,null,"mustBeLoggedIn"));die;
                  }
                  else
                  {
                      $user = getSessionUser();
                   }
                  if(array_key_exists("id2",$_GET))
                  {
                      if(ctype_digit($_GET["id2"]))
                      {
                          $parentID = $_GET["id2"];
                      }
                  }
                  if(array_key_exists("id1",$_GET))
                  {
                      if($_GET["id1"] == "photo" || $_GET["id1"] == "gig" || $_GET["id1"] == "diary" || $_GET["id1"] == "news") {
                          $parentType = $_GET["id1"];
                          }
                  }
                  //print $parentID.$parentType;
                  if(!isset($parentID) || !isset($parentType))
                  {
                      header("Location: ". $this->getHeader("pictures",null,null,null,null,null,"badPhotoGig"));  die;
                  }
              
              

              the above code seems to have some error in it somewhere...

              the block of code inside the last if statement is executed whenever the print statement is commented out, but is not executed when the script prints out $parentID and $parentType.

              anyone have any ideas why?

              cheers
              stew

              • the problem was that the $user object had lost its association with the class definition... i moved the updateOnline() function call to the line after the require_once... at it appears to have solved my problem ...somehow... 🙂

                • update...

                  a form is being posted to bookmark.php (entire contents listed)

                  require_once("includes.php");
                  if(!checkSession())
                  {
                      print "bad session";
                      die;
                  }
                  
                  if(isLoggedIn())
                  {
                      $user = getSessionUser();
                      $bk = new bookmark();
                      $bk->setTitle($_POST["title"]);
                      $bk->setUrl($_SERVER["HTTP_REFERER"]);
                      $bk->userID = $user->ID;
                      updateOnline();
                      if(saveBookmark($bk))
                      {
                          header("Location: ".$_SERVER["HTTP_REFERER"]."&sid=".session_id());
                          exit;
                      }
                  }
                  
                  

                  When the script is called the $user is created successfully with all correct details. The saveBookmark function stores the session user's ID in the database correctly.
                  when the header function is called the same valid sid is attached to the URI. when the page is forwarded to the refering page the isLogged in function (listed above) returns true; but contains an stdClass object instead of a User Object.

                  i hope this makes my query a bit easier to understand!

                  • ok...

                    I have made a pretty complex community based website, that is controlled by the index.php file (all requested go to it). The index.php includes a session.php which contains functions like isLoggedIn(), getSessionUser() and alike... however, when i post data from a form to say bookmark.php which updates a database table and returns the user to the refering page, the $_SESSION['user'] variable empties.

                    I haven't experience the $SESSION['user'] emptying when a request is made to the index.php file, by always when a request is made to any other file. When isLoggedIn() is called from another file (eg bookmark.php) it returns true.

                    function isLoggedIn()
                    {
                       return !(!isset($_SESSION['user'));
                    
                    }
                    
                    print_r($_SESSION['user']); /// prints stdClass Object ( [lastClicks] => 1130694728 ) - should be a whole lot mote data and the object should be of type User, not stdClass
                    
                    

                    anyone know why this might be happening?

                    stew

                    • i guess the file could be out of date.... or empty even?

                      i dont have shell access to check any of those, but php_info() says that browscap is set to extras/browscap.ini.

                      • the only reason i can see for the script not displaying anything would be the 'exit' statement, when you test for the file being uploaded.

                        do you know if the file is successfully uploaded?

                        make sure the directory permissions allow apache to write to that (httpdocs/uploads) directory.

                        stew

                        • thanks, that was very helpful!

                          i've read the manual (twice) and the php code that i quote is copied directly from the manual. so, assuming the manual is right, then the code quoted should print the browsers detail.... but it doesn't!

                          can anyone give me some constructive suggestions.....

                          • print_r(get_browser(null,true));

                            prints nothing...

                            i have just got my host to restart the server after having set the browscap ini directive - but now there is no errors, nor an array being returned!

                            anyone have any ideas about the source of this problem?

                            • im using php desinger 2005... and i have no idea what it is set to encode in... but the same function works fine when called with "community" as the first parameter. i'm assuming it can make a big difference which way the scripts are encoded!!

                              • ok i have the following function...

                                function getHeader($section=null,$action=null,$id1=null,$id2=null,$id3=null,$limit=null,$error = null)
                                    {      $link = "?";
                                
                                        $link .= ($section) ? "section=".$section."&" : "";
                                        $link .= ($action) ? "action=".$action."&" : "";
                                        $link .= ($id1) ? "id1=".$id1."&" : "";
                                        $link .= ($id2) ? "id2=".$id2."&" : "";
                                        $link .= ($id3) ? "id3=".$id3."&" : "";
                                        $link .= ($limit) ? "limit=".$limit."&" : "";
                                        $link .= ($error) ? "e=".$error."&" : "";
                                        $link = substr($link,0,-1);
                                
                                        return $link;
                                }
                                

                                being called like...

                                $header = getHeader("community","profile");
                                

                                in the above example $header contains ?section=hE(some sort of filled in black square)&action=profile

                                I have tested this function throughly and it works fine in all other circumstances

                                also:

                                $header = getHeader("communi","profile");  /// works fine
                                $header = getHeader("communit","profile");  /// doesn't work either!!
                                

                                for the record im running easy php on windows...

                                hope someone will be able to help!

                                cheers

                                stewart

                                • hey there guys...

                                  im also trying to protect against SQL injections so far ive come up with:

                                  $expr = array ("/--/","/1\=1/","/$' or/","/$' Or/","/$' oR/","/$' OR/");
                                        if(pre_match($expr,$sql_statement))
                                          die;
                                  

                                  to prevent dangerous sql statements being executed... I know that the this doesn't protect against union injections, but the it would be easy enough to alter.

                                  Question: is there any other types of sql injection attacks that i should be aware of?

                                  • RewriteEngine on
                                    RewriteRule $ http://domain.com/index.php?section=news
                                    RewriteRule ([a-zA-Z]+)([/]?)$ http://domain.com/index.php?section=$1
                                    RewriteRule ([a-zA-Z]+)/([a-zA-Z0-9]+)([/]?)$ http://domain.com/index.php?section=$1&action=$2
                                    RewriteRule ([a-zA-Z]+)/([a-zA-Z0-9]+)/([0-9]+)([/]?)$ http://domain.com/index.php?section=$1&action=$2&limit=$3
                                    RewriteRule ([a-zA-Z]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([0-9]+)([/]?)$ http://domain.com/index.php?section=$1&action=$2&id1=$3&limit=$4
                                    RewriteRule ([a-zA-Z]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([0-9]+)/([0-9]+)([/]?)$ http://domain.com/index.php?section=$1&action=$2&id1=$3&id2=$4&limit=$5

                                    hey there guys...
                                    its probably pretty easy to see what i'm trying to do here...

                                    i have the first folders such domain.com/folder1/folder2 being translated into
                                    index.php?section=folder1&action=folder2... it works fine... but in some cases there is going to be other variables /folder1/folder2/33 or /folder1/folder2/33/44/55 with limit being set at 33 and then 55 respectively...

                                    however, the way i did it above seems a bit inefficient and probably to rigidly defined... is there a better to do this... in this case:

                                    domain.com/news/show/11/22/33/44/55/66

                                    could be translated into index.php?section=news;action=show;id1=11;id2=22;id3=33;id4=44;id5=55;limit=66

                                    first and second parts put into section and action respectively the last number the limit and all others inbetween are id1...id5? is it possible to dynamically do this, or does there have to be strict rules for everything in the .htaccess file?

                                    cheers
                                    stewart

                                    • hey there i'm not on a computer that i can test php scripts on at the moment otherwise i would try it myself....

                                      is it possible to have an abstract class that extends another class?

                                      stew

                                      • well it just goes to show... that you do learn something new everyday!