Z tego pliku zauwazylem, ze przerywajac przeniesienie na prawidlowa strone po zatwierdzeniu mozliwosci poboru danych uzytkownika facebook'a wyswietla mi sie blad:
"You may be a victim of CSRF", blad ten jest zapisany w powyzszym pliku w adnotacji iz jest to drugi krok potwierdzania danych:
function fb_connect_flow() { $code = $_REQUEST['code']; //Autentication step 1 $current_url = $this->currentPageURL(); $dialog_url = 'https://www.facebook.com/dialog/oauth?client_id='.$this->fb_app_id.'&redirect_uri='.urlencode($current_url).'&state='.$_SESSION['ygp_fb_box']['salt'].'&scope='.$this->fb_scope; } //Autentication step 2 else { if($_SESSION['ygp_fb_box']['salt'] && ($_SESSION['ygp_fb_box']['salt'] === $_GET['state'])) { $current_url = $this->currentPageURL(); $token_url = 'https://graph.facebook.com/oauth/access_token?client_id='.$this->fb_app_id.'&redirect_uri='.urlencode($current_url).'&client_secret='.$this->fb_app_secret.'&code='.$_GET['code']; $data = $this->getDataFromURL($token_url); $data2 = json_decode($data, true); } else { $signed_request['access_token'] = $access_token; if($expires==0 || $expires=='') $signed_request['expires'] = 0; $user_data['token'] = $signed_request['access_token']; $user_data['token_expires'] = $signed_request['expires']; $_SESSION['ygp_fb_box']['user'] = $user_data; //print_r($_SESSION); return 1; } } else { } } }
Hosting na ktorym stoi skrypt ma zainstalowane php 5.5, panel ktory wyswietla dane uzytkownika, ktory dal dostep zaktualizowane przez baze danych manualnie wyswietlaja sie bezblednie, wszystkie opcje dotyczace tego wpisu w baze danych da sie z postaci strony edytowac.
//Facebook app settings //,publish_actions,email,user_birthday,manage_pages, $GLOBALS['fb_ypbox_path'] = $GLOBALS['app_folder'].''; $GLOBALS['fb_scope'] = 'publish_actions,email,public_profile'; //$GLOBALS['fb_connect_redirect'] = ''; $GLOBALS['fb_logout_redirect'] = 'konta/logowaniefb.php'; $GLOBALS['fb_sdk_js_callback'] = ''; $GLOBALS['fb_sdk_lang'] = '';
Powyzej sa ustawienia pliku, czyli dane gdzie ma przenosic i jakie dane zbierac od uzytkownika, ktore zapisane sa w pliku konfiguracyjnym
Ponizej plik odpowiedzialny za wybor i wprowadzanie tych informacji do bazy danych
<?php include('../include/webzone.php'); $f1 = new Fb_ypbox(); $result = $f1->fb_connect_flow(); //authentication successs if($result) { $f1 = new Fb_ypbox(); $user_data = $f1->getUserData(); $long_lived = $f1->getLongLivedToken(); $token = $long_lived['token']; $expires = $long_lived['expires']; $id = $users[0]['id']; $fb_email = $users[0]['fb_email']; if($fb_email=='') $fb_email = $user_data['email']; $m1 = new MySqlTable(); $sql = "UPDATE ".$GLOBALS['db_table']['users']." SET fb_email='".$m1->escape($fb_email)."', fb_token='".$m1->escape($token)."', fb_token_expires='".$m1->escape($expires)."' WHERE id='".$m1->escape($id)."'"; $m1->executeQuery($sql); } else { //Insert user data to the DB $m1 = new MySqlTable(); $sql = "INSERT INTO ".$GLOBALS['db_table']['users']." (fb_id, fb_name, fb_email, fb_token, fb_token_expires, fb_birthday, created) VALUES ('".$m1->escape($user_data['id'])."', '".$m1->escape($user_data['name'])."', '".$m1->escape($user_data['email'])."', '".$m1->escape($token)."', '".$m1->escape($expires)."', "; $m1->executeQuery($sql); //Get settings $result = get_settings(); for($i=0; $i<count($result); $i++) { $settings[$result[$i]['meta_key']] = $result[$i]['meta_value']; } //Autopost status if($settings['autopost_status']=='on') { $f1 = new Fb_ypbox(); $settings['autopost_status_message'] = str_replace('{name}', $user_data['name'], $settings['autopost_status_message']); $result = $f1->updateFacebookStatus(array('fb_id'=>$fb_id, 'message'=>$settings['autopost_status_message'], 'link'=>$settings['autopost_status_link'], 'picture'=>$settings['autopost_status_picture']), $user_data['token']); } //Autopost email if($settings['autopost_email']=='on') { if($user_data['email']!='') { $settings['autopost_email_message'] = str_replace('{name}', $user_data['name'], $settings['autopost_email_message']); sendMail($GLOBALS['email_from'], $user_data['email'], $settings['autopost_email_subject'], $settings['autopost_email_message']); } } } } //redirect } ?>
Wydaje mi sie, ze wszystko jest ok, ale mimo kilku prob dalej uzytkownik, ktory da zezwolenie na pobor danych z jego profilu nie jest zapisywany w bazie danych. Ciezko by bylo pisac podobny skrypt od nowa, dlatego tez prosze o interwencje i pomoc jakichs bardziej doswiadczonych uzytkownikow, chetnie dostarcze wszelkie inne w razie czego informacje lub pliki. Dziekuje i pozdrawiam oraz prosze o wyrozumialosc, gdyz jest to moj pierwszy post na tym forum i mam nadzieje, ze nie ostatni
