diff --git a/.gitignore b/.gitignore
index 86ed2afd..3d3a8844 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,10 @@
.buildpath
.project
.settings
+.env
.gitignore.swp
*.sublime-workspace
*.sublime-project
plugins/*
themes/odbox*
+tmp/*
diff --git a/INSTALLATION b/INSTALLATION
index b214a16d..90cbef0e 100644
--- a/INSTALLATION
+++ b/INSTALLATION
@@ -6,7 +6,7 @@ Seo Control Panel - Seo Panel
Installation: Simple 5 minute installation
------------------------------------------
- Simply use Softaculous / Installatron / Webuzo / AMPPS to install SEO Panel or Follow the below steps
+ Simply use Softaculous / Installatron / Webuzo / AMPPS / Bitnami to install SEO Panel or Follow the below steps
1. Download and Unzip the package
@@ -23,7 +23,7 @@ Installation: Simple 5 minute installation
7. Change the permissions on "config/sp-config.php" to be writable only by yourself (644 or -rw-r--r-- within your FTP Client)
- 8. Please use following login details to access Admin Interface.
+ 8. Please use the following login details to access Admin Interface.
Admin Section:
@@ -35,11 +35,27 @@ Installation: Simple 5 minute installation
Add moz api key using the link shown in the page
Note:
- a) Please change password of administrator by visiting 'Profile' link on right top of the seo panel to prevent from security threats.
+ a) Please change the password of administrator by visiting Profile link on right top of the seo panel to prevent from security threats.
b) Remove "install" directory of seo panel
+------------------------------------------
+Docker Installation
+------------------------------------------
+
+ 1. Copy sample_env file to .env file and edit required details in it
+
+ cp sample_env .env
+
+ 2. Execute following command to start docker containers
+
+ docker compose up
+
+ 3. Take following link in browser and follow the installation instructions
+
+ http://localhost/
+
--------------------------------------------
Steps to Upgrade Seo Panel to Latest Version
@@ -100,7 +116,7 @@ Steps to Upgrade Seo Panel to Latest Version
b. Copy all plugins from "plugins" folder of old seo panel folder to "plugins" folder of new Seo Panel.
-Installation Reference Link: http://www.seopanel.in/install/
+Installation Reference Link: https://www.seopanel.org/install/
If you have any issues while installation, Please use following resources to fix it or contact seo panel team.
@@ -112,9 +128,9 @@ a) Seo Panel Help Guide: http://help.seopanel.in/
b) Seo Panel Forum: http://forum.seopanel.in/
-b) Seo Panel Support: http://www.seopanel.in/support/
+b) Seo Panel Support: https://www.seopanel.org/support/
-d) Seo Panel Contact: http://www.seopanel.in/contact/
+d) Seo Panel Contact: https://www.seopanel.org/contact/
-------------------------------------------
Developed By Geo Varghese (www.seopanel.in)
diff --git a/README b/README
index af1d7fac..d27bd316 100644
--- a/README
+++ b/README
@@ -140,7 +140,7 @@ b) Keyword Position Checker
c) Site Auditor
-d) Google and Alexa Rank Checker
+d) Moz Rank Checker
e) Backlinks Checker
diff --git a/README.md b/README.md
index 32506142..35c35cc5 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ Simply use Softaculous / Installatron / Webuzo / AMPPS to install SEO Panel or F
7. Change the permissions on config/sp-config.php to be writable only by yourself (644 or -rw-r--r-- within your FTP Client)
-8. Please use following login details to access Admin Interface.
+8. Please use the following login details to access Admin Interface.
#### Admin Section:
@@ -45,11 +45,28 @@ Password: spadmin
#### Note:
-a. Please change password of administrator by visiting Profile link on right top of the seo panel to prevent from security threats.
+a. Please change the password of administrator by visiting Profile link on right top of the seo panel to prevent from security threats.
b. Remove install directory of seo panel
+## Docker Installation
+
+Follow below steps to install seo panel as docker container.
+
+- Copy sample_env file to .env file and edit required details in it
+
+ `cp sample_env .env`
+
+- Execute following command to start docker containers
+
+ `docker compose up`
+
+- Take following link in browser and follow the installation instructions
+
+ http://localhost/
+
+
## Online Seo Panel Resources:
@@ -57,9 +74,9 @@ a) Seo Panel Help Guide: http://docs.seopanel.in/
b) Seo Panel Forum: http://forum.seopanel.in/
-b) Seo Panel Support: http://www.seopanel.in/support/
+b) Seo Panel Support: https://www.seopanel.org/support/
-e) Seo Panel Contact: http://www.seopanel.in/contact/
+e) Seo Panel Contact: https://www.seopanel.org/contact/
## The major features of Seo Panel:
@@ -70,7 +87,7 @@ b) Keyword Position Checker
c) Site Auditor
-d) Google and Alexa Rank Checker
+d) Moz Rank Checker
e) Backlinks Checker
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 00000000..f5d91d90
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,5 @@
+# Security Policy
+
+## Reporting a Vulnerability
+
+Please report security issues to support@seopanel.in
diff --git a/api/website.api.php b/api/website.api.php
index 5508d439..c2b37d2e 100644
--- a/api/website.api.php
+++ b/api/website.api.php
@@ -81,10 +81,7 @@ function getFormattedReport($websiteInfo, $fromTime, $toTime) {
// rank reports
$report = $rankCtrler->__getWebsiteRankReport($websiteInfo['id'], $fromTime, $toTime);
$report = $report[0];
- $toTimeDate = date('Y-m-d', $toTime);
- $websiteInfo['alexa']['alexarank']['rank'] = empty($report['alexa_rank']) ? "-" : $report['alexa_rank'];
- $websiteInfo['alexa']['alexarank']['diff'] = removeBraces($report['rank_diff_alexa']);
- $websiteInfo['alexa']['alexarank']['date'] = $toTimeDate;
+ $toTimeDate = date('Y-m-d', $toTime);
$websiteInfo['moz']['pagerank']['rank'] = empty($report['moz_rank']) ? "-" : $report['moz_rank'];
$websiteInfo['moz']['pagerank']['diff'] = removeBraces($report['rank_diff_moz']);
$websiteInfo['noz']['pagerank']['date'] = $toTimeDate;
@@ -95,9 +92,6 @@ function getFormattedReport($websiteInfo, $fromTime, $toTime) {
$websiteInfo['google']['backlinks']['rank'] = empty($report['google']) ? "-" : $report['google'];
$websiteInfo['google']['backlinks']['diff'] = $report['rank_diff_google'];
$websiteInfo['google']['backlinks']['date'] = $toTimeDate;
- $websiteInfo['alexa']['backlinks']['rank'] = empty($report['alexa']) ? "-" : $report['alexa'];
- $websiteInfo['alexa']['backlinks']['diff'] = $report['rank_diff_alexa'];
- $websiteInfo['alexa']['backlinks']['date'] = $toTimeDate;
$websiteInfo['bing']['backlinks']['rank'] = empty($report['msn']) ? "-" : $report['msn'];
$websiteInfo['bing']['backlinks']['diff'] = $report['rank_diff_msn'];
$websiteInfo['bing']['backlinks']['date'] = $toTimeDate;
@@ -310,8 +304,6 @@ function updateWebsite($info) {
// if website exists
if ($websiteInfo = $this->ctrler->__getWebsiteInfo($websiteId)) {
- $websiteInfo['oldName'] = $websiteInfo['name'];
-
// loop through inputs
foreach ($info as $key => $val) {
$websiteInfo[$key] = $val;
diff --git a/config/sp-config-sample.php b/config/sp-config-sample.php
index 2c1cefff..c0831ecc 100644
--- a/config/sp-config-sample.php
+++ b/config/sp-config-sample.php
@@ -40,7 +40,7 @@
define('DB_ENGINE', 'mysql');
# The version of seo panel installed
-define('SP_INSTALLED', '4.10.0');
+define('SP_INSTALLED', '4.11.0');
# The DB debug mode
define('SP_DEBUG', 0);
diff --git a/controllers/analytics.ctrl.php b/controllers/analytics.ctrl.php
index 98656db1..121a4bb0 100644
--- a/controllers/analytics.ctrl.php
+++ b/controllers/analytics.ctrl.php
@@ -20,161 +20,217 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-// include google api module
-include_once(SP_CTRLPATH . "/googleapi.ctrl.php");
+include_once(SP_LIBPATH . "/analyticsdata/vendor/autoload.php");
+include_once(SP_CTRLPATH . "/user-token.ctrl.php");
+
+use Google\Auth\Credentials\UserRefreshCredentials;
+use Google\Analytics\Data\V1beta\BetaAnalyticsDataClient;
+use Google\Analytics\Data\V1beta\DateRange;
+use Google\Analytics\Data\V1beta\Metric;
+use Google\Analytics\Data\V1beta\Dimension;
// class defines all google analytics api controller functions
-class AnalyticsController extends GoogleAPIController {
+class AnalyticsController extends Controller {
var $spTextGA;
var $metrics;
var $metricList;
var $defaultMetricName = "users";
- var $dimensionName = "source";
+ var $dimensionName = "sourceMedium";
+ var $sourceTypeList = ['referral', 'direct', 'organic', 'cpc', 'social'];
+ var $socialNetworkList;
+ var $totalLabel = "total";
+ var $tokenCtrler;
+ var $sourceName = 'google';
function __construct() {
- parent::__construct();
- $this->spTextGA = $this->getLanguageTexts('analytics', $_SESSION['lang_code']);
- $this->set('spTextGA', $this->spTextGA);
- $this->metrics = array(
- 'users' => $this->spTextGA['Users'],
- 'newUsers' => $this->spTextGA['New Users'],
- 'sessions' => $this->spTextGA['Sessions'],
- 'bounceRate' => $this->spTextGA['Bounce Rate'],
- 'avgSessionDuration' => $this->spTextGA['Avg. Session Duration'],
- 'goalCompletionsAll' => $this->spTextGA['Goal Completions'],
- );
-
-
- $this->set('metricColList', $this->metrics);
- $this->metricList = array_keys($this->metrics);
+ parent::__construct();
+ $this->spTextGA = $this->getLanguageTexts('analytics', $_SESSION['lang_code']);
+ $this->set('spTextGA', $this->spTextGA);
+ $this->metrics = array(
+ 'users' => $this->spTextGA['Users'],
+ 'newUsers' => $this->spTextGA['New Users'],
+ 'sessions' => $this->spTextGA['Sessions'],
+ 'bounceRate' => $this->spTextGA['Bounce Rate'],
+ 'avgSessionDuration' => $this->spTextGA['Avg. Session Duration'],
+ 'goalCompletionsAll' => $this->spTextGA['Goal Completions'],
+ );
+
+ $this->dimensions = array(
+ 'sourceMedium' => "Source",
+ 'pagePath' => "Page",
+ 'country' => "Country",
+ /*'socialNetwork' => "Social Network",*/
+ 'deviceCategory' => "Device",
+ 'language' => "Language",
+ 'browser' => "Browser",
+ 'operatingSystem' => "Operating System",
+ );
+
+ $this->set('dimensions', $this->dimensions);
+ $this->set('metricColList', $this->metrics);
+ $this->metricList = array_keys($this->metrics);
+ }
+
+ /**
+ * function to get google analytics GA4 auth client
+ */
+ function getGoogleAnalyticsGA4AuthClient($userId) {
+ // get user token info
+ $tokenCtrler = new UserTokenController();
+ $tokenInfo = $tokenCtrler->getUserToken($userId, $this->sourceName);
+
+ // if token not set for the user
+ if (empty($tokenInfo['refresh_token'])) {
+ $spTextWebmaster = $this->getLanguageTexts('webmaster', $_SESSION['lang_code']);
+ $errorText = $spTextWebmaster["Error: Google api connection failed"] . ". ";
+ $errorText .= "{$spTextWebmaster['Click here to connect to your google account']}.";
+ $alertCtler = new AlertController();
+ $alertInfo = array(
+ 'alert_subject' => $spTextWebmaster['Click here to connect to your google account'],
+ 'alert_message' => $spTextWebmaster["Error: Google api connection failed"],
+ 'alert_url' => SP_WEBPATH ."/admin-panel.php?sec=connections",
+ 'alert_type' => "danger",
+ 'alert_category' => "reports",
+ );
+ $alertCtler->createAlert($alertInfo, $userId);
+ return $errorText;
+ }
+
+ try {
+ $credentials = new UserRefreshCredentials(['https://www.googleapis.com/auth/analytics.readonly'], [
+ 'client_id' => SP_GOOGLE_API_CLIENT_ID,
+ 'client_secret' => SP_GOOGLE_API_CLIENT_SECRET,
+ 'refresh_token' => $tokenInfo['refresh_token'],
+ ]);
+
+ // Initialize the client
+ $ga4Client = new BetaAnalyticsDataClient(['credentials' => $credentials]);
+ return $ga4Client;
+ } catch (Exception $e) {
+ $err = $e->getMessage();
+ return "Error: Google analytics GA4 client creation - $err";
+ }
}
/*
* function to get analytics query result
*/
- function getAnalyticsResults($userId, $VIEW_ID, $startDate, $endDate) {
- $result = array('status' => false);
-
- if (empty($VIEW_ID)) {
- $result['msg'] = $this->spTextGA['view_id_not_found_error'];
- $alertCtler = new AlertController();
- $alertInfo = array(
- 'alert_subject' => $this->spTextGA['view_id_not_found_error'],
- 'alert_message' => "",
- 'alert_url' => SP_WEBPATH ."/admin-panel.php",
- 'alert_type' => "danger",
- 'alert_category' => "reports",
- );
- $alertCtler->createAlert($alertInfo, $userId);
- return $result;
- }
-
- try {
-
- $client = $this->getAuthClient($userId);
-
- // check whether client created successfully
- if (!is_object($client)) {
- $result['msg'] = $client;
- return $result;
- }
-
- $analytics = new Google_Service_AnalyticsReporting($client);
-
- // Create the DateRange object.
- $dateRange = new Google_Service_AnalyticsReporting_DateRange();
- $dateRange->setStartDate($startDate);
- $dateRange->setEndDate($endDate);
-
- // Create the Metrics object list
- $metricObjList = [];
- foreach ($this->metricList as $metricName) {
- $sessions = new Google_Service_AnalyticsReporting_Metric();
- $sessions->setExpression("ga:$metricName");
- $sessions->setAlias($metricName);
- $metricObjList[] = $sessions;
- }
-
- // Create the dimension.
- $dimension = new Google_Service_AnalyticsReporting_Dimension();
- $dimension->setName("ga:$this->dimensionName");
-
- // Create the Ordering.
- $ordering = new Google_Service_AnalyticsReporting_OrderBy();
- $ordering->setFieldName("ga:$this->defaultMetricName");
- $ordering->setOrderType("VALUE");
- $ordering->setSortOrder("DESCENDING");
-
- // Create the ReportRequest object.
- $request = new Google_Service_AnalyticsReporting_ReportRequest();
- $request->setViewId($VIEW_ID);
- $request->setDateRanges($dateRange);
- $request->setMetrics($metricObjList);
- $request->setDimensions(array($dimension));
- $request->setOrderBys($ordering);
-
- $body = new Google_Service_AnalyticsReporting_GetReportsRequest();
- $body->setReportRequests( array( $request) );
- $res = $analytics->reports->batchGet( $body );
- $resultList = $this->formatResult($res);
-
- $result['status'] = true;
- $result['resultList'] = $resultList;
- } catch (Exception $e) {
- $err = $e->getMessage();
- $result['msg'] = "Error: search query analytics - $err";
- }
-
- return $result;
-
+ function getAnalyticsResults($userId, $propertyId, $startDate, $endDate, $dimensionName="sourceMedium") {
+ $result = array('status' => false);
+ if (empty($propertyId)) {
+ $result['msg'] = $this->spTextGA['view_id_not_found_error'];
+ $alertCtler = new AlertController();
+ $alertInfo = array(
+ 'alert_subject' => $this->spTextGA['view_id_not_found_error'],
+ 'alert_message' => "",
+ 'alert_url' => SP_WEBPATH ."/admin-panel.php",
+ 'alert_type' => "danger",
+ 'alert_category' => "reports",
+ );
+ $alertCtler->createAlert($alertInfo, $userId);
+ return $result;
+ }
+
+ try {
+ // create GA4 client
+ $client = $this->getGoogleAnalyticsGA4AuthClient($userId);
+ if (!is_object($client)) {
+ $result['msg'] = $client;
+ return $result;
+ }
+
+ // Define the date range for your query
+ $dateRange = new DateRange();
+ $dateRange->setStartDate($startDate);
+ $dateRange->setEndDate($endDate);
+
+ // create the dimension.
+ $dimensionName = !empty($dimensionName) ? $dimensionName : $this->dimensionName;
+ $dimension = [
+ new Dimension(['name' => self::getActualQueryDimensionName($dimensionName)]),
+ ];
+
+ $metricObjList = [];
+ foreach ($this->metricList as $metricName) {
+ $metricObjList[] = new Metric(['name' => self::getActualQueryMetricName($metricName)]);
+ }
+
+ // Make the request
+ $resultList = [];
+ $response = $client->runReport([
+ 'property' => 'properties/' . $propertyId,
+ 'dateRanges' => [$dateRange],
+ 'dimensions' => $dimension,
+ 'metrics' => $metricObjList,
+ ]);
+
+ // Extract and print the results
+ $rows = $response->getRows();
+ foreach ($rows as $row) {
+ $dimensionValues = $row->getDimensionValues();
+ $metricValues = $row->getMetricValues();
+
+ $dimensionVal = $dimensionValues[0]->getValue();
+ if (!empty($dimensionVal)) {
+ $metricData = [];
+ $i = 0;
+ foreach ($this->metricList as $metricName) {
+ $metricDataVal = $metricValues[$i]->getValue();
+ $metricData[$metricName] = self::formatMetricValue($metricDataVal, $metricName);
+ $i++;
+ }
+
+ $resultList[$dimensionVal] = $metricData;
+ }
+ }
+
+ $result['status'] = true;
+ $result['resultList'] = $resultList;
+ } catch (Exception $e) {
+ $err = $e->getMessage();
+ $result['msg'] = "Error: search query analytics - $err";
+ }
+
+ return $result;
}
- function formatMetricValue($value, $metricName) {
-
- if ($metricName == "bounceRate") {
- $value = round($value, 2);
- }
-
- if ($metricName == "avgSessionDuration") {
- $value = round(($value/60), 2);
- }
-
- return $value;
+ public static function getActualQueryMetricName($metricName) {
+ $queryMetricName = $metricName;
+ if ($metricName == "users") {
+ $queryMetricName = "activeUsers";
+ }
+
+ if ($metricName == "avgSessionDuration") {
+ $queryMetricName = "averageSessionDuration";
+ }
+
+ if ($metricName == "goalCompletionsAll") {
+ $queryMetricName = "conversions";
+ }
+
+ return $queryMetricName;
}
- function formatResult($reports) {
- $resultList = array();
-
- // loop through the reports
- for ( $reportIndex = 0; $reportIndex < count( $reports ); $reportIndex++ ) {
- $report = $reports[ $reportIndex ];
-
- // get total value
- $totals = $report->getData()->getTotals();
- $values = $totals[0]->getValues();
- $resultList['total'] = [];
- foreach ($this->metricList as $i => $metricName) {
- $resultList['total'][$metricName] = $this->formatMetricValue($values[$i], $metricName);
- }
-
- // get dimension type value
- $rows = $report->getData()->getRows();
- for ( $rowIndex = 0; $rowIndex < count($rows); $rowIndex++) {
- $row = $rows[$rowIndex];
- $dimensions = $row->getDimensions();
- $metrics = $row->getMetrics();
- $values = $metrics[0]->getValues();
-
- // find metric values
- $resultList[$dimensions[0]] = [];
- foreach ($this->metricList as $i => $metricName) {
- $resultList[$dimensions[0]][$metricName] = $this->formatMetricValue($values[$i], $metricName);
- }
- }
- }
-
- return $resultList;
+ public static function getActualQueryDimensionName($dimensionName) {
+ $queryDimensionName = $dimensionName;
+ if ($dimensionName == "sourceMedium") {
+ $queryDimensionName = "sessionSourceMedium";
+ }
+
+ return $queryDimensionName;
+ }
+
+ public static function formatMetricValue($value, $metricName) {
+ if (in_array($metricName, ["bounceRate", "goalCompletionsAll"])) {
+ $value = round($value, 2);
+ }
+
+ if ($metricName == "avgSessionDuration") {
+ $value = round(($value/60), 2);
+ }
+
+ return $value;
}
function getAnalyticsSourceList() {
@@ -264,8 +320,8 @@ function viewQuickChecker($searchInfo='') {
}
// func to do quick report
- function doQuickChecker($searchInfo = '') {
-
+ function doQuickChecker($searchInfo=[]) {
+
if (!empty($searchInfo['website_id'])) {
$websiteId = intval($searchInfo['website_id']);
$websiteController = New WebsiteController();
@@ -278,7 +334,7 @@ function doQuickChecker($searchInfo = '') {
// query results from api and verify no error occured
$result = $this->getAnalyticsResults($websiteInfo['user_id'], $websiteInfo['analytics_view_id'], $reportStartDate, $reportEndDate);
-
+
// if status is success
if ($result['status']) {
$websiteReport = array_shift($result['resultList']);
@@ -289,7 +345,6 @@ function doQuickChecker($searchInfo = '') {
$this->set('searchInfo', $searchInfo);
$this->render('analytics/quick_checker_results');
return true;
-
}
}
}
diff --git a/controllers/analytics_old.ctrl.php b/controllers/analytics_old.ctrl.php
new file mode 100644
index 00000000..be112639
--- /dev/null
+++ b/controllers/analytics_old.ctrl.php
@@ -0,0 +1,667 @@
+spTextGA = $this->getLanguageTexts('analytics', $_SESSION['lang_code']);
+ $this->set('spTextGA', $this->spTextGA);
+ $this->metrics = array(
+ 'users' => $this->spTextGA['Users'],
+ 'newUsers' => $this->spTextGA['New Users'],
+ 'sessions' => $this->spTextGA['Sessions'],
+ 'bounceRate' => $this->spTextGA['Bounce Rate'],
+ 'avgSessionDuration' => $this->spTextGA['Avg. Session Duration'],
+ 'goalCompletionsAll' => $this->spTextGA['Goal Completions'],
+ );
+
+
+ $this->set('metricColList', $this->metrics);
+ $this->metricList = array_keys($this->metrics);
+ }
+
+ /*
+ * function to get analytics query result
+ */
+ function getAnalyticsResults($userId, $VIEW_ID, $startDate, $endDate) {
+ $result = array('status' => false);
+
+ if (empty($VIEW_ID)) {
+ $result['msg'] = $this->spTextGA['view_id_not_found_error'];
+ $alertCtler = new AlertController();
+ $alertInfo = array(
+ 'alert_subject' => $this->spTextGA['view_id_not_found_error'],
+ 'alert_message' => "",
+ 'alert_url' => SP_WEBPATH ."/admin-panel.php",
+ 'alert_type' => "danger",
+ 'alert_category' => "reports",
+ );
+ $alertCtler->createAlert($alertInfo, $userId);
+ return $result;
+ }
+
+ try {
+
+ $client = $this->getAuthClient($userId);
+
+ // check whether client created successfully
+ if (!is_object($client)) {
+ $result['msg'] = $client;
+ return $result;
+ }
+
+ $analytics = new Google_Service_AnalyticsReporting($client);
+
+ // Create the DateRange object.
+ $dateRange = new Google_Service_AnalyticsReporting_DateRange();
+ $dateRange->setStartDate($startDate);
+ $dateRange->setEndDate($endDate);
+
+ // Create the Metrics object list
+ $metricObjList = [];
+ foreach ($this->metricList as $metricName) {
+ $sessions = new Google_Service_AnalyticsReporting_Metric();
+ $sessions->setExpression("ga:$metricName");
+ $sessions->setAlias($metricName);
+ $metricObjList[] = $sessions;
+ }
+
+ // Create the dimension.
+ $dimension = new Google_Service_AnalyticsReporting_Dimension();
+ $dimension->setName("ga:$this->dimensionName");
+
+ // Create the Ordering.
+ $ordering = new Google_Service_AnalyticsReporting_OrderBy();
+ $ordering->setFieldName("ga:$this->defaultMetricName");
+ $ordering->setOrderType("VALUE");
+ $ordering->setSortOrder("DESCENDING");
+
+ // Create the ReportRequest object.
+ $request = new Google_Service_AnalyticsReporting_ReportRequest();
+ $request->setViewId($VIEW_ID);
+ $request->setDateRanges($dateRange);
+ $request->setMetrics($metricObjList);
+ $request->setDimensions(array($dimension));
+ $request->setOrderBys($ordering);
+
+ $body = new Google_Service_AnalyticsReporting_GetReportsRequest();
+ $body->setReportRequests( array( $request) );
+ $res = $analytics->reports->batchGet( $body );
+ $resultList = $this->formatResult($res);
+
+ $result['status'] = true;
+ $result['resultList'] = $resultList;
+ } catch (Exception $e) {
+ $err = $e->getMessage();
+ $result['msg'] = "Error: search query analytics - $err";
+ }
+
+ return $result;
+
+ }
+
+ function formatMetricValue($value, $metricName) {
+
+ if ($metricName == "bounceRate") {
+ $value = round($value, 2);
+ }
+
+ if ($metricName == "avgSessionDuration") {
+ $value = round(($value/60), 2);
+ }
+
+ return $value;
+ }
+
+ function formatResult($reports) {
+ $resultList = array();
+
+ // loop through the reports
+ for ( $reportIndex = 0; $reportIndex < count( $reports ); $reportIndex++ ) {
+ $report = $reports[ $reportIndex ];
+
+ // get total value
+ $totals = $report->getData()->getTotals();
+ $values = $totals[0]->getValues();
+ $resultList['total'] = [];
+ foreach ($this->metricList as $i => $metricName) {
+ $resultList['total'][$metricName] = $this->formatMetricValue($values[$i], $metricName);
+ }
+
+ // get dimension type value
+ $rows = $report->getData()->getRows();
+ for ( $rowIndex = 0; $rowIndex < count($rows); $rowIndex++) {
+ $row = $rows[$rowIndex];
+ $dimensions = $row->getDimensions();
+ $metrics = $row->getMetrics();
+ $values = $metrics[0]->getValues();
+
+ // find metric values
+ $resultList[$dimensions[0]] = [];
+ foreach ($this->metricList as $i => $metricName) {
+ $resultList[$dimensions[0]][$metricName] = $this->formatMetricValue($values[$i], $metricName);
+ }
+ }
+ }
+
+ return $resultList;
+ }
+
+ function getAnalyticsSourceList() {
+ $sourceList = [];
+ $list = $this->dbHelper->getAllRows("analytic_sources");
+ foreach ($list as $listInfo) {
+ $sourceList[$listInfo['source_name']] = $listInfo['id'];
+ }
+
+ return $sourceList;
+ }
+
+ function generateSource($sourceName) {
+ $sourceId = false;
+ if ($this->dbHelper->insertRow("analytic_sources", array("source_name" => $sourceName))) {
+ $sourceId = $this->db->getMaxId("analytic_sources");
+ }
+
+ return $sourceId;
+ }
+
+ /*
+ * function to store website results
+ */
+ function storeWebsiteAnalytics($websiteId, $reportDate) {
+ $websiteId = intval($websiteId);
+ $websiteCtrler = new WebsiteController();
+ $websiteInfo = $websiteCtrler->__getWebsiteInfo($websiteId);
+
+ // query results from api and verify no error occured
+ $result = $this->getAnalyticsResults($websiteInfo['user_id'], $websiteInfo['analytics_view_id'], $reportDate, $reportDate);
+ if ($result['status']) {
+ $sourceList = $this->getAnalyticsSourceList();
+
+ // loop through the result list
+ foreach ($result['resultList'] as $sourceName => $reportInfo) {
+
+ // generate source list, if not set it yet
+ if (!isset($sourceList[$sourceName])) {
+ $sourceId = $this->generateSource($sourceName);
+ } else {
+ $sourceId = $sourceList[$sourceName];
+ }
+
+ if (!empty($sourceId)) {
+ $this->insertWebsiteAnalytics($websiteId, $sourceId, $reportInfo, $reportDate);
+ } else {
+ $result['msg'] .= "Error: Analytics source id not found";
+ }
+ }
+ }
+
+ return $result;
+
+ }
+
+ /*
+ * function to insert website analytics
+ */
+ function insertWebsiteAnalytics($websiteId, $sourceId, $reportInfo, $resultDate, $clearExisting = true) {
+ $websiteId = intval($websiteId);
+ $sourceId = intval($sourceId);
+ $resultDate = addslashes($resultDate);
+
+ if ($clearExisting) {
+ $whereCond = "website_id=$websiteId and report_date='$resultDate' and source_id='$sourceId'";
+ $this->dbHelper->deleteRows('website_analytics', $whereCond);
+ }
+
+ $reportInfo['website_id'] = $websiteId;
+ $reportInfo['source_id'] = $sourceId;
+ $reportInfo['report_date'] = $resultDate;
+ $this->dbHelper->insertRow('website_analytics', $reportInfo);
+ }
+
+ // func to show quick checker
+ function viewQuickChecker($searchInfo='') {
+ $userId = isLoggedIn();
+ $websiteController = New WebsiteController();
+ $websiteList = $websiteController->__getAllWebsites($userId, true);
+ $this->set('websiteList', $websiteList);
+ $websiteId = empty ($searchInfo['website_id']) ? $websiteList[0]['id'] : intval($searchInfo['website_id']);
+ $this->set('websiteId', $websiteId);
+ $this->set('fromTime', date('Y-m-d', strtotime('-1 days')));
+ $this->set('toTime', date('Y-m-d'));
+ $this->render('analytics/quick_checker');
+ }
+
+ // func to do quick report
+ function doQuickChecker($searchInfo = '') {
+
+ if (!empty($searchInfo['website_id'])) {
+ $websiteId = intval($searchInfo['website_id']);
+ $websiteController = New WebsiteController();
+ $websiteInfo = $websiteController->__getWebsiteInfo($websiteId);
+ $this->set('websiteInfo', $websiteInfo);
+
+ if (!empty($websiteInfo['url'])) {
+ $reportStartDate = !empty($searchInfo['from_time']) ? $searchInfo['from_time'] : date('Y-m-d', strtotime('-1 days'));
+ $reportEndDate = !empty($searchInfo['to_time']) ? $searchInfo['to_time'] : date('Y-m-d');
+
+ // query results from api and verify no error occured
+ $result = $this->getAnalyticsResults($websiteInfo['user_id'], $websiteInfo['analytics_view_id'], $reportStartDate, $reportEndDate);
+
+ // if status is success
+ if ($result['status']) {
+ $websiteReport = array_shift($result['resultList']);
+ $sourceReport = $result['resultList'];
+ $this->set('websiteReport', $websiteReport);
+ $this->set('sourceReport', $sourceReport);
+
+ $this->set('searchInfo', $searchInfo);
+ $this->render('analytics/quick_checker_results');
+ return true;
+
+ }
+ }
+ }
+
+ $errorMsg = !empty($result['msg']) ? $result['msg'] : "Internal error occured while accessing webmaster tools.";
+ showErrorMsg($errorMsg);
+ }
+
+ // function check whether analytics reports already saved
+ function isReportsExists($websiteId, $resultDate) {
+ $websiteId = intval($websiteId);
+ $resultDate = addslashes($resultDate);
+ $whereCond = "website_id=$websiteId and report_date='$resultDate'";
+ $info = $this->dbHelper->getRow("website_analytics", $whereCond, "website_id");
+ return !empty($info['website_id']) ? true : false;
+ }
+
+ # func to show analytics report summary
+ function viewAnalyticsSummary($searchInfo = '', $summaryPage = false, $cronUserId=false) {
+
+ $userId = !empty($cronUserId) ? $cronUserId : isLoggedIn();
+ $this->set('summaryPage', $summaryPage);
+ $this->set('searchInfo', $searchInfo);
+ $this->set('cronUserId', $cronUserId);
+
+ $exportVersion = false;
+ switch($searchInfo['doc_type']){
+
+ case "export":
+ $exportVersion = true;
+ $exportContent = "";
+ break;
+
+ case "pdf":
+ $this->set('pdfVersion', true);
+ break;
+
+ case "print":
+ $this->set('printVersion', true);
+ break;
+ }
+
+ $fromTime = !empty($searchInfo['from_time']) ? addslashes($searchInfo['from_time']) : date('Y-m-d', strtotime('-2 days'));
+ $toTime = !empty($searchInfo['to_time']) ? addslashes($searchInfo['to_time']) : date('Y-m-d', strtotime('-1 days'));
+ $this->set('fromTime', $fromTime);
+ $this->set('toTime', $toTime);
+
+ $websiteController = New WebsiteController();
+ $wList = $websiteController->__getAllWebsites($userId, true);
+ $websiteList = [];
+ foreach ($wList as $wInfo) {
+ $websiteList[$wInfo['id']] = $wInfo;
+ }
+
+ $websiteList = count($websiteList) ? $websiteList : array(0);
+ $this->set('websiteList', $websiteList);
+ $websiteId = intval($searchInfo['website_id']);
+ $this->set('websiteId', $websiteId);
+
+ // to find order col
+ if (!empty($searchInfo['order_col'])) {
+ $orderCol = $searchInfo['order_col'];
+ $orderVal = getOrderByVal($searchInfo['order_val']);
+ } else {
+ $orderCol = "users";
+ $orderVal = 'DESC';
+ }
+
+ $this->set('orderCol', $orderCol);
+ $this->set('orderVal', $orderVal);
+ $scriptName = $summaryPage ? "archive.php" : "analytics.php";
+ $scriptPath = SP_WEBPATH . "/$scriptName?sec=viewAnalyticsSummary&website_id=$websiteId";
+ $scriptPath .= "&from_time=$fromTime&to_time=$toTime&search_name=" . $searchInfo['search_name'];
+ $scriptPath .= "&order_col=$orderCol&order_val=$orderVal&report_type=analytics-reports";
+
+ $conditions = !empty($searchInfo['search_name']) ? " and k.source_name like '%".addslashes($searchInfo['search_name'])."%'" : "";
+
+ // set website id to get exact keywords of a user
+ if (!empty($websiteId)) {
+ $conditions .= " and r.website_id=$websiteId";
+ } else {
+ $conditions .= " and r.website_id in (".implode(',', array_keys($websiteList)).")";
+ }
+
+ $analyticsCols = implode(",", array_keys($this->metrics));
+ $sql = "select k.id,k.source_name,r.website_id,$analyticsCols
+ from analytic_sources k, website_analytics r
+ where k.id=r.source_id $conditions and r.report_date='$toTime'
+ order by " . addslashes($orderCol) . " " . addslashes($orderVal);
+
+ if ($orderCol != 'users') $sql .= ", users";
+
+ // pagination setup, if not from cron job email send function, pdf and export action
+ if (!in_array($searchInfo['doc_type'], array("pdf", "export"))) {
+ $this->db->query($sql, true);
+ $this->paging->setDivClass('pagingdiv');
+ $this->paging->loadPaging($this->db->noRows, SP_PAGINGNO);
+ $pagingDiv = $this->paging->printPages($scriptPath, '', 'scriptDoLoad', 'content', "");
+ $this->set('pagingDiv', $pagingDiv);
+ $this->set('pageNo', $searchInfo['pageno']);
+ $sql .= " limit ".$this->paging->start .",". $this->paging->per_page;
+ }
+
+ # set report list
+ $baseReportList = $this->db->select($sql);
+ $this->set('baseReportList', $baseReportList);
+ $this->set('colList', $this->colList);
+
+ // if keywords existing
+ if (!empty($baseReportList)) {
+
+ $sourceIdList = array();
+ foreach ($baseReportList as $info) {
+ $sourceIdList[] = $info['id'];
+ }
+
+ $sql = "select k.id,k.source_name,r.website_id, $analyticsCols
+ from analytic_sources k, website_analytics r where k.id=r.source_id
+ $conditions and r.report_date='$fromTime'";
+ $sql .= " and k.id in(" . implode(",", $sourceIdList) . ")";
+ $reportList = $this->db->select($sql);
+ $compareReportList = array();
+
+ foreach ($reportList as $info) {
+ $compareReportList[$info['website_id']][$info['id']] = $info;
+ }
+
+ $this->set('compareReportList', $compareReportList);
+ }
+
+ if ($exportVersion) {
+ $spText = $_SESSION['text'];
+ $reportHeading = $this->spTextTools['Website Analytics Summary']."($fromTime - $toTime)";
+ $exportContent .= createExportContent( array('', $reportHeading, ''));
+ $exportContent .= createExportContent( array());
+ $headList = array($spText['common']['Website'], $spText['common']['Source']);
+
+ $pTxt = str_replace("-", "/", substr($fromTime, -5));
+ $cTxt = str_replace("-", "/", substr($toTime, -5));
+ foreach ($this->metrics as $colKey => $colLabel) {
+ if ($colKey == 'name') continue;
+ $headList[] = $colLabel . "($pTxt)";
+ $headList[] = $colLabel . "($cTxt)";
+ $headList[] = $colLabel . "(+/-)";
+ }
+
+ $exportContent .= createExportContent($headList);
+ foreach($baseReportList as $listInfo){
+
+ $valueList = array($websiteList[$listInfo['website_id']]['url'], $listInfo['source_name']);
+ foreach ($this->metrics as $colName => $colVal) {
+ if ($colName == 'name') continue;
+
+ $currRank = isset($listInfo[$colName]) ? $listInfo[$colName] : 0;
+ $prevRank = isset($compareReportList[$listInfo['website_id']][$listInfo['id']][$colName]) ? $compareReportList[$listInfo['website_id']][$listInfo['id']][$colName] : 0;
+ $rankDiff = "";
+
+ // if both ranks are existing
+ if ($prevRank != '' && $currRank != '') {
+ $rankDiff = $currRank - $prevRank;
+ if ($colName == 'bounceRate') $rankDiff = $rankDiff * -1;
+ }
+
+ $valueList[] = $prevRank;
+ $valueList[] = $currRank;
+ $valueList[] = $rankDiff;
+ }
+
+ $exportContent .= createExportContent( $valueList);
+ }
+
+ if ($summaryPage) {
+ return $exportContent;
+ } else {
+ exportToCsv('analytics_summary', $exportContent);
+ }
+
+ } else {
+
+ // if pdf export
+ if ($summaryPage) {
+ return $this->getViewContent('analytics/analytics_summary');
+ } else {
+ // if pdf export
+ if ($searchInfo['doc_type'] == "pdf") {
+ exportToPdf($this->getViewContent('analytics/analytics_summary'), "analytics_summary_$fromTime-$toTime.pdf");
+ } else {
+ $this->set('searchInfo', $searchInfo);
+ $this->render('analytics/analytics_summary');
+ }
+ }
+
+ }
+ }
+
+ function __getWebsiteSourceList($websiteId) {
+ $websiteId = intval($websiteId);
+ $sql = "select * from analytic_sources where
+ id in (select distinct source_id from website_analytics where website_id=$websiteId)
+ order by source_name";
+ $sourceList = $this->db->select($sql);
+ return $sourceList;
+ }
+
+ // func to show analytics reports
+ function viewAnalyticsReports($searchInfo = '') {
+
+ $userId = isLoggedIn();
+
+ if (!empty ($searchInfo['from_time'])) {
+ $fromTimeDate = addslashes($searchInfo['from_time']);
+ } else {
+ $fromTimeDate = date('Y-m-d', strtotime('-17 days'));
+ }
+
+ if (!empty ($searchInfo['to_time'])) {
+ $toTimeDate = addslashes($searchInfo['to_time']);
+ } else {
+ $toTimeDate = date('Y-m-d', strtotime('-1 days'));
+ }
+
+ $this->set('fromTime', $fromTimeDate);
+ $this->set('toTime', $toTimeDate);
+
+ $websiteController = New WebsiteController();
+ $websiteList = $websiteController->__getAllWebsites($userId, true);
+ $this->set('websiteList', $websiteList);
+ $websiteId = empty ($searchInfo['website_id']) ? $websiteList[0]['id'] : intval($searchInfo['website_id']);
+ $this->set('websiteId', $websiteId);
+
+ $sourceList = $this->__getWebsiteSourceList($websiteId);
+ $this->set('sourceList', $sourceList);
+ $sourceId = empty ($searchInfo['source_id']) ? $sourceList[0]['id'] : $searchInfo['source_id'];
+ $this->set('sourceId', $sourceId);
+
+ $conditions = " and s.website_id=$websiteId";
+ $conditions .= empty ($sourceId) ? "" : " and s.source_id=$sourceId";
+ $sql = "select s.* from website_analytics s
+ where report_date>='$fromTimeDate' and report_date<='$toTimeDate' $conditions
+ order by s.report_date";
+ $reportList = $this->db->select($sql);
+
+ $colList = array_keys($this->metrics);
+ $prevRank = [];
+ $rankDiff = [];
+ foreach ($colList as $col) {
+ $prevRank[$col] = 0;
+ }
+
+ // loop through rank
+ foreach ($reportList as $key => $repInfo) {
+
+ // exclude first row
+ if ($key) {
+ foreach ($colList as $col) {
+ $rankDiff[$col] = '';
+ }
+
+ foreach ($colList as $col) {
+ $rankDiff[$col] = round($repInfo[$col] - $prevRank[$col], 2);
+ if (empty($rankDiff[$col])) {
+ continue;
+ }
+
+ if ($col == "bounceRate" ) {
+ $rankDiff[$col] = $rankDiff[$col] * -1;
+ }
+
+ $rankClass = ($rankDiff[$col] > 0) ? 'green' : 'red';
+ $rankDiff[$col] = "($rankDiff[$col])";
+ $reportList[$key]['rank_diff_'.$col] = empty($rankDiff[$col]) ? '' : $rankDiff[$col];
+ }
+ }
+
+ foreach ($colList as $col) {
+ $prevRank[$col] = $repInfo[$col];
+ }
+ }
+
+ $this->set('list', array_reverse($reportList, true));
+ $this->render('analytics/analytics_reports');
+
+ }
+
+ // func to show analytics reports in graph
+ function viewAnalyticsGraphReports($searchInfo = '') {
+ $userId = isLoggedIn();
+
+ if (!empty ($searchInfo['from_time'])) {
+ $fromTimeDate = addslashes($searchInfo['from_time']);
+ } else {
+ $fromTimeDate = date('Y-m-d', strtotime('-17 days'));
+ }
+
+ if (!empty ($searchInfo['to_time'])) {
+ $toTimeDate = addslashes($searchInfo['to_time']);
+ } else {
+ $toTimeDate = date('Y-m-d', strtotime('-1 days'));
+ }
+
+ $this->set('fromTime', $fromTimeDate);
+ $this->set('toTime', $toTimeDate);
+
+ $websiteController = New WebsiteController();
+ $websiteList = $websiteController->__getAllWebsites($userId, true);
+ $this->set('websiteList', $websiteList);
+ $websiteId = empty ($searchInfo['website_id']) ? $websiteList[0]['id'] : intval($searchInfo['website_id']);
+ $this->set('websiteId', $websiteId);
+
+ $sourceList = $this->__getWebsiteSourceList($websiteId);
+ $this->set('sourceList', $sourceList);
+ $sourceId = empty ($searchInfo['source_id']) ? $sourceList[0]['id'] : $searchInfo['source_id'];
+ $this->set('sourceId', $sourceId);
+
+ $conditions = " and s.website_id=$websiteId";
+ $conditions .= empty ($sourceId) ? "" : " and s.source_id=$sourceId";
+ $sql = "select s.* from website_analytics s
+ where report_date>='$fromTimeDate' and report_date<='$toTimeDate' $conditions
+ order by s.report_date";
+ $reportList = $this->db->select($sql);
+
+ // if reports not empty
+ $colList = $this->metrics;
+ $this->set('colList', $colList);
+ $this->set('searchInfo', $searchInfo);
+
+ $graphColList = array();
+ if (!empty($searchInfo['attr_type'])) {
+ $graphColList[$searchInfo['attr_type']] = $colList[$searchInfo['attr_type']];
+ if ($searchInfo['attr_type'] == 'bounceRate') {
+ $this->set('reverseDir', true);
+ }
+ } else {
+ $graphColList = $colList;
+ unset($graphColList['bounceRate']);
+ }
+
+ if (!empty($reportList)) {
+
+ $dataArr = "['Date', '" . implode("', '", array_values($graphColList)) . "']";
+
+ // loop through data list
+ foreach ($reportList as $dataInfo) {
+
+ $valStr = "";
+ foreach ($graphColList as $seId => $seVal) {
+ $valStr .= ", ";
+ $valStr .= !empty($dataInfo[$seId]) ? $dataInfo[$seId] : 0;
+ }
+
+ $dataArr .= ", ['{$dataInfo['report_date']}' $valStr]";
+ }
+
+ $this->set('dataArr', $dataArr);
+ $this->set('graphTitle', $this->spTextTools['Website Analytics Summary']);
+ $graphContent = $this->getViewContent('report/graph');
+ } else {
+ $graphContent = showErrorMsg($_SESSION['text']['common']['No Records Found'], false, true);
+ }
+
+ // get graph content
+ $this->set('graphContent', $graphContent);
+ $this->render('analytics/graphicalreport');
+
+ }
+
+ // func to show keyword select box
+ function showSourceSelectBox($websiteId){
+ $websiteId = intval($websiteId);
+ $this->set('sourceList', $this->__getWebsiteSourceList($websiteId));
+ $this->render('analytics/source_select_box', 'ajax');
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/controllers/backlink.ctrl.php b/controllers/backlink.ctrl.php
index 2bd855c0..83e35319 100644
--- a/controllers/backlink.ctrl.php
+++ b/controllers/backlink.ctrl.php
@@ -23,15 +23,13 @@
# class defines all backlink controller functions
class BacklinkController extends Controller{
var $url;
- var $colList = array('google' => 'google', 'alexa' => 'alexa', 'msn' => 'msn');
+ var $colList = array('google' => 'google', 'msn' => 'bing');
var $backUrlList = array(
'google' => 'http://www.google.com/search?hl=en&q=link%3A',
- 'alexa' => 'http://www.alexa.com/siteinfo/',
'msn' => 'http://www.bing.com/search?q=link%3A',
);
function showBacklink() {
-
$this->render('backlink/showbacklink');
}
@@ -70,7 +68,7 @@ function printBacklink($backlinkInfo){
echo "$backlinkCount";
}
- function __getBacklinks ($engine) {
+ function __getBacklinks ($engine, $cron=false) {
if (SP_DEMO && !empty($_SERVER['REQUEST_METHOD'])) return 0;
// check whether any api source is enabled for crawl keyword
@@ -124,20 +122,9 @@ function __getBacklinks ($engine) {
$backlinkCount = !empty($r[1]) ? str_replace(',', '', $r[1]) : 0;
break;
- # alexa
+ // alexa
case 'alexa':
- $url = $this->backUrlList[$engine] . urlencode($this->url);
- $v = $this->spider->getContent($url);
- $pageContent = empty($v['page']) ? '' : $v['page'];
- $r = [];
- $engineInfo = Spider::getCrawlEngineInfo('alexa', 'backlink');
- if (preg_match($engineInfo['regex1'], $pageContent, $r)) {
- } else {
- $crawlInfo['crawl_status'] = 0;
- $crawlInfo['log_message'] = SearchEngineController::isCaptchInSearchResults($pageContent) ? "Captcha found in search result page" : "Regex not matched error occured while parsing search results!";
- }
-
- $backlinkCount = !empty($r[1]) ? intval(str_replace(",", "", $r[1])) : 0;
+ $backlinkCount = 0;
break;
}
@@ -199,8 +186,8 @@ function saveRankResults($matchInfo, $remove=false) {
$this->db->query($sql);
}
- $sql = "insert into backlinkresults(website_id,google,alexa,msn,result_date)
- values({$matchInfo['id']},{$matchInfo['google']},{$matchInfo['alexa']},{$matchInfo['msn']}, '$resultDate')";
+ $sql = "insert into backlinkresults(website_id,google,msn,result_date)
+ values({$matchInfo['id']},{$matchInfo['google']},{$matchInfo['msn']}, '$resultDate')";
$this->db->query($sql);
}
@@ -282,7 +269,6 @@ function showReports($searchInfo = '') {
$this->set('directLinkList', array(
'google' => $this->backUrlList['google'] . $websiteUrl,
'msn' => $this->backUrlList['msn'] . $websiteUrl,
- 'alexa' => $this->backUrlList['alexa'] . $websiteUrl,
));
$this->set('list', array_reverse($reportList, true));
diff --git a/controllers/components/review_base.ctrl.php b/controllers/components/review_base.ctrl.php
index 7981da5c..1bb09946 100644
--- a/controllers/components/review_base.ctrl.php
+++ b/controllers/components/review_base.ctrl.php
@@ -35,20 +35,47 @@ function __construct() {
"rating" => $engineList['google']['regex2'],
],
"url_part" => '?hl=en',
- 'example' => ['https://www.google.com/search?q=kfc+Damrak']
+ 'example' => ['https://www.google.com/search?q=kfc+Damrak'],
+ 'icon' => 'fab fa-google',
],
- "glassdoor" => [
+ /*"glassdoor" => [
"label" => "Glassdoor",
"regex" => [
"reviews" => $engineList['glassdoor']['regex1'],
"rating" => $engineList['glassdoor']['regex2'],
],
'example' => ['https://www.glassdoor.com/Overview/Working-at-Google-EI_IE9079.11,17.htm']
+ ],*/
+ "yelp" => [
+ "label" => "Yelp",
+ "regex" => [
+ "reviews" => $engineList['yelp']['regex1'],
+ "rating" => $engineList['yelp']['regex2'],
+ ],
+ 'example' => ['https://www.yelp.com/biz/intercontinental-singapore-singapore-2'],
+ 'icon' => 'fab fa-yelp',
+ ],
+ "trustpilot" => [
+ "label" => "Trustpilot",
+ "regex" => [
+ "reviews" => $engineList['trustpilot']['regex1'],
+ "rating" => $engineList['trustpilot']['regex2'],
+ ],
+ 'example' => ['https://www.trustpilot.com/review/xohotels.com'],
+ 'icon' => 'fab fa-buffer',
+ ],
+ "tripadvisor" => [
+ "label" => "Tripadvisor",
+ "regex" => [
+ "reviews" => $engineList['tripadvisor']['regex1'],
+ "rating" => $engineList['tripadvisor']['regex2'],
+ ],
+ 'example' => ['https://www.tripadvisor.com/Hotel_Review-g188098-d236186-Reviews-Hotel_Julen-Zermatt_Canton_of_Valais_Swiss_Alps.html'],
+ 'icon' => 'fab fa-tripadvisor',
],
];
parent::__construct();
- }
-
+ }
}
?>
\ No newline at end of file
diff --git a/controllers/cron.ctrl.php b/controllers/cron.ctrl.php
index 50ce27b3..5ebb35bc 100644
--- a/controllers/cron.ctrl.php
+++ b/controllers/cron.ctrl.php
@@ -102,9 +102,8 @@ function executeReportGenerationScript($info=[]) {
$this->render('report/reportgenerator');
}
- # common cron execute function
+ // common cron execute function
function executeCron($includeList=array(), $userSelectList=array()) {
-
$this->loadCronJobTools($includeList);
$lastGenerated = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
@@ -134,7 +133,6 @@ function executeCron($includeList=array(), $userSelectList=array()) {
$repSetInfo = $reportCtrler->isGenerateReportsForUser($userInfo['id']);
if (!empty($repSetInfo['generate_report'])) {
-
$websiteCtrler = New WebsiteController();
$sql = "select * from websites where status=1 and user_id=" . $userInfo['id'] . " and crawled=0 order by name";
$websiteList = $websiteCtrler->db->select($sql);
@@ -142,9 +140,7 @@ function executeCron($includeList=array(), $userSelectList=array()) {
// if websites are available
if ($websiteCount > 0) {
-
foreach($websiteList as $websiteInfo){
-
$this->websiteInfo = $websiteInfo;
$this->routeCronJob($websiteInfo['id'], '', true);
$this->checkedWebsites++;
@@ -212,9 +208,8 @@ function executeCron($includeList=array(), $userSelectList=array()) {
}
- # function to route the cronjobs to different methods
- function routeCronJob($websiteId, $repTools='', $cron=false){
-
+ // function to route the cronjobs to different methods
+ function routeCronJob($websiteId, $repTools='', $cron=false) {
$websiteId = intval($websiteId);
if(empty($this->websiteInfo)){
$websiteCtrler = New WebsiteController();
@@ -225,6 +220,7 @@ function routeCronJob($websiteId, $repTools='', $cron=false){
if(empty($this->cronList)){
$this->loadCronJobTools();
}
+
$seoTools = $this->cronList;
}else{
$this->loadReportGenerationTools(explode(':', $repTools));
@@ -247,7 +243,9 @@ function routeCronJob($websiteId, $repTools='', $cron=false){
foreach ($seoTools as $cronInfo) {
// check whether user have acccess to the tool
- if (!$isAdmin && empty($toolAccessList[$cronInfo['id']]['value']) ) continue;
+ if (!$isAdmin && empty($toolAccessList[$cronInfo['id']]['value']) ) {
+ continue;
+ }
switch($cronInfo['url_section']){
@@ -427,31 +425,26 @@ function backlinkCheckerCron($websiteId){
}
- # func to generate rank reports from cron
- function rankCheckerCron($websiteId){
-
+ // func to generate rank reports from cron
+ function rankCheckerCron($websiteId) {
include_once(SP_CTRLPATH."/rank.ctrl.php");
$this->debugMsg("Starting Rank Checker cron for website: {$this->websiteInfo['name']}....
\n");
$rankCtrler = New RankController();
$websiteInfo = $this->websiteInfo;
-
- if (SP_MULTIPLE_CRON_EXEC && $rankCtrler->isReportsExists($websiteInfo['id'], $this->timeStamp)) return;
+ if (SP_MULTIPLE_CRON_EXEC && $rankCtrler->isReportsExists($websiteInfo['id'], $this->timeStamp)) {
+ return;
+ }
$websiteUrl = addHttpToUrl($websiteInfo['url']);
- /*$mozRankInfo = $rankCtrler->__getMozRank(array($websiteUrl));*/
-
$mozCtrler = new MozController();
$mozRankInfo = $mozCtrler->__getMozRankInfo(array($websiteUrl));
- $websiteInfo['moz_rank'] = $mozRankInfo[0]['moz_rank'];
- $websiteInfo['page_authority'] = $mozRankInfo[0]['page_authority'];
- $websiteInfo['domain_authority'] = $mozRankInfo[0]['domain_authority'];
-
- $websiteInfo['alexaRank'] = $rankCtrler->__getAlexaRank($websiteUrl);
+ $websiteInfo['moz_rank'] = !empty($mozRankInfo[0]['moz_rank']) ? $mozRankInfo[0]['moz_rank'] : 0;
+ $websiteInfo['page_authority'] = !empty($mozRankInfo[0]['page_authority']) ? $mozRankInfo[0]['page_authority'] : 0;$mozRankInfo[0]['page_authority'];
+ $websiteInfo['domain_authority'] = !empty($mozRankInfo[0]['domain_authority']) ? $mozRankInfo[0]['domain_authority'] : 0;$mozRankInfo[0]['domain_authority'];
$rankCtrler->saveRankResults($websiteInfo, true);
$this->debugMsg("Saved rank results of $websiteUrl.....
\n");
-
}
# func to find the keyword position checker
diff --git a/controllers/googleapi.ctrl.php b/controllers/googleapi.ctrl.php
index aafc708f..452b9bd9 100644
--- a/controllers/googleapi.ctrl.php
+++ b/controllers/googleapi.ctrl.php
@@ -141,8 +141,12 @@ function getAuthClient($userId) {
* function to setup app scopes(read write permissions)
*/
function setAppScopes($client) {
- $client->addScope([Google_Service_Webmasters::WEBMASTERS, Google_Service_AnalyticsReporting::ANALYTICS_READONLY]);
- return $client;
+ $client->addScope([
+ Google_Service_Webmasters::WEBMASTERS,
+ Google_Service_AnalyticsReporting::ANALYTICS_READONLY,
+ Google_Service_Analytics::ANALYTICS_READONLY,
+ ]);
+ return $client;
}
/*
@@ -167,8 +171,7 @@ function getAPIAuthUrl($userId) {
$ret['msg'] = $client;
}
- return $ret;
-
+ return $ret;
}
/*
@@ -202,7 +205,6 @@ function createUserAuthToken($userId, $authCode) {
}
return $ret;
-
}
/*
@@ -227,8 +229,90 @@ function removeUserAuthToken($userId) {
$tokenInfo = $this->tokenCtrler->deleteAllUserTokens($userId, $this->sourceName);
return $ret;
-
}
-
+
+ function getanalyticWebsitesPropertyIds($userId) {
+ $websites = array();
+ $client = $this->getAuthClient($userId);
+
+ // if error occured
+ if (!is_object($client)) {
+ return [FALSE, $websites, $client];
+ }
+
+ // Create a Google_Service_Analytics object
+ $analytics = new Google_Service_Analytics($client);
+
+ // Retrieve the list of accounts
+ $accounts = $analytics->management_accounts->listManagementAccounts();
+
+ // Loop through the accounts
+ foreach ($accounts->getItems() as $account) {
+ // Get the account ID and name
+ $accountId = $account->getId();
+ $accountName = $account->getName();
+
+ // get analytics admin properties
+ $accessToken = $this->__getAccessToken($client);
+ $apiUrl = "https://analyticsadmin.googleapis.com/v1alpha/properties?filter=parent:accounts/$accountId";
+ $ret = $this->plainAPICall($apiUrl, $accessToken);
+ if (!empty($ret['error'])) {
+ continue;
+ }
+
+ if (!empty($ret['page']['properties'])) {
+ foreach ($ret['page']['properties'] as $property) {
+ $propertyId = str_replace("properties/", "", $property['name']);
+ $propertyName = $property['displayName'];
+ $websites[] = array(
+ 'account_name' => $accountName,
+ 'account_id' => $accountId,
+ 'property_name' => $propertyName,
+ 'property_id' => $propertyId,
+ );
+ }
+ }
+ }
+
+ return [TRUE, $websites, "success"];
+ }
+
+ // Function to get GA4 properties
+ function getGA4Properties($client, $accountId) {
+ $accessToken = $this->__getAccessToken($client);
+ $apiUrl = "https://analyticsadmin.googleapis.com/v1alpha/properties?filter=parent%3Daccounts%2F$accountId";
+ $ret = $this->plainAPICall($apiUrl, $accessToken);
+ if (!empty($ret['error'])) {
+ return [false, $ret['errmsg'], []];
+ }
+ }
+
+ function __getAccessToken($client) {
+ $tokenInfo = $client->getAccessToken();
+ $accessToken = !empty($tokenInfo['access_token']) ? $tokenInfo['access_token'] : FALSE;
+ return $accessToken;
+ }
+
+ function plainAPICall($apiUrl, $accessToken, $postArgs=[]) {
+ $spider = new Spider();
+ array_push($spider ->_CURL_HTTPHEADER, 'Authorization: Bearer ' . $accessToken);
+
+ if (!empty($postArgs)) {
+ $spider->_CURLOPT_POSTFIELDS = http_build_query($postArgs);
+ }
+
+ $ret = $spider->getContent($apiUrl);
+ if (!empty($ret['page'])) {
+ $apiRes = json_decode($ret['page'], TRUE);
+ if ($ret['http_code'] == 200) {
+ $ret['page'] = $apiRes;
+ } else {
+ $ret['error'] = $ret['http_code'];
+ $ret['errmsg'] = !empty($apiRes['error']['message']) ? $apiRes['error']['message'] : "API Error";
+ }
+ }
+
+ return $ret;
+ }
}
?>
\ No newline at end of file
diff --git a/controllers/rank.ctrl.php b/controllers/rank.ctrl.php
index 836a4c1b..aee88f59 100644
--- a/controllers/rank.ctrl.php
+++ b/controllers/rank.ctrl.php
@@ -23,11 +23,10 @@
# class defines all rank controller functions
class RankController extends Controller{
- var $colList = array('moz' => 'moz_rank', 'alexa' => 'alexa_rank', 'domain_authority' => 'domain_authority', 'page_authority' => 'page_authority');
+ var $colList = array('moz' => 'moz_rank', 'domain_authority' => 'domain_authority', 'page_authority' => 'page_authority');
# func to show quick rank checker
function showQuickRankChecker() {
-
$this->render('rank/showquickrank');
}
@@ -55,17 +54,6 @@ function findQuickRank($searchInfo) {
$this->render('rank/findquickrank');
}
- function printGooglePageRank($url){
- $pageRank = $this->__getGooglePageRank($url);
- if($pageRank >= 0){
- $imageUrl = SP_IMGPATH."/pr/pr".$pageRank.".gif";
- }else{
- $imageUrl = SP_IMGPATH."/pr/pr.gif";
- }
-
- print "";
- }
-
function printMOZRank($url){
$pageRank = $this->__getMozRank($url);
if($pageRank >= 0){
@@ -76,92 +64,6 @@ function printMOZRank($url){
print "";
}
-
- function __getGooglePageRank ($url) {
-
- return 0;
-
- // commented due to gooogle stops this service
- /*
- if (SP_DEMO && !empty($_SERVER['REQUEST_METHOD'])) return 0;
- $websiteUrl = $url;
- $url = "http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=".$this->CheckHash($this->hashURL($url))."&features=Rank&q=info:".$url."&num=100&filter=0";
- $ret = $this->spider->getContent($url);
- $rank = 0;
-
- // parse rank from the page
- if (!empty($ret['page'])) {
- if (preg_match('/Rank_([0-9]+):([0-9]+):([0-9]+)/si', $ret['page'], $matches) ) {
- $rank = empty($matches[3]) ? 0 : $matches[3];
- } else {
- $crawlInfo['crawl_status'] = 0;
- $crawlInfo['log_message'] = SearchEngineController::isCaptchInSearchResults($ret['page']) ? "Captcha found in search result page" : "Regex not matched error occured while parsing search results!";
- }
- }
-
- // update crawl log
- $crawlLogCtrl = new CrawlLogController();
- $crawlInfo['crawl_type'] = 'rank';
- $crawlInfo['ref_id'] = $websiteUrl;
- $crawlInfo['subject'] = "google";
- $crawlLogCtrl->updateCrawlLog($ret['log_id'], $crawlInfo);
-
- return $rank;
- */
- }
-
- function printAlexaRank($url){
- $alexaRank = $this->__getAlexaRank($url);
- $imageUrl = SP_WEBPATH."/rank.php?sec=alexaimg&rank=$alexaRank";
-
- print "";
- }
-
- function printAlexaRankImg($alexaRank) {
- $rankImage = SP_IMGPATH."/alexa-rank.jpeg";
-
- $im = imagecreatefromjpeg ($rankImage);
- $textColor = imagecolorallocate($im, 0, 0, 255);
- $width = imagesx($im);
- $height = imagesy($im);
- $leftTextPos = ( $width - (7 * strlen($alexaRank)) )/2;
- imagestring($im, 3, $leftTextPos, 35, $alexaRank, $textColor);
-
- ob_end_clean();
- Header('Content-type: image/jpeg');
- imagejpeg($im);
- exit;
- }
-
- # alexa_rank
- function __getAlexaRank ($url) {
- if (SP_DEMO && !empty($_SERVER['REQUEST_METHOD'])) return 0;
- $websiteUrl = $url;
- $url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url=' . urlencode($url);
- $ret = $this->spider->getContent($url);
- $rank = 0;
-
- // parse rank from teh page
- if(!empty($ret['page'])) {
- $matches = [];
- $engineInfo = Spider::getCrawlEngineInfo('alexa', 'rank');
- if (preg_match($engineInfo['regex1'], $ret['page'], $matches) ) {
- $rank = empty($matches[2]) ? 0 : $matches[2];
- } else {
- $crawlInfo['crawl_status'] = 0;
- $crawlInfo['log_message'] = SearchEngineController::isCaptchInSearchResults($ret['page']) ? "Captcha found in search result page" : "Regex not matched error occured while parsing search results!";
- }
- }
-
- // update crawl log
- $crawlLogCtrl = new CrawlLogController();
- $crawlInfo['crawl_type'] = 'rank';
- $crawlInfo['ref_id'] = $websiteUrl;
- $crawlInfo['subject'] = "alexa";
- $crawlLogCtrl->updateCrawlLog($ret['log_id'], $crawlInfo);
-
- return $rank;
- }
// function to get moz rank
function __getMozRank ($urlList = array(), $accessID = "", $secretKey = "", $returnLog = false) {
@@ -297,19 +199,16 @@ function checkHash($Hashnum) {
}
# func to show genearte reports interface
- function showGenerateReports($searchInfo = '') {
-
+ function showGenerateReports($searchInfo=[]) {
$userId = isLoggedIn();
$websiteController = New WebsiteController();
$websiteList = $websiteController->__getAllWebsites($userId, true);
- $this->set('websiteList', $websiteList);
-
+ $this->set('websiteList', $websiteList);
$this->render('rank/generatereport');
}
# func to generate reports
- function generateReports( $searchInfo='' ) {
-
+ function generateReports($searchInfo=[]) {
$userId = isLoggedIn();
$websiteId = empty ($searchInfo['website_id']) ? '' : intval($searchInfo['website_id']);
@@ -338,7 +237,6 @@ function generateReports( $searchInfo='' ) {
// loop through each websites
foreach ( $websiteList as $i => $websiteInfo ) {
$websiteUrl = addHttpToUrl($websiteInfo['url']);
- $websiteInfo['alexaRank'] = $this->__getAlexaRank($websiteUrl);
$websiteInfo['moz_rank'] = !empty($mozRankList[$i]['moz_rank']) ? $mozRankList[$i]['moz_rank'] : 0;
$websiteInfo['domain_authority'] = !empty($mozRankList[$i]['domain_authority']) ? $mozRankList[$i]['domain_authority'] : 0;
$websiteInfo['page_authority'] = !empty($mozRankList[$i]['page_authority']) ? $mozRankList[$i]['page_authority'] : 0;
@@ -360,8 +258,8 @@ function saveRankResults($matchInfo, $remove=false) {
$mozRank = floatval($matchInfo['moz_rank']);
$domainAuthority = floatval($matchInfo['domain_authority']);
$pageAuthority = floatval($matchInfo['page_authority']);
- $sql = "insert into rankresults(website_id, moz_rank, alexa_rank, domain_authority, page_authority, result_date)
- values({$matchInfo['id']}, $mozRank, {$matchInfo['alexaRank']}, $domainAuthority, $pageAuthority, '$resultDate')";
+ $sql = "insert into rankresults(website_id, moz_rank, domain_authority, page_authority, result_date)
+ values({$matchInfo['id']}, $mozRank, $domainAuthority, $pageAuthority, '$resultDate')";
$this->db->query($sql);
}
@@ -374,8 +272,7 @@ function isReportsExists($websiteId, $time) {
}
# func to show reports
- function showReports($searchInfo = '') {
-
+ function showReports($searchInfo=[]) {
$userId = isLoggedIn();
if (!empty ($searchInfo['from_time'])) {
$fromTime = $searchInfo['from_time'];
@@ -448,10 +345,8 @@ function showReports($searchInfo = '') {
$this->render('rank/rankreport');
}
-
- # func to show reports for a particular website
+ // func to show reports for a particular website
function __getWebsiteRankReport($websiteId, $fromTime, $toTime) {
-
$fromTimeLabel = date('Y-m-d', $fromTime);
$toTimeLabel = date('Y-m-d', $toTime);
$sql = "select s.* ,w.name
@@ -513,8 +408,7 @@ function __getWebsiteRankReport($websiteId, $fromTime, $toTime) {
}
# func to show graphical reports
- function showGraphicalReports($searchInfo = '') {
-
+ function showGraphicalReports($searchInfo=[]) {
$userId = isLoggedIn();
$fromTime = !empty($searchInfo['from_time']) ? $searchInfo['from_time'] : date('Y-m-d', strtotime('-30 days'));
$toTime = !empty ($searchInfo['to_time']) ? $searchInfo['to_time'] : date("Y-m-d");
@@ -537,7 +431,6 @@ function showGraphicalReports($searchInfo = '') {
$colLabelList = array(
'moz_rank' => $_SESSION['text']['common']['MOZ Rank'],
- 'alexa_rank' => $_SESSION['text']['common']['Alexa Rank'],
'domain_authority' => $_SESSION['text']['common']['Domain Authority'],
'page_authority' => $_SESSION['text']['common']['Page Authority'],
);
diff --git a/controllers/report.ctrl.php b/controllers/report.ctrl.php
index 8d0e80d2..a8622ddb 100644
--- a/controllers/report.ctrl.php
+++ b/controllers/report.ctrl.php
@@ -615,7 +615,7 @@ function generateReports( $searchInfo='' ) {
# function to format pagecontent
function formatPageContent($seInfoId, $pageContent) {
if (!empty($this->seList[$seInfoId]['from_pattern']) && $this->seList[$seInfoId]['to_pattern']) {
- $pattern = $this->seList[$seInfoId]['from_pattern']."(.*)".$this->seList[$seInfoId]['to_pattern'];
+ $pattern = $this->seList[$seInfoId]['from_pattern']."(.*?)".$this->seList[$seInfoId]['to_pattern'];
if (preg_match("/$pattern/is", $pageContent, $matches)) {
if (!empty($matches[1])) {
$pageContent = $matches[1];
@@ -1194,7 +1194,6 @@ function showOverallReportSummary($searchInfo='', $cronUserId=false) {
# rank reports
$report = $rankCtrler->__getWebsiteRankReport($listInfo['id'], $fromTime, $toTime);
$report = $report[0];
- $listInfo['alexarank'] = empty($report['alexa_rank']) ? "-" : $report['alexa_rank']." ".$report['rank_diff_alexa'];
$listInfo['mozrank'] = empty($report['moz_rank']) ? "-" : $report['moz_rank']." ".$report['rank_diff_moz'];
$listInfo['domain_authority'] = empty($report['domain_authority']) ? "-" : $report['domain_authority']." ".$report['rank_diff_domain_authority'];
$listInfo['page_authority'] = empty($report['page_authority']) ? "-" : $report['page_authority']." ".$report['rank_diff_page_authority'];
@@ -1203,7 +1202,6 @@ function showOverallReportSummary($searchInfo='', $cronUserId=false) {
$report = $backlinlCtrler->__getWebsitebacklinkReport($listInfo['id'], $fromTime, $toTime);
$report = $report[0];
$listInfo['google']['backlinks'] = empty($report['google']) ? "-" : $report['google']." ".$report['rank_diff_google'];
- $listInfo['alexa']['backlinks'] = empty($report['alexa']) ? "-" : $report['alexa']." ".$report['rank_diff_alexa'];
$listInfo['msn']['backlinks'] = empty($report['msn']) ? "-" : $report['msn']." ".$report['rank_diff_msn'];
# rank reports
@@ -1232,6 +1230,7 @@ function showOverallReportSummary($searchInfo='', $cronUserId=false) {
if ((isAdmin() && !empty($webUserId))) {
$exportContent .= createExportContent( array());
$exportContent .= createExportContent( array());
+ $userCtrler = new UserController();
$userInfo = $userCtrler->__getUserInfo($webUserId);
$exportContent .= createExportContent( array($_SESSION['text']['common']['User'], $userInfo['username']));
}
@@ -1242,9 +1241,7 @@ function showOverallReportSummary($searchInfo='', $cronUserId=false) {
$_SESSION['text']['common']['MOZ Rank'],
$_SESSION['text']['common']['Domain Authority'],
$_SESSION['text']['common']['Page Authority'],
- $_SESSION['text']['common']['Alexa Rank'],
'Google '.$spTextHome['Backlinks'],
- 'alexa '.$spTextHome['Backlinks'],
'Bing '.$spTextHome['Backlinks'],
'Google '.$spTextHome['Indexed'],
'Bing '.$spTextHome['Indexed'],
@@ -1261,9 +1258,7 @@ function showOverallReportSummary($searchInfo='', $cronUserId=false) {
strip_tags($websiteInfo['mozrank']),
strip_tags($websiteInfo['domain_authority']),
strip_tags($websiteInfo['page_authority']),
- strip_tags($websiteInfo['alexarank']),
strip_tags($websiteInfo['google']['backlinks']),
- strip_tags($websiteInfo['alexa']['backlinks']),
strip_tags($websiteInfo['msn']['backlinks']),
strip_tags($websiteInfo['google']['indexed']),
strip_tags($websiteInfo['msn']['indexed']),
diff --git a/controllers/review_manager.ctrl.php b/controllers/review_manager.ctrl.php
index 88292a61..9c9f9bfc 100644
--- a/controllers/review_manager.ctrl.php
+++ b/controllers/review_manager.ctrl.php
@@ -357,14 +357,19 @@ function getReviewDetails($smType, $smLink) {
if (!empty($matches[1])) {
$result['status'] = 1;
- $result['rating'] = formatNumber($matches[1]);
+ $result['rating'] = round(formatNumber($matches[1]), 2);
}
}
+ // if not found any details
+ if (!$result['status']) {
+ $result['msg'] = "Review page details not found.";
+ } else {
+ $result['msg'] = "Review page details fetched successfully.";
+ }
} else {
$result['msg'] = $smContentInfo['errmsg'];
}
-
}
return $result;
@@ -520,7 +525,7 @@ function viewReportSummary($searchInfo = '', $summaryPage = false, $cronUserId=f
$reportHeading = $this->spTextTools['Review Report Summary']."($fromTime - $toTime)";
$exportContent .= createExportContent( array('', $reportHeading, ''));
$exportContent .= createExportContent( array());
- $headList = array($spText['common']['Website'], $spText['common']['Url']);
+ $headList = array($spText['common']['Website'], $spText['common']['Url'], $spText['label']['Type']);
$pTxt = str_replace("-", "/", substr($fromTime, -5));
$cTxt = str_replace("-", "/", substr($toTime, -5));
@@ -534,7 +539,7 @@ function viewReportSummary($searchInfo = '', $summaryPage = false, $cronUserId=f
$exportContent .= createExportContent($headList);
foreach($baseReportList as $listInfo){
- $valueList = array($websiteList[$listInfo['website_id']]['url'], $listInfo['url']);
+ $valueList = array($websiteList[$listInfo['website_id']]['url'], $listInfo['url'], $this->serviceList[$listInfo['type']]['label']);
foreach ($this->colList as $colName => $colVal) {
if ($colName == 'name') continue;
diff --git a/controllers/seoplugins.ctrl.php b/controllers/seoplugins.ctrl.php
index bd32981f..57976f84 100644
--- a/controllers/seoplugins.ctrl.php
+++ b/controllers/seoplugins.ctrl.php
@@ -506,21 +506,26 @@ function parsePluginInfoFile($file) {
}
# function to create helpers for main controlller
- function createHelper($helperName) {
- $pluginPath = !empty($this->pluginPath) ? $this->pluginPath : PLUGIN_PATH;
- include_once($pluginPath . "/".strtolower($helperName).".ctrl.php");
- $helperObj = New $helperName();
- $helperObj->pluginPath = $this->pluginPath;
- $helperObj->pluginId = $this->pluginId;
- $helperObj->pluginViewPath = $this->pluginViewPath;
- $helperObj->pluginWebPath = $this->pluginWebPath;
- $helperObj->pluginImagePath = $this->pluginImagePath;
- $helperObj->pluginCssPath = $this->pluginCssPath;
- $helperObj->pluginJsPath = $this->pluginJsPath;
- $helperObj->pluginScriptUrl = $this->pluginScriptUrl;
- $helperObj->data = $this->data;
- $helperObj->pluginText = $this->pluginText;
- return $helperObj;
+ function createHelper($helperName, $pluginDirName='') {
+ $pluginPath = !empty($this->pluginPath) ? $this->pluginPath : SP_PLUGINPATH."/$pluginDirName";
+ $pluginHelperFile = $pluginPath . "/".strtolower($helperName).".ctrl.php";
+ if (!file_exists($pluginHelperFile)) {
+ return false;
+ }
+
+ include_once($pluginHelperFile);
+ $helperObj = New $helperName();
+ $helperObj->pluginPath = $this->pluginPath;
+ $helperObj->pluginId = $this->pluginId;
+ $helperObj->pluginViewPath = $this->pluginViewPath;
+ $helperObj->pluginWebPath = $this->pluginWebPath;
+ $helperObj->pluginImagePath = $this->pluginImagePath;
+ $helperObj->pluginCssPath = $this->pluginCssPath;
+ $helperObj->pluginJsPath = $this->pluginJsPath;
+ $helperObj->pluginScriptUrl = $this->pluginScriptUrl;
+ $helperObj->data = $this->data;
+ $helperObj->pluginText = $this->pluginText;
+ return $helperObj;
}
# func to get plugin language texts
diff --git a/controllers/social_media.ctrl.php b/controllers/social_media.ctrl.php
index 9eae8b02..bbef0f1b 100644
--- a/controllers/social_media.ctrl.php
+++ b/controllers/social_media.ctrl.php
@@ -40,6 +40,7 @@ function __construct() {
"follower" => $engineList['facebook']['regex2'],
],
"url_part" => $engineList['facebook']['url_part'],
+ "example" => "https://www.facebook.com/seopanel",
],
"twitter" => [
"label" => "Twitter",
@@ -47,6 +48,7 @@ function __construct() {
"regex" => [
"follower" => $engineList['twitter']['regex1'],
],
+ "example" => "https://twitter.com/seopanel",
],
"instagram" => [
"label" => "Instagram",
@@ -54,6 +56,7 @@ function __construct() {
"follower" => $engineList['instagram']['regex1'],
],
"url_part" => $engineList['instagram']['url_part'],
+ "example" => "https://www.instagram.com/seopanelorg",
],
"linkedin" => [
"label" => "LinkedIn",
@@ -62,12 +65,14 @@ function __construct() {
"follower" => $engineList['linkedin']['regex1'],
],
"show_url" => "https://www.linkedin.com/company",
+ "example" => "14576538",
],
"pinterest" => [
"label" => "Pinterest",
"regex" => [
"follower" => $engineList['pinterest']['regex1'],
],
+ "example" => "https://www.pinterest.com/seopanel",
],
"youtube" => [
"label" => "Youtube",
@@ -75,7 +80,17 @@ function __construct() {
"follower" => $engineList['youtube']['regex1'],
],
"url_part" => $engineList['youtube']['url_part'],
+ "example" => "https://www.youtube.com/c/seopanel",
],
+ "reddit" => [
+ "label" => "reddit",
+ "data_from" => "crawl",
+ "regex" => [
+ "follower" => $engineList['reddit']['regex1'],
+ ],
+ "url_part" => $engineList['reddit']['url_part'],
+ 'example' => 'https://www.reddit.com/r/Twitter',
+ ],
];
$this->set('pageScriptPath', $this->pageScriptPath);
@@ -420,6 +435,18 @@ function getSocialMediaDetails($smType, $smLink) {
if (!empty($smInfo) && !empty($smLink)) {
$smLink = $this->formatMediaLink($smType, $smLink);
$smContentInfo = $this->spider->getContent($smLink);
+
+ // testing val
+ /*$myfile = fopen(SP_TMPPATH . "/smcpage.html", "w") or die("Unable to open file!");
+ fwrite($myfile, $smContentInfo['page']);
+ fclose($myfile);
+ exit;
+
+ $smContentInfo = [];
+ $myfile = fopen(SP_TMPPATH . "/smcpage.html", "r") or die("Unable to open file!");
+ $smContentInfo['page'] = fread($myfile,filesize(SP_TMPPATH . "/smcpage.html"));
+ fclose($myfile);*/
+
if (!empty($smContentInfo['page'])) {
$matches = [];
@@ -440,10 +467,16 @@ function getSocialMediaDetails($smType, $smLink) {
$result['followers'] = formatNumber($matches[1]);
}
}
+
+ // if not found any details
+ if (!$result['status']) {
+ $result['msg'] = "Social media channel details not found.";
+ } else {
+ $result['msg'] = "Social media channel details fetched successfully.";
+ }
} else {
$result['msg'] = $smContentInfo['errmsg'];
}
-
}
return $result;
diff --git a/controllers/user.ctrl.php b/controllers/user.ctrl.php
index a33b1505..ed37be49 100644
--- a/controllers/user.ctrl.php
+++ b/controllers/user.ctrl.php
@@ -444,9 +444,9 @@ function listUsers($info=[]) {
# func to change status
function __changeStatus($userId, $status){
-
$userId = intval($userId);
- $sql = "update users set status=$status where id=$userId";
+ $confirmStr = !empty($status) ? ",confirm=1" : "";
+ $sql = "update users set status=$status $confirmStr where id=$userId";
$this->db->query($sql);
# deaactivate all websites under this user
@@ -562,10 +562,10 @@ function createUser($userInfo, $renderResults = true){
if(!$this->validate->flagErr){
if (!$this->__checkUserName($userInfo['userName'])) {
if (!$this->__checkEmail($userInfo['email'])) {
- $sql = "insert into users(utype_id,username,password,first_name,last_name,email,created,status, expiry_date)
+ $sql = "insert into users(utype_id,username,password,first_name,last_name,email,created,status, expiry_date, confirm)
values($userTypeId,'".addslashes($userInfo['userName'])."','".md5($userInfo['password'])."'
,'".addslashes($userInfo['firstName'])."', '".addslashes($userInfo['lastName'])."'
- ,'".addslashes($userInfo['email'])."',UNIX_TIMESTAMP(),$userStatus, {$userInfo['expiry_date']})";
+ ,'".addslashes($userInfo['email'])."',UNIX_TIMESTAMP(),$userStatus, {$userInfo['expiry_date']}, 1)";
$this->db->query($sql);
// if render results
diff --git a/controllers/website.ctrl.php b/controllers/website.ctrl.php
index f1060632..1f038483 100644
--- a/controllers/website.ctrl.php
+++ b/controllers/website.ctrl.php
@@ -24,8 +24,7 @@
class WebsiteController extends Controller{
# func to show websites
- function listWebsites($info=[]){
-
+ function listWebsites($info=[]) {
$userId = isLoggedIn();
$info['pageno'] = intval($info['pageno']);
$pageScriptPath = 'websites.php?stscheck=';
@@ -81,6 +80,9 @@ function listWebsites($info=[]){
$this->set('statusList', $statusList);
$this->set('info', $info);
+
+ $propertyList = $this->__getAllAnalyticProperties(TRUE);
+ $this->set('propertyList', $propertyList);
$websiteList = $this->db->select($sql);
$this->set('pageNo', $info['pageno']);
@@ -207,8 +209,7 @@ function __deleteWebsite($websiteId){
$sql = "delete from dirsubmitinfo where website_id=$websiteId";
$this->db->query($sql);
$sql = "delete from skipdirectories where website_id=$websiteId";
- $this->db->query($sql);
-
+ $this->db->query($sql);
}
function newWebsite($info=[]) {
@@ -238,24 +239,34 @@ function newWebsite($info=[]) {
$this->set('isAdmin', 1);
}
- $this->render('website/new');
+ $propertyList = $this->__getAllAnalyticProperties(TRUE);
+ $this->set('propertyList', $propertyList);
+ $this->set('editAction', 'create');
+ $this->render('website/edit_website');
}
- function __checkName($name, $userId){
-
- $sql = "select id from websites where name='".addslashes($name)."' and user_id=$userId";
+ function __checkName($name, $userId, $websiteId=FALSE) {
+ $userId = intval($userId);
+ $websiteId = intval($websiteId);
+ $sql = "select id
+ from websites
+ where name='".addslashes($name)."' and user_id=$userId";
+ $sql .= !empty($websiteId) ? " and id!=$websiteId" : "";
$listInfo = $this->db->select($sql, true);
return empty($listInfo['id']) ? false : $listInfo['id'];
}
- function __checkWebsiteUrl($url, $websiteId=0){
+ function __checkWebsiteUrl($url, $websiteId=0) {
+ $websiteId = intval($websiteId);
$sql = "select id from websites where url='".addslashes($url)."'";
$sql .= $websiteId ? " and id!=$websiteId" : "";
$listInfo = $this->db->select($sql, true);
return empty($listInfo['id']) ? false : $listInfo['id'];
}
- function createWebsite($listInfo, $apiCall = false){
+ function createWebsite($listInfo, $apiCall=false) {
+ $listInfo['url'] = trim($listInfo['url']);
+ $listInfo['name'] = trim($listInfo['name']);
// add user id when using as admin or calling api
if (isAdmin() || $apiCall) {
@@ -268,7 +279,7 @@ function createWebsite($listInfo, $apiCall = false){
$listInfo['name'] = strip_tags($listInfo['name']);
$this->set('post', $listInfo);
$errMsg['name'] = formatErrorMsg($this->validate->checkBlank($listInfo['name']));
- $errMsg['url'] = formatErrorMsg($this->validate->checkBlank($listInfo['url']));
+ $errMsg['url'] = formatErrorMsg($this->validate->checkUrl($listInfo['url']));
$listInfo['url'] = addHttpToUrl($listInfo['url']);
$statusVal = isset($listInfo['status']) ? intval($listInfo['status']) : 1;
@@ -324,34 +335,40 @@ function __getWebsiteInfo($websiteId){
return empty($listInfo['id']) ? false : $listInfo;
}
- function editWebsite($websiteId, $listInfo=''){
-
+ function editWebsite($websiteId, $listInfo=[]) {
$websiteId = intval($websiteId);
if(!empty($websiteId)){
if(empty($listInfo)){
$listInfo = $this->__getWebsiteInfo($websiteId);
- $listInfo['oldName'] = $listInfo['name'];
}
+
$listInfo['title'] = stripslashes($listInfo['title']);
$listInfo['description'] = stripslashes($listInfo['description']);
$listInfo['keywords'] = stripslashes($listInfo['keywords']);
$this->set('post', $listInfo);
- # get all users
- if(isAdmin()){
+ // get all users
+ if(isAdmin()) {
$userCtrler = New UserController();
$userList = $userCtrler->__getAllUsers();
$this->set('userList', $userList);
$this->set('isAdmin', 1);
}
- $this->render('website/edit');
+ $propertyList = $this->__getAllAnalyticProperties(TRUE);
+ $this->set('propertyList', $propertyList);
+
+ $this->set('editAction', 'update');
+ $this->render('website/edit_website');
exit;
- }
+ }
+
$this->listWebsites([]);
}
- function updateWebsite($listInfo, $apiCall = false){
+ function updateWebsite($listInfo, $apiCall=false) {
+ $listInfo['url'] = trim($listInfo['url']);
+ $listInfo['name'] = trim($listInfo['name']);
// check whether admin or api calll
if (isAdmin() || $apiCall) {
@@ -364,9 +381,9 @@ function updateWebsite($listInfo, $apiCall = false){
$listInfo['name'] = strip_tags($listInfo['name']);
$this->set('post', $listInfo);
$errMsg['name'] = formatErrorMsg($this->validate->checkBlank($listInfo['name']));
- $errMsg['url'] = formatErrorMsg($this->validate->checkBlank($listInfo['url']));
+ $errMsg['url'] = formatErrorMsg($this->validate->checkUrl($listInfo['url']));
$listInfo['url'] = addHttpToUrl($listInfo['url']);
- $statusVal = isset($listInfo['status']) ? "status = " . intval($listInfo['status']) ."," : "";
+ $statusVal = isset($listInfo['status']) ? "status = " . intval($listInfo['status']) ."," : "";
// check limit
if(!$this->validate->flagErr && !empty($listInfo['user_id'])){
@@ -385,13 +402,11 @@ function updateWebsite($listInfo, $apiCall = false){
}
// verify the form
- if(!$this->validate->flagErr){
+ if(!$this->validate->flagErr) {
- if(strtolower($listInfo['name']) != strtolower($listInfo['oldName'])){
- if ($this->__checkName($listInfo['name'], $userId)) {
- $errMsg['name'] = formatErrorMsg($this->spTextWeb['Website already exist']);
- $this->validate->flagErr = true;
- }
+ if ($this->__checkName($listInfo['name'], $userId, $listInfo['id'])) {
+ $errMsg['name'] = formatErrorMsg($this->spTextWeb['Website already exist']);
+ $this->validate->flagErr = true;
}
if ($this->__checkWebsiteUrl($listInfo['url'], $listInfo['id'])) {
@@ -432,8 +447,7 @@ function updateWebsite($listInfo, $apiCall = false){
} else {
$this->set('errMsg', $errMsg);
$this->editWebsite($listInfo['id'], $listInfo);
- }
-
+ }
}
# func to crawl meta data of a website
@@ -499,7 +513,6 @@ public static function crawlMetaData($websiteUrl, $keyInput='', $pageContent='',
}
public static function addInputValue($value, $col) {
-
$value = removeNewLines($value);
?>
-
- | - | + | + | @@ -238,9 +238,7 @@ | Moz | - | Alexa | Alexa | Bing | Bing | @@ -256,11 +254,9 @@ $rangeFromTime = date('Y-m-d', strtotime('-14 days', strtotime($fromTime))); $timeArg = "&from_time=$rangeFromTime&to_time=$toTime"; $googleRankLink = scriptAJAXLinkHrefDialog('rank.php', 'content', "sec=reports&website_id=".$websiteInfo['id'] . $timeArg, $websiteInfo['mozrank']); - $alexaRankLink = scriptAJAXLinkHrefDialog('rank.php', 'content', "sec=reports&website_id=".$websiteInfo['id'] . $timeArg, $websiteInfo['alexarank']); $daLink = scriptAJAXLinkHrefDialog('rank.php', 'content', "sec=reports&website_id=".$websiteInfo['id'] . $timeArg, $websiteInfo['domain_authority']); $paLink = scriptAJAXLinkHrefDialog('rank.php', 'content', "sec=reports&website_id=".$websiteInfo['id'] . $timeArg, $websiteInfo['page_authority']); $googleBackLInk = scriptAJAXLinkHrefDialog('backlinks.php', 'content', "sec=reports&website_id=".$websiteInfo['id'] . $timeArg, $websiteInfo['google']['backlinks']); - $alexaBackLInk = scriptAJAXLinkHrefDialog('backlinks.php', 'content', "sec=reports&website_id=".$websiteInfo['id'] . $timeArg, $websiteInfo['alexa']['backlinks']); $bingBackLInk = scriptAJAXLinkHrefDialog('backlinks.php', 'content', "sec=reports&website_id=".$websiteInfo['id'] . $timeArg, $websiteInfo['msn']['backlinks']); $googleIndexLInk = scriptAJAXLinkHrefDialog('saturationchecker.php', 'content', "sec=reports&website_id=".$websiteInfo['id'] . $timeArg, $websiteInfo['google']['indexed']); $bingIndexLInk = scriptAJAXLinkHrefDialog('saturationchecker.php', 'content', "sec=reports&website_id=".$websiteInfo['id'] . $timeArg, $websiteInfo['msn']['indexed']); @@ -276,9 +272,7 @@- | - | diff --git a/themes/classic/views/report/graph.ctp.php b/themes/classic/views/report/graph.ctp.php index 9e8fcda8..528e486e 100644 --- a/themes/classic/views/report/graph.ctp.php +++ b/themes/classic/views/report/graph.ctp.php @@ -21,4 +21,4 @@ function drawChart() { chart.draw(data, options); } - \ No newline at end of file + \ No newline at end of file diff --git a/themes/classic/views/review/edit_review_link.ctp.php b/themes/classic/views/review/edit_review_link.ctp.php index eccd7da1..06f7ca5a 100644 --- a/themes/classic/views/review/edit_review_link.ctp.php +++ b/themes/classic/views/review/edit_review_link.ctp.php @@ -39,7 +39,7 @@ | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
: | - | @@ -84,4 +84,18 @@
: | @@ -99,7 +99,7 @@ } $baseColCount = count($colList); -$colCount = ($baseColCount * 3) -1 ; +$colCount = ($baseColCount * 3); ?>+ | + | ||||||
---|---|---|---|---|---|---|---|---|
- + + + | - + + | ++ + + + | $colVal){ @@ -185,8 +194,8 @@ $rankDiffTxt = ""; } - $prevRankLink = scriptAJAXLinkHrefDialog($pageScriptPath, 'content', $scriptLink . "&sec=viewDetailedReports", $prevRank); - $currRankLink = scriptAJAXLinkHrefDialog($pageScriptPath, 'content', $scriptLink . "&sec=viewDetailedReports", $currRank); + $prevRankLink = scriptAJAXLinkHrefDialog($pageScriptPath, 'content', $scriptLink . "&sec=viewDetailedReports", round($prevRank, 2)); + $currRankLink = scriptAJAXLinkHrefDialog($pageScriptPath, 'content', $scriptLink . "&sec=viewDetailedReports", round($currRank, 2)); $graphLink = scriptAJAXLinkHrefDialog($pageScriptPath, 'content', $scriptLink . "&sec=viewGraphReports&attr_type=$colName", ' ', 'graphicon'); // if pdf report remove links diff --git a/themes/classic/views/review/review_reports.ctp.php b/themes/classic/views/review/review_reports.ctp.php index 37c0db03..0754ae24 100644 --- a/themes/classic/views/review/review_reports.ctp.php +++ b/themes/classic/views/review/review_reports.ctp.php @@ -1,4 +1,7 @@ - +||||||
: |
+
+ Eg: + |