| Server IP : 104.21.21.239 / Your IP : 216.73.216.68 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/home2/mommybites/wp-admin/dashboard/ |
Upload File : |
<?php
require_once '../../wp-config.php';
/*$ch = curl_init("https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A53503582&start-date=2017-11-29&end-date=2017-12-07&metrics=ga%3Apageviews&access_token=ya29.GlsaBVc0-AXeesnpD02VQM48uaGfKy5rOmUNasWnEzdWj5r5jVFH5ZE9vTLf-sAIf3NHHtONSlkNWijr6Ziejkgfqt-Uu9a9Kvqr0Jcj1ytI9FqiZJ5l19eb2gKj");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo '====='.$output.'=====';*/
function getReport($blog_id=2)
{
global $wpdb;
if(!isset($_REQUEST['start'])) return 'Please Select a Date Range';
$query = "select count(*) as total from nanny_post where created_date between '".$_REQUEST['start']." 00:00:01' AND '".$_REQUEST['end']." 23:59:59' AND post_status='approved' AND blog_id=$blog_id AND billing_id > 0";
// print_r($query);
$result = $wpdb->get_results($query,ARRAY_A);
//$wpdb->bail('some error');
$query2 = "select sum(find_views) as find_views, sum(post_views) as post_views from Stats where theday between '".$_REQUEST['start']."' AND '".$_REQUEST['end']."' AND blog_id=$blog_id AND board='nanny' group by blog_id,board";
//echo $query2;
$result2 = $wpdb->get_results($query2,ARRAY_A);
$str .= '<table>';
$str .= '<tr><th>Page</th><th>Find Views</th><th>Post Views</th><th>Paid</th><th>Revenue</th><th>Conversion</th></tr>';
foreach ($result as $row)
{
foreach ($result2 as $row2)
{
$find_views = $row2['find_views'];
$post_views = $row2['post_views'];
}
$tot = $row['total']*85;
$con = $row['total']/$post_views*100;
$str .= '<tr class="darker"><td>Nanny</td><td>'.$find_views.'</td><td>'.$post_views.'</td><td>'.$row['total'].'</td><td>$'.number_format($tot).'</td><td>'.number_format($con,2).'%</td></tr>';
}
// SHARE
$find_views=$post_views=0;
$query = "select count(*) as total from nanny_share_post where created_date between '".$_REQUEST['start']." 00:00:01' AND '".$_REQUEST['end']." 23:59:59' AND blog_id=$blog_id AND status='approved' AND blog_id=$blog_id AND billing_id > 0";
$result = $wpdb->get_results($query,ARRAY_A);
//$wpdb->bail('some error');
$query2 = "select sum(find_views) as find_views, sum(post_views) as post_views from Stats where theday between '".$_REQUEST['start']."' AND '".$_REQUEST['end']."' AND blog_id=$blog_id AND board='share' group by blog_id,board";
//echo $query2;
$result2 = $wpdb->get_results($query2,ARRAY_A);
foreach ($result as $row)
{
foreach ($result2 as $row2)
{
$find_views = $row2['find_views'];
$post_views = $row2['post_views'];
}
$tot = $row['total']*25;
$con = $row['total']/$post_views*100;
$str .= '<tr><td>Share</td><td>'.$find_views.'</td><td>'.$post_views.'</td><td>'.$row['total'].'</td><td>$'.number_format($tot).'</td><td>'.number_format($con,2).'%</td></tr>';
}
// JOB
$query = "select count(*) as total from mom_job_post where created_date between '".$_REQUEST['start']." 00:00:01' AND '".$_REQUEST['end']." 23:59:59' AND blog_id=$blog_id AND status='approved' AND blog_id=$blog_id AND billing_id > 0";
$result = $wpdb->get_results($query,ARRAY_A);
//$wpdb->bail('some error');
$query2 = "select sum(find_views) as find_views, sum(post_views) as post_views from Stats where theday between '".$_REQUEST['start']."' AND '".$_REQUEST['end']."' AND blog_id=$blog_id AND board='job' group by blog_id,board";
//echo $query2;
$result2 = $wpdb->get_results($query2,ARRAY_A);
foreach ($result as $row)
{
foreach ($result2 as $row2)
{
$find_views = $row2['find_views'];
$post_views = $row2['post_views'];
}
$tot = $row['total']*40;
$con = $row['total']/$post_views*100;
$str .= '<tr class="darker"><td>Job</td><td>'.$find_views.'</td><td>'.$post_views.'</td><td>'.$row['total'].'</td><td>$'.number_format($tot).'</td><td>'.number_format($con,2).'%</td></tr>';
}
// EVENT
$query = "select count(*) as total from event_post where created_date between '".$_REQUEST['start']." 00:00:01' AND '".$_REQUEST['end']." 23:59:59' AND blog_id=$blog_id AND status='approved' AND blog_id=$blog_id AND billing_id > 0";
$result = $wpdb->get_results($query,ARRAY_A);
//$wpdb->bail('some error');
$query2 = "select sum(find_views) as find_views, sum(post_views) as post_views from Stats where theday between '".$_REQUEST['start']."' AND '".$_REQUEST['end']."' AND blog_id=$blog_id AND board='event' group by blog_id,board";
//echo $query2;
$result2 = $wpdb->get_results($query2,ARRAY_A);
foreach ($result as $row)
{
foreach ($result2 as $row2)
{
$find_views = $row2['find_views'];
$post_views = $row2['post_views'];
}
$tot = $row['total']*40;
$con = $row['total']/$post_views*100;
$str .= '<tr><td>Event</td><td>'.$find_views.'</td><td>'.$post_views.'</td><td>'.$row['total'].'</td><td>$'.number_format($tot).'</td><td>'.number_format($con,2).'%</td></tr>';
}
// BABYSITTER
$query = "select count(*) as total from babysitter_post where created_date between '".$_REQUEST['start']." 00:00:01' AND '".$_REQUEST['end']." 23:59:59' AND blog_id=$blog_id AND status='approved' AND blog_id=$blog_id AND billing_id > 0";
$result = $wpdb->get_results($query,ARRAY_A);
//$wpdb->bail('some error');
$query2 = "select sum(find_views) as find_views, sum(post_views) as post_views from Stats where theday between '".$_REQUEST['start']."' AND '".$_REQUEST['end']."' AND blog_id=$blog_id AND board='babysitter' group by blog_id,board";
//echo $query2;
$result2 = $wpdb->get_results($query2,ARRAY_A);
foreach ($result as $row)
{
foreach ($result2 as $row2)
{
$find_views = $row2['find_views'];
$post_views = $row2['post_views'];
}
$tot = $row['total']*25;
$con = $row['total']/$post_views*100;
$str .= '<tr class="darker"><td>Babysitter</td><td>'.$find_views.'</td><td>'.$post_views.'</td><td>'.$row['total'].'</td><td>$'.number_format($tot).'</td><td>'.number_format($con,2).'%</td></tr>';
}
$str .= '</table>';
if(sizeof($result)==0) return 'No records';
return $str;
}
$str = getReport();
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dashboard</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" media="all" href="daterangepicker.css" />
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="bootstrap.min.js"></script>
<script type="text/javascript" src="moment.js"></script>
<script type="text/javascript" src="daterangepicker.js"></script>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style type="text/css">
html, body, p {
font-family: Arial, sans-serif;
}
h1, h2, h3 {
font-family: "Roboto Slab", serif;
color: #5b4735;
}
table {
width: 100%;
background-color: #f4f5eb !important;
margin-top: 30px;
}
table tr td {
width: 16.6%;
}
th {
background-color: #5b4735;
color: white;
padding: 5px !important;
border: 1px solid white;
}
tr {
height: 40px !important;
}
tr.darker {
background-color: #e9ebd8;
}
td {
padding: 5px !important;
border: 1px solid white;
}
.button {
border-radius: 4px;
background-color: #5fbad7;
color: white;
display: inline-block;
padding: 7px 15px;
margin-top: 30px;
}
.button:hover {
background-color: #fec1cc;
}
.button a {
color: white;
text-decoration: none;
}
@media only screen and (max-width: 500px) {
th {
font-weight: normal;
font-size: 12px;
}
}
</style>
</head>
<body style="margin: 20px 0">
<div class="container">
<div class="logo">
<a href="https://mommybites.com/"><img src="https://mommybites.com/wp-content/uploads/2017/04/mommybites-logo.png"></a>
</div>
<h2>Dashboard</h2>
<div class="row">
<div class="col-md-6 demo">
<h4>Date Range</h4>
<input type="text" id="config-demo" class="form-control">
<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
</div>
</div>
</div>
<style type="text/css">
.demo { position: relative; }
.demo i {
position: absolute; bottom: 10px; right: 24px; top: auto; cursor: pointer;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
function toDate(dateStr) {
var parts = dateStr.split("-");
return parts[1]+'/'+parts[2]+'/'+parts[0]; //new Date(parts[2], parts[1] - 1, parts[0]);
}
updateConfig();
function updateConfig() {
var options = {};
options.autoApply = true;
<?php if(isset($_REQUEST['start'])) { ?>
var start = toDate("<?php echo $_REQUEST['start']?>");
var end = toDate("<?php echo $_REQUEST['end']?>");
options.startDate = start;
options.endDate = end;
<?php } ?>
if ($('#ranges').is(':checked')) {
options.ranges = {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
};
}
if ($('#locale').is(':checked')) {
$('#rtl-wrap').show();
options.locale = {
direction: $('#rtl').is(':checked') ? 'rtl' : 'ltr',
format: 'MM/DD/YYYY HH:mm',
separator: ' - ',
applyLabel: 'Apply',
cancelLabel: 'Cancel',
fromLabel: 'From',
toLabel: 'To',
customRangeLabel: 'Custom',
daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'],
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
firstDay: 1
};
} else {
$('#rtl-wrap').hide();
}
//$('#config-text').val("$('#demo').daterangepicker(" + JSON.stringify(options, null, ' ') + ", function(start, end, label) {\n console.log(\"New date range selectedd: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')\");\n});");
$('#config-demo').daterangepicker(options, function(start, end, label) { console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')');
window.location.href = 'index.php' + "?start=" + start.format('YYYY-MM-DD')+'&end='+end.format('YYYY-MM-DD') ;
}
);
}
});
</script>
<div class='container'>
<div class='button'>
<a href="#" id ="export" role='button'>Click Here To Export to a CSV File
</a>
</div>
<div id="dvData">
<?php echo $str;?>
</div>
</div>
<!-- If you want to use jquery 2+: https://code.jquery.com/jquery-2.1.0.min.js -->
<script type='text/javascript'>
$(document).ready(function () {
function exportTableToCSV($table, filename) {
var $headers = $table.find('tr:has(th)')
,$rows = $table.find('tr:has(td)')
// Temporary delimiter characters unlikely to be typed by keyboard
// This is to avoid accidentally splitting the actual contents
,tmpColDelim = String.fromCharCode(11) // vertical tab character
,tmpRowDelim = String.fromCharCode(0) // null character
// actual delimiter characters for CSV format
,colDelim = '","'
,rowDelim = '"\r\n"';
// Grab text from table into CSV formatted string
var csv = '"';
csv += formatRows($headers.map(grabRow));
csv += rowDelim;
csv += formatRows($rows.map(grabRow)) + '"';
// Data URI
var csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);
// For IE (tested 10+)
if (window.navigator.msSaveOrOpenBlob) {
var blob = new Blob([decodeURIComponent(encodeURI(csv))], {
type: "text/csv;charset=utf-8;"
});
navigator.msSaveBlob(blob, filename);
} else {
$(this)
.attr({
'download': filename
,'href': csvData
//,'target' : '_blank' //if you want it to open in a new window
});
}
//------------------------------------------------------------
// Helper Functions
//------------------------------------------------------------
// Format the output so it has the appropriate delimiters
function formatRows(rows){
return rows.get().join(tmpRowDelim)
.split(tmpRowDelim).join(rowDelim)
.split(tmpColDelim).join(colDelim);
}
// Grab and format a row from the table
function grabRow(i,row){
var $row = $(row);
//for some reason $cols = $row.find('td') || $row.find('th') won't work...
var $cols = $row.find('td');
if(!$cols.length) $cols = $row.find('th');
return $cols.map(grabCol)
.get().join(tmpColDelim);
}
// Grab and format a column from the table
function grabCol(j,col){
var $col = $(col),
$text = $col.text();
return $text.replace('"', '""'); // escape double quotes
}
}
// This must be a hyperlink
$("#export").click(function (event) {
// var outputFile = 'export'
var outputFile = window.prompt("What do you want to name your output file (Note: This won't have any effect on Safari)") || 'export';
outputFile = outputFile.replace('.csv','') + '.csv'
// CSV
exportTableToCSV.apply(this, [$('#dvData > table'), outputFile]);
// IF CSV, don't do event.preventDefault() or return false
// We actually need this to be a typical hyperlink
});
});
</script>
</body>
</html>