mrnutter

KMITL48 FB App

Jul 25th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.92 KB | None | 0 0
  1. <?
  2.     require_once("facebook.php");
  3.  
  4.     $config = array();
  5.     $config['appId'] = '';
  6.     $config['secret'] = '';
  7.  
  8.     $facebook = new Facebook($config);
  9.  
  10.     $user = $facebook->getUser();
  11.  
  12.     if (!$user) {
  13.         $url =   "https://graph.facebook.com/oauth/authorize?"
  14.                  ."client_id=".$config['appId']."&"
  15.                  ."redirect_uri=https://apps.facebook.com/kmitlfortyeight/&"
  16.                  ."scope=user_photos";
  17.         echo "<script>location.href='$url';</script>";     
  18.         die();
  19.     }
  20.    
  21.     if(isset($_GET[add])) {
  22.         $add = str_replace(".","",$_GET[add]);
  23.         $img = file_get_contents("https://graph.facebook.com/$user/picture");
  24.         $fp = fopen("./uploads/$add.jpg","w+");
  25.         fwrite($fp,$img);
  26.         fclose($fp);
  27.         $fp = fopen("db.txt","a+");
  28.         fwrite($fp,$add."\t".$user."\n");
  29.         fclose($fp);
  30.     }
  31.    
  32.    
  33. ?>
  34. <html>
  35. <head>
  36. <title>KMITL48</title>
  37. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  38. <style>
  39. .box,table {
  40.     border-width:1px;
  41.     border-style:solid;
  42.     font-size:9px;
  43.     font-family:"arial";
  44. }
  45. body {
  46.     margin:0px;
  47.     padding:0px;
  48.  
  49. }
  50. a {
  51.     text-decoration:none;
  52. }
  53. </style>
  54. </head>
  55.  
  56. <body>
  57. <script>
  58. function add(id) {
  59.     var ans = confirm("คุณมั่นใจหรือไม่ว่าคุณรหัส " +id);
  60.     if(ans) {
  61.         location.href="index.php?add="+id;     
  62.     }
  63.  
  64. }
  65. </script>
  66. <?php
  67.     echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
  68.     for($i=1; $i<=1400; $i++) {
  69.         $id=52010000+$i;
  70.         if(($i-1)%15==0) echo "<tr>\n";
  71.    
  72.         if(file_exists("./uploads/$id.jpg")) {
  73.             echo "<td>";
  74.             echo "<img src=\"https://www.theinspirehost.com/kmitl48/uploads/$id.jpg\">";
  75.             echo "</td>\n";        
  76.         } else {
  77.             echo "<td width=\"48\" height=\"48\" align=\"center\" valign=\"middle\" class=\"box\">";
  78.             echo "<a href=\"javascript:add($id)\">$id</a>";
  79.             echo "</td>\n";
  80.         }
  81.         if(($i-1)%10==14) echo "</tr>\n";      
  82.     }
  83.     echo "</table>\n";
  84. ?>
  85. </body>
Advertisement
Add Comment
Please, Sign In to add comment