hotfix/远程访问多媒体中心
赵鹏 7 years ago
commit 0fc00af133

@ -0,0 +1,158 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Gaapi extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->permission->is_admin();
$this->site_code = $this->config->item('site_code');
//ga verder
$this->load->library('MY_Composer');
}
public function user_track()
{
$cid = $this->input->get_post('cid');
$analytics = $this->initializeAnalytics();
$response = $this->getReport($analytics, $cid);
$this->printResults($response);
}
/**
* Initializes an Analytics Reporting API V4 service object.
*
* @return An authorized Analytics Reporting API V4 service object.
*/
function initializeAnalytics()
{
// Use the developers console and download your service account
// credentials in JSON format. Place them in this directory or
// change the key file location if necessary.
$KEY_FILE_LOCATION = __DIR__ . '/gaapi_json/sylvan-box-234910-357cb59e6bf0.json';
// Create and configure a new client object.
$client = new Google_Client();
$client->setApplicationName("User Tracker");
$client->setAuthConfig($KEY_FILE_LOCATION);
$client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']);
$analytics = new Google_Service_AnalyticsReporting($client);
return $analytics;
}
/**
* Queries the Analytics Reporting API V4.
*
* @param service An authorized Analytics Reporting API V4 service object.
* @return The Analytics Reporting API V4 response.
*/
function getReport($analytics, $cid_no)
{
//die($cid);
// Replace with your view ID, for example XXXX.
$VIEW_ID = "68484932";
// Create the DateRange object.
$dateRange = new Google_Service_AnalyticsReporting_DateRange();
$dateRange->setStartDate("30daysAgo");
$dateRange->setEndDate("today");
// Create the Metrics object.
$pv = new Google_Service_AnalyticsReporting_Metric();
$pv->setExpression("ga:pageviews");
$pv->setAlias("pageviews");
//Create the dimensions
$pageUrl = new Google_Service_AnalyticsReporting_Dimension();
$pageUrl->setName("ga:pagePath");
$cid = new Google_Service_AnalyticsReporting_Dimension();
$cid->setName("ga:dimension1");
$hitTime = new Google_Service_AnalyticsReporting_Dimension();
$hitTime->setName("ga:dimension3");
$ip = new Google_Service_AnalyticsReporting_Dimension();
$ip->setName("ga:dimension3");
// Create Dimension Filter 1
$cidFilter = new Google_Service_AnalyticsReporting_DimensionFilter();
$cidFilter->setDimensionName("ga:dimension1");
$cidFilter->setOperator('EXACT');
$cidFilter->setExpressions($cid_no);
// Create the DimensionFilterClauses
$dimensionFilterClause = new Google_Service_AnalyticsReporting_DimensionFilterClause();
$dimensionFilterClause->setFilters(array($cidFilter));
// OrderBy maybe some bugs
$order = new Google_Service_AnalyticsReporting_OrderBy;
$order->setFieldName("ga:dimension3");
$order->setOrderType("VALUE");
$order->setSortOrder("DESCENDING");
// Create the ReportRequest object.
$request = new Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId($VIEW_ID);
$request->setDateRanges($dateRange);
$request->setMetrics(array($pv));
$request->setDimensions(array($pageUrl, $cid, $hitTime));
$request->setDimensionFilterClauses(array($dimensionFilterClause));
$request->setOrderBys(array($order));
$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests(array($request));
return $analytics->reports->batchGet($body);
}
/**
* Parses and prints the Analytics Reporting API V4 response.
*
* @param An Analytics Reporting API V4 response.
*/
function printResults($reports)
{
$alais_array = array(
"ga:dimension1" => "cid",
"ga:dimension3" => "hitTime",
"ga:pagePath" => "path"
);
$rs_array = array();
for ($reportIndex = 0; $reportIndex < count($reports); $reportIndex++) {
$report = $reports[$reportIndex];
$header = $report->getColumnHeader();
$dimensionHeaders = $header->getDimensions();
$metricHeaders = $header->getMetricHeader()->getMetricHeaderEntries();
$rows = $report->getData()->getRows();
$rs_row = array();
for ($rowIndex = 0; $rowIndex < count($rows); $rowIndex++) {
$row = $rows[$rowIndex];
$dimensions = $row->getDimensions();
$metrics = $row->getMetrics();
for ($i = 0; $i < count($dimensionHeaders) && $i < count($dimensions); $i++) {
//print($dimensionHeaders[$i] . ": " . $dimensions[$i] . "\n");
$rs_row[$alais_array[$dimensionHeaders[$i]]] = $dimensions[$i];
}
for ($j = 0; $j < count($metrics); $j++) {
$values = $metrics[$j]->getValues();
for ($k = 0; $k < count($values); $k++) {
$entry = $metricHeaders[$k];
//print($entry->getName() . ": " . $values[$k] . "\n");
$rs_row[$entry->getName()] = $values[$k];
}
}
array_push($rs_array, $rs_row);
}
}
echo(json_encode($rs_array));
}
}
//end of gaapi

@ -0,0 +1,12 @@
{
"type": "service_account",
"project_id": "sylvan-box-234910",
"private_key_id": "357cb59e6bf066231fe9d421a1cada76b6af29ef",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDSNl/aj3hQf6bf\naPBHuGTLemiUl2OborE8MNvl5brhJMncTSslS1Q5CQRPk4K6nW1gAq2/gQ5KZ7Sd\nh9gdtWzIDoUS1DBDaZiPB8vVN6YOjIWpRSylIXTewQ6YYuw9kt7vW0orfDSsaWrE\nc2Yb5YN+6GTxVBjFEb19IYg5/8zfmvaUCOinDwO+F8mh6fCS9FyhiN5omKD+ixiQ\nYFIo1CM1SCpT3eH67JIF+hzuGAVWhF7YmdNTBdfrM0/1PBM8HRry0jD1VaDeyv+e\n4lTnPCtvUgc5SJOaLv/UR06X1FpIYikK0RHJ04fTslQxu7hTLqbhg/7d/+aj95K0\nAwaGERvdAgMBAAECggEAAOQZHFdoDVxwlSJEqeNyIDZh+GIfmnYQAUFhMKkOsPCc\nw9rtTxrNRxace0fd2sXtVkF8pp5dWTasmmIMPGNt+dLR7pP/z4Of2o9ZQcJR1vCp\nZc195rz/EL+AmGgLgZXg/5lxGhyDKhJ9vpORNt/FPiFALyOueJ/wslEnkZfwDANv\n0C+uIv2L3g0mrgTqXVwU/dVdYi9UK7hhn0YMgtlbdpxRHV0cIiilb23Cyy0QsFXN\n2MsoHPQWf+72nE+5jNnysXcR8AjAthzOvP/jIcqqBguid1w9F3goH4adLTa1aPIL\ndNGI/z9mwuqGQg5C78ZfmZMb3YIRwV4nmUia7kzrowKBgQDr2h14VyEGAypCjo+r\nXRvDti55PY+jKUnUzbseJca7Z1Z2snvGXWgkoasZc8ozsQjoH7wJJnRoJOGnAJdF\ntyZxtJV5W0pefB6Pfqy6k5MlJJhMy6lGpkQo96iPOBqfowHa1r/S55USHjQAMXG2\nKrX6oq1IWmEmFYMFZnQo7+SPqwKBgQDkK4rnCbirwHC0Z6eXkbk0Fb8KrS0huq3C\nupaoBtwkfkyISBzcXx6Bup/Gg7czSxvY6U/Bg93WtTzzJwVuqKSqcTUrwW4rAmrh\nZNEYjJc5YLKK1xXVOEeisMIsWCEpF8JHvyrCRsoBCOVRbQROFqz9IOSGrplw1Rq6\ntuPp2fsalwKBgQDgbfabG/X9vadKHFSUUY5pBwRkNHNpZJGwIXEMeBALJoN9gcwM\nb7f5G6owFyHzXGRIVmJdJq2gqG/dtc889NJtYtTV3UwAawW9sGH3TRS5RIB0m1xi\nMTcs8LYCSvXysG/EaZOxwtL0oa8D/AjjuvLeJEzWS8KkNdYunlas2dJZ7wKBgEAO\nlWV9jjHxyfJr81oTGDquLD80FSqV/ThhJ/CuVFmOd6//BtM7hRYIrdiOm/0zhfLk\ntXZvrfUcVqsw9k513BzZwYKyQFqkyBrVMfrBZac/JYDjF4cP0NS06R6H829U8z8v\nRTLbqtSVicPNZlsB9Ljv5hiFpiBOQ73NoLjDcMKrAoGAC+mrH9aOBeQuikQllpWJ\naZ7XoDdZcmh3j+o7OZWHAP3mpQ6q6/1iPW4lhG/q6l+syjsYRmQuzYICtSJ6xQlC\nM+AYPjD+O6sW3MWGz469cqrym8o+Bm24emxJNvilo/U/N2Yif2gUGWgw8qXLEGsu\nUedwiH6aWGBFnlVuPz6CZ6s=\n-----END PRIVATE KEY-----\n",
"client_email": "gaapi-904@sylvan-box-234910.iam.gserviceaccount.com",
"client_id": "112785767675412711830",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gaapi-904%40sylvan-box-234910.iam.gserviceaccount.com"
}

@ -0,0 +1,15 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* ??MY_Composer
*
* @author lmr
*/
class MY_Composer
{
function __construct()
{
include("C:/VHD/icht-ga/vendor/autoload.php");
}
}

@ -16,6 +16,15 @@
<div class="container-fluid">
<div class="row">
<div class="preview_box" id="iframe_box"></div>
<div>
<h4>多媒体中心图片</h4>
<div class="input-group">
<input type="text" class="form-control" placeholder="请选择图片后复制地址到相应位置" id='selectedImageUrl'>
<span class="input-group-btn">
<button class="btn btn-default" type="button" id='mediaButton'>选择</button>
</span>
</div>
</div>
<div class="code_editor" id="editor"></div>
</div>
@ -94,6 +103,27 @@
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
function openKCFinder_Root() {
var site_url = 'https://www.chinahighlights.com';
var weburl = encodeURI(site_url + '<?php echo $information->ic_url ?>');
window.CallBack = openKCFinder_Root_callback;
window.open('/media/popselectpicture.php?site_code=cht&site_lgc=1&WebUrl=' + weburl, 'kcfinder_textbox', 'status=0, toolbar=0, location=0, menubar=0, directories=0,resizable=1, scrollbars=0, width=800, height=600');
}
function openKCFinder_Root_callback(result) {
var site_image_url = '<?php echo $this->config->item('media_image_url') ?>';
if (result != null && result.Pinfo[0]) {
console.info(result.Pinfo[0]);
$("#selectedImageUrl").val(site_image_url + result.Pinfo[0].PUrl);
}
}
$(function() {
$('#mediaButton').click(function() {
openKCFinder_Root();
});
});
var editor = ace.edit("editor");
editor.setTheme("ace/theme/eclipse");
editor.session.setMode("ace/mode/html");

@ -4,7 +4,6 @@
function batch_update_cache(url, index) {
var msg_obj="#cache" + index;
$(msg_obj).html("\u7a0d\u7b49...");
$.ajax({
type: "post",
dataType: "json",
@ -32,7 +31,8 @@ function batch_update_cache(url, index) {
function create_cache_data(index){
if ($('#cache_url' + index).length > 0) {
if ($('#cache' + index).html() != '\u66f4\u65b0\u9759\u6001\u9875\u9762\u6210\u529f\uff01') {
batch_update_cache($('#cache_url' + index).html(),index);
url=$('#cache_url' + index).html();
setTimeout("batch_update_cache('"+url+"',"+index+")",5000);
}
}
}

@ -67,7 +67,7 @@
if ($('#cache' + index).html() == '手动管理,不会自动更新') { //手动更新的项目跳过
create_amp_data(++index);
} else {
batch_update_amp(index);
setTimeout("batch_update_amp("+index+")",5000);
}
}
}

@ -97,6 +97,7 @@ function is_remote_ip()
|| stripos($ip_list,'221.7.151.37')!==false
|| stripos($ip_list,'221.7.151.41')!==false
|| stripos($ip_list,'111.59.90.31')!==false
|| stripos($ip_list,'180.140.114.225')!==false
|| stripos($ip_list,'180.140.114.208')!==false
|| stripos($ip_list,'::1')!==false //这个也是本地IP
){

@ -1,13 +0,0 @@
fs.js:115
throw err;
^
Error: EPERM: operation not permitted, lstat 'C:\Users\lmr'
at Object.realpathSync (fs.js:1457:7)
at toRealPath (internal/modules/cjs/loader.js:202:13)
at Function.Module._findPath (internal/modules/cjs/loader.js:268:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:578:25)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Loading…
Cancel
Save