2009-07-04 03:08:03 +00:00
< ? php
/*
2010-10-28 11:12:45 +00:00
* e107 website system
*
2013-02-25 20:14:59 +01:00
* Copyright ( C ) 2008 - 2013 e107 Inc ( e107 . org )
2010-10-28 11:12:45 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Info panel admin view
*
* $URL $
* $Id $
2009-09-03 01:27:27 +00:00
*/
2010-10-28 11:12:45 +00:00
2009-07-23 10:46:11 +00:00
if ( ! defined ( 'e107_INIT' ))
2009-07-04 13:36:15 +00:00
{
2009-07-23 10:46:11 +00:00
exit ;
2009-07-04 13:36:15 +00:00
}
2009-09-03 01:27:27 +00:00
2013-09-11 11:08:50 -07:00
define ( 'ADMINFEED' , 'http://e107.org/adminfeed' );
define ( 'ADMINFEEDMORE' , 'http://e107.org/blog' );
2012-12-04 00:14:43 -08:00
class adminstyle_infopanel
2009-07-23 10:46:11 +00:00
{
2010-03-16 07:46:01 +00:00
2012-12-08 00:36:34 -08:00
private $iconlist = array ();
2012-12-04 00:14:43 -08:00
function __construct ()
2009-09-03 01:27:27 +00:00
{
2013-09-11 11:08:50 -07:00
e107 :: js ( 'core' , 'zrssfeed/jquery.zrssfeed.min.js' ); // http://www.zazar.net/developers/jquery/zrssfeed/
$code = "
2012-12-04 00:14:43 -08:00
2013-09-11 11:08:50 -07:00
jQuery ( function ( $ ){
$ ( '#e-adminfeed' ) . rssfeed ( '".ADMINFEED."' , {
limit : 3 ,
header : false ,
linktarget : '_blank'
});
});
" ;
2012-12-04 00:14:43 -08:00
2013-02-25 20:14:59 +01:00
global $user_pref ; // quick fix.
$pref = e107 :: getPref ();
2013-02-22 02:16:06 -08:00
2012-12-04 00:14:43 -08:00
e107 :: js ( 'inline' , $code , 'jquery' );
if ( isset ( $_POST [ 'submit-mye107' ]) || varset ( $_POST [ 'submit-mymenus' ]))
{
2013-02-22 02:16:06 -08:00
2012-12-04 00:14:43 -08:00
$user_pref [ 'core-infopanel-mye107' ] = $_POST [ 'e-mye107' ];
save_prefs ( 'user' );
$pref [ 'core-infopanel-menus' ] = $_POST [ 'e-mymenus' ];
save_prefs ();
}
2012-12-08 00:36:34 -08:00
2013-02-26 18:57:33 -08:00
// $array_functions_assoc = e107::getNav()->adminLinks('assoc');
2012-12-08 00:36:34 -08:00
2013-02-26 18:57:33 -08:00
// $this->iconlist = array_merge($array_functions_assoc, e107::getNav()->pluginLinks(E_16_PLUGMANAGER, "array"));
$this -> iconlist = e107 :: getNav () -> adminLinks ();
2012-12-08 00:36:34 -08:00
2009-09-03 01:27:27 +00:00
}
2012-12-03 02:21:51 -08:00
2012-11-26 03:23:20 -08:00
2012-12-04 00:14:43 -08:00
function render ()
{
$tp = e107 :: getParser ();
$ns = e107 :: getRender ();
$sql = e107 :: getDb ();
$mes = e107 :: getMessage ();
$pref = e107 :: getPref ();
$frm = e107 :: getForm ();
2012-12-04 17:02:01 -08:00
2013-09-11 11:08:50 -07:00
// XXX Check Bootstrap bug is fixed.
/*
2012-12-04 17:02:01 -08:00
echo '
< ul class = " thumbnails " >
< li class = " span4 " >
< a href = " # " class = " thumbnail " >
< img src = " http://placehold.it/360x270 " alt = " " >
</ a >
</ li >
< li class = " span4 " >
< a href = " # " class = " thumbnail " >
< img src = " http://placehold.it/360x270 " alt = " " >
</ a >
</ li >
< li class = " span4 " >
< a href = " # " class = " thumbnail " >
< img src = " http://placehold.it/360x270 " alt = " " >
</ a >
</ li >
< li class = " span4 " >
< a href = " # " class = " thumbnail " >
< img src = " http://placehold.it/360x270 " alt = " " >
</ a >
</ li >
< li class = " span4 " >
< a href = " # " class = " thumbnail " >
< img src = " http://placehold.it/360x270 " alt = " " >
</ a >
</ li >
< li class = " span4 " >
< a href = " # " class = " thumbnail " >
< img src = " http://placehold.it/360x270 " alt = " " >
</ a >
</ li >
</ ul >
' ;
2013-09-11 11:08:50 -07:00
*/
2012-12-04 00:14:43 -08:00
//TODO LANs throughout.
2012-12-04 04:11:00 -08:00
2013-02-22 02:16:06 -08:00
global $style , $user_pref ;
2012-12-04 00:14:43 -08:00
// ---------------------- Start Panel --------------------------------
2012-12-04 17:02:01 -08:00
// $text = "<div >";
2012-12-04 00:14:43 -08:00
if ( getperms ( '0' ) && ! vartrue ( $user_pref [ 'core-infopanel-mye107' ])) // Set default icons.
{
2012-12-07 15:16:42 -08:00
$defArray = array (
0 => 'e-administrator' ,
1 => 'e-cpage' ,
2 => 'e-frontpage' ,
3 => 'e-mailout' ,
4 => 'e-image' ,
5 => 'e-menus' ,
6 => 'e-meta' ,
7 => 'e-newspost' ,
8 => 'e-plugin' ,
9 => 'e-prefs' ,
10 => 'e-links' ,
11 => 'e-theme' ,
12 => 'e-userclass2' ,
13 => 'e-users' ,
14 => 'e-wmessage'
);
$user_pref [ 'core-infopanel-mye107' ] = vartrue ( $pref [ 'core-infopanel-default' ], $defArray );
2012-12-04 00:14:43 -08:00
}
2013-02-26 18:57:33 -08:00
2012-12-04 00:14:43 -08:00
// "<form method='post' action='".e_SELF."?".e_QUERY."'>";
$tp -> parseTemplate ( " { SETSTYLE=core-infopanel} " );
// Personalized Panel
2009-09-03 01:27:27 +00:00
// Rendering the saved configuration.
2012-12-04 00:14:43 -08:00
$mainPanel = "
< div id = 'core-infopanel_mye107' >
2013-02-22 02:16:06 -08:00
" ;
/*
$mainPanel .= ' < span class = " pull-right " >
< span class = " options " >
< div class = " btn-group " >
< a class = " dropdown-toggle " data - toggle = " dropdown " >< i class = " icon-cog " ></ i ></ a >
< ul class = " dropdown-menu black-box-dropdown dropdown-right " >
< li > '.$this->render_infopanel_icons().' </ li >
</ ul >
</ div >
</ span >
</ span > ' ;
*/
2013-02-26 18:57:33 -08:00
// print_a($user_pref['core-infopanel-mye107']);
2013-02-22 02:16:06 -08:00
$mainPanel .= "
2012-12-04 17:02:01 -08:00
2015-01-27 15:20:12 -08:00
< div class = 'left' style = 'padding-bottom:20px' > " ;
2012-12-04 00:14:43 -08:00
2012-12-08 00:36:34 -08:00
foreach ( $this -> iconlist as $key => $val )
2012-12-04 00:14:43 -08:00
{
if ( ! vartrue ( $user_pref [ 'core-infopanel-mye107' ]) || in_array ( $key , $user_pref [ 'core-infopanel-mye107' ]))
{
2013-02-06 13:01:09 -08:00
$mainPanel .= e107 :: getNav () -> renderAdminButton ( $val [ 'link' ], $val [ 'title' ], $val [ 'caption' ], $val [ 'perms' ], $val [ 'icon_32' ], " div " );
2012-12-04 00:14:43 -08:00
}
}
2012-12-04 17:02:01 -08:00
$mainPanel .= " <div class='clear'> </div> " ;
$mainPanel .= " </div>
2012-12-04 00:14:43 -08:00
</ div > " ;
2012-12-06 14:53:58 -08:00
$text = $ns -> tablerender ( ucwords ( USERNAME ) . " 's Control Panel " , $mainPanel , " core-infopanel_mye107 " , true );
2012-12-04 00:14:43 -08:00
// ------------------------------- e107 News --------------------------------
2013-09-11 11:08:50 -07:00
$text2 = $ns -> tablerender ( " e107 News " , " <div id='e-adminfeed'></div><div class='right'><a rel='external' href=' " . ADMINFEEDMORE . " '> " . LAN_MORE . " </a></div> " , " core-infopanel_news " , true );
2012-12-04 17:02:01 -08:00
2013-02-22 00:50:51 -08:00
2012-12-04 17:02:01 -08:00
2012-12-04 00:14:43 -08:00
// ---------------------Latest Stuff ---------------------------
2013-02-09 16:02:03 +02:00
//require_once (e_CORE."shortcodes/batch/admin_shortcodes.php");
e107 :: getScBatch ( 'admin' );
2012-12-04 00:14:43 -08:00
2013-02-22 00:50:51 -08:00
$text2 .= $ns -> tablerender ( " Website Status " , $this -> renderWebsiteStatus (), " " , true );
2013-02-21 17:38:26 -08:00
// $text .= $ns->tablerender(ADLAN_LAT_1,$tp->parseTemplate("{ADMIN_LATEST=norender}"),"core-infopanel_latest",true);
// $text .= $ns->tablerender(LAN_STATUS,$tp->parseTemplate("{ADMIN_STATUS=norender}"),"core-infopanel_latest",true);
2012-12-04 17:02:01 -08:00
/*
$text .= " <li class='span6'>
" . $tp->parseTemplate ( " { ADMIN_LATEST = norender } " ).
$tp -> parseTemplate ( " { ADMIN_STATUS=norender} " ) . "
</ div > " ;
*/
2012-12-04 00:14:43 -08:00
2013-02-22 00:50:51 -08:00
$text .= $this -> renderLatestComments ();
2012-12-04 00:14:43 -08:00
2013-02-22 00:50:51 -08:00
// ---------------------- Who's Online ------------------------
// TODO Could use a new _menu item instead.
2013-01-16 13:08:16 -08:00
2012-11-26 03:23:20 -08:00
2013-02-22 00:50:51 -08:00
// $text2 .= $ns->tablerender('Visitors Online : '.vartrue($nOnline), $panelOnline,'core-infopanel_online',true);
2012-12-04 00:14:43 -08:00
// --------------------- User Selected Menus -------------------
2012-11-26 03:23:20 -08:00
2012-12-04 00:14:43 -08:00
if ( varset ( $pref [ 'core-infopanel-menus' ]))
{
foreach ( $pref [ 'core-infopanel-menus' ] as $val )
{
$id = $frm -> name2id ( 'core-infopanel_' . $val );
$inc = $tp -> parseTemplate ( " { PLUGIN= $val |TRUE} " );
$text .= $inc ;
// $text .= $ns->tablerender("", $inc, $id,true);
}
}
2012-11-26 03:23:20 -08:00
2012-12-04 00:14:43 -08:00
2012-12-04 17:02:01 -08:00
// $text .= "<div class='clear'> </div>";
2012-12-04 00:14:43 -08:00
$text .= $this -> render_infopanel_options ();
2012-12-04 17:02:01 -08:00
// $text .= "</div>";
2012-12-04 00:14:43 -08:00
2012-12-08 00:32:37 +01:00
if ( vartrue ( $_GET [ 'mode' ]) != 'customize' )
2012-12-04 00:14:43 -08:00
{
// $ns->tablerender(ADLAN_47." ".ADMINNAME, $emessage->render().$text);
2012-12-04 17:02:01 -08:00
echo $mes -> render () . '
<!-- INFOPANEL -->
< div class = " span6 " >
< ul class = " thumbnails " > '.$text.' </ ul >
</ div >
< div class = " span6 " >
< ul class = " thumbnails " > '.$text2.' </ ul >
</ div >
<!-- -->
' ;
2012-12-04 00:14:43 -08:00
}
else
{
2013-02-22 02:16:06 -08:00
echo $frm -> open ( 'infopanel' , 'post' , e_SELF );
2012-12-04 00:14:43 -08:00
echo $this -> render_infopanel_options ( true );
2012-12-04 17:02:01 -08:00
echo $frm -> close ();
2012-12-04 00:14:43 -08:00
}
2012-11-26 03:23:20 -08:00
2012-12-04 00:14:43 -08:00
}
2012-11-26 03:23:20 -08:00
2013-05-15 15:01:55 -07:00
private function renderChart ()
2013-02-22 00:50:51 -08:00
{
2013-05-14 23:51:19 -07:00
2013-05-15 15:01:55 -07:00
2013-03-17 14:47:35 -07:00
// REQUIRES Log Plugin to be installed.
2013-02-22 00:50:51 -08:00
if ( e107 :: isInstalled ( 'log' ))
{
2013-05-15 15:01:55 -07:00
return $this -> renderStats ( 'log' );
2013-02-22 00:50:51 -08:00
}
elseif ( e107 :: isInstalled ( 'awstats' ))
{
2013-05-15 15:01:55 -07:00
return $this -> renderStats ( 'awstats' );
2013-02-22 00:50:51 -08:00
}
else
{
2013-05-15 15:01:55 -07:00
return $this -> renderStats ( 'demo' );
2013-02-22 00:50:51 -08:00
}
}
function renderWebsiteStatus ()
{
2014-01-17 06:49:55 -08:00
$tp = e107 :: getParser ();
2013-02-22 00:50:51 -08:00
/*
// Settings button if needed.
< div class = " tab-header " >
< span class = " pull-right " >
< span class = " options " >
< div class = " btn-group " >
< a class = " dropdown-toggle " data - toggle = " dropdown " >< i class = " icon-cog " ></ i ></ a >
< ul class = " dropdown-menu black-box-dropdown dropdown-left " >
< li >< a href = " # " > Action </ a ></ li >
< li >< a href = " # " > Another action </ a ></ li >
< li >< a href = " # " > Something else here </ a ></ li >
< li class = " divider " ></ li >
< li >< a href = " # " > Separated link </ a ></ li >
</ ul >
</ div >
</ span >
</ span >
</ div >
*/
2015-01-09 21:43:16 -08:00
$tab = array ();
$tab [ 'e-stats' ] = array ( 'caption' => $tp -> toGlyph ( 'fa-signal' ) . ' Stats' , 'text' => $this -> renderChart ());
$tab [ 'e-online' ] = array ( 'caption' => $tp -> toGlyph ( 'fa-user' ) . ' Online (' . $this -> renderOnlineUsers ( 'count' ) . ')' , 'text' => $this -> renderOnlineUsers ());
2013-02-22 00:50:51 -08:00
2015-01-09 21:43:16 -08:00
if ( $plugs = e107 :: getAddonConfig ( 'e_dashboard' , null , 'chart' ))
{
foreach ( $plugs as $plug => $val )
{
foreach ( $val as $item )
{
if ( ! empty ( $item ))
{
$tab [] = $item ;
}
}
}
}
return e107 :: getForm () -> tabs ( $tab );
2013-02-22 00:50:51 -08:00
}
2013-09-11 11:08:50 -07:00
function renderOnlineUsers ( $data = false )
2013-02-22 00:50:51 -08:00
{
$ol = e107 :: getOnline ();
$tp = e107 :: getParser ();
$panelOnline = "
< table class = 'table table-condensed table-striped' style = 'width:96%;margin-left:auto;margin-right:auto' >
< colgroup >
< col style = 'width: 10%' />
< col style = 'width: 25%' />
< col style = 'width: 10%' />
< col style = 'width: 40%' />
< col style = 'width: auto' />
</ colgroup >
< thead >
< tr class = 'first' >
< th > Timestamp </ th >
< th > Username </ th >
< th > IP </ th >
< th > Page </ th >
< th class = 'center' > Agent </ th >
</ tr >
</ thead >
< tbody > " ;
$online = $ol -> userList () + $ol -> guestList ();
2013-09-11 11:08:50 -07:00
if ( $data == 'count' )
{
return count ( $online );
}
2013-02-22 00:50:51 -08:00
// echo "Users: ".print_a($online);
foreach ( $online as $val )
{
$panelOnline .= "
< tr >
< td class = 'nowrap' > " .e107::getDateConvert()->convert_date( $val['user_currentvisit'] ,'%H:%M:%S'). " </ td >
< td > " . $this->renderOnlineName ( $val['online_user_id'] ). " </ td >
< td > " .e107::getIPHandler()->ipDecode( $val['user_ip'] ). " </ td >
< td >< a class = 'e-tip' href = '".$val[' user_location ']."' title = '".$val[' user_location ']."' > " . $tp->html_truncate (basename( $val['user_location'] ),50, " ... " ). " </ a ></ td >
< td class = 'center' >< a class = 'e-tip' href = '#' title = '".$val[' user_agent ']."' > " . $this->browserIcon ( $val ). " </ a ></ td >
</ tr >
" ;
}
$panelOnline .= " </tbody></table> " ;
return $panelOnline ;
}
2012-11-26 03:23:20 -08:00
2012-12-04 21:02:47 -08:00
function browserIcon ( $row )
{
$types = array (
" ie " => " MSIE " ,
'chrome' => 'Chrome' ,
'firefox' => 'Firefox' ,
'seamonkey' => 'Seamonkey' ,
// 'Chromium/xyz
'safari' => " Safari " ,
'opera' => " Opera "
);
if ( $row [ 'user_bot' ] === true )
{
2013-01-15 18:01:51 -08:00
return " <i class='browser e-bot-16'></i> " ;
2012-12-04 21:02:47 -08:00
}
foreach ( $types as $icon => $b )
{
if ( strpos ( $row [ 'user_agent' ], $b ) !== false )
{
2013-01-15 18:01:51 -08:00
return " <i class='browsers e- " . $icon . " -16' ></i> " ;
2012-12-04 21:02:47 -08:00
}
}
2010-02-10 21:53:56 +00:00
2013-01-15 18:01:51 -08:00
return " <i class='browsers e-firefox-16'></i> " ; // FIXME find a default icon.
2012-12-04 21:02:47 -08:00
}
2012-11-26 03:23:20 -08:00
2010-03-16 07:46:01 +00:00
2012-12-04 00:14:43 -08:00
function renderOnlineName ( $val )
2009-07-23 10:46:11 +00:00
{
2012-12-04 00:14:43 -08:00
if ( $val == 0 )
2009-09-03 01:27:27 +00:00
{
2012-12-04 00:14:43 -08:00
return " Guest " ;
2009-09-03 01:27:27 +00:00
}
2012-12-04 00:14:43 -08:00
return $val ;
2009-07-04 03:08:03 +00:00
}
2012-11-26 03:23:20 -08:00
2013-02-22 00:50:51 -08:00
function renderLatestComments ()
{
2013-05-17 19:45:39 -07:00
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2013-02-22 00:50:51 -08:00
2013-05-17 19:45:39 -07:00
if ( ! check_class ( 'B' )) // XXX problems?
{
// return;
}
2013-05-20 13:37:39 -07:00
if ( ! $rows = $sql -> retrieve ( 'comments' , '*' , 'comment_blocked=2 ORDER BY comment_id DESC LIMIT 25' , true ) )
2013-05-17 19:45:39 -07:00
{
return ;
}
2013-02-22 00:50:51 -08:00
2013-05-17 19:45:39 -07:00
$sc = e107 :: getScBatch ( 'comment' );
2013-05-20 13:37:39 -07:00
2013-05-17 19:45:39 -07:00
$text = '
< ul class = " media-list unstyled " > ' ;
// <button class='btn btn-mini'><i class='icon-pencil'></i> Edit</button>
2013-05-20 13:37:39 -07:00
//XXX Always keep template hardcoded here - heavy use of ajax and ids.
$count = 1 ;
foreach ( $rows as $row )
{
$hide = ( $count > 3 ) ? ' hide' : '' ;
2013-05-17 19:45:39 -07:00
$TEMPLATE = " { SETIMAGE: w=40}
2013-05-20 13:37:39 -07:00
< li id = 'comment-".$row[' comment_id ']."' class = 'media".$hide."' >
2013-05-17 19:45:39 -07:00
< span class = 'media-object pull-left' > { USER_AVATAR = " . $row['comment_author_id'] . " } </ span >
< div class = 'btn-group pull-right' >
2013-05-20 13:37:39 -07:00
< button data - target = '".e_BASE."comment.php' data - comment - id = '".$row[' comment_id ']."' data - comment - action = 'delete' class = 'btn btn-mini btn-danger' >< i class = 'icon-remove' ></ i > Delete </ button >
< button data - target = '".e_BASE."comment.php' data - comment - id = '".$row[' comment_id ']."' data - comment - action = 'approve' class = 'btn btn-mini btn-success' >< i class = 'icon-ok' ></ i > Approve </ button >
2013-05-17 19:45:39 -07:00
</ div >
< div class = 'media-body' >< small class = 'muted smalltext' > Posted by { USERNAME } { TIMEDATE = relative } </ small >< br />
< p > { COMMENT } </ p >
</ div >
</ li > " ;
$sc -> setVars ( $row );
$text .= $tp -> parseTemplate ( $TEMPLATE , true , $sc );
2013-05-20 13:37:39 -07:00
$count ++ ;
2013-05-17 19:45:39 -07:00
}
2013-02-22 00:50:51 -08:00
2013-05-17 19:45:39 -07:00
$text .= '
2013-05-20 13:37:39 -07:00
</ ul >
< div class = " right " >
< a class = " btn btn-mini btn-primary text-right " href = " '.e_ADMIN.'comment.php?searchquery=&filter_options=comment_blocked__2 " > View all </ a >
</ div >
' ;
// $text .= "<small class='text-center text-warning'>Note: Not fully functional at the moment.</small>";
2013-02-22 00:50:51 -08:00
$ns = e107 :: getRender ();
return $ns -> tablerender ( " Latest Comments " , $text , 'core-infopanel_online' , true );
}
2012-11-26 14:41:32 -08:00
2012-12-04 00:14:43 -08:00
function render_info_panel ( $caption , $text )
2009-09-03 01:27:27 +00:00
{
2012-12-04 00:14:43 -08:00
return " <div class='main_caption bevel left'><b> " . $caption . " </b></div>
< div class = 'left block-text' > " . $text . " </ div > " ;
2009-09-03 01:27:27 +00:00
}
2012-12-04 00:14:43 -08:00
function render_infopanel_options ( $render = false )
2009-10-22 23:43:21 +00:00
{
2012-12-04 00:14:43 -08:00
// $frm = e107::getSingleton('e_form');
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
$start = " <div>
To customize this page , please < a title = 'Customize Admin' href = '".e_SELF."?mode=customize&iframe=1' class = 'e-modal-iframe' > click here </ a >.
</ div >
" ;
if ( $render == false ){ return " " ; }
$text2 = " <div id='customize_icons' class='forumheader3' style='border:0px;margin:0px'>
< form method = 'post' id = 'e-modal-form' action = '".e_SELF."' > " ;
2012-12-08 00:36:34 -08:00
$text2 .= $ns -> tablerender ( " Personalize Icons " , $this -> render_infopanel_icons (), 'personalize' , true );
2012-12-04 00:14:43 -08:00
$text2 .= " <div class='clear'> </div> " ;
2012-12-08 00:36:34 -08:00
$text2 .= $ns -> tablerender ( " Personalize Menus " , $this -> render_infopanel_menu_options (), 'personalize' , true );
2012-12-04 00:14:43 -08:00
// $text2 .= render_infopanel_icons();
//$text2 .= "<div class='clear'> </div>";
// $text2 .= "<h3>Menus</h3>";
// $text2 .= render_infopanel_menu_options();
$text2 .= " <div class='clear'> </div> " ;
$text2 .= " <div id='button' class='buttons-bar center'> " ;
$text2 .= $frm -> admin_button ( 'submit-mye107' , 'Save' , 'create' );
$text2 .= " </div></form> " ;
// $text2 .= "</div>";
// $end = "</div>";
2011-08-19 23:40:29 +00:00
2012-12-04 00:14:43 -08:00
return $mes -> render () . $text2 . $end ;
}
2010-02-10 21:53:56 +00:00
2009-09-18 23:14:01 +00:00
2012-12-04 00:14:43 -08:00
function render_infopanel_icons ()
2009-09-03 01:27:27 +00:00
{
2012-12-08 00:36:34 -08:00
$frm = e107 :: getForm ();
global $user_pref ;
2012-12-04 00:14:43 -08:00
2015-01-27 15:20:12 -08:00
$text = " <div style='padding-left:20px'> " ;
2013-02-26 18:57:33 -08:00
2012-12-04 00:14:43 -08:00
2012-12-08 00:36:34 -08:00
foreach ( $this -> iconlist as $key => $icon )
2009-09-03 01:27:27 +00:00
{
if ( getperms ( $icon [ 'perms' ]))
{
2012-12-04 00:14:43 -08:00
$checked = ( varset ( $user_pref [ 'core-infopanel-mye107' ]) && in_array ( $key , $user_pref [ 'core-infopanel-mye107' ])) ? true : false ;
2015-01-27 15:20:12 -08:00
$text .= " <div class='left f-left list field-spacer checkbox' style='display:block;height:24px;width:200px;'>
2012-12-04 00:14:43 -08:00
" . $icon['icon'] .' '. $frm->checkbox_label ( $icon['title'] , 'e-mye107[]', $key , $checked ). " </ div > " ;
2012-12-08 00:36:34 -08:00
2012-12-04 00:14:43 -08:00
}
}
2012-12-08 00:36:34 -08:00
2012-12-04 00:14:43 -08:00
if ( is_array ( $pluglist ))
{
foreach ( $pluglist as $key => $icon )
{
if ( getperms ( $icon [ 'perms' ]))
{
$checked = ( in_array ( 'p-' . $key , $user_pref [ 'core-infopanel-mye107' ])) ? true : false ;
2015-01-27 15:20:12 -08:00
$text .= " <div class='left f-left list field-spacer checkbox' style='display:block;height:24px;width:200px;'>
2012-12-04 00:14:43 -08:00
" . $icon['icon'] . $frm->checkbox_label ( $icon['title'] , 'e-mye107[]', $key , $checked ). " </ div > " ;
}
2009-09-03 01:27:27 +00:00
}
}
2015-01-27 15:20:12 -08:00
$text .= " </div><div class='clear'> </div> " ;
2012-12-04 00:14:43 -08:00
return $text ;
2009-09-03 01:27:27 +00:00
}
2012-11-26 14:41:32 -08:00
2010-02-10 21:53:56 +00:00
2012-12-04 00:14:43 -08:00
function render_infopanel_menu_options ()
2009-09-03 01:27:27 +00:00
{
2012-12-04 00:14:43 -08:00
if ( ! getperms ( '0' ))
2009-09-03 01:27:27 +00:00
{
2012-12-04 00:14:43 -08:00
return ;
}
$frm = e107 :: getForm ();
$pref = e107 :: getPref ();
2015-01-27 15:20:12 -08:00
$text = " <div style='padding-left:20px'> " ;
2012-12-04 00:14:43 -08:00
$menu_qry = 'SELECT * FROM #menus WHERE menu_id!= 0 GROUP BY menu_name ORDER BY menu_name' ;
$settings = varset ( $pref [ 'core-infopanel-menus' ], array ());
if ( e107 :: getDb () -> db_Select_gen ( $menu_qry ))
{
while ( $row = e107 :: getDb () -> db_Fetch ())
2009-10-26 09:50:00 +00:00
{
2012-12-04 00:14:43 -08:00
// if(!is_numeric($row['menu_path']))
{
$label = str_replace ( " _menu " , " " , $row [ 'menu_name' ]);
$path_to_menu = $row [ 'menu_path' ] . $row [ 'menu_name' ];
$checked = ( $settings && in_array ( $path_to_menu , $settings )) ? true : false ;
$text .= " \n <div class='left f-left list field-spacer' style='display:block;height:24px;width:200px;'> " ;
$text .= $frm -> checkbox_label ( $label , " e-mymenus[] " , $path_to_menu , $checked );
$text .= " </div> " ;
}
2009-10-26 09:50:00 +00:00
}
2009-09-03 01:27:27 +00:00
}
2012-12-04 00:14:43 -08:00
2015-01-27 15:20:12 -08:00
$text .= " </div><div class='clear'> </div> " ;
2012-12-04 00:14:43 -08:00
return $text ;
2009-09-03 01:27:27 +00:00
}
2012-12-04 17:02:01 -08:00
2013-05-15 15:01:55 -07:00
private function getStats ( $type )
2012-12-04 17:02:01 -08:00
{
2013-05-15 15:01:55 -07:00
if ( file_exists ( e_PLUGIN . " awstats/awstats.graph.php " ))
2013-01-15 18:01:51 -08:00
{
require_once ( e_PLUGIN . " awstats/awstats.graph.php " );
2013-05-25 22:30:10 -07:00
$stat = new awstats ;
2013-05-17 19:45:39 -07:00
2013-05-25 22:30:10 -07:00
if ( $data = $stat -> getData ())
2013-05-17 19:45:39 -07:00
{
return $data ;
}
2013-05-15 15:01:55 -07:00
// return;
2013-01-15 18:01:51 -08:00
}
2012-12-04 17:02:01 -08:00
2013-05-15 15:01:55 -07:00
if ( $type == 'demo' )
2013-03-17 14:47:35 -07:00
{
2013-05-15 15:01:55 -07:00
$data = array ();
2012-12-04 17:02:01 -08:00
2013-05-15 15:01:55 -07:00
$data [ 'labels' ] = array ( " January " , " February " , " March " , " April " , " May " , " June " , " July " );
$data [ 'datasets' ][] = array (
'fillColor' => " rgba(220,220,220,0.5) " ,
'strokeColor' => " rgba(220,220,220,1) " ,
'pointColor ' => " rgba(220,220,220,1) " ,
'pointStrokeColor' => " #fff " ,
2014-06-22 16:58:18 -07:00
'data' => array ( 65 , 59 , 90 , 81 , 56 , 55 , 40 ),
'title' => " Visits "
2013-05-15 15:01:55 -07:00
);
$data [ 'datasets' ][] = array (
'fillColor' => " rgba(151,187,205,0.5) " ,
'strokeColor' => " rgba(151,187,205,1) " ,
'pointColor ' => " rgba(151,187,205,1) " ,
'pointStrokeColor' => " #fff " ,
2014-06-22 16:58:18 -07:00
'data' => array ( 28 , 48 , 40 , 19 , 96 , 27 , 100 ),
'title' => " Unique Visits "
2013-05-15 15:01:55 -07:00
);
return $data ;
}
2012-12-04 17:02:01 -08:00
$sql = e107 :: getDB ();
$td = date ( " Y-m-j " , time ());
$dayarray [ $td ] = array ();
$pagearray = array ();
$qry = "
SELECT * from #logstats WHERE log_id REGEXP('[[:digit:]]+\-[[:digit:]]+\-[[:digit:]]+')
ORDER BY CONCAT ( LEFT ( log_id , 4 ), SUBSTRING ( log_id , 6 , 2 ), LPAD ( SUBSTRING ( log_id , 9 ), 2 , '0' ))
2012-12-04 21:02:47 -08:00
DESC LIMIT 0 , 9
2012-12-04 17:02:01 -08:00
" ;
2013-05-16 13:12:29 -07:00
if ( $amount = $sql -> gen ( $qry ))
2012-12-04 17:02:01 -08:00
{
2013-05-16 13:12:29 -07:00
$array = $sql -> db_getList ();
2012-12-04 17:02:01 -08:00
$ttotal = 0 ;
$utotal = 0 ;
foreach ( $array as $key => $value )
{
extract ( $value );
if ( is_array ( $log_data )) {
$entries [ 0 ] = $log_data [ 'host' ];
$entries [ 1 ] = $log_data [ 'date' ];
$entries [ 2 ] = $log_data [ 'os' ];
$entries [ 3 ] = $log_data [ 'browser' ];
$entries [ 4 ] = $log_data [ 'screen' ];
$entries [ 5 ] = $log_data [ 'referer' ];
}
else
{
$entries = explode ( chr ( 1 ), $log_data );
}
$dayarray [ $log_id ][ 'daytotal' ] = $entries [ 0 ];
$dayarray [ $log_id ][ 'dayunique' ] = $entries [ 1 ];
unset ( $entries [ 0 ]);
unset ( $entries [ 1 ]);
foreach ( $entries as $entry )
{
if ( $entry )
{
list ( $url , $total , $unique ) = explode ( " | " , $entry );
if ( strstr ( $url , " / " ))
{
$urlname = preg_replace ( " / \ .php| \ ?.*/ " , " " , substr ( $url , ( strrpos ( $url , " / " ) + 1 )));
}
else
{
$urlname = preg_replace ( " / \ .php| \ ?.*/ " , " " , $url );
}
$dayarray [ $log_id ][ $urlname ] = array ( 'url' => $url , 'total' => $total , 'unique' => $unique );
if ( ! isset ( $pagearray [ $urlname ][ 'total' ])) $pagearray [ $urlname ][ 'total' ] = 0 ;
if ( ! isset ( $pagearray [ $urlname ][ 'unique' ])) $pagearray [ $urlname ][ 'unique' ] = 0 ;
$pagearray [ $urlname ][ 'total' ] += $total ;
$pagearray [ $urlname ][ 'unique' ] += $unique ;
$ttotal += $total ;
$utotal += $unique ;
}
}
}
}
$logfile = e_LOG . 'logp_' . date ( 'z.Y' , time ()) . '.php' ; // was logi_ ??
if ( is_readable ( $logfile ))
{
require ( $logfile );
}
2012-12-06 14:16:55 -08:00
if ( vartrue ( $pageInfo ))
2012-12-04 17:02:01 -08:00
{
2012-12-06 14:16:55 -08:00
foreach ( $pageInfo as $fkey => $fvalue )
{
$dayarray [ $td ][ $fkey ][ 'total' ] += $fvalue [ 'ttl' ];
$dayarray [ $td ][ $fkey ][ 'unique' ] += $fvalue [ 'unq' ];
$dayarray [ $td ][ 'daytotal' ] += $fvalue [ 'ttl' ];
$dayarray [ $td ][ 'dayunique' ] += $fvalue [ 'unq' ];
$pagearray [ $fkey ][ 'total' ] += $fvalue [ 'ttl' ];
$pagearray [ $fkey ][ 'unique' ] += $fvalue [ 'unq' ];
$ttotal += $fvalue [ 'ttl' ];
$utotal += $fvalue [ 'unq' ];
}
2012-12-04 17:02:01 -08:00
}
2013-05-15 15:01:55 -07:00
$visitors = array ();
$unique = array ();
2012-12-04 17:02:01 -08:00
ksort ( $dayarray );
foreach ( $dayarray as $k => $v )
{
$unix = strtotime ( $k );
2013-05-15 15:01:55 -07:00
$visitors [] = intval ( vartrue ( $v [ 'daytotal' ]));
$unique [] = intval ( vartrue ( $v [ 'dayunique' ]));
2012-12-04 17:02:01 -08:00
$label [] = " ' " . date ( " D " , $unix ) . " ' " ;
}
2013-05-15 15:01:55 -07:00
$data = array ();
$data [ 'labels' ] = $label ;
2013-05-16 13:12:29 -07:00
//visitors
2013-05-15 15:01:55 -07:00
$data [ 'datasets' ][] = array (
'fillColor' => " rgba(220,220,220,0.5) " ,
'strokeColor' => " rgba(220,220,220,1) " ,
'pointColor ' => " rgba(220,220,220,1) " ,
'pointStrokeColor' => " #fff " ,
'data' => $visitors
);
2013-05-16 13:12:29 -07:00
//Unique Visitors
2013-05-15 15:01:55 -07:00
$data [ 'datasets' ][] = array (
'fillColor' => " rgba(151,187,205,0.5) " ,
'strokeColor' => " rgba(151,187,205,1) " ,
'pointColor ' => " rgba(151,187,205,1) " ,
'pointStrokeColor' => " #fff " ,
'data' => $unique
);
return $data ;
2012-12-04 17:02:01 -08:00
}
2013-05-15 15:01:55 -07:00
private function renderStats ( $type )
2012-12-04 17:02:01 -08:00
{
2013-05-15 15:01:55 -07:00
$data = $this -> getStats ( $type );
2013-03-17 14:47:35 -07:00
2013-05-15 15:01:55 -07:00
$cht = e107 :: getChart ();
$cht -> setType ( 'line' );
2014-06-22 16:58:18 -07:00
$cht -> setOptions ( array (
'annotateDisplay' => true ,
'annotateFontSize' => 8
));
2013-05-15 15:01:55 -07:00
$cht -> setData ( $data , 'canvas' );
$text = $cht -> render ( 'canvas' );
if ( $type == 'demo' )
{
$text .= " <div class='center'><small>These stats are for demonstration purposes only. <a class='btn btn-mini' href=' " . e_ADMIN . " plugin.php?avail'>Install Site Stats Plugin</a></small></div> " ;
}
else
{
$text .= " <div class='center'><small>
< span style = 'color:rgba(220,220,220,0.5)' >& diams ; </ span > Visitors & nbsp ; & nbsp ;
< span style = 'color:rgba(151,187,205,1)' >& diams ; </ span > Unique Visitors
</ small ></ div > " ;
}
2012-12-04 17:02:01 -08:00
2013-05-15 15:01:55 -07:00
return $text ;
2012-12-04 17:02:01 -08:00
}
2009-09-03 01:27:27 +00:00
}
2009-07-04 03:08:03 +00:00
?>