Advertisement
Guest User

Untitled

a guest
May 29th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.44 KB | None | 0 0
  1. <?php
  2. // Load the classes and stuff thats needed.
  3. require_once('kbconfig.php');
  4. require_once('common/includes/db.php');
  5. require_once('common/includes/class.config.php');
  6. require_once('common/includes/class.memcached.php');
  7.  
  8. // Initiate a new config
  9. $config = new Config(KB_SITE);
  10.  
  11. // Grab the info from the kb3_config table
  12. $name = $config->get("style_name");
  13. $owner = $config->get("style_owner");
  14.  
  15. // Set the style name as an MD5 (Since names are unique)
  16. $md5 = md5($name);
  17.  
  18. // First check if the stylesheet is in memcached
  19. if (memcached::get($md5)){
  20.         // Stylesheet is memcached, grab it!!
  21.         $stylesheet = unserialize(memcached::get($md5));
  22.         echo "/*memcached*/\n";
  23. }
  24. else{
  25.         // Then if its not, grab it from mysql and insert to memcached - and then use the stylesheet from the database
  26.         $qry = new DBQuery();
  27.         $qry->execute("SELECT stylesheet FROM kb3_stylesheets WHERE kbsite = '$owner' AND name = '$name'");
  28.         $row = $qry->getRow();
  29.         // Insert stylesheet to memcached for further usage
  30.         memcached::set($md5, serialize(stripslashes($row['stylesheet'])));
  31.         // Instead of having to start all over, just use the already fetched stylesheet from mysql
  32.         $stylesheet = stripslashes($row['stylesheet']);
  33.         echo "/*mysql*/\n";
  34. }
  35.  
  36. // No header expires or anything, seeing as its all grabbed from memcached
  37. header('Content-Type: text/css');
  38. echo "".$stylesheet."\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement