Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //-----------------------------------------------
- // exception and error handlers
- //-----------------------------------------------
- function exceptionHandler($e) {
- echo '<div class="remark">Uncaught exception'.$e->getMessage().'</div>';
- }
- //----------------------
- function errorHandler($errno, $errstr, $errfile, $errline) {
- switch ($errno) {
- case E_ERROR:
- echo '<div class="remark">';
- echo 'Error: '.$errstr.'<br/>File: '.$errfile.'<br/>Line: '.$errline;
- echo '</div>';
- break;
- case E_WARNING:
- echo '<div class="remark">';
- echo 'Warning: '.$errstr.'<br/>File: '.$errfile.'<br/>Line: '.$errline;
- echo '</div>';
- break;
- case E_NOTICE:
- echo '<div class="remark">';
- echo 'Notice: '.$errstr.'<br/>File: '.$errfile.'<br/>Line: '.$errline;
- echo '</div>';
- break;
- case 2048:
- break;
- default:
- echo '<div class="remark">';
- echo 'Errno: '.$errno.'<br/>Error: '.$errstr.
- '<br/>File: '.$errfile.'<br/>Line: '.$errline;
- echo '</div>';
- }
- return true;
- }
- set_exception_handler('exceptionHandler');
- $default_error_handler = set_error_handler('errorHandler');
- //-----------------------------------------------
- require 'fb.inc.php';
- //-----------------------------------------------
- // process request
- //-----------------------------------------------
- $fb = fbManager::getInstance();
- if (!isset($_REQUEST['ajax']))
- draw_form();
- else
- {
- //---------------------------
- switch ($_REQUEST['reqtype']) {
- case 'showfqlcurr':
- case 'showfqlall':
- case 'showfqlcurr_list':
- case 'showfqlall_list':
- $tname = $_REQUEST['req'];
- $tname = trim(substr($tname, strpos($tname, 'from')+4));
- $tname = 'fql_'.substr($tname,0, strpos($tname,' '));
- break;
- case 'showcurr':
- case 'showall':
- case 'showcurr_list':
- case 'showall_list':
- $tname = 'fb_'.array_pop(explode('/',$_REQUEST['req']));
- break;
- case 'showcustom':
- case 'showcustomall':
- case 'showcustom_list':
- case 'showcustomall_list':
- $tname = $_REQUEST['req'];
- break;
- }
- //---------------------------
- switch ($_REQUEST['reqtype']) {
- case 'showfqlcurr':
- case 'showfqlcurr_list':
- case 'showcurr':
- case 'showcurr_list':
- case 'showcustom':
- case 'showcustom_list':
- $tcurruser=true;
- break;
- case 'showfqlall':
- case 'showfqlall_list':
- case 'showall':
- case 'showall_list':
- case 'showcustomall':
- case 'showcustomall_list':
- $tcurruser=false;
- break;
- }
- //---------------------------
- switch ($_REQUEST['reqtype']) {
- case 'showcurr':
- case 'showall':
- case 'showfqlcurr':
- case 'showfqlall':
- case 'showcustom':
- case 'showcustomall':
- $tprocname='db_drawTab';
- break;
- case 'showcurr_list':
- case 'showall_list':
- case 'showfqlcurr_list':
- case 'showfqlall_list':
- case 'showcustom_list':
- case 'showcustomall_list':
- $tprocname='db_drawList';
- break;
- }
- //---------------------------
- switch ($_REQUEST['reqtype']) {
- //-----------------------basic
- case 'apigraph':
- echo json_encode($fb->getNode($_REQUEST['req']));
- break;
- case 'fql':
- echo json_encode($fb->get_fql($_REQUEST['req']));
- break;
- //------------------------async requests
- case 'apigrapha':
- echo serialize($fb->getNode($_REQUEST['req']));
- break;
- case 'fqla':
- echo serialize($fb->get_fql($_REQUEST['req']));
- break;
- //---------------------------------
- case 'getfqls':
- echo json_encode(getFqls());
- break;
- case 'mktab':
- echo '<pre>'.print_r($fb->createNodeTable($_REQUEST['req'],true),true).'</pre>';
- break;
- case 'mkfqltab':
- echo '<pre>'.print_r($fb->createFqlTable($_REQUEST['req'],true),true).'</pre>';
- break;
- case 'filltab':
- echo '<pre>'.print_r($fb->fillNodeTable($_REQUEST['req']),true).'</pre>';
- break;
- case 'fillfqltab':
- echo '<pre>'.print_r($fb->fillFqlTable($_REQUEST['req']),true).'</pre>';
- break;
- //---------------------------------------show info
- case 'showcurr':
- case 'showall':
- case 'showfqlcurr':
- case 'showfqlall':
- case 'showcustom':
- case 'showcustomall':
- case 'showcurr_list':
- case 'showall_list':
- case 'showfqlcurr_list':
- case 'showfqlall_list':
- case 'showcustom_list':
- case 'showcustomall_list':
- echo $fb->$tprocname($tname, $tcurruser);
- break;
- //-------------------------------------------------
- case 'drawwidget':
- echo ($fb->drawWidget($_REQUEST['req']));
- break;
- //------------------------------complex
- case 'relatedusers':
- $_SESSION["step"]=1;
- $_SESSION["errorsz"]=0;
- header('location: '.$_SERVER['PHP_SELF'].
- '?ajax&reqtype=relatedusers_go');
- break;
- //---------------------
- case 'relatedusers_go':
- $fb->writeRelatedUsers();
- break;
- //----------------------------
- case 'relatedusers4':
- echo '<h3>Information successfully collected</h3>'.
- '<pre>'.print_r($fb->findRelatedUsers(),true).'</pre>';
- break;
- //----------------------------
- case 'relatedusers5':
- echo '<h3>Result page for related users</h3>';
- echo $fb->drawRelatedUsers();
- break;
- //----------------------------
- case 'likestofql':
- $outinf =$fb->likesBasesToFqlUsers();
- echo '<h3>Operation results</h3>';
- echo '<pre>'.print_r($outinf,true).'</pre>';
- break;
- }
- }
- //-------------------------------------------
- // read fqls file
- //-------------------------------------------
- function getFqls() {
- $s = file_get_contents('fql.txt');
- $spl3=str_repeat('=',76);
- $arr = explode($spl3,$s );
- //----------------
- function inff ($value) {
- $spl4=str_repeat('-',76);
- $inf = array();
- list($nam,$val) = explode($spl4, $value);
- $nam=implode(' ',array_filter(array_map('trim',explode(' ',str_replace(array("\n","\r")," ",$nam)))));
- $val=implode(' ',array_filter(array_map('trim',explode(' ',str_replace(array("\n","\r")," ",$val)))));
- $inf["name"]=$nam;
- $inf["value"]=$val;
- return $inf;
- }
- //----------------
- $arr4 = array_map('inff', $arr);
- return $arr4;
- }
- //-------------------------------------------
- // draw page
- //-------------------------------------------
- function draw_form() {
- global $fb;
- //---------------------
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns:fb="http://ogp.me/ns/fb#">
- <head>
- <title>Check page for fb operations</title>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta name="description" content="Check page for fb operations" />
- <meta name="keywords" content="facebook, api" />
- <script type="text/javascript" src="jquery.min.js"></script>
- <!-- ----------------------------------------- -->
- <style type="text/css">
- * {
- margin:0;
- padding:0;
- }
- h1 {
- padding:5px;
- }
- h3 {
- margin:15px 0 10px 0;
- }
- li {
- list-style-type:none;
- margin-bottom:4px;
- }
- #loginblock {
- font-family: arial, tahoma, sans-serif;
- font-size: 12px;
- word-wrap: break-word;
- }
- #loginblock a, #loginblock a:visited {
- display:block;
- padding:5px 0 5px 20px;
- margin: 4px 4px 5px 20px;
- border:solid 1px #888;
- background-color: #f0f0f0;
- text-decoration:none;
- color:#444;
- font-weight:bold;
- width:200px;
- font-size:150%;
- }
- #loginblock a:hover {
- background-color:#aaa;
- color:white;
- }
- #leftcolumn {
- float:left;
- width:400px;
- background-color:#f5f5f5;
- padding:10px;
- font-family: verdana, sans-serif;
- font-size:18px;
- }
- #leftcolumn a, #leftcolumn a:visited {
- color: #800;
- text-decoration:none;
- }
- #leftcolumn a:hover {
- text-decoration: underline;
- }
- #maincontent {
- margin-left:450px;
- }
- #ajaxcontent {
- min-height:40px;
- background-color:#fffff0;
- }
- #ajaxcontent p {
- }
- #ajaxstatus, #ajaxstatus3 {
- /*min-height:50px;*/
- margin: 5px;
- border: solid 1px #999;
- background-color: #eee;
- }
- #ajaxstatus p, #ajaxstatus3 p, #ajaxcontent p {
- overflow:hidden;
- border:solid 1px #aaa;
- margin:5px;
- padding:10px;
- }
- .remark {
- padding:10px;
- font-size:16px;
- border:solid 4px #888;
- background-color:#f5f5f5;
- margin-top:15px;
- width:500px;
- font-weight:bold;
- word-wrap: break-word;
- }
- #flinfo {
- position:absolute;
- display:none;
- z-index:100;
- }
- /*--------------------------------*/
- form {
- font-family: tahoma, geneva, sans-serif;
- font-size: 16px;
- color:#926262;
- padding:10px;
- }
- fieldset {
- border:1px solid #926262;
- padding:20px;
- padding-left:-1px;
- -webkit-border-radius:5px;
- -moz-border-radius:5px;
- -border-radius:5px;
- -khtml-border-radius:5px;
- margin-top:10px;
- margin-bottom:5px;
- }
- input[type=checkbox], input[type=radio] {
- display:block;
- float:left;
- margin-top:5px;
- margin-right:10px;
- }
- input[type=button] {
- padding:10px;
- background:#fea;
- color:red;
- font-weight:bold;
- cursor:pointer;
- border:solid 1px #800;
- -border-radius:5px;
- -moz-border-radius:5px;
- -webkit-border-radius:5px;
- }
- label {
- display:block;
- float:left;
- width:260px;
- margin-bottom:10px;
- margin-right:20px;
- text-align:right;
- }
- legend {
- font-size:1.5em;
- color:#926262;
- margin-left:20px;
- padding: 5px 10px;
- border: 1px solid #926262;
- -webkit-border-radius:5px;
- -moz-border-radius:5px;
- -border-radius:5px;
- -khtml-border-radius:5px;
- text-transform:capitalize;
- }
- .zrightfld p {
- margin-left: 200px;
- }
- /*--------------------------------*/
- </style>
- <!-- ----------------------------------------- -->
- <script type="text/javascript">
- function print_r(arr, level) {
- var print_red_text = "";
- if(!level)
- level = 0;
- //--------------------------------
- var level_padding = "";
- for(var j=0; j<level+1; j++)
- level_padding += " ";
- //--------------------------------
- if (typeof(arr) == 'object') {
- for (var item in arr) {
- var value = arr[item];
- if (typeof(value) == 'object') {
- print_red_text += level_padding + "'" + item + "' :\n";
- print_red_text += print_r(value,level+1);
- }
- else
- print_red_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
- }
- }
- else
- print_red_text = "===>"+arr+"<===("+typeof(arr)+")";
- return '<pre>'+print_red_text+'</pre>';
- }
- //---------------------------------
- $(document).ready(init);
- //----------------------------------------------
- // iframe query
- //----------------------------------------------
- function iframeq(param, command) {
- $('#ajaxcontent').empty();
- $('#ajaxcontent').append($('<iframe/>',
- {id:'ziframe', width:'700', height:'400', scrolling: 'no'}));
- $('#ziframe').css('border','solid 1px #888');
- $('#ziframe').attr('src',
- "<?='http://'.$_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"]?>"+
- "?ajax&reqtype="+command+'&req='+param);
- }
- //----------------------------------------------
- // draw widget
- //----------------------------------------------
- function draw_widget(el) {
- var f= $(el).parents('form');
- var sel = f.find('select').get(0);
- var ctype = f.find('input[name="ctype"]:checked').attr('value');
- for (var i=0; i<(sel.options.length); i++) {
- if (sel.options[i].selected) {
- var zreq = sel.options[i].value+'_'+ctype;
- el=$('#facebook-jssdk');
- if ((el).get(0)) {
- el.removeAttr('src');
- el.removeAttr('id');
- }
- //----------------------------------------------
- if (!$('#wiframme').get(0)) {
- $('#ajaxcontent').empty();
- $('#ajaxcontent').append($('<iframe/>',
- {id:'wiframe', width:"500", height:"400"}));
- $('#ajaxcontent').append($('<iframe/>',
- {id:'wiframe3', width:"500", height:"400"}));
- }
- //----------------------------------------------
- $('#wiframe').attr('src',
- "<?='http://'.$_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"].
- '?ajax&reqtype=drawwidget&req='?>"+zreq);
- $('#wiframe').before($('<div/>').append(
- $('<a/>', {href : $('#wiframe').attr('src'),
- target : "_blank"
- })
- .text($('#wiframe').attr('src'))));
- //----------------------------------------------
- $('#wiframe3').attr('src',
- "<?='http://'.$_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"].
- '?ajax&reqtype=drawwidget&alt3&req='?>"+zreq);
- $('#wiframe3').before($('<div/>').append(
- $('<a/>', {href : $('#wiframe3').attr('src'),
- target : "_blank"
- })
- .text($('#wiframe3').attr('src'))));
- //-----------------------------
- break;
- }
- }
- }
- //----------------------------------------------
- // initialization
- //----------------------------------------------
- function init() {
- glTime=0;
- //---------------------------
- load_fql_list();
- //---------------------------widget select list
- var optarr = ['login','activity','comments','facepile','likebox',
- 'likebutton','recommendbar','recommendbox',
- '_registration','sendbutton','_sharelinks','sharedactivity',
- 'subscribebutton'];
- var type_arr = ['html5','opengraph','iframe', 'link'];
- var sel=$('form[name="fdrawwidget"] select').get(0);
- for (var i=0; i<optarr.length; i++) {
- var opt = new Option (optarr[i]+' widget', optarr[i], false, false);
- try {
- sel.add(opt, null);
- } catch (e) {
- sel.add(opt);
- }
- }
- var frmz = $(sel).parents('form');
- frmz.find('input[type=button]').before($('<fieldset/>'));
- frmz.find('fieldset:last').append($('<legend/>').text('code type'));
- var tmpf = frmz.find('fieldset:last');
- for (var i=0; i<type_arr.length; i++) {
- var tmpp = tmpf.append($('<p/>').text(type_arr[i])).find('p:eq('+i+')');
- tmpp.prepend($('<input/>',{type:'radio',name:'ctype',value:type_arr[i]}));
- }
- tmpf.find('input[type=radio]:first').attr('checked',true);
- //---------------------------
- $('#leftcolumn h3').css({cursor:'pointer'}).click( function()
- {$(this).next('ul').slideToggle('fast');}
- )
- //---------------------------
- $('form[name=paramform] input[type="checkbox"]').change(
- function() {
- var curel = this;
- $(this).parent().children('input').each(
- function(index) {
- if (this!==curel) {
- $(this).removeAttr('checked');
- }
- }
- )
- }
- )
- //------------------------------------------------------------------
- // Graph API Requests
- //------------------------------------------------------------------
- $('#operationslist a').each(
- function(i) {
- $(this).click(function() {
- //-----------------------
- var inp = $('form[name=paramform] input[name=crtab]');
- var outtype =
- $('form[name=paramform] fieldset:last input[name="outtype"]:checked').attr('value');
- if ((inp.attr('checked')!==undefined) && (inp.attr('checked')!==false))
- //---------------creating table
- req_createtable($(this).attr('rel'),'mktab');
- else
- //---------------------filling table
- if (inp.nextAll('input').first().attr('checked')==='checked')
- req_createtable($(this).attr('rel'),'filltab');
- else
- //------------------show table for current user
- if (inp.nextAll('input').eq(1).attr('checked')==='checked') {
- if (outtype=='zlist')
- req_createtable($(this).attr('rel'), 'showcurr_list');
- else
- req_createtable($(this).attr('rel'), 'showcurr' );
- } else
- //-------------------show table for all users
- if (inp.nextAll('input').eq(2).attr('checked')==='checked') {
- if (outtype=='zlist')
- req_createtable($(this).attr('rel'),'showall_list');
- else
- req_createtable($(this).attr('rel'),'showall');
- } else
- //-----------------graph api request
- ajax_request($(this).attr('rel'),'apigraph');
- });
- $(this).text('load '+$(this).attr('rel'));
- //alert $(this);
- })
- //------------------------------------------------------------------
- // custom tables
- //------------------------------------------------------------------
- $('#operationslist4 a').each(
- function(i) {
- $(this).click( function() {
- var inp3 = $('form[name=paramform] input[name=showcurr]');
- var inp4 = $('form[name=paramform] input[name=showall]');
- var outtype =
- $('form[name=paramform] fieldset:last input[name="outtype"]:checked').attr('value');
- //--------------------------------
- if ((inp3.attr('checked')!==undefined) && (inp3.attr('checked')!==false)) {
- if (outtype=='zlist')
- req_createtable($(this).attr('rel'), 'showcustom_list');
- else
- req_createtable($(this).attr('rel'), 'showcustom');
- }
- //--------------------------------
- if ((inp4.attr('checked')!==undefined) && (inp4.attr('checked')!==false)) {
- if (outtype=='zlist')
- req_createtable($(this).attr('rel'), 'showcustomall_list');
- else
- req_createtable($(this).attr('rel'), 'showcustomall');
- }
- })
- $(this).text('show '+$(this).attr('rel'));
- }
- )
- //----------- AjaxStart, AjaxStop, AjaxSend, AjaxSuccess, AjaxError, AjaxComplete events
- //---------------------------------------
- // ajaxStart
- //---------------------------------------
- $('#ajaxstatus').ajaxStart(
- function() {
- $(this).html('Request started. Please wait...');
- })
- //---------------------------------------
- // ajaxStop
- //---------------------------------------
- $('#ajaxstatus').ajaxStop(
- function() {
- $(this).html('Request finished');
- } )
- //---------------------------------------
- // ajaxSend
- //---------------------------------------
- $('#ajaxstatus3').ajaxSend (
- function(ev, jqXHR, options) {
- $(this).empty();
- $(this).append($('<p/>').html('<b>triggered ajaxSend</b>'));
- $(this).append($('<p/>').html('ajaxResponse: <pre>'+jqXHR.responseText+'</pre>'));
- $(this).append($('<p/>').html('status: '+jqXHR.status+'<br/>ready state:'+jqXHR.readyState));
- //---------------------------
- $(this).append(
- $('<p>', {class:'info'}).html('ev: <br/>'/*+print_r(ev)*/));
- $(this).append(
- $('<p>', {class:'info'}).html('jqXHR: <br/>'+print_r(jqXHR))
- .css({'height':'50px', 'cursor':'pointer'})
- .click(function() {
- if ($(this).height()<800)
- $(this).animate({'height':'800px'},"fast");
- else
- $(this).animate({'height':'50px'},"fast");
- }));
- $(this).append($(document.createElement('P'))
- .html('options: <br/>' +print_r(options))
- .css({'height':'50px', 'cursor':'pointer'})
- .click(function() {
- if ($(this).height()<800)
- $(this).animate({'height':'800px'},"fast");
- else
- $(this).animate({'height':'50px'},"fast");
- }));
- }
- )
- //---------------------------------------
- // ajaxSuccess
- //---------------------------------------
- $('#ajaxstatus3').ajaxSuccess(
- function (ev, jqXHR, options) {
- $(this).append($('<p/>').html('<b>triggered ajaxSuccess</b>'));
- //$(this).append($('<p/>').html('ajaxResponse: <pre>'+jqXHR.responseText+'</pre>'));
- $(this).append($('<p/>').html('status: '+jqXHR.status+'<br/>ready state:'+jqXHR.readyState));
- }
- );
- //---------------------------------------
- // ajaxError
- //---------------------------------------
- $('#ajaxstatus3').ajaxError(
- function (ev, jqXHR, options, exception) {
- $(this).append($('<p/>').html('<b>triggered ajaxError</b>'));
- $(this).append($('<p/>').html('ajaxResponse: <pre>'+jqXHR.responseText+'</pre>'));
- $(this).append($('<p/>').html('status: '+jqXHR.status+'<br/>ready state:'+jqXHR.readyState));
- $(this).append($('<p/>').html('exception: '+exception));
- }
- );
- //---------------------------------------
- // ajaxComplete
- //---------------------------------------
- $('#ajaxstatus3').ajaxComplete(
- function (ev, jqXHR, options) {
- $(this).append($('<p/>').html('<b>triggered ajaxComplete</b>'));
- //$(this).append($('<p/>').html('ajaxResponse: <pre>'+jqXHR.responseText+'</pre>'));
- $(this).append($('<p/>').html('status: '+jqXHR.status+'<br/>ready state:'+jqXHR.readyState));
- }
- );
- }
- //-------------------------------------------------------
- // local events
- //-------------------------------------------------------
- //-------------------------------------------------------
- // onSuccess
- //-------------------------------------------------------
- function onSuccess(inf, textStatus, jqXHR) {
- var a = $('#ajaxstatus3');
- a.append($('<p/>').html('<font color="red"><b>triggered local success</b></font>'));
- //a.append($('<p/>').html('ajaxResponse: <pre>'+jqXHR.responseText+'</pre>'));
- a.append($('<p/>').html('status: '+jqXHR.status+'<br/>ready state:'+jqXHR.readyState));
- a.append($('<p/>').html('textStatus: '+textStatus));
- var s='';
- //--------------------
- function get_obj(objel, deep) {
- var s3= new Array(deep*3).join(' ');
- for (var el in objel) {
- s3+=typeof(objel[el])+' : '+el+' = '
- if (typeof(objel[el])=='object')
- s3+=String.fromCharCode(13)+String.fromCharCode(10)+
- get_obj(objel[el], deep+1);
- else {
- s3+= objel[el]+String.fromCharCode(13)+String.fromCharCode(10);
- }
- }
- return s3;
- }
- //--------------------
- s=get_obj(inf,0);
- var tnode = $('#ajaxcontent');
- tnode.empty();
- tnode.append($(document.createElement('P')));
- tnode.children('p').filter(':eq(0)').html('<b>'+textStatus+'</b>');
- tnode.append($('<p/>').html('<pre>'+s+'</pre>'));
- tnode.append($('<p>', {class: 'zinfo'}).html('XHR:<br/>'+print_r(jqXHR)));
- }
- //-------------------------------------------------------
- // onError
- //-------------------------------------------------------
- function onError(xhr, status, exception) {
- var a = $('#ajaxstatus3');
- a.append($('<p/>').html('<font color="red"><b>triggered local error</b></font>'));
- a.append($('<p/>').html('ajaxResponse: <pre>'+xhr.responseText+'</pre>'));
- a.append($('<p/>').html('status: '+xhr.status+'<br/>ready state:'+xhr.readyState));
- a.append($('<p/>').html('textStatus: '+status));
- a.append($('<p/>').html('Exception: '+exception));
- }
- //-------------------------------------------------------
- // onBeforeSend
- //-------------------------------------------------------
- function onBeforeSend(xhr, settings) {
- var tnode = $('#ajaxcontent');
- tnode.html('please wait...');
- var a = $('#ajaxstatus3');
- a.empty();
- a.append($('<p/>').html('<font color="red"><b>triggered local beforeSend</b></font>'));
- a.append($('<p/>').html('ajaxResponse: <pre>'+xhr.responseText+'</pre>'));
- a.append($('<p/>').html('status: '+xhr.status+'<br/>ready state:'+xhr.readyState));
- //a.append($('<p/>').html('settings: '+print_r(settings)));
- }
- //-------------------------------------------------------
- // onComplete
- //-------------------------------------------------------
- function onComplete(xhr, status) {
- var a = $('#ajaxstatus3');
- a.append($('<p/>').html('<font color="red"><b>triggered local complete</b></font>'));
- //a.append($('<p/>').html('ajaxResponse: <pre>'+xhr.responseText+'</pre>'));
- a.append($('<p/>').html('status: '+xhr.status+'<br/>ready state:'+xhr.readyState));
- a.append($('<p/>').html('textStatus: '+status));
- }
- //-------------------------------------------------------
- // ajax request
- //-------------------------------------------------------
- function ajax_request(param, reqtypeval) {
- $.ajaxSetup( {
- type: 'POST',
- url: "<?php echo $_SERVER["PHP_SELF"]?>",
- dataType: 'json',
- processData: true,
- cache: false,
- timeout: 50000,
- username: '',
- password: '',
- ifModified: false,
- global: true,
- crossDomain: false,
- })
- //----------------------------
- $.ajax (
- {
- data: {ajax:'',
- reqtype:reqtypeval,
- req: param},
- //-----------------
- beforeSend: onBeforeSend,
- success: onSuccess,
- error: onError,
- complete: onComplete,
- statusCode: {
- 404: function() {
- var tnode = $('#ajaxcontent');
- tnode.html
- }
- }
- })
- }
- //-------------------------------------------------------
- // load fql list
- //-------------------------------------------------------
- function onGetSuccess (data, status, xhr) {
- el = $('#operationslist3');
- $.each(data, function (i, valu) {
- var lii=$('<li/>');
- var a = $('<a/>');
- a.text(valu["name"]);
- a.attr('href','#');
- //-----------------------------
- a.click(
- //------------
- {fqlval: valu["value"]},
- //------------
- function(ev) {
- var inp = $('form[name=paramform] input[name=crtab]');
- var outtype =
- $('form[name=paramform] fieldset:last input[name="outtype"]:checked').attr('value');
- if ((inp.attr('checked')!==undefined) && (inp.attr('checked')!==false))
- //-----------------creating table
- req_createtable(ev.data.fqlval, 'mkfqltab');
- else
- //----------------------filling table
- if (inp.nextAll('input').first().attr('checked')==='checked')
- req_createtable(ev.data.fqlval,'fillfqltab');
- else
- //------------------------show table for current user
- if (inp.nextAll('input').eq(1).attr('checked')==='checked') {
- if (outtype=='zlist')
- req_createtable(ev.data.fqlval, 'showfqlcurr_list');
- else
- req_createtable(ev.data.fqlval, 'showfqlcurr');
- }
- else
- //--------------------show table for all users
- if (inp.nextAll('input').eq(2).attr('checked')==='checked') {
- if (outtype=='zlist')
- req_createtable(ev.data.fqlval, 'showfqlall_list');
- else
- req_createtable(ev.data.fqlval, 'showfqlall');
- }
- else
- //-------------------fql request
- ajax_request(ev.data.fqlval,'fql');
- return false;
- });
- //-----------------------------
- a.data('fqv',valu["value"]);
- a.hover (
- function(ev) {
- //$(this).after($('<p/>',{class:'remark'}).text($(this).data('fqv')));
- //alert (ev.clientX);
- clearTimeout(glTime);
- $('#flinfo').text($(this).data('fqv'))
- .clearQueue()
- .addClass('remark')
- .css('left',ev.clientX+100)
- .css('top',ev.clientY+
- ((document.documentElement && document.documentElement.scrollTop) ||
- (document.body && document.body.scrollTop) || 0)-100)
- .fadeIn("fast");
- },
- function(ev) {
- //$(this).next('p').remove();
- glTime= setTimeout( function() {
- $('#flinfo').fadeOut("slow")
- .queue(
- function() {
- $(this).removeClass('remark');
- $(this).dequeue();
- })}, 1000);
- }
- )
- lii.append(a);
- el.append(lii);
- });
- }
- //--------------------------------------------
- function load_fql_list() {
- $inf = $.get( "<?php echo $_SERVER["PHP_SELF"]?>",
- {ajax:'', reqtype:'getfqls'},
- onGetSuccess,
- 'json');
- }
- //------------------------------------------------------------
- // create table - request
- //------------------------------------------------------------
- function onPostSuccess (data, status, xhr) {
- var tnode =$('#ajaxcontent');
- tnode.empty();
- tnode.append($('<p/>').text('status: '+status));
- tnode.append($('<p/>').html(data));
- }
- //-------------------------------------------------------
- function req_createtable (param, command) {
- var tnode =$('#ajaxcontent');
- tnode.empty();
- $inf = $.post("<?php echo $_SERVER["PHP_SELF"]?>",
- {ajax:'',
- reqtype: command,
- req: param},
- onPostSuccess,
- 'text'
- );
- return $inf;
- }
- //------------------------------------------------------------
- // simple get request
- //------------------------------------------------------------
- function onGetSuccess4(data, status, xhr) {
- var tnode = $('#ajaxcontent');
- tnode.append($('<p/>').text('status: '+status));
- tnode.append($('<p/>').html(data));
- }
- //------------------------------------------------------
- function ajax_get(param, command) {
- var tnode = $('#ajaxcontent');
- tnode.empty();
- $inf = $.get("<?php echo $_SERVER["PHP_SELF"]?>",
- { ajax:'',
- reqtype: command,
- req: param},
- onGetSuccess4,
- 'text');
- return $inf;
- }
- </script>
- <!-- ------------------------------------------ -->
- </head>
- <body>
- <div id="flinfo">
- </div>
- <h1>Test fb operational page</h1>
- <div id="loginblock">
- <?php
- //echo '<pre>'.print_r($_SESSION,true).'</pre>';
- if (!$fb->connected()) {
- echo "<a href=\"$fb->loginUrl\">Login</a>";
- //echo $fb->drawLogin(true);
- }
- else {
- echo "<a href=\"$fb->logoutUrl\">Logout</a>";
- }
- ?>
- </div>
- <div id="leftcolumn">
- <h3>Operations</h3>
- <a href='#' onclick="iframeq('','relatedusers');return false;">Related users: collect info</a><br/>
- <a href='#' onclick="ajax_get('','relatedusers4');return false;">Related users: Show info</a><br/>
- <a href='#' onclick="ajax_get('','relatedusers5');return false;">Related users: Result page</a><br/>
- <a href='#' onclick="ajax_get('','likestofql');return false;">Service: likes:base->fb_user</a>
- <h3>Utils</h3>
- <a href='#' onclick="ajax_request('','getfqls');return false;">list of fqls</a>
- <form name="fdrawwidget">
- <fieldset>
- <legend>draw facebook widget</legend>
- <select>
- </select>
- <input type="button" onclick="draw_widget(this);" value="draw" />
- </fieldset>
- </form>
- <form name="paramform">
- <fieldset>
- <legend>commands</legend>
- <label for="crtab">create table for node</label>
- <input type="checkbox" name="crtab" />
- <label for="filltab">fill table for node</label>
- <input type="checkbox" name="filltab" />
- <label for="showcurr">show contents (current user) </label>
- <input type="checkbox" name="showcurr" />
- <label for="showall">show contents (all) </label>
- <input type="checkbox" name="showall" />
- </fieldset>
- <fieldset class="zrightfld">
- <p><input type="radio" name="outtype" value="ztable" checked />output table</p>
- <p><input type="radio" name="outtype" value="zlist" />output list</p>
- </fieldset>
- </form>
- <h3>Custom tables</h3>
- <ul id="operationslist4">
- <li><a href="#" rel="fbs_likes_users"></a></li>
- </ul>
- <h3>Api graph requests</h3>
- <ul id="operationslist">
- <li><a href="#" rel="me"></a></li>
- <li><a href="#" rel="me/accounts"></a></li>
- <li><a href="#" rel="me/achievements"></a></li>
- <li><a href="#" rel="me/activities"></a></li>
- <li><a href="#" rel="me/albums"></a></li>
- <li><a href="#" rel="me/apprequests"></a></li>
- <li><a href="#" rel="me/books"></a></li>
- <li><a href="#" rel="me/checkins"></a></li>
- <li><a href="#" rel="me/events"></a></li>
- <li><a href="#" rel="me/family"></a></li>
- <li><a href="#" rel="me/friendlists"></a></li>
- <li><a href="#" rel="me/friendrequests"></a></li>
- <li><a href="#" rel="me/friends"></a></li>
- <li><a href="#" rel="me/games"></a></li>
- <li><a href="#" rel="me/groups"></a></li>
- <li><a href="#" rel="me/home"></a></li>
- <li><a href="#" rel="me/inbox"></a></li>
- <li><a href="#" rel="me/interests"></a></li>
- <li><a href="#" rel="me/likes"></a></li>
- <li><a href="#" rel="me/links"></a></li>
- <li><a href="#" rel="me/locations"></a></li>
- <li><a href="#" rel="me/movies"></a></li>
- <li><a href="#" rel="me/music"></a></li>
- <li><a href="#" rel="me/mutualfriends"></a></li>
- <li><a href="#" rel="me/notes"></a></li>
- <li><a href="#" rel="me/notifications"></a></li>
- <li><a href="#" rel="me/outbox"></a></li>
- <li><a href="#" rel="me/payments"></a></li>
- <li><a href="#" rel="me/permissions"></a></li>
- <li><a href="#" rel="me/photos"></a></li>
- <li><a href="#" rel="me/photos/uploaded"></a></li>
- <li><a href="#" rel="me/picture"></a></li>
- <li><a href="#" rel="me/pokes"></a></li>
- <li><a href="#" rel="me/posts"></a></li>
- <li><a href="#" rel="me/questions"></a></li>
- <li><a href="#" rel="me/scores"></a></li>
- <li><a href="#" rel="me/sharedposts"></a></li>
- <li><a href="#" rel="me/statuses"></a></li>
- <li><a href="#" rel="me/subscribedto"></a></li>
- <li><a href="#" rel="me/subscribers"></a></li>
- <li><a href="#" rel="me/tagged"></a></li>
- <li><a href="#" rel="me/television"></a></li>
- <li><a href="#" rel="me/updates"></a></li>
- <li><a href="#" rel="me/videos"></a></li>
- </ul>
- <h3>Fql requests</h3>
- <ul id="operationslist3">
- </ul>
- </div>
- <div id="maincontent">
- <div id="ajaxcontent"></div>
- <div id="ajaxstatus"></div>
- <div id="ajaxstatus3"></div>
- </div>
- </body>
- </html>
- <?php
- //--------------------
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement