Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (strpos($_SERVER['SERVER_NAME'],'unisample')===false) {
- session_start();
- }
- require 'fb.inc.php';
- $fb = fbManager::getInstance();
- if (!isset($_GET['ajax'])) {
- drawForm();
- exit();
- }
- //--------------------------------------------------------
- switch ($_GET['req']) {
- case 'fql_user':
- echo $fb->db_drawTab('select '.$_GET['reqfld'].
- ' from fql_user group by '.$_GET['reqfld'], false, true);
- break;
- case 'corr_user':
- drawCorrs();
- break;
- case 'tblinfo':
- drawtblinfo();
- break;
- case 'csvinfo':
- csvdownload();
- break;
- case 'cleartab':
- echo $fb->db_clearTable($_GET['reqt']);
- break;
- case 'droptab':
- echo $fb->db_dropTable($_GET['reqt']);
- break;
- }
- //------------------------------------------------------------------
- // csv download
- //------------------------------------------------------------------
- function csvdownload() {
- global $fb;
- $fb->downloadcsv();
- }
- //------------------------------------------------------------------
- // draw all tables info
- //------------------------------------------------------------------
- function drawtblinfo() {
- global $fb;
- $alltabs = $fb->db_getQuery('select name,sql from sqlite_master where type="table" order by name');
- foreach ($alltabs as $key=>$el) {
- $ss = strstr($el['sql'],'(');
- $zpos = strrpos($ss,')');
- $ss = substr_replace($ss,'',$zpos);
- $alltabs[$key]['flds']= explode(',',$ss);
- }
- $tabcontent = array();
- for ($i=0; $i<count($alltabs); $i++) {
- $tabb = $alltabs[$i]['name'];
- $tabcontent[] = $fb->db_drawTab("select * from $tabb", false, true);
- }
- ?>
- <!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>sqlite information page</title>
- <meta http-equiv="content-type" content="text/html;charset=utf8" />
- <meta name="description" content="detail page for fb statistics" />
- <meta name="keywords" content="facebook,api" />
- <script type="text/javascript" src="jquery.min.js"></script>
- <style type="text/css">
- * {
- margin:0;
- padding:0;
- border:none;
- outline:none;
- }
- body {
- font-size: 100%;
- font-family:verdana, arial, sans-serif;
- }
- ul {
- list-style-type:none;
- }
- #container {
- width:1200px;
- margin:0 auto;
- }
- #header {
- height:100px;
- color:white;
- background-color:#600;
- margin-bottom:30px;
- padding:30px 0 0 0;
- }
- #header h1 {
- font-size: 1.5em;
- line-height:1;
- width:40%;
- margin-left:auto;
- margin-right:auto;
- }
- #leftcol {
- float:left;
- width: 300px;
- margin-right:50px;
- }
- #rightcol {
- float:left;
- width:650px;
- }
- .hiddiv {
- display: none;
- }
- #flydiv {
- position:absolute;
- width:300px;
- height:500px;
- padding:10px 0 0 5px;
- border:solid 1px #999;
- background-color:#eee;
- overflow:hidden;
- display:none;
- font-size:0.75em;
- font-family: courier new, monospace;
- white-space: nowrap;
- }
- .inftab {
- font-family: courier new, monospace;
- font-size: 0.75em;
- border-collapse:collapse;
- border: solid 1px #777;
- }
- .inftab tr:first-child td {
- font-weight:bold;
- }
- .inftab td {
- padding: 3px 5px;
- border: solid 1px;
- }
- #conmenu {
- position:absolute;
- width:250px;
- height:50px;
- border:solid 1px #999;
- background-color:#ffe;
- padding:4px 20px;
- line-height:1.5;
- cursor:pointer;
- display:none;
- }
- </style>
- <script type="text/javascript">
- //-------------------------------------------
- function clearTab(tabb) {
- ajax_request({'ajax':'','req':'cleartab','reqt':tabb});
- }
- //-------------------------------------------
- function dropTab(tabb) {
- ajax_request({'ajax':'','req':'droptab','reqt':tabb});
- }
- //-------------------------------------------
- function onGetSuccess(data,status,xhr) {
- $('#rightcol').html(data);
- }
- //-------------------------------------------
- function ajax_request (params) {
- $.get("<?php echo $_SERVER["PHP_SELF"]; ?>",
- params, onGetSuccess);
- }
- //-------------------------------------------
- function init() {
- $('#conmenu').mouseout( function(ev) {
- mell = $(this);
- var target = ev.target || ev.srcElement;
- if (target!==this)
- return;
- var ztm = setTimeout( function() {
- mell.stop(true,true).fadeOut('fast');
- }, 200);
- $(this).data('zhide', ztm);
- });
- $('#conmenu li').hover (
- function (ev) {
- $(this).css('font-weight','bold');
- },
- function (ev) {
- $(this).css('font-weight','normal');
- });
- $('#conmenu li:first').click (
- function(ev) {
- var tabb = $('#conmenu').data('tabb');
- if (confirm('clear '+tabb+ '?'))
- clearTab(tabb);
- })
- $('#conmenu li:eq(1)').click (
- function(ev) {
- var tabb = $('#conmenu').data('tabb');
- if (confirm('drop '+tabb+' ?'))
- dropTab(tabb);
- }
- );
- //-------------------------------------
- var tbrs = $('#maintab>tbody>tr');
- tbrs.each(
- function (i) {
- $(this).children('td:first')
- .find ('div.hiddiv:last table:first').attr('class','inftab').end()
- .css('cursor','pointer')
- //------------------------------
- .click( function() {
- $('#rightcol').html($(this).find('div.hiddiv:last').html());
- })
- //------------------------------
- .hover (
- function(ev) {
- if ($('#flydiv').data('ztime'))
- clearTimeout($('#flydiv').data('ztime'));
- $(this).css('font-weight','bold');
- $('#flydiv').html($(this).find('div.hiddiv:eq(0)').html())
- .css('left', ev.clientX+300)
- .css('top', ev.clientY+ (
- (document.documentElement && document.documentElement.scrollTop) ||
- (document.body && document.body.scrollTop) || 0)-200)
- .stop(true, true).fadeIn('fast')
- },
- function(ev) {
- $('#flydiv').data('ztime',
- setTimeout( function() {
- $('#flydiv').stop(true, true).fadeOut('fast');
- },200));
- $(this).css('font-weight','normal');
- })
- //------------------------------
- .on('contextmenu', function(ev) {
- ev = ev || event;
- var mdiv = $('#conmenu');
- mdiv.data('tabb', $(this).text().slice(0, $(this).text().indexOf('(')).trim());
- var ztm = mdiv.data('zhide');
- if (ztm)
- clearTimeout(ztm);
- mdiv.css('left', ev.clientX -30 )
- .css('top', ev.clientY +
- ( (document.documentElement && document.documentElement.scrollTop) ||
- (document.body && document.body.scrollTop) || 0) -30)
- .stop(true,true).fadeIn('fast');
- try {
- ev.preventDefault();
- } catch(e) {
- ev.returnValue = false;
- }
- }
- );
- }
- )
- }
- //----------------------------------
- $(document).ready (
- function() {
- init();
- }
- )
- </script>
- </head>
- <body>
- <div id="flydiv"></div>
- <div id="conmenu">
- <ul>
- <li>clear table</li>
- <li>drop table</li>
- </ul>
- </div>
- <div id="container">
- <div id="header">
- <h1>sqlite information</h1>
- </div>
- <div id="leftcol">
- <table id="maintab">
- <tr><th>name</th>
- <?php
- for ($i=0; $i<count($alltabs); $i++) {
- $el = $alltabs[$i];
- echo '<tr><td>'.$el['name'].
- '<div class="hiddiv"><ul>';
- foreach ($el['flds'] as $fld) {
- echo '<li>'.$fld.'</li>';
- }
- echo '</ul></div>';
- echo "<div class=\"hiddiv\">{$tabcontent[$i]}</div>";
- echo '</td></tr>';
- }
- ?>
- </table></div>
- <div id="rightcol">
- </div>
- </div>
- </body>
- </html>
- <?php
- }
- //------------------------------------------------------------------
- // draw correlated users diagram
- //------------------------------------------------------------------
- function drawCorrs() {
- global $fb;
- $inf = $fb->drawRelatedUsers($_GET['uid'],true);
- if (!is_array($inf)) {
- echo 'error: '.$inf;
- exit();
- }
- //-------------------------------------------------------
- ?>
- <!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>Details page</title>
- <meta http-equiv="content-type" content="text/html;charset=utf8" />
- <meta name="description" content="detail page for fb statistics" />
- <meta name="keywords" content="facebook,api" />
- <script type="text/javascript" src="jquery.min.js"></script>
- <style type="text/css">
- body {
- background:black;
- }
- a, img {
- text-decoration:none;
- outline:none;
- border:none;
- }
- .brick {
- position:absolute;
- }
- .roundb {
- border-radius:50%;
- -webkit-border-radius:50%;
- -moz-border-radius:50%;
- padding:10px;
- }
- </style>
- <script type="text/javascript">
- $(document).ready(
- function() {
- var b= $(document.body);
- for (var i=0; i<40; i++) {
- b.append($('<div/>',{'class':'roundb',}).css(
- 'background-color', 'rgb('+i*5+','+i*4+','+i*3+')'));
- b= b.children('.roundb').first();
- }
- var els = $('.brick');
- var r=100;
- var psy=0;
- var psy_step=0.5;
- for (var i=0; i<els.length; i++) {
- r+=2;
- psy_step-=0.002;
- psy+=psy_step;
- var x= Math.floor(r*Math.cos(psy)+window.innerWidth/2);
- var y= Math.floor(r*Math.sin(psy)+window.innerHeight/2);
- els.eq(i).css('left',x).css('top',y).css('z-index',els.length-i);
- }
- }
- )
- </script>
- </head>
- <body>
- <?php
- //-------------------------------------------------------
- function wsort($a, $b) {
- return ($a['weight']<$b['weight']) ? 1 : -1;
- }
- foreach ($inf as &$el) {
- $el['weight']=$el['lk_count']*1000 +
- (($el['usersex']=='female') ? 1 : 0)*100+
- (($el['userlocale']=='ru_RU') ? 1 : 0)*10;
- }
- usort ($inf, 'wsort');
- $nels=0;
- foreach ($inf as $el) {
- $nels++;
- if ($nels>400)
- break;
- if ($el['userid']==$_GET['uid'])
- continue;
- echo "<div class=\"brick\" rel=\"{$el["weight"]}\">".
- "<a href=\"{$el["userurl"]}\" target=\"_blank\">".
- "<img src=\"{$el["userpic"]}\" alt=\"{$el["username"]}\" /></a></div>";
- }
- ?>
- </body></html>
- <?php
- }
- //------------------------------------------------------------------
- function drawForm() {
- global $fb;
- $inf = $fb->getUserInfo();
- $flds = $fb->db_getTableFields('fql_user');
- if (is_array($inf))
- extract($inf[0]);
- else
- $err3=$inf;
- ?>
- <!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>Details page</title>
- <meta http-equiv="content-type" content="text/html;charset=utf8" />
- <meta name="description" content="detail page for fb statistics" />
- <meta name="keywords" content="facebook,api" />
- <script type="text/javascript" src="jquery.min.js"></script>
- <style type="text/css">
- * {
- margin:0;
- padding:0;
- }
- body {
- font-family:helvetica,verdana,sans-serif;
- font-size:14px;
- margin:10px 0 0 30px;
- }
- h1 {
- font-size:1.5em;
- margin: 0 0 20px 0;
- }
- a, a:visited {
- color: #800;
- text-decoration:none;
- }
- a:hover, a:active {
- text-decoration:underline;
- }
- ul {
- list-style-type:none;
- }
- #userinfo {
- max-width:200px;
- border:solid 1px #888;
- padding:10px 10px 20px 10px;
- overflow:auto;
- margin-bottom:10px;
- }
- #userinfo img {
- display:block;
- float:left;
- padding-right:15px;
- }
- #userinfo a {
- line-height:1.5em;
- }
- .errormes {
- border:solid 3px #900;
- background:#ff8f8;
- color: #900;
- padding:10px;
- max-width:300px;
- margin-bottom:10px;
- }
- #utfields {
- border:solid 1px #888;
- background:#eee;
- padding:10px 20px 10px 30px;
- float: left;
- width:50%;
- margin-right:200px;
- }
- .button {
- /*position:absolute;*/
- font-size:0.85em;
- border: solid 2px #800;
- margin-bottom:5px;
- margin-right:5px;
- width:140px;
- float:left;
- overflow:hidden;
- padding:6px 10px;
- background:#f8f8f8;
- cursor:pointer;
- }
- .button:last-child {
- margin-bottom:0;
- }
- #selectedfields {
- position:relative;
- float: left;
- min-height:400px;
- width:30%;
- border:solid 1px #888;
- }
- #selectedfields:after {
- content: "drag fields here";
- position:absolute;
- left:50%;
- top:40%;
- margin-left:-3.5em;
- color:#ccc;
- font-size:4em;
- width:600px;
- }
- #ftgbutton {
- padding: 5px 20px;
- border:solid 1px #666;
- background:#eee;
- cursor:pointer;
- border-radius:5px;
- -moz-border-radius:5px;
- -webkit-border-radius:5px;
- float:left;
- margin-top:5px;
- }
- #ftgbutton:hover {
- background:#666;
- color:white;
- }
- #ajaxresult {
- clear:both;
- border:solid 1px #ccc;
- }
- ul.accinfo {
- overflow:auto;
- border:solid 1px #ccc;
- padding:5px 10px;
- margin-bottom:10px;
- width:50%;
- }
- ul.accinfo li {
- float:left;
- margin-right:10px;
- }
- ul.accinfo li img {
- float:left;
- margin-right:10px;
- }
- </style>
- <script type="text/javascript">
- $(document).ready(init);
- var Helper = {
- //---------------------------
- scroX : function() {
- return (document.documentElement && document.documentElement.scrollLeft ||
- document.body && document.body.scrollLeft || 0);
- },
- //---------------------------
- scroY : function() {
- return (document.documentElement && document.documentElement.scrollTop ||
- document.body && document.body.scrollTop || 0);
- },
- //---------------------------
- mouseX : function(ev) {
- return ev.clientX + this.scroX();
- },
- //---------------------------
- mouseY : function(ev) {
- return ev.clientY + this.scroY();
- },
- //---------------------------
- elX : function(el) {
- var zrect = el.getBoundingClientRect();
- return zrect.left + this.scroX();
- },
- //---------------------------
- elY : function(el) {
- var zrect = el.getBoundingClientRect();
- return zrect.top + this.scroY();
- }
- //---------------------------
- }
- //-----------------------------------------------
- function Ddrop(hlp) {
- var _self = this;
- this._helper = hlp;
- this.hook = function(el) {
- for (var i=0; i<el.length; i++) {
- var el4 = el.get(i);
- el4.onmousedown = this.mouseDown;
- el4.onmouseup = this.mouseUp;
- el4.onmousemove = this.mouseMove;
- el4.onmouseout = this.mouseOut;
- }
- }
- //-----------------------------------------------
- this.mouseDown = function(ev) {
- //alert('test');
- var ev = ev || event;
- var target = this;
- target.pressed=true;
- var mouseX = _self._helper.mouseX(ev);
- var mouseY = _self._helper.mouseY(ev);
- var elX = _self._helper.elX(target);
- var elY = _self._helper.elY(target);
- target.diffX = mouseX - elX;
- target.diffY = mouseY - elY;
- target.style.left=elX+'px';
- target.style.top=elY+'px';
- $(target).css('z-index','1000');
- target.style.position='absolute';
- try {
- ev.preventDefault();
- } catch(ex) {
- ev.returnValue=false;
- }
- }
- //-----------------------------------------------
- this.mouseUp = function(ev) {
- var ev = ev || event;
- var target = this;
- var aim =$('#selectedfields').get(0);
- var elX = _self._helper.elX(target);
- var elY = _self._helper.elY(target);
- var aimX = _self._helper.elX(aim);
- var aimY = _self._helper.elY(aim);
- var aimX3 = aimX + aim.offsetWidth;
- var aimY3 = aimY + aim.offsetHeight;
- if ((elX+target.offsetWidth>aimX) && (elX<aimX3) &&
- (elY>aimY) && (elY<aimY3)) {
- aim.appendChild(target);
- }
- target.pressed=false;
- target.style.position='';
- $(target).css('z-index','10');
- }
- //-----------------------------------------------
- this.mouseMove = function(ev) {
- var ev = ev || event;
- var target = this;
- //alert(target);
- if (target.pressed) {
- target.style.left = _self._helper.mouseX(ev)-target.diffX+'px';
- target.style.top = _self._helper.mouseY(ev)-target.diffY+'px';
- }
- }
- //-----------------------------------------------
- this.mouseOut = function(ev) {
- //_self.mouseUp(ev);
- var ev = ev || event;
- var target = this;
- target.pressed=false;
- target.style.position='';
- $(target).css('z-index','');
- }
- //-----------------------------------------------
- }
- //-----------------------------------------
- // init
- //-----------------------------------------
- function init() {
- ddrop = new Ddrop(Helper);
- ddrop.hook($('#utfields .button'));
- //------------------------------------
- $('#ftgbutton').click ( function() {
- var fldels = $('#selectedfields .button');
- var flds ='';
- for (var i=0; i<fldels.length; i++) {
- if (flds!='')
- flds+=',';
- flds+=fldels[i].innerHTML;
- }
- if (flds=='') return;
- $.ajax ( {
- type : 'GET',
- url : "<?php echo $_SERVER["PHP_SELF"] ?>",
- data : {
- ajax:'',
- req:'fql_user',
- reqfld: flds
- },
- success: onSuccess,
- error: onError
- });
- });
- //------------------------------------
- $('#ajaxresult').ajaxStart( function() {
- $(this).html('Request started. Please wait...');
- })
- }
- //-----------------------------------------
- function onSuccess(inf, status, xhr) {
- $('#ajaxresult').html(inf);
- }
- //-----------------------------------------
- function onError(xhr, status, exception) {
- $('#ajaxresult').html('Exception: '+exception);
- }
- //-----------------------------------------
- </script>
- </head>
- <body>
- <h1>fb tests detail page</h1>
- <?php if (!isset($err3)): ?>
- <div id="userinfo">
- <a href="<?php echo $fb_profile_url ?>" target="_blank">
- <img src="<?php echo $fb_pic_square ?>" />
- Logged in user <?php echo $fb_name ?>
- </a>
- </div>
- <?php else: ?>
- <div class="errormes">
- <?php echo $err3 ?>
- </div>
- <?php endif;?>
- <h3>Information gathered</h3>
- <ul class="accinfo">
- <?php
- $inf = $fb->getAcceptors();
- foreach ($inf as $el) {
- echo '<li><a href="'.$_SERVER["PHP_SELF"].'?ajax&req=corr_user&uid='.$el['user_id'].
- '" ><img src="'
- .$el['userpic'].'" />'.$el['user_name'].'</a></li>';
- }
- ?>
- </ul>
- <a href="<?php echo $_SERVER["PHP_SELF"].'?ajax&req=tblinfo'; ?>" target="_blank">
- retrieve all sqlite info
- </a><br/>
- <h3>
- <a href="<?php echo $_SERVER["PHP_SELF"].'?ajax&req=csvinfo'; ?>" target="_blank">
- download csv
- </a></h3>
- <div id="fldwrapper">
- <div id="utfields">
- <?php
- for ($i=0; $i<count($flds); $i++) {
- echo "<div class=\"button\" >{$flds[$i]}</div>";
- }
- ?>
- </div>
- <div id="selectedfields">
- </div>
- <div id="ftgbutton">show info</div>
- </div>
- <div id="ajaxresult">
- </div>
- </body>
- </html>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement