New Paste

 

Recent Pastes

Administrate




pzt.me

/p'eɪːzt.miː/
A simple, multi-purpose pastebin for sharing and collaborating with text, code, images, video and URLs over miscellaneous messaging and microblogging media.
PZT.Me or PZTMe is a short-url pastebin and image-bin with video embedding capabilities. It supports Syntax Highlighting, made available through GeSHi. The sole purpose of this pastebin is to create a quick, easy pastebin that provides the user with a short url, suitable for Twitter, Facebook, IRC and a number of other microblogging and instant messaging clients. It's a free pastebin, it is quick and has it's own JSON API. There is a bookmarklet plugin that works on most browsers, powered by Javascript, allowing you to easily paste text to the pastebin anywhere and quickly retrieve a short-url address in seconds!
 
PasteID: m
Pasted by Xan, Sun, 28 Feb 2010 15:35:50 +0000 GMT
Expires in 30 weeks 1 day
Paste size 3.8 Kb
Toggle Expand   Wrap   Raw
Copy Contents   Copy URL
 
  1. <?php
  2. /*
  3.  *	Cookie Updater (updateCookie.php)
  4.  *
  5.  *	Keeps the user session alive and healthy...
  6.  *
  7.  */
  8.  
  9.  
  10. /* This file updates the cookie (as long as it exists) to
  11. stop the cookie from expiring mid-session. This is because
  12. you create a cookie that expires an hour from creation at login
  13. but do not update the expiration time when there is activity
  14. in the admin area so if the user is doing something for an hour
  15. in the admin area they end up being logged out after an hour and
  16. losing their work. */
  17.  
  18. if(isset($_COOKIE['ID_my_site']) && isset($_COOKIE['Key_my_site']) && isset($_COOKIE['Permission_my_site']))
  19. 	{
  20. 		setcookie('ID_my_site', $_COOKIE['ID_my_site'], time() + 3600);
  21. 		setcookie('Key_my_site', $_COOKIE['Key_my_site'], time() + 3600);
  22. 		setcookie('Permission_my_site', $_COOKIE['Permission_my_site'], time() + 3600);
  23. 	}
  24.  
  25. /* Had an idea in regards to how to log activity (I think). I am working on the
  26. presumption you need to know when they were last active? To do this you just need
  27. to add the column 'LastActive' to the table 'staff'
  28.  
  29. ALTER TABLE  `staff` ADD  `LastActive` BIGINT NULL
  30.  
  31. What 'LastActive' will be is a Unix timestamp produced from this page, writing
  32. the last time they were active on this system with the a timestamp.
  33.  
  34. Below is the modified condition from above.*/
  35.  
  36. if(isset($_COOKIE['ID_my_site']) && isset($_COOKIE['Key_my_site']) && isset($_COOKIE['Permission_my_site']))
  37. 	{
  38. 		mysql_connect("localhost", "ian", "j******") or die(mysql_error());
  39. 		mysql_select_db("ian") or die(mysql_error());
  40. 		$sql = "UPDATE staff SET LastActive = " . time() . " WHERE Username = '" . $_COOKIE['ID_my_site'] . "'";
  41. 		if($query = mysql_query($sql))
  42. 			{
  43. 				setcookie('ID_my_site', $_COOKIE['ID_my_site'], time() + 3600);
  44. 				setcookie('Key_my_site', $_COOKIE['Key_my_site'], time() + 3600);
  45. 				setcookie('Permission_my_site', $_COOKIE['Permission_my_site'], time() + 3600);
  46. 			}
  47. 		else
  48. 			die('User Tracking Error!');
  49. 		mysql_close();
  50. 	}
  51.  
  52. ?>
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. <?php
  64.  
  65. /*
  66.  *	Example of showing time since last active (ExampleLastActive.php)
  67.  *
  68.  *	Shows the Years, Months, Weeks, Days, Hours, Minutes and Seconds since
  69.  *	the user was last active, using the 'LastActive' column in 'staff'.
  70.  *
  71.  *
  72.  *	ex, "iapoxon was last active 20 hours and 3 seconds ago."
  73.  */
  74.  
  75. function LastActive($time)
  76. 	{
  77. 		$context = array(
  78. 				array(60 * 60 * 24 * 365 , "years"),
  79. 				array(60 * 60 * 24 * 7, "weeks"),
  80. 				array(60 * 60 * 24 , "days"),
  81. 				array(60 * 60 , "hours"),
  82. 				array(60 , "minutes"),
  83. 				array(1 , "seconds"),
  84. 	 		);
  85.  
  86. 			$now = gmdate('U');
  87. 				$difference = $now - $time;
  88.  
  89.  
  90. 			for ($i = 0, $n = count($context); $i < $n; $i++) {
  91.  
  92. 					$seconds = $context[$i][0];
  93. 					$name = $context[$i][1];
  94.  
  95. 					if (($count = floor($difference / $seconds)) > 0) {
  96. 			   			break;
  97. 						}
  98. 				}
  99.  
  100. 		$print = ($count == 1) ? '1 ' . substr($name, 0, -1) : $count . " " . $name;
  101.  
  102. 				if ($i + 1 < $n) {
  103. 	      				$seconds2 = $context[$i + 1][0];
  104. 					$name2 = $context[$i + 1][1];
  105.  
  106. 					if (($count2 = floor(($difference - ($seconds * $count)) / $seconds2)) > 0) {
  107. 								$print .= ($count2 == 1) ? ' 1 ' . substr($name2, 0, -1) : " " . $count2 . " " . $name2;
  108. 			}
  109. 		}
  110.  
  111. 		return $print;
  112. 	}
  113.  
  114.  
  115. /* Now if we were use this in a page (the above is a custom function and needs to be included in whatever page you use it in)
  116. We would need to write the following... */
  117.  
  118. mysql_connect("localhost", "ian", "j******") or die(mysql_error());
  119. mysql_select_db("ian") or die(mysql_error());
  120. $sql = "SELECT LastActive FROM staff WHERE Username = 'xamanning'";
  121. if($query = mysql_query($sql))
  122. 	{
  123. 		while($user = mysql_fetch_assoc($query))
  124. 			echo "Xan was last active " . LastActive($user['LastActive']) . " ago.";
  125. 	}
  126. else
  127. 	die('User Tracking Error!');
  128. mysql_close();
  129.  
  130. /* The Result I got from doing this produced the following
  131.  
  132. "Xan was last active 10 minutes 41 seconds ago." (How long it took to write this page) */
  133.  
  134. ?>
 

 
 

 
 
 
 
 
Written for RPM-Productions.org by Knoxious.co.uk, 2010.   [ Valid HTML5 ]
YOU NEED FLASH!   YOU NEED FLASH!