Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function fb_profile_picture($id_user)
- {
- global $facebook;
- $profile_picture = $facebook->api(array('method' => 'fql.query', 'query' => "select src_big from photo where pid in (select cover_pid from album where owner='".$id_user."' and name='Profile Pictures')"));
- if(!empty($profile_picture[0]['src_big']))
- {
- $url_image = $profile_picture[0]['src_big'];
- }
- else
- {
- $url_image = 'http://graph.facebook.com/'.$id_user.'/picture?type=large';
- }
- $file = dirname(dirname(__FILE__)).'/page/generate/'.$id_user.'.jpg';
- if(function_exists('fopen'))
- {
- $image = file_get_contents($url_image);
- }
- else
- {
- $curl_handle=curl_init();
- curl_setopt($curl_handle,CURLOPT_URL,$url_image);
- curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
- curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
- $image = curl_exec($curl_handle);
- curl_close($curl_handle);
- }
- file_put_contents($file, $image);
- }
- function postGeneratedImage($img)
- {
- global $facebook, $user;
- /* DETECT APLICATION */
- $album_name = ALBUM_NAME;
- $album_description = ALBUM_DESCRIPTION;
- $photo_description = PHOTO_DESCRIPTION;
- $facebook->setFileUploadSupport(true);
- $album = $facebook->api(array('method' => 'fql.query','query' => "SELECT object_id FROM album WHERE owner='".$user['id']."' AND name='".$album_name."'"));
- if(!$album)
- {
- $create_album = $facebook->api('/me/albums', 'post', array('message'=> str_replace("#LINK_TAG#", PAGE_URL.'?sk=app_'.APP_ID, $album_description), 'name'=> $album_name));
- $album_uid = $create_album['id'];
- }
- else
- {
- $album_uid = $album[0]['object_id'];
- }
- $upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', array('message' => str_replace("#LINK_TAG#", PAGE_URL.'?sk=app_'.APP_ID, $photo_description), 'image' => '@' . realpath($img)));
- }
- session_start();
- //The License key as found in the License Mate system
- $key = DOMAIN_KEY;
- //Location of the License Mate System
- $host = 'licence.sillytalks.com';
- if (!(isset($_SESSION['license']))) {
- ini_set('default_socket_timeout', 1);
- //Get the return fo the system.
- $return = @file_get_contents('http://'.$host.'/index.php?p=api&host='.$_SERVER["HTTP_HOST"].'&key='.$key);
- //If Connection failed do nothing (the server might be expierencing problems, not a reason to den usage of the system).
- if (!($return === FALSE)) {
- if (!($return==1)) {
- //There was a problem with the license, you can do anything you like here. We decided to display the error returned and exit the script.
- echo $return;
- exit();
- } else {
- //The license is correct, to skip further uneccesary load on the server we place a session variable. You may replace this with your own system, but don't forget to edit the IF satement further up in this script.
- $_SESSION['license'] = '1';
- }
- }
- }
- //The license is valid.
- function app_core()
- {
- global $user;
- $path_fonts = dirname(dirname(__FILE__)).'/page/font/';
- $img = dirname(dirname(__FILE__)).'/page/generate/image'. $user['id'] .'.jpg';
- if (!file_exists($img))
- {
- fb_profile_picture($user['id']);
- /* PROFILES */
- $file_1 = dirname(dirname(__FILE__)).'/page/generate/'.$user['id'].'.jpg';
- /* RESIZE */
- include("resize.php");
- if(file_exists($file_1))
- {
- $resizeObj = new resize($file_1);
- $resizeObj -> resizeImage(USER_PIC_SIZE_X, USER_PIC_SIZE_Y, 'exact');
- $resizeObj -> saveImage($file_1, 100);
- }
- else
- {
- $file_1 = dirname(dirname(__FILE__)).'/page/images/default-user.jpg';
- }
- //======================================== PAYMENT =====================================//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement