KingCuddles's Profile User Rating: -----

Reputation: 176 Stalwart
Active Members
Active Posts:
496 (0.21 per day)
20-December 08
Profile Views:
Last Active:
User is offline Jun 21 2013 12:36 AM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Who Cares
Dream Kudos:
Icon   KingCuddles has not set their status

Posts I've Made

  1. In Topic: Looking Filemanager

    Posted 5 Jun 2013


    Want something already built? Or build it yourself?
  2. In Topic: Most secure way to store a session id?

    Posted 4 Jun 2013

    I would have a quick look at session security just to make sure you are not making any basic mistakes. Chris Shiflett has a great article on session hijacking.

    Other than that you shouldn't be too concerned about user sessions getting mixed up.

    If you still want to store sessions in a database (or anywhere else) you can use session_set_save_handler() - again Chris has you covered!
  3. In Topic: Is Using PHP Caching And Login Sessions A Dangerous Combination?

    Posted 4 Jun 2013

    I would have a quick look at session security just to make sure you are not making any basic mistakes. Chris Shiflett has a great article on session hijacking.

    I think what you mean though, is if you cache a user profile page when I am logged in, then you log in you would see my data? Normally when you cache something you would give it a unique key, in this case (at a basic level) you could use the users id to ensure that the cache is tied to an individual. There is an example below (using Memcahe) which shows roughly what I mean.

    That said, I would think as long as your HTML isn't horrendous and you have good (clean/minified/cached) CSS/js the effort involved with caching HTML would not be worth your time.

    I know I have used Smarty, Blade and Twig (templating languages) extensively and I am fairly sure they all do some sort of caching out of the box.

    So what I would do is focus on caching heavy SQL queries, so if your user queries are huge you could using Memcache(d) to do:

    // Obviously validate your user is logged in and all that good stuff up here
    // See if the data is cached
    if ($memcahce->get($user_id) != false)
      // In which case use what we have in the cache
      $data = $memcahce->get($user_id);
    // Data not cached!
      // Run our monster user query
      $data = $database->getUser();
      // Cache the results for later
      $memcache->set($user_id, $data, MEMCACHE_COMPRESSED, $cachePeriod);
    // Use $data...

    Obviously this is a ridiculously simple example, but it should make sense.

    As Atli points out below, it is probably not worth caching your users control panel, I should have made that clearer :)/>
  4. In Topic: Centering Text using GD (using ImageTTFText)

    Posted 4 Jun 2013

    I did something similar when generating a certificate:

      * Returns the cordinates for text to be central to an image
      * @param string $img_width - The width of the image
      * @param int $font_size - The size of the string font
      * @param int $font_file - The font file
      * @param string $string - The string
    function get_center_text_position($img_width, $font_size, $font_file, $string) {
      //Grab the width of the text box
      $bounding_box_size = imagettfbbox($font_size, 0, $font_file, $string);
      $text_width = $bounding_box_size[2] - $bounding_box_size[0];
      //Return the position the text should start
      return ceil(($img_width - $text_width) / 2);
    // Generate a new image (WxH)
    $img_path = '/x/y/z/images/certificate.png';
    $img = imagecreatefrompng($img_path);
    imagealphablending($img, false);
    imagesavealpha($img, true);
    //Grab the certificate width
    $img_width = getimagesize($img_path);
    // Set the text color (RGB)
    $text_colour = imagecolorallocatealpha($img, 0, 0, 0, 70);
    // Configure Font
    $font_size = 35;
    $font_file = '/x/y/z/fonts/font.ttf';
    // Add the various data we want to overlay - imagettftext(resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text)
    imagettftext($img, $font_size, 0, get_center_text_position($img_width[0], $font_size, $font_file, $candidate_name), 50, -$text_colour, $font_file, $candidate_name);

    That's just extracted from my code so may not be 100% or I may have missed bits out (or broken things when I changed paths) so let me know if you have any questions!
  5. In Topic: PHP and Simogeo Filemanager

    Posted 4 Jun 2013

    Did you try the docs for the config file? Particularly fileRoot?

My Information

Member Title:
D.I.C Regular
24 years old
February 22, 1991
Salisbury, Wiltshire
Web Development
Full Name:
Tom Green
Programming Languages:

Contact Information

Website URL:
Website URL