Advertisement
jargon

Very Real Peeps cookie script

Feb 20th, 2017
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.54 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.     1: This source file is the "Very Real Peeps" Support (peeps-support.php) module from build "0-050j" of NenGame PHP.
  5.     2: "NenGame" is a scripting engine coordinated by Nick of Neinstar Filmz.
  6.     3: Nick's contact information is locatable via data:text/html=<style>url(http://neinstarfilmz.com/);</style>
  7. **/
  8.  
  9. vrp_boot();
  10.  
  11. function vrp_id($id=NULL)
  12. {
  13.     global $nen;
  14.    
  15.     if(!is_dir($nen['root'].'/'.$nen['peeps']))
  16.         mkdir($nen['root'].'/'.$nen['peeps']);
  17.  
  18.     if(is_string($id))
  19.     {
  20.         $pattern='([0-9]{14})((\+|\-)([0-9]{4}))\_([0-9]{8})';
  21.         if(preg_match('/'.$pattern.'/',$id,$matches))
  22.             if($matches[0]===$id)
  23.                 if(!is_file($nen['root'].'/'.$nen['peeps'].'/'.$id.'.ini'))
  24.                     $id=NULL;
  25.             else
  26.                 $id=NULL;
  27.         else
  28.             $id=NULL;
  29.     }
  30.     if(is_null($id))
  31.     {
  32.         if(isset($_COOKIE['id']))
  33.             $id=$_COOKIE['id'];
  34.         else
  35.             $id=NULL;
  36.         if($id=NULL)
  37.         {
  38.             $id=date('YmdHisO');
  39.             echo '<h1><tt>id:'.htmlentities($id).'</tt></h1>';
  40.             $i=0;
  41.             while(is_file($nen['root'].'/'.$nen['peeps'].'/'.$id.'_'.str_pad($i,8,'0',STR_PAD_LEFT).'.ini'))
  42.                 $i++;
  43.             $id=$id.'_'.str_pad($i,8,'0',STR_PAD_LEFT);
  44.         }
  45.         setcookie('id',$id,time()+86400*365*15);
  46.     }
  47.     $nen['id']=$id;
  48.     echo '<h1><tt>id:'.htmlentities($id).'</tt></h1>';
  49.     return $id;
  50. }
  51.  
  52. function vrp_boot()
  53. {
  54.     global $nen,$nenini;
  55.    
  56.     if(isset($_COOKIE['id']))
  57.         $id=vrp_id($_COOKIE['id']);
  58.     else
  59.         $id=vrp_id();
  60.        
  61.     $vrp=false;
  62.     if(is_file($nen['root'].'/'.$nen['peeps'].'/'.$nen['id'].'.ini'))
  63.         $vrp=nenscript_list_ini_load('/'.$nen['peeps'].'/'.$nen['id'].'.ini',"\r\n",'file');
  64.     if(is_array($vrp))
  65.     {
  66.         $vrp['id']=$nen['id'];
  67.         ksort($vrp);
  68.         $temp=array();
  69.         foreach($vrp as $key => $value)
  70.         {
  71.             $nen[$key]=$value;
  72.             array_push($temp,'"'.$key.'"="'.$value.'"');
  73.         }
  74.         file_put_contents($nen['root'].'/'.$nen['peeps'].'/'.$nen['id'].'.ini',implode("\r\n",$temp));
  75.         $nen['vrp']=$nen['id'];
  76.     }
  77.     else
  78.     {
  79.         $vrp=array('id'=>$nen['id']);
  80.         ksort($vrp);
  81.         $temp=array();
  82.         foreach($vrp as $key => $value)
  83.         {
  84.             $nen[$key]=$value;
  85.             array_push($temp,'"'.$key.'"="'.$value.'"');
  86.         }
  87.         file_put_contents($nen['root'].'/'.$nen['peeps'].'/'.$nen['id'].'.ini',implode("\r\n",$temp));
  88.         $nen['vrp']=$nen['id'];
  89.     }
  90.     if(isset($_REQUEST['debug']))
  91.         if($nen['vrp']!==false)
  92.         {
  93.             echo '<h1><tt>Very Real Peeps, New Model No."'.$nen['vrp'].'"</tt></h1>';
  94.             echo '<p><tt>';
  95.             if(is_array($vrp))
  96.                 foreach($vrp as $key => $value)
  97.                     echo '"'.htmlentities($key).'"="'.htmlentities($value).'"';
  98.             else
  99.                 echo '<i>(empty)</i>';
  100.             echo '</tt></p>';
  101.         }
  102. }
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement