function mx_mnfriends($page, $option, $action) { global $mxuser, $me, $facebook; echo '<p>' . _('Welcome to your Friends page') . '</p>'; $mxfriends = $mxuser->getfriends($mxuser->id); echo '<h5>' . _('Current friends') . '</h5>'; mx_showdir($mxfriends['confirmed']); echo '<h5>' . _('Pending friends') . '</h5>'; mx_showdir($mxfriends['pending']); echo '<h5>' . _('Recused friends') . '</h5>'; mx_showdir($mxfriends['recused']); echo '<h5>' . _('Ignored friends') . '</h5>'; mx_showdir($mxfriends['ignored']); if ($mxuser->fbid) { echo '<h5>' . _('Facebook friends already on MusXpand') . '</h5>'; if ($action == 'showfb') { mx_checkfblogin(); } if ($me) { $fbfriends = $facebook->api('/me/friends'); $fbfriendsids = array(); foreach ($fbfriends['data'] as $fbfriend) { $fbfriendsids[] = $fbfriend['id']; } $friends = $mxuser->checkfbfriends($fbfriendsids); mx_showdir($friends, true); //echo sprintf(_('If you want to check which of your Facebook friends' . //' are already on MusXpand, please %s'), //'<fb:login-button>'._('Synchronize with Facebook').'</fb:login-button>'); } else { echo '<p>'; echo sprintf(_('Click %s to see which Facebook friends are already on MusXpand'), '<a href="' . mx_actionurl($page, $option, 'showfb') . '" alt="' . _('Facebook friends') . '">' . _('here') . '</a>'); echo '</p>'; } } }
function savefbpics_async() { global $me, $mxdb, $s3; mx_checkfblogin(false); $fmt = array('large', 'small', 'square'); //$userdir=mx_option('usersdir').'/'.$this->hashdir; ini_set('allow_url_fopen', 1); if ($me) { $ok = 0; foreach ($fmt as $value) { if (@copy('http://graph.facebook.com/' . $this->fbid . '/picture?type=' . $value, mx_option('usersdir') . '/tmp/' . $this->hashdir . '_' . $value . '.jpg')) { $ok += 1; } } if ($ok == count($fmt)) { $pic = @imagecreatefromjpeg(mx_option('usersdir') . '/tmp/' . $this->hashdir . '_large.jpg'); if ($pic) { $w = imagesx($pic); $h = imagesy($pic); $nhl = round($h * 150 / $w); //$nhs=round($h*50/$w); //$mwh=min($w,$h); $imlarge = imagecreatetruecolor(150, $h * 150 / $w); //$imsmall=imagecreatetruecolor(50,$h*50/$w); //$imsquare=imagecreatetruecolor(50,50); imageantialias($imlarge, true); //imageantialias($imsmall,true); //imageantialias($imsquare,true); imagecopyresampled($imlarge, $pic, 0, 0, 0, 0, 150, $nhl, $w, $h); //imagecopyresampled($imsmall,$pic,0,0,0,0,50,$nhs,$w,$h); //imagecopyresampled($imsquare,$pic,0,0, // ($mwh==$h?($w-$mwh)/2:0),($mwh==$w?($h-$mwh)/2:0),50,50,$mwh,$mwh); // write logo //$impic=imagecreatetruecolor(150,$nhl); //imagecopy($impic,$imlarge,0,0,0,0,150,$nhl); $logo = imagecreatefrompng(mx_option('rootdir') . '/images/general/musxpand-logo.png'); $imlogo = imagerotate($logo, 90, 0); $lw = imagesx($imlogo); $lh = imagesy($imlogo); imagecopyresampled($imlarge, $imlogo, 129, 0, 0, 0, $lw / 2, $lh / 2, $lw, $lh); imagejpeg($imlarge, mx_option('usersdir') . '/tmp/' . $this->hashdir . '_large.jpg'); } foreach ($fmt as $value) { $keyname = 'users/' . $this->hashdir . '/pics/me_' . $value . '.jpg'; /*if ($s3->if_object_exists(MXS3BUCKET,$keyname)) { $s3->delete_object(MXS3BUCKET,$keyname); }*/ $res = $s3->create_object(MXS3BUCKET, $keyname, array('fileUpload' => mx_option('usersdir') . '/tmp/' . $this->hashdir . '_' . $value . '.jpg', 'acl' => AmazonS3::ACL_PUBLIC, 'meta' => array('origfilename' => 'http://graph.facebook.com/' . $this->fbid . '/picture?type=' . $value))); } $this->setoption('picture', 'local'); } else { $this->setoption('picture', ''); } } ini_set('allow_url_fopen', 0); return $this->picture(); }