Ejemplo n.º 1
0
 									$video_id = $mc->string( array('type' =>'remove-space' , 'string'=>$video_id ) ); 

 								# assign to the source of the image

 									$src = str_replace(' ','', "http://i4.ytimg.com/vi/$video_id/hqdefault.jpg");

 									 // $src = 'http://i4.ytimg.com/vi/jV67jvvurCg/hqdefault.jpg';


 							endif;

 							echo "<img src='$src' /> ";

 							echo "  $src  <br><BR><Br><br>"; 
 
	 						$pa->download_image_from_other_site( $artno , $src , 'fs_folders/images/uploads/posted articles/detail/' );    
 					else:  				 	
	 					$response = $mc->upload_image(    
	 						array(
	 							"tmp_name" =>$_FILES["file"]["tmp_name"] , 
	 							"destination" =>"$mc->article_detail/$artno.jpg"
	 						)
	 					);	 	 
	 					$mc-> message ( 'image upload ', $response , ' ' ); 
 					endif;
 					echo " video id = $video_id  <br>";

 				/** resize image */

	 				$response = $mc->resize_image( 
					  	array( 
Ejemplo n.º 2
0
    public function social_site_login($type)
    {
        $article = new postarticle();
        $image = new resizeImage();
        switch ($type) {
            case 'facebook':
                ?>


						<div id="fb-root"></div> 

						    <script src="http://connect.facebook.net/en_US/all.js"></script>  
						    <script> 
							    FB.init({ 
							      appId: '528594163842974', 
							      cookie: true,
							      status: true, 
							      xfbml: true 
							    }); 
						    </script>    

					        <?php 
                /** 
                 * Copyright 2011 Facebook, Inc.
                 *
                 * Licensed under the Apache License, Version 2.0 (the "License"); you may
                 * not use this file except in compliance with the License. You may obtain
                 * a copy of the License at
                 *
                 *     http://www.apache.org/licenses/LICENSE-2.0
                 *
                 * Unless required by applicable law or agreed to in writing, software
                 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
                 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
                 * License for the specific language governing permissions and limitations
                 * under the License.
                 * get friend list: https://developers.facebook.com/docs/graph-api/reference/user/friendlists/
                 */
                if ($mno != 136) {
                    // already logged in and redirecting to authenticate the account.
                    // echo " mno $mno <br>";
                    // $_SESSION['temp_mno'] = intval($mno);
                    // $this->go( 'login-authentication' );
                } else {
                    require '../../../fs_folders/API/facebook-php-sdk-master/src/facebook.php';
                    $facebook = new Facebook(array('appId' => '528594163842974', 'secret' => 'a411c8a3c4361556491b2c2ddf38bf21'));
                    $user = $facebook->getUser();
                    if ($user) {
                        try {
                            // $user_profile = $facebook->api('/me');
                            echo "user logon!";
                        } catch (FacebookApiException $e) {
                            error_log($e);
                            $user = null;
                            echo "user logout!";
                        }
                    }
                    if ($user) {
                        // echo " logout user";
                        $logoutUrl = $facebook->getLogoutUrl();
                    } else {
                        echo " set parametter to login ";
                        /*
                        								        $params = array(
                        								            'scope' =>'ads_management,create_event,create_note,email,export_stream,friends_about_me, 
                        								            	friends_activities, friends_birthday, friends_checkins, friends_education_history, friends_events, 
                        								            	friends_games_activity, friends_groups, friends_hometown, friends_interests, 
                        								            	friends_likes, friends_location, friends_notes, friends_online_presence, 
                        								            	friends_photo_video_tags, friends_photos, friends_questions, friends_relationship_details
                        								            	friends_relationships, friends_religion_politics, friends_status, friends_subscriptions
                        								            	friends_videos, friends_website, friends_work_history, manage_friendlists
                        								            	manage_notifications, manage_pages, offline_access, photo_upload, publish_actions
                        								            	publish_checkins, publish_stream, read_friendlists, read_insights, read_mailbox
                        								            	read_requests, read_stream, rsvp_event, share_item, sms, status_update, user_about_me
                        								            	user_activities, user_birthday, user_checkins, user_education_history, user_events
                        								            	user_games_activity, user_groups, user_hometown, user_interests, user_likes
                        								            	user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos
                        								            	user_questions, user_relationship_details, user_relationships, user_religion_politics
                        								            	user_status, user_subscriptions, user_videos, user_website, user_work_history
                        								            	video_upload xmpp_login', 
                        								            	'redirect_uri' => 'http://fashionsponge.com/login'
                        								        );
                        */
                        $params = array('scope' => ' email,friends_about_me,user_about_me,user_birthday, user_education_history,
							            	user_games_activity, user_groups, user_hometown, user_interests, user_likes
							            	user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos
							            	user_questions, user_relationship_details, user_relationships, user_religion_politics
							            	user_status, user_subscriptions, user_videos, user_website, user_work_history
							            	', 'redirect_uri' => 'http://fashionsponge.com/login');
                        $statusUrl = $facebook->getLoginStatusUrl();
                        $loginUrl = $facebook->getLoginUrl($params);
                    }
                }
                ?>
 

					        <!doctype html>
					        <html xmlns:fb="http://www.facebook.com/2008/fbml">
					          <head> 
					            <title>php-sdk FS-LogIN</title> 
					          	</head>
					          	<body>
						          	<?php 
                echo " <br> user =  {$user} <br> ";
                // echo " <br> user= "******" facebook user logon.";
                    echo " \n\t\t\t\t\t\t\t\t\t\t\t\t<a href='{$logoutUrl}'; >facebook Logout</a>\n\t\t\t\t\t\t\t\t\t\t        <a href='logout.php'>fs Logout</a> <br> \n\t\t\t\t\t\t\t\t\t\t    ";
                    echo " <h4> user facebook user logon info. </h4>";
                    echo '<pre>';
                    print_r($user_profile);
                    echo '</pre>';
                    #saving to account info and user info.
                    // echo "<hr>";
                    // freinds
                    /*
                    													echo " <h4> user facebook user logon friends. </h4>";
                    	print_r($friends);   
                    */
                    // sign up of get mno
                    $fs_user = selectV1('*', 'fs_members', array('fbid' => intval($user_profile['id'])));
                    $mno1 = $fs_user[0]['mno'];
                    if (!empty($mno1)) {
                        #allready a members
                        echo " 1.) fb user is already a member <br>";
                        echo " 2.) update all friends , friends in fs and friends in fb <br> ";
                        $fb_friends = $this->get_logging_in_fb_friends_and_filter($friends['data']);
                        $this->update_logging_in_fb_friends($mno1, $fb_friends['fb_all_freinds'], $fb_friends['fb_freinds_on_fs'], $fb_friends['fb_freinds_on_fb']);
                        $_SESSION['temp_mno'] = $mno1;
                        $this->go('login-authentication');
                    } else {
                        #new member
                        echo " 1.) fb user is a new member <br> ";
                        echo " 2.) add new info member to fashionsponge database [done] <br> ";
                        echo " 2.) add new account member to fashionsponge database [done] <br> ";
                        echo " 3.) update all friends , friends in fs and friends in fb [done] <br> ";
                        echo " 4.) get new profile pic from fb and save to fs [done]  <br> ";
                        echo " 5.) add activity action that new fs member joind and post it on the feed with the profile pic [done] <br> ";
                        echo " 6.) show profile information fields to fill up <br> ";
                        echo " 7.) show suggested brand  <br> ";
                        echo " 8.) show suggested member according to its style generated through the brands selected  <br> ";
                        echo " 9.) a welcome fashionsponge message sent to email <br> ";
                        // fb info
                        $fbid = $user_profile['id'];
                        $firstname = $user_profile['first_name'];
                        $lastname = $user_profile['last_name'];
                        $gender = $user_profile['gender'];
                        $birthday = substr($user_profile['birthday'], strlen($user_profile['birthday']) - 4, strlen($user_profile['birthday']));
                        $bio = $user_profile['bio'];
                        $workwith = $user_profile['work'][0]['position']['name'];
                        $workat = $user_profile['work'][0]['location']['name'];
                        $email = $user_profile['email'];
                        $username = str_replace('.', '', $user_profile['username']);
                        $username = str_replace('and', '', $username);
                        echo " <br><BR> FB INFO <br><BR><BR><BR>";
                        // education
                        $school_ex_len = count($user_profile['education']) - 1;
                        echo " total school expeience {$school_ex_len} <br> ";
                        # college
                        $studied_with = $user_profile['education'][$school_ex_len]['concentration'][0]['name'];
                        $studied_at = $user_profile['education'][$school_ex_len]['school']['name'];
                        $studied_graduate_date = $user_profile['education'][$school_ex_len]['year']['name'];
                        if (empty($studied_at)) {
                            # high school
                            $studied_at = $user_profile['education'][$school_ex_len - 1]['school']['name'];
                            $studied_graduate_date = $user_profile['education'][$school_ex_len - 1]['year']['name'];
                        }
                        echo " \t\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfbid = {$fbid}      <br> \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfirstname = {$firstname}  <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlastname = {$lastname}   <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgender = {$gender}    <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbirthday = {$birthday}  <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbio = {$bio}       <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twork = {$work}          <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tworkat = {$workat}        <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstudied_with = {$studied_with}   <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstudied_at = {$studied_at}     <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstudied_graduate_date = {$studied_graduate_date} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\temail = {$email}    <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tusername = {$username}   <br><br><br><br><br><br> ";
                        /*
                        	$fbid = 100000954625049; 
                        	$firstname = 'Mary';
                        	$nickname  = 'Jean'; 
                        	$lastname = 'Suarez';   
                        */
                        // insert new user info .
                        $b = insert('fs_members', array('firstname', 'nickname', 'lastname', 'fbid', 'aboutme', 'bdate', 'gender', 'work_at', 'occupation', 'studied_at', 'studied_with', 'studied_graduate_date', 'datejoined'), array($firstname, $nickname, $lastname, $fbid, $bio, $birthday, $gender, $workat, $workwith, $studied_at, $studied_with, $studied_graduate_date, date("Y-m-d H:i:s")), 'mno');
                        // get new user info inserted
                        $userinfo = $this->get_latest_user_info();
                        $mno = intval($userinfo[0]['mno']);
                        // $email     = '*****@*****.**';
                        // $username  = '******';
                        // $pass      = '';
                        // insert new user account
                        $b = insert('fs_member_accounts', array('mno', 'email', 'username', 'pass'), array($mno, $email, $username, ''), 'mano');
                        // echo " new member <br>";
                        // $fs_user = selectV1('*','fs_members', array('fbid'=> intval($fbid) ) );
                        $fs_user = selectV1('*', 'fs_members', null, 'order by mno desc', 'limit 1');
                        $mno1 = intval($fs_user[0]['mno']);
                        $fb_friends = $this->get_logging_in_fb_friends_and_filter($friends['data']);
                        $this->update_logging_in_fb_friends($mno1, $fb_friends['fb_all_freinds'], $fb_friends['fb_freinds_on_fs'], $fb_friends['fb_freinds_on_fb']);
                        echo " big profile pic <br> ";
                        $size = 'large';
                        $url = "http://graph.facebook.com/{$fbid}/picture?type={$size}";
                        $headers = get_headers($url, 1);
                        if (isset($headers['Location'])) {
                            $bigpicurl = $headers['Location'];
                            // string
                        } else {
                            echo "ERROR";
                        }
                        echo "profile pic path src. {$bigpicurl} <br>";
                        echo "<img src=\"{$bigpicurl}\"  />";
                        // download from fb photo server
                        $mppno = $this->member_profile_pic_query(array('mno' => $mno1, 'action' => 'Joined', 'type' => 'insert-new-profile-pic-db'));
                        echo " your new profile pic in {$mppno} <br>";
                        $article->download_image_from_other_site($mppno, $bigpicurl, 'fs_folders/images/uploads/members/mem_original/');
                        /*
                        									                                	$profile_fs_src_original   = 'fs_folders/images/uploads/members/mem_original';
                        									                                	$profile_fs_src_thumbnail  = 'fs_folders/images/uploads/members/mem_thumnails'; 
                        									                                	$profile_fs_src_profilepic = 'fs_folders/images/uploads/members/mem_profile';  
                        */
                        // resize the profile pic downloaded
                        $this->resize_profile_pic_thumbnail_and_profile($mppno);
                        // $this->resize_fb_profile_pic( $mno1 , $image , $profile_fs_src_original , $profile_fs_src_thumbnail , $profile_fs_src_profilepic );
                        // add activity post feed
                        $this->add_activity_wall_post($mno1, $mppno, 'Joined', 'fs_members', $this->date_time);
                        // redirect to the main page
                        $_SESSION['type'] = 'new-member-fb-login';
                        $_SESSION['temp_mno'] = $mno1;
                        $_SESSION['lastpagevisited'] = 'profile_crop_display.php';
                        $this->go('login-authentication');
                    }
                    echo " ur mno {$mno1} <br> ";
                    // add update friends on fb and on fs
                    // updated
                    #saving to fb_all_friends , fb_friends_on_fs , fb_friends on fb at [ user account info ]
                    // echo "<hr>";
                } else {
                    // $b = updateArray('fs_members',array('fb_all_freinds'), array('505457421-+-549151146-+-'),'mno',$mno);
                    // if ($b) {
                    // 	echo " succesfully updated <br> ";
                    // }else{
                    // 	echo " failled to update ";
                    // }
                    echo "  \n\t\t\t\t\t\t\t\t                <a href='{$loginUrl}'>Login with Facebook</a> \n\t\t\t\t\t\t\t\t            ";
                    // $name = $this->get_facebook_user_info_by_fbid( $facebook , '100004690904448' );
                    // echo " fbid = 100004690904448 and name = $name <br>";
                }
                ?>
 
					          	</body>
					        </html>  
							<?php 
                break;
            case 'twitter':
                # code...
                break;
            case 'google':
                # code...
                break;
            case 'tumblr':
                # code...
                break;
            default:
                # code...
                break;
        }
    }
								// retrieve big profile pic of the new user
									echo " big profile pic <br> ";
								  	$size = 'large';
	                                $url = "http://graph.facebook.com/$fbid/picture?type=$size"; 
	                                $headers = get_headers($url, 1); 
	                                if( isset($headers['Location']) ){  
	                                    $bigpicurl = $headers['Location']; // string
	                                }else{
	                                    echo "ERROR";
	                                }   
	                                echo "profile pic path src. $bigpicurl <br>";
	                                echo "<img src=\"$bigpicurl\"  />";    
	                            // add new profile pic for the new user
	                            	$mppno = $mc->member_profile_pic_query( array('mno'=>$mno1 , 'action'=> 'Joined' , 'type'=>'insert-new-profile-pic-db' ) );   
	                            // download from fb photo server 
										$article->download_image_from_other_site( $mno1 , $bigpicurl , 'fs_folders/images/uploads/members/mem_original/' );   
	                            // resize the profile pic downloaded  
	                            	$mc->resize_profile_pic_thumbnail_and_profile( $mno1 , $mppno );    
	                            // add activity post feed  
	                            	#$mc->add_activity_wall_post ( $mno1 , $mppno , 'Joined' , 'fs_members' , $mc->date_time );    
	                            // send confirmation code 
	                            	if ( !empty($email) ) {
	                            		if ( $mc->send_verification_code_to_email( $email , $mc->generate_vefirification_code( $email ) , $firstname )  ) { 
	                            			echo " email confirmation successfully sent. . .";
	                            		} 
	                            	}   
	                            // set notification 
	                            		//$mc->set_notification_info( 'fs_members' , $mno1 , "your facebook friend Just <span class='fs-text-red'> joined </span>"  , $mno1 , 0 , 'join-fb' ); 
	                            		$mc->set_notification_info( 'fs_members' ,  $mno1 , 'joined' , null , null , 0 , 'join-fb' ); 
	                            // add or updated keyword 
	                            		$mc->fs_search(   array(  'type'=> 'add-or-updated-keyword' ,  'table_name'=>'fs_members' ,   'table_id'=>$mno1 )  );