Ïnitial Commit App
This commit is contained in:
parent
ebde8bc052
commit
f9dee33e2f
26 changed files with 6860 additions and 0 deletions
204
assets/css/custom.css
Normal file
204
assets/css/custom.css
Normal file
|
@ -0,0 +1,204 @@
|
|||
.remove-sucees-message{display: none;}
|
||||
/********************************************
|
||||
****** Flash notice css start *******
|
||||
*********************************************/
|
||||
/* flash */
|
||||
.inline-flash-wrapper{position:fixed;z-index:999999999;bottom:1.6rem;display:none;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:end;-webkit-align-items:flex-end;-ms-flex-align:end;align-items:flex-end;width:100%;pointer-events:none}.inline-flash-wrapper--is-visible{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.inline-flash{position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin:0 1.6rem;background:rgba(0,0,0,.88);-webkit-box-shadow:0 0 0 1px rgba(63,63,68,.05),0 1px 3px 0 rgba(63,63,68,.15);box-shadow:0 0 0 1px rgba(63,63,68,.05),0 1px 3px 0 rgba(63,63,68,.15);border-radius:3px;color:#fff;cursor:default;pointer-events:auto;font-size:1.6rem;font-weight:400;line-height:2.4rem}.inline-flash__message{padding:.8rem 1.6rem;margin-bottom:0;margin-top:0}p{margin:0;display:block;
|
||||
/*-webkit-margin-before:1em;-webkit-margin-after:1em;*/
|
||||
|
||||
-webkit-margin-start:0;-webkit-margin-end:0}.inline-flash-wrapper.animated{-webkit-animation-duration:2s;animation-duration:2s;-webkit-animation-fill-mode:both;animation-fill-mode:both}@-webkit-keyframes bounceInUp{0%{opacity:0;-webkit-transform:translateY(2000px);transform:translateY(2000px)}60%{opacity:1;-webkit-transform:translateY(-30px);transform:translateY(-30px)}80%{-webkit-transform:translateY(10px);transform:translateY(10px)}100%{-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes bounceInUp{0%{opacity:0;-webkit-transform:translateY(2000px);-ms-transform:translateY(2000px);transform:translateY(2000px)}60%{opacity:1;-webkit-transform:translateY(-30px);-ms-transform:translateY(-30px);transform:translateY(-30px)}80%{-webkit-transform:translateY(10px);-ms-transform:translateY(10px);transform:translateY(10px)}100%{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}}.inline-flash-wrapper.bounceInUp{-webkit-animation-name:bounceInUp;animation-name:bounceInUp}@media screen and (min-width:768px){.inline-flash--nav-offset{margin-left:24rem}}@media (min-width:640px){.inline-flash{font-size:2rem;line-height:2.8rem}}
|
||||
/* error */
|
||||
.inline-flash.error{background:-webkit-gradient(linear,left top,left bottom,from(#e6391a),to(#d53417));background:linear-gradient(to bottom,#e6391a,#d53417);border-color:background:rgba(255,0,0,.88);-webkit-box-shadow:inset 0 1px 0 0 #e84528;box-shadow:inset 0 1px 0 0 #e84528}
|
||||
/* add other color flash here */
|
||||
/********************************************
|
||||
****** Flash notice css start Ene *******
|
||||
*********************************************/
|
||||
/*added by Mazhar front*/
|
||||
.Polaris-Banner-hol{
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: -moz-box;
|
||||
display: -moz-flex;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-moz-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
-moz-box-direction: normal;
|
||||
-webkit-flex-flow: row wrap;
|
||||
-moz-flex-flow: row wrap;
|
||||
-ms-flex-flow: row wrap;
|
||||
flex-flow: row wrap;
|
||||
-webkit-box-align: justify;
|
||||
-moz-box-align: justify;
|
||||
-webkit-box-pack: justify;
|
||||
-moz-box-pack: justify;
|
||||
-ms-flex-pack: justify;
|
||||
-webkit-justify-content: space-between;
|
||||
-moz-justify-content: space-between;
|
||||
-ms-justify-content: space-between;
|
||||
justify-content: space-between;
|
||||
-webkit-box-align: start;
|
||||
-moz-box-align: start;
|
||||
-ms-flex-align: start;
|
||||
-webkit-align-items: flex-start;
|
||||
-moz-flex-align: flex-start;
|
||||
-ms-flex-align: flex-start;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.Polaris-Banner{
|
||||
background-color: #fff !important;
|
||||
box-shadow: none !important;
|
||||
border: 1px solid #c1c1c1;
|
||||
border-radius: 4px;
|
||||
flex:auto;
|
||||
flex-direction:column;
|
||||
}
|
||||
.Polaris-Heading {
|
||||
font-size: 1.6rem;
|
||||
/*margin: 0 0 10px 0;*/
|
||||
}
|
||||
.Polaris-Banner-head{
|
||||
flex-basis: 50%;
|
||||
margin: 10px 0 15px 0;
|
||||
text-indent: 200px;
|
||||
|
||||
}
|
||||
.Polaris-Banner-head span{
|
||||
display:block;
|
||||
margin:0 0 5px 0;
|
||||
color:#212b36;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.Polaris-Banner-head p.grey-text{
|
||||
color:#adb5bd;
|
||||
margin:0 0 10px 0;
|
||||
}
|
||||
.Polaris-Banner p.enable-banner{
|
||||
color:#212b36;
|
||||
margin: 0 0 10px 7px;
|
||||
}
|
||||
/********** Added by Ghulam Fareed ********/
|
||||
.onoffswitch {
|
||||
position: relative; width: 90px;
|
||||
margin: 0 0 0 25px;
|
||||
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
|
||||
}
|
||||
.onoffswitch-checkbox {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.onoffswitch-label {
|
||||
display: block; overflow: hidden; cursor: pointer;
|
||||
border-radius: 20px;
|
||||
width:60px;
|
||||
}
|
||||
.onoffswitch-inner {
|
||||
display: block; width: 200%; margin-left: -100%;
|
||||
transition: margin 0.3s ease-in 0s;
|
||||
}
|
||||
.onoffswitch-inner:before, .onoffswitch-inner:after {
|
||||
display: block;
|
||||
float: left;
|
||||
width: 50%;
|
||||
height: 26px !important;
|
||||
padding: 0;
|
||||
line-height: 25px !important;
|
||||
font-size: 14px;
|
||||
color: white;
|
||||
font-family: Trebuchet, Arial, sans-serif;
|
||||
font-weight: bold;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.onoffswitch-inner:before {
|
||||
content: "ON";
|
||||
padding: 2px 0 0 7px;
|
||||
font-size: 12px;
|
||||
background-color:#95bf47; color: #FFFFFF;
|
||||
}
|
||||
.onoffswitch-inner:after {
|
||||
content: "OFF";
|
||||
padding: 2px 7px 0 0;
|
||||
font-size: 12px;
|
||||
background-color: #dc3545; color: #ffffff;
|
||||
text-align: right;
|
||||
}
|
||||
.onoffswitch-switch {
|
||||
display: block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
/* margin: 6px; */
|
||||
background: #FFFFFF;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
/* bottom: 0; */
|
||||
margin: 1px 3px 0 0;
|
||||
right: 64px;
|
||||
border-radius: 50%;
|
||||
transition: all 0.3s ease-in 0s;
|
||||
}
|
||||
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
|
||||
margin-left: 0;
|
||||
}
|
||||
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
|
||||
right: 31px;
|
||||
}
|
||||
.Polaris-Page {
|
||||
margin: 0 auto;
|
||||
padding: 0 1.5rem !important;
|
||||
max-width: 99.8rem;
|
||||
}
|
||||
.banner-tick {
|
||||
width: 7px;
|
||||
height: 14px;
|
||||
border-right: 2px solid #95BF47;
|
||||
border-bottom: 2px solid #95BF47;
|
||||
-webkit-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
margin: -9px 7px 0 0;
|
||||
display: inline-block;
|
||||
}
|
||||
@media (max-width: 767px){
|
||||
.Polaris-Banner-head{
|
||||
flex-basis: 100%!important;
|
||||
text-indent: 0px!important;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.Polaris-Banner label{
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
.Polaris-Banner input[type=text].input-text{
|
||||
margin: 0 0 10px 0;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #c1c1c1;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.Polaris-Banner input[type=text].input-text:focus{
|
||||
outline:0;
|
||||
border:1px solid #777272;
|
||||
}
|
||||
.Polaris-Banner input[type=email].input-text{
|
||||
margin: 0 0 10px 0;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #c1c1c1;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.Polaris-Banner input[type=email].input-text:focus{
|
||||
outline:0;
|
||||
border:1px solid #777272;
|
||||
}
|
||||
|
||||
.Polaris-Banner p.cooloes-text{
|
||||
color:#212b36;
|
||||
margin: 0 0 10px 7px;
|
||||
}
|
11
assets/css/index.html
Normal file
11
assets/css/index.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
5020
assets/css/polaris.css
Normal file
5020
assets/css/polaris.css
Normal file
File diff suppressed because it is too large
Load diff
11
assets/index.html
Normal file
11
assets/index.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
128
assets/js/custom.js
Normal file
128
assets/js/custom.js
Normal file
|
@ -0,0 +1,128 @@
|
|||
"use strict";
|
||||
/****************************
|
||||
* SOME COMMON SVG CONSTANT *
|
||||
****************************/
|
||||
var SVG_LOADER = '<svg viewBox="0 0 20 20" class="Polaris-Spinner Polaris-Spinner--colorInkLightest Polaris-Spinner--sizeSmall" aria-label="Loading" role="status"><path d="M7.229 1.173a9.25 9.25 0 1 0 11.655 11.412 1.25 1.25 0 1 0-2.4-.698 6.75 6.75 0 1 1-8.506-8.329 1.25 1.25 0 1 0-.75-2.385z"></path></svg>';
|
||||
/****************************
|
||||
* SOME COMMON SVG CONSTANT*
|
||||
****************************/
|
||||
|
||||
/*
|
||||
*
|
||||
* @param string $message
|
||||
* @returns {undefined} show flash message
|
||||
*/
|
||||
function flashNotice($message, $class) {
|
||||
$class = ($class != undefined) ? $class : '';
|
||||
var flashMsgHtml = '<div class="inline-flash-wrapper animated bounceInUp inline-flash-wrapper--is-visible ourFlashMsg"><div class="inline-flash ' + $class + ' "><p class="inline-flash__message">' + $message + '</p></div></div>';
|
||||
if ($('.ourFlashMsg').length) {
|
||||
$('.ourFlashMsg').remove();
|
||||
}
|
||||
$("body").append(flashMsgHtml);
|
||||
setTimeout(function () {
|
||||
if ($('.ourFlashMsg').length) {
|
||||
$('.ourFlashMsg').remove();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param {string} $className
|
||||
* @returns {undefined} show loader
|
||||
*/
|
||||
function loading_show($selector) {
|
||||
$($selector).addClass("Polaris-Button--loading").html('<span class="Polaris-Button__Content"><span class="Polaris-Button__Spinner">' + SVG_LOADER + '</span><span>Loading</span></span>').fadeIn('fast').attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} $className
|
||||
* @param {string} $buttonName
|
||||
* @returns {undefined} hide loader
|
||||
*/
|
||||
function loading_hide($selector, $buttonName, $buttonIcon) {
|
||||
if ($buttonIcon != undefined) {
|
||||
$buttonIcon = '<span class="Polaris-Button__Icon"><span class="Polaris-Icon">' + $buttonIcon + '</span></span>'
|
||||
} else {
|
||||
$buttonIcon = '';
|
||||
}
|
||||
|
||||
$($selector).removeClass("Polaris-Button--loading").html('<span class="Polaris-Button__Content">' + $buttonIcon + '<span>' + $buttonName + '</span></span>').removeAttr("disabled");
|
||||
}
|
||||
|
||||
$(document).on('click', '.close-message', function () {
|
||||
$('.remove-sucees-message').hide();
|
||||
});
|
||||
|
||||
|
||||
|
||||
function removeCode(thisObj, data_key) {
|
||||
var current = $(thisObj);
|
||||
var btnText = current.html();
|
||||
loading_show(current);
|
||||
var deleteAjax = function deleteAjax(){
|
||||
loading_show(thisObj);
|
||||
$.ajax({
|
||||
url: "ajax_actions.php",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {method_name: 'remove_code', data_key: data_key, shop: shop},
|
||||
success: function (response) {
|
||||
if (response['result'] == 'success') {
|
||||
flashNotice(response['msg']);
|
||||
$('.remove-sucees-message').show();
|
||||
$('.remove-sucees-message').css({'display': 'flex'});
|
||||
}
|
||||
loading_hide(current, btnText);
|
||||
},
|
||||
error: function () {
|
||||
flashNotice('Please try again!','error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(mode == 'live'){
|
||||
ShopifyApp.Modal.confirm({
|
||||
title: 'Uninstall',
|
||||
message: 'Are you sure you want to remove? This action cannot be reversed.',
|
||||
okButton: 'Delete',
|
||||
cancelButton: 'Cancel',
|
||||
style: "danger"
|
||||
}, function (result) {
|
||||
if (result) {
|
||||
$('.ui-button.close-modal.btn-destroy-no-hover').addClass("ui-button ui-button--destructive js-btn-loadable is-loading disabled");
|
||||
deleteAjax();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
var r = confirm('Are you sure you want to remove? This action cannot be reversed.');
|
||||
if (r == true) {
|
||||
deleteAjax();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCheckedVal(switchval,userdomain,useremail,datakey){
|
||||
$.ajax({
|
||||
url: "ajax_actions.php",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {method_name: 'change_appStatus', data_status: switchval, user_name:userdomain, user_email:useremail, data_key:datakey, shop: shop},
|
||||
beforeSend: function(){
|
||||
$('#myonoffswitch').prop('disabled', true);
|
||||
},
|
||||
complete: function(){
|
||||
$('#myonoffswitch').prop('disabled', false);
|
||||
},
|
||||
success: function (response) {
|
||||
if (response['result'] == 'success') {
|
||||
$(".enable-banner").html(response['msg']);
|
||||
$('#user_key').val(response['key']);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
flashNotice('Please try again!','error');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
11
assets/js/index.html
Normal file
11
assets/js/index.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
4
assets/js/jquery-2.1.1.min.js
vendored
Normal file
4
assets/js/jquery-2.1.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
566
include/common_function.php
Normal file
566
include/common_function.php
Normal file
|
@ -0,0 +1,566 @@
|
|||
<?php
|
||||
|
||||
class common_function {
|
||||
|
||||
protected $current_store_obj = null;
|
||||
protected $store_user_id = null;
|
||||
protected $store_name = null;
|
||||
protected $store_email = null;
|
||||
protected $app_status = null;
|
||||
protected $app_plan = null;
|
||||
protected $is_charge_approve = '';
|
||||
protected $money_format = null;
|
||||
protected $currency = null;
|
||||
protected $shop_plan = '';
|
||||
protected $timezone = '';
|
||||
public $db_connection = null;
|
||||
public $apisecrekkey = '$2y$10$9ygTfodVBVM0XVCdyzEUK.0FIuLnJT0D42sIE6dIu9r/KY3XaXXyS';
|
||||
protected $last_query = '';
|
||||
|
||||
public function __construct($shop = '') {
|
||||
if ($this->db_connection == null) {
|
||||
$db_connection = new DB_Class();
|
||||
$this->db_connection = $GLOBALS['conn'];
|
||||
}
|
||||
|
||||
if ($shop != '') {
|
||||
$this->set_user_data($shop);
|
||||
}
|
||||
}
|
||||
|
||||
public function set_user_data($shop) {
|
||||
$selected_field = '*';
|
||||
$where = array('shop' => $shop, 'status' => '1');
|
||||
$user_store = $this->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
if (!empty($user_store)) {
|
||||
$this->current_store_obj = $user_store;
|
||||
$this->store_user_id = $user_store['store_user_id'];
|
||||
$this->store_name = $user_store['name'];
|
||||
$this->store_email = $user_store['email'];
|
||||
$this->app_status = ((!empty($user_store['app_status'])) ? $user_store['app_status'] : "");
|
||||
$this->app_plan = ((!empty($user_store['app_plan'])) ? $user_store['app_plan'] : "");
|
||||
$this->shop_plan = $user_store['shop_plan'];
|
||||
$this->money_format = $user_store['money_format'];
|
||||
$this->currency = $user_store['currency'];
|
||||
$this->charge_approve = ((!empty($user_store['charge_approve'])) ? $user_store['charge_approve'] : "");
|
||||
$this->timezone = $user_store['iana_timezone'];
|
||||
}
|
||||
}
|
||||
|
||||
public function get_store_detail_obj() {
|
||||
if ($this->current_store_obj != null) {
|
||||
return $this->current_store_obj;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_store_user_id() {
|
||||
return $this->store_user_id;
|
||||
}
|
||||
|
||||
public function get_store_name() {
|
||||
return $this->store_name;
|
||||
}
|
||||
|
||||
public function get_store_email() {
|
||||
return $this->store_email;
|
||||
}
|
||||
|
||||
public function get_app_status() {
|
||||
return $this->app_status;
|
||||
}
|
||||
|
||||
public function get_app_plan() {
|
||||
return $this->app_plan;
|
||||
}
|
||||
|
||||
public function get_shop_plan() {
|
||||
return $this->shop_plan;
|
||||
}
|
||||
|
||||
public function get_is_charge_approve() {
|
||||
return $this->charge_approve;
|
||||
}
|
||||
|
||||
public function get_currency() {
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
public function get_timezone() {
|
||||
return $this->timezone;
|
||||
}
|
||||
|
||||
function insert($table, $fields) {
|
||||
$columns = $values = array();
|
||||
foreach ($fields as $key => $value) {
|
||||
$columns[] = $key;
|
||||
$values[] = $value;
|
||||
}
|
||||
$insert_query = "INSERT INTO $table" . ' (' . implode(',', $columns) . ") VALUES('" . implode("','", $values) . "')";
|
||||
$this->query($insert_query);
|
||||
return $this->db_connection->insert_id;
|
||||
}
|
||||
|
||||
function insert_on_duplicate_update($table, $fields) {
|
||||
$insert_columns = $values = array();
|
||||
$update_columns = '';
|
||||
foreach ($fields as $key => $value) {
|
||||
$insert_columns[] = $key;
|
||||
$values[] = $value;
|
||||
if ($key != 'created_on') {
|
||||
$update_columns .= $key . "='$value',";
|
||||
}
|
||||
}
|
||||
$insert_query = "INSERT INTO $table" . ' (' . implode(',', $insert_columns) . ") VALUES('" . implode("','", $values) . "')";
|
||||
$update_query = "UPDATE " . rtrim($update_columns, ",");
|
||||
|
||||
$insert_on_duplicate_update_query = $insert_query . " ON DUPLICATE KEY " . $update_query . ";";
|
||||
|
||||
$this->query($insert_on_duplicate_update_query);
|
||||
|
||||
return $this->db_connection->insert_id;
|
||||
}
|
||||
|
||||
function update($table, $fields, $where, $limit = NULL) {
|
||||
$update_query = "UPDATE $table SET ";
|
||||
$columns = '';
|
||||
foreach ($fields as $key => $value) {
|
||||
$columns .= $key . "='$value',";
|
||||
}
|
||||
|
||||
$where = $this->prepare_where_condition($where);
|
||||
|
||||
if ($where == '') {
|
||||
echo "<pre>update without where condition not allowed</pre>";
|
||||
exit;
|
||||
}
|
||||
|
||||
$update_query .= rtrim($columns, ",") . " $where ";
|
||||
|
||||
if (isset($limit) && is_numeric($limit) && $limit > 0) {
|
||||
$update_query .= "LIMIT $limit";
|
||||
}
|
||||
|
||||
$update_query .= " ;";
|
||||
return $this->query($update_query);
|
||||
}
|
||||
|
||||
function delete($table, $where, $limit = NULL) {
|
||||
|
||||
$where = $this->prepare_where_condition($where);
|
||||
|
||||
if ($where == '') {
|
||||
echo "<pre>delete without where condition not allowed</pre>";
|
||||
exit;
|
||||
}
|
||||
|
||||
$delete_query = "DELETE FROM $table $where ";
|
||||
|
||||
if (isset($limit) && is_numeric($limit) && $limit > 0) {
|
||||
$delete_query .= "LIMIT $limit";
|
||||
}
|
||||
|
||||
$delete_query .= " ;";
|
||||
|
||||
return $this->query($delete_query);
|
||||
}
|
||||
|
||||
function select_row($table, $selected_field = '*', $where = NULL) {
|
||||
|
||||
$where = $this->prepare_where_condition($where);
|
||||
|
||||
$sql = "SELECT " . $selected_field . " FROM " . $table . " " . $where . " LIMIT 1;";
|
||||
|
||||
$query_resource = $this->query($sql);
|
||||
|
||||
$table_data = array();
|
||||
|
||||
if ($query_resource && $query_resource->num_rows > 0) {
|
||||
$table_data = $query_resource->fetch_assoc();
|
||||
}
|
||||
return $table_data;
|
||||
}
|
||||
|
||||
function select_result($table, $selected_field = '*', $where = NULL, $orderBy = NULL, $groupBy = NULL, $limit = NULL, $offset = NULL) {
|
||||
|
||||
$where = $this->prepare_where_condition($where);
|
||||
|
||||
$sql = "SELECT " . $selected_field . " FROM " . $table . " " . $where;
|
||||
|
||||
if (isset($groupBy)) {
|
||||
$sql .= " GROUP BY " . $groupBy . " ";
|
||||
}
|
||||
if (isset($orderBy)) {
|
||||
$sql .= " ORDER BY " . $orderBy . " ";
|
||||
}
|
||||
if (isset($offset) && isset($limit)) {
|
||||
$sql .= " LIMIT " . $offset . "," . $limit;
|
||||
}
|
||||
if (isset($limit) && !isset($offset)) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
$sql .= ";";
|
||||
|
||||
$query_resource = $this->query($sql);
|
||||
|
||||
$table_data = array();
|
||||
|
||||
if ($query_resource && $query_resource->num_rows > 0) {
|
||||
while ($row = $query_resource->fetch_assoc()) {
|
||||
$table_data[] = $row;
|
||||
}
|
||||
}
|
||||
return $table_data;
|
||||
}
|
||||
|
||||
function prepare_where_condition($where_condition) {
|
||||
if (!isset($where_condition) || $where_condition == '') {
|
||||
$where_condition = '';
|
||||
} elseif (is_array($where_condition) && !empty($where_condition)) {
|
||||
$where = array();
|
||||
foreach ($where_condition as $field => $value) {
|
||||
$where[] = "$field = '$value'";
|
||||
}
|
||||
$where_condition = " WHERE " . implode(" AND ", $where);
|
||||
} else if (isset($where_condition) && is_string($where_condition)) {
|
||||
$where_condition = " WHERE " . $where_condition;
|
||||
}
|
||||
return $where_condition;
|
||||
}
|
||||
|
||||
function get_record_with_join($table, $selected_field = '', $where = NULL, $orderBy = NULL, $groupBy = NULL, $limit = NULL, $offset = NULL, $join_arr = array()) {
|
||||
$sql = "SELECT " . $selected_field . " FROM " . $table . "";
|
||||
if (!empty($join_arr)) {
|
||||
foreach ($join_arr as $join) {
|
||||
if ($join['join_type'] == '') {
|
||||
$sql .= " INNER JOIN " . $join['table'] . " ON " . $join['join_table_id'] . " = " . $join['from_table_id'];
|
||||
} else {
|
||||
$sql .= " " . $join['join_type'] . " " . $join['table'] . " ON " . $join['join_table_id'] . " = " . $join['from_table_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$where = $this->prepare_where_condition($where);
|
||||
|
||||
if ($where != '') {
|
||||
$sql .= " " . $where;
|
||||
}
|
||||
|
||||
if (isset($groupBy)) {
|
||||
$sql .= " GROUP BY " . $groupBy . " ";
|
||||
}
|
||||
if (isset($orderBy)) {
|
||||
$sql .= " ORDER BY " . $orderBy . " ";
|
||||
}
|
||||
if (isset($offset) && isset($limit)) {
|
||||
$sql .= " LIMIT " . $offset . "," . $limit;
|
||||
}
|
||||
if (isset($limit) && !isset($offset)) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
$sql .= ";";
|
||||
|
||||
$query_resource = $this->query($sql);
|
||||
$table_data = array();
|
||||
|
||||
if ($query_resource && $query_resource->num_rows > 0) {
|
||||
while ($row = $query_resource->fetch_assoc()) {
|
||||
$table_data[] = $row;
|
||||
}
|
||||
}
|
||||
return $table_data;
|
||||
}
|
||||
|
||||
function query($query) {
|
||||
$this->last_query = $query;
|
||||
|
||||
$query_resource_obj = $this->db_connection->query($query);
|
||||
|
||||
/* if mode is dev and query getting error than below block display the query
|
||||
* and stop execution of script
|
||||
*/
|
||||
if (!$query_resource_obj && MODE == 'dev') {
|
||||
echo "<pre>" . mysqli_error($this->db_connection) . "<br>" . "\n";
|
||||
print_r($query);
|
||||
echo "\n" . "<br>" . "</pre>";
|
||||
exit;
|
||||
}
|
||||
|
||||
return $query_resource_obj;
|
||||
}
|
||||
|
||||
function get_total_record($table, $where = NULL, $group_by = NULL, $join_arr = array()) {
|
||||
$where = $this->prepare_where_condition($where);
|
||||
$count = "COUNT(*)";
|
||||
if (isset($group_by)) {
|
||||
$count = "COUNT(DISTINCT $group_by)";
|
||||
}
|
||||
$sql = "SELECT $count as total_row FROM $table";
|
||||
|
||||
if (!empty($join_arr)) {
|
||||
foreach ($join_arr as $join) {
|
||||
if ($join['join_type'] == '') {
|
||||
$sql .= " INNER JOIN " . $join['table'] . " ON " . $join['join_table_id'] . " = " . $join['from_table_id'];
|
||||
} else {
|
||||
$sql .= " " . $join['join_type'] . " " . $join['table'] . " ON " . $join['join_table_id'] . " = " . $join['from_table_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql .= ' ' . $where . ';';
|
||||
$mysql_resource = $this->query($sql);
|
||||
if ($mysql_resource) {
|
||||
return $mysql_resource->fetch_row()['0'];
|
||||
} else {
|
||||
return '0';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Last query get
|
||||
* @return (string)
|
||||
*/
|
||||
public function last_query() {
|
||||
return $this->last_query;
|
||||
}
|
||||
|
||||
public function verify_webhook($data, $hmac_header) {
|
||||
$calculated_hmac = base64_encode(hash_hmac('sha256', $data, SHOPIFY_SECRET, true));
|
||||
return ($hmac_header == $calculated_hmac);
|
||||
}
|
||||
|
||||
function prepare_api_condition($api_main_url_arr, $url_param_arr = array(), $method = 'GET', $is_object = 1, $token = '', $shop = '', $request_headers = array()) {
|
||||
if ($this->current_store_obj != NULL) {
|
||||
$shop_info = $this->current_store_obj;
|
||||
$token = $shop_info['token'];
|
||||
$shop = $shop_info['shop'];
|
||||
}
|
||||
$shopify_api_version = '';
|
||||
$date = strtotime('-1 day', strtotime(date('Y-m-d')));
|
||||
$month = date('m', $date);
|
||||
$year = date('Y', $date);
|
||||
|
||||
switch ($month) {
|
||||
case $month <= 3:
|
||||
$shopify_api_version = $year . '-01';
|
||||
break;
|
||||
case $month <= 6:
|
||||
$shopify_api_version = $year . '-04';
|
||||
break;
|
||||
case $month <= 9:
|
||||
$shopify_api_version = $year . '-07';
|
||||
break;
|
||||
case $month <= 12:
|
||||
$shopify_api_version = $year . '-10';
|
||||
break;
|
||||
}
|
||||
$api_main_url_arr = ($token != '') ? array_merge(array('/admin/api/' . $shopify_api_version), $api_main_url_arr) : array_merge(array('/admin'), $api_main_url_arr);
|
||||
$api_main_url = ($token != '') ? implode('/', $api_main_url_arr) . '.json' : implode('/', $api_main_url_arr);
|
||||
return $this->api_call($token, $shop, $api_main_url, $url_param_arr, $method, $is_object, $request_headers);
|
||||
}
|
||||
|
||||
function api_call($token, $shop, $api_endpoint, $query = array(), $method = 'GET', $is_object, $request_headers) {
|
||||
$url = "https://" . $shop . $api_endpoint;
|
||||
if (!empty($query) && !is_null($query) && in_array($method, array('GET', 'DELETE'))) {
|
||||
$url = $url . "?" . http_build_query($query);
|
||||
} else {
|
||||
$url = $url;
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'ohShopify-php-api-client');
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
||||
|
||||
$request_headers[] = "";
|
||||
|
||||
if (!is_null($token) && $token != '')
|
||||
$request_headers[] = "X-Shopify-Access-Token: " . $token;
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);
|
||||
if ($method != 'GET' && in_array($method, array('POST', 'PUT'))) {
|
||||
if (is_array($query))
|
||||
$query = http_build_query($query);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
|
||||
}
|
||||
|
||||
$response = curl_exec($ch);
|
||||
if (count(preg_split("/\r\n\r\n|\n\n|\r\r/", $response)) == 3) {
|
||||
list(, $headers, $body) = preg_split("/\r\n\r\n|\n\n|\r\r/", $response, 3);
|
||||
} else {
|
||||
list($headers, $body) = preg_split("/\r\n\r\n|\n\n|\r\r/", $response, 2);
|
||||
}
|
||||
|
||||
$header_lines = preg_split("/\r\n|\n|\r/", $headers);
|
||||
$header = array();
|
||||
if (count(explode(' ', trim(array_shift($header_lines)), 3)) == '3') {
|
||||
list(, $header['http_status_code'], $header['http_status_message']) = explode(' ', trim(array_shift($header_lines)), 3);
|
||||
} else {
|
||||
list($header['http_status_code'], $header['http_status_message']) = explode(' ', trim(array_shift($header_lines)), 2);
|
||||
}
|
||||
|
||||
foreach ($header_lines as $header_line) {
|
||||
list($name, $value) = explode(':', $header_line, 2);
|
||||
$name = strtolower($name);
|
||||
$header[$name] = str_replace(array('<', '>'), '', trim($value));
|
||||
}
|
||||
|
||||
$error_number = curl_errno($ch);
|
||||
$error_message = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($error_number) {
|
||||
return $error_message;
|
||||
} else {
|
||||
if ($is_object) {
|
||||
return array('headers' => $header, 'body' => json_decode($body));
|
||||
} else {
|
||||
return array('headers' => $header, 'body' => json_decode($body, TRUE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function is_json($args) {
|
||||
json_decode($args);
|
||||
return (json_last_error() === JSON_ERROR_NONE);
|
||||
}
|
||||
|
||||
public function get_data_key($domain, $email) {
|
||||
$data = array(
|
||||
'domain' => $domain,
|
||||
'email' => $email,
|
||||
'user_email' => $email,
|
||||
'secret' => $this->apisecrekkey,
|
||||
'platform' => 'shopify',
|
||||
);
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://seersco.com/api/get-key-for-shopify",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$error_number = curl_errno($curl);
|
||||
$error_message = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
return json_decode($response, TRUE);
|
||||
}
|
||||
|
||||
public function snippest_insert($shop, $token, $domain, $email) {
|
||||
|
||||
$selected_field = 'data_key';
|
||||
$where = array('shop' => $shop, 'status' => '1');
|
||||
$store_row = $this->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
$old_script = '';
|
||||
$datakey = '';
|
||||
if(!empty($store_row)){
|
||||
$datakey = $store_row['data_key'];
|
||||
}
|
||||
|
||||
$response = $this->get_data_key($domain, $email);
|
||||
|
||||
$datakey = $response['key'];
|
||||
|
||||
$fields['data_key'] = $response['key'];
|
||||
$where = array('shop' => $shop);
|
||||
$last_id = $this->update(TABLE_USER_STORES, $fields, $where);
|
||||
|
||||
$arrsrc = ['https://cmp.seersco.com/script/cb.js', 'https://seers-application-assets.s3.amazonaws.com/scripts/cbattributes.js?key=' . $datakey . '&name=CookieXray'];
|
||||
$cbattrjspath = 'https://seers-application-assets.s3.amazonaws.com/scripts/cbattributes.js';
|
||||
$arrscriptexist = [false, false];
|
||||
|
||||
|
||||
//get all avialable tags
|
||||
$allscriptags = $this->prepare_api_condition(array('script_tags'), array(), 'GET', '0', $token, $shop);
|
||||
|
||||
//print_r($allscriptags);
|
||||
|
||||
if(!empty($allscriptags['body']) && !empty($allscriptags['body']['script_tags'])) {
|
||||
|
||||
foreach ($allscriptags['body']['script_tags'] as $thescript) {
|
||||
|
||||
if (strcasecmp($thescript['src'], $arrsrc[0]) === 0) {
|
||||
$arrscriptexist[0] = true;
|
||||
} else if (strcasecmp($thescript['src'], $arrsrc[1]) === 0) {
|
||||
$arrscriptexist[1] = true;
|
||||
} else if (stripos($thescript['src'], $cbattrjspath) !== false && strcasecmp($thescript['src'], $arrsrc[1]) !== 0) {
|
||||
$arrscriptexist[1] = false;
|
||||
//remove the script
|
||||
$scriptdel = $this->prepare_api_condition(array('script_tags', $thescript['id']), array(), 'DELETE', '0', $token, $shop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
foreach ($arrsrc as $sitind => $sitesrc) {
|
||||
|
||||
if (!$arrscriptexist[$sitind]) {
|
||||
|
||||
//add this src in scripts
|
||||
$scriptinsert = $this->prepare_api_condition(array('script_tags'), array('script_tag' => array( "event"=>"onload", "src"=>$sitesrc)), 'POST', '0', $token, $shop);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function plugin_active_inactive($shopdetail, $isative = 0){
|
||||
$postData = array(
|
||||
'domain' => $shopdetail['shop'],
|
||||
'isactive' => $isative,
|
||||
'secret' => $this->apisecrekkey,
|
||||
'platform' => 'shopify',
|
||||
'pluginname' => $shopdetail['name']
|
||||
);
|
||||
$request_headers = array(
|
||||
'Content-Type' => 'application/json',
|
||||
'Referer' => $shopdetail['shop'],
|
||||
);
|
||||
//$url = "https://seersco.backend/api/plugin-domain";
|
||||
$url = "https://cmp.seersco.com/api/plugin-domain";
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_HTTPHEADER => $request_headers,
|
||||
CURLOPT_POSTFIELDS => $postData
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$error_number = curl_errno($curl);
|
||||
$error_message = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$response =json_decode($response, TRUE);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
84
include/config.php
Normal file
84
include/config.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Configuration for: Database Connection
|
||||
* This is the place where your database login constants are saved
|
||||
*
|
||||
* DB_HOST: database host, usually it's "127.0.0.1" or "localhost", some servers also need port info
|
||||
* DB_NAME: name of the database. please note: database and database table are not the same thing
|
||||
* DB_USER: user for your database. the user needs to have rights for SELECT, UPDATE, DELETE and INSERT.
|
||||
* by the way, it's bad style to use "root", but for development it will work.
|
||||
* DB_PASS: the password of the above user
|
||||
* MODE : Project on local or server
|
||||
*/
|
||||
|
||||
if ($_SERVER['SERVER_NAME'] == 'localhost') {
|
||||
define("DB_HOST", "localhost");
|
||||
define("DB_NAME", "seers-cookie-consent");
|
||||
define("DB_USER", "root");
|
||||
define("DB_PASS", "");
|
||||
define('MODE', 'dev');
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
/* define site url and admin details */
|
||||
define('ABS_PATH', dirname(dirname(__FILE__)));
|
||||
define('SITE_URL', 'https://localhost/private-apps/seers-cookie-consent/');
|
||||
define('SITE_USER_URL', 'https://localhost/private-apps/seers-cookie-consent/user/');
|
||||
define('ASSETS_URL','https://localhost/private-apps/seers-cookie-consent/assets/');
|
||||
} elseif ($_SERVER['SERVER_NAME'] == 'gdpr-cookie-consent-banner-cookie-notice-seers.seersco.com') {
|
||||
define("DB_HOST", "seers-serverless-rds-production-cluster.cluster-cieqfdwbhtqi.eu-central-1.rds.amazonaws.com");
|
||||
define("DB_NAME", "seers_web_db");
|
||||
define("DB_USER", "seers_web_user");
|
||||
define("DB_PASS", "fCSsaZvX3M7XkEvxWQcXsqpAjXEJfPfEA243tjvtsJ9pccGuvA");
|
||||
define('MODE', 'live');
|
||||
|
||||
/* define site url and admin details */
|
||||
define('ABS_PATH', dirname(dirname(__FILE__)));
|
||||
define('SITE_URL', 'https://gdpr-cookie-consent-banner-cookie-notice-seers.seersco.com/');
|
||||
define('SITE_USER_URL', 'https://gdpr-cookie-consent-banner-cookie-notice-seers.seersco.com/user/');
|
||||
define('ASSETS_URL','https://gdpr-cookie-consent-banner-cookie-notice-seers.seersco.com/assets/');
|
||||
} else {
|
||||
echo 'Undefine host';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for: Shopify
|
||||
*/
|
||||
define("SHOPIFY_API_KEY", "f9a59ca1f7f63d4c0bb6427f26b1e746");
|
||||
define("SHOPIFY_SECRET", "2329cab0c3aaba09f2eeb7616ef85ec4");
|
||||
define("SHOPIFY_SCOPE", "read_themes,write_themes,write_script_tags,read_script_tags, read_analytics");
|
||||
define("SITE_PATH", "https://gdpr-cookie-consent-banner-cookie-notice-seers.seersco.com/index.php");
|
||||
|
||||
/*
|
||||
* Database connection
|
||||
* */
|
||||
class DB_Class {
|
||||
|
||||
function __construct() {
|
||||
if (!isset($GLOBALS['conn']) && empty($GLOBALS['conn'])) {
|
||||
$objdbconn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||
if (mysqli_connect_errno()) {
|
||||
echo "Failed : connect to MySQL: " . mysqli_connect_error();
|
||||
die;
|
||||
}
|
||||
$GLOBALS['conn'] = $objdbconn;
|
||||
mysqli_set_charset($objdbconn, "utf8mb4");
|
||||
return $objdbconn;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$protocol = isset($_SERVER["HTTPS"]) ? 'https://' : 'http://';
|
||||
define('PROTOCOL', $protocol);
|
||||
|
||||
define('SITE_NAME', 'Seers Cookie Consent');
|
||||
define('SITE_EMAIL', 'alex.reed@seersco.com');
|
||||
/**
|
||||
* Table name constant
|
||||
*/
|
||||
define('TABLE_USER_STORES', 'user_stores');
|
||||
|
||||
/* Database formate Date decalre */
|
||||
define('DATE', date('Y-m-d H:i:s'));
|
11
include/index.html
Normal file
11
include/index.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
122
index.php
Normal file
122
index.php
Normal file
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
include_once 'include/config.php';
|
||||
include_once 'include/common_function.php';
|
||||
|
||||
/* * ****************************************
|
||||
* WEBHOOK ARRAY *
|
||||
* **************************************** */
|
||||
/*
|
||||
* When we need to add webhook you need to add topic into
|
||||
* array list and need to make(add) file with same as topic name
|
||||
* just replace "/" (slash) with "-" (hypehn,minus) sign
|
||||
* for e.g app-unistalled.php
|
||||
*/
|
||||
|
||||
$__webhook_arr = array(
|
||||
'app/uninstalled',
|
||||
'shop/update'
|
||||
);
|
||||
|
||||
/* * ****************************************
|
||||
* WEBHOOK ARRAY END *
|
||||
* **************************************** */
|
||||
|
||||
/* create object common function */
|
||||
$cf_obj = new common_function();
|
||||
|
||||
if (isset($_REQUEST['shop']) && $_REQUEST['shop'] != "") {
|
||||
$shop = isset($_POST['shop']) ? $_POST['shop'] : $_GET['shop'];
|
||||
$selected_field = 'store_user_id, token';
|
||||
$where = array('shop' => $shop, 'status' => '1');
|
||||
$store_row = $cf_obj->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
|
||||
if (isset($_GET['code'])) {
|
||||
$url_param_arr = array('client_id' => SHOPIFY_API_KEY, 'client_secret' => SHOPIFY_SECRET, 'code' => $_GET['code']);
|
||||
$responce = $cf_obj->prepare_api_condition(array('oauth', 'access_token'), $url_param_arr, 'POST', 0, '', $shop);
|
||||
|
||||
$token = $responce['body']['access_token'];
|
||||
if (!empty($store_row)) {
|
||||
header('Location: ' . SITE_USER_URL . '?shop=' . $shop);
|
||||
} else {
|
||||
$responce = $cf_obj->prepare_api_condition(array('shop'), array(), 'GET', 0, $token, $shop);
|
||||
|
||||
$shopinfo = $responce['body']['shop'];
|
||||
/* Register Webhook */
|
||||
if (!empty($__webhook_arr)) {
|
||||
foreach ($__webhook_arr as $topic) {
|
||||
$file_name = str_replace('/', '-', $topic) . '.php';
|
||||
$url_param_arr = array('webhook' => array(
|
||||
'topic' => $topic,
|
||||
'address' => SITE_URL . 'webhook/' . $file_name,
|
||||
'format' => 'json'
|
||||
));
|
||||
$cf_obj->prepare_api_condition(array('webhooks'), $url_param_arr, 'POST', 0, $token, $shop);
|
||||
}
|
||||
}
|
||||
|
||||
$email = $shopinfo['email'];
|
||||
$domain = $shopinfo['domain'];
|
||||
$timezone = $shopinfo['iana_timezone'];
|
||||
$shop_name = $shopinfo['name'];
|
||||
$shop_details = array(
|
||||
'email' => $email,
|
||||
'name' => mysqli_real_escape_string($cf_obj->db_connection, $shopinfo['name']), /* e.g example */
|
||||
'shop' => $shop, /* e.g example.myshopify.com */
|
||||
'domain' => $shopinfo['domain'],
|
||||
'token' => $token,
|
||||
'owner' => $shopinfo['shop_owner'],
|
||||
'shop_plan' => $shopinfo['plan_name'],
|
||||
'money_format' => mysqli_real_escape_string($cf_obj->db_connection, strip_tags($shopinfo['money_format'])),
|
||||
'currency' => $shopinfo['currency'],
|
||||
'address1' => $shopinfo['address1'],
|
||||
'address2' => $shopinfo['address2'],
|
||||
'city' => $shopinfo['city'],
|
||||
'country_name' => $shopinfo['country_name'],
|
||||
'phone' => $shopinfo['phone'],
|
||||
'province' => $shopinfo['province'],
|
||||
'zip' => $shopinfo['zip'],
|
||||
'timezone' => $shopinfo['timezone'],
|
||||
'iana_timezone' => $shopinfo['iana_timezone'],
|
||||
'weight_unit' => $shopinfo['weight_unit'],
|
||||
'toggle_status' =>$shopinfo['toggle_status']
|
||||
);
|
||||
|
||||
$selected_field = '*';
|
||||
$where = array('shop' => $shop);
|
||||
$is_store_exist = $cf_obj->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
/* if store already available than */
|
||||
$fields = $shop_details;
|
||||
/* need to add bcoz its not exist in $shop_details array */
|
||||
$fields['status'] = '1';
|
||||
$fields['updated_on'] = DATE;
|
||||
if (!empty($is_store_exist)) {
|
||||
$where = array('shop' => $shop);
|
||||
$last_id = $cf_obj->update(TABLE_USER_STORES, $fields, $where);
|
||||
$store_user_id = $is_store_exist['store_user_id'];
|
||||
} else {
|
||||
/* need to add bcoz its not exist in $shop_details array */
|
||||
$fields['created_on'] = DATE;
|
||||
$store_user_id = $cf_obj->insert(TABLE_USER_STORES, $fields);
|
||||
}
|
||||
//active this plugin
|
||||
$cf_obj->plugin_active_inactive($fields, 1);
|
||||
$cf_obj->snippest_insert($shop, $token, $domain, $email);
|
||||
header('Location: ' . SITE_USER_URL . '?shop=' . $shop);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
/* Check store is active or not */
|
||||
if (!empty($store_row)) {
|
||||
header('Location: ' . SITE_USER_URL . '?shop=' . $shop);
|
||||
} else {
|
||||
$install_url = "https://" . $shop . "/admin/oauth/authorize?client_id=" . SHOPIFY_API_KEY . "&scope=" . urlencode(SHOPIFY_SCOPE) . "&redirect_uri=" . urlencode(SITE_PATH);
|
||||
header("Location: " . $install_url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo 'Directory access is forbidden.';
|
||||
exit;
|
||||
}
|
||||
?>
|
0
log/error.log
Normal file
0
log/error.log
Normal file
0
log/requests.log
Normal file
0
log/requests.log
Normal file
39
user/ajax_actions.php
Normal file
39
user/ajax_actions.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
/* include main config file file */
|
||||
include_once ('../include/config.php');
|
||||
/* include main client function file */
|
||||
include_once ('user_functions.php');
|
||||
|
||||
//ob_clean();
|
||||
|
||||
$is_bad_shop = 0;
|
||||
if (isset($_POST['shop']) && $_POST['shop'] != '') {
|
||||
|
||||
if(isset($_POST['is_analytics']) && $_POST['is_analytics']=='1'){
|
||||
include_once ('analytics.php');
|
||||
$uf_obj = new Analytics($_POST['shop']);
|
||||
}else{
|
||||
$uf_obj = new User_functions($_POST['shop']);
|
||||
}
|
||||
|
||||
$current_user = $uf_obj->get_store_detail_obj();
|
||||
|
||||
if (!empty($current_user)) {
|
||||
/* used for called function (comes from ajax call) */
|
||||
if (isset($_POST['method_name']) && $_POST['method_name'] != '') {
|
||||
$response = call_user_func(array($uf_obj, $_POST['method_name']));
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$is_bad_shop ++;
|
||||
}
|
||||
} else {
|
||||
$is_bad_shop ++;
|
||||
}
|
||||
|
||||
if ($is_bad_shop > 0) {
|
||||
$response = array('result' => 'fail', 'msg' => 'Opps! Bad request call!', 'code' => '403');
|
||||
echo json_encode($response);
|
||||
}
|
34
user/app_bridge.php
Normal file
34
user/app_bridge.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php if (MODE == 'live') { ?>
|
||||
<script src="https://cdn.shopify.com/s/assets/external/app.js"></script>
|
||||
<script type="text/javascript">
|
||||
var query_output = '';
|
||||
ShopifyApp.init({
|
||||
forceRedirect: true,
|
||||
apiKey: '<?php echo SHOPIFY_API_KEY; ?>',
|
||||
shopOrigin: 'https://<?php echo $shop; ?>'
|
||||
});
|
||||
ShopifyApp.ready(function () {
|
||||
ShopifyApp.Bar.initialize({
|
||||
buttons: {
|
||||
secondary: [{"label": "Dashboard", "href": "index.php?shop=<?php echo $shop; ?>"}]}
|
||||
});
|
||||
var shopifyQL = 'SHOW ua_browser_version, ua_os, ua_form_factor, ua_os_version, ua_browser, referrer_host, page_type, page_path, page_url, page_resource_id, referrer_host, referrer_name, referrer_path, referrer_url, referrer_source, utm_campaign_content, utm_campaign_term, utm_campaign_medium, utm_campaign_source, utm_campaign_name, location_country, location_region, location_city OVER day(timestamp) AS day FROM visits SINCE -7d UNTIL today ORDER BY day ASC';
|
||||
//var shopifyQL = 'SELECT * FROM shopify.online_store_sessions';
|
||||
var renderData = function (response) {
|
||||
query_output = response;
|
||||
console.log('renderData',JSON.stringify(response));
|
||||
// do amazing things here
|
||||
};
|
||||
var handleError = function (response) {
|
||||
console.log('handleError',response);
|
||||
// handle missing API errors here (missing scopes, back shopifyql, etc...)
|
||||
};
|
||||
ShopifyApp.Analytics.fetch({
|
||||
query: shopifyQL,
|
||||
success: renderData,
|
||||
error: handleError
|
||||
});
|
||||
});
|
||||
ShopifyApp.Bar.loadingOff();
|
||||
</script>
|
||||
<?php } ?>
|
18
user/error_log
Normal file
18
user/error_log
Normal file
|
@ -0,0 +1,18 @@
|
|||
[25-Aug-2020 18:44:43 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[25-Aug-2020 18:48:14 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[25-Aug-2020 18:49:17 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[31-Aug-2020 12:16:50 UTC] PHP Recoverable fatal error: Object of class common_function could not be converted to string in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/user_functions.php on line 45
|
||||
[31-Aug-2020 12:16:55 UTC] PHP Recoverable fatal error: Object of class common_function could not be converted to string in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/user_functions.php on line 45
|
||||
[31-Aug-2020 12:37:50 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[31-Aug-2020 12:38:14 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[31-Aug-2020 12:39:14 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[01-Sep-2020 04:30:07 UTC] PHP Parse error: syntax error, unexpected '}' in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/index.php on line 39
|
||||
[09-Sep-2020 06:50:13 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:50:34 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:50:58 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:51:14 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:53:05 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:59:39 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 07:02:12 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 07:03:51 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 07:05:03 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
3
user/footer.php
Normal file
3
user/footer.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
</div>
|
||||
</body>
|
||||
</html>
|
39
user/header.php
Normal file
39
user/header.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/* include main config file file */
|
||||
include_once ('../include/config.php');
|
||||
|
||||
/* include main client function file */
|
||||
include_once ('user_functions.php');
|
||||
/* client function class variable */
|
||||
if (isset($_REQUEST['shop']) && $_REQUEST['shop'] != '') {
|
||||
$shop = $_REQUEST['shop'];
|
||||
$uf_obj = new User_functions($shop);
|
||||
$current_user = $uf_obj->get_store_detail_obj();
|
||||
if (empty($current_user)) {
|
||||
header('Location:' . PAGE_404 . '');
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header('Location:' . PAGE_404 . '');
|
||||
exit;
|
||||
}
|
||||
$custom_client_mode_time = filemtime('../assets/css/custom.css');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo SITE_NAME; ?> | <?php echo $shop; ?></title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" media="screen" href="../assets/css/polaris.css" />
|
||||
<link rel="stylesheet" media="screen" href="../assets/css/custom.css?v=<?php echo $custom_client_mode_time; ?>" />
|
||||
|
||||
<!-- Js -->
|
||||
<script type="text/javascript">var shop = '<?php echo $shop; ?>'; var mode = '<?php echo MODE; ?>';</script>
|
||||
<script type="text/javascript" src="../assets/js/jquery-2.1.1.min.js"></script>
|
||||
<?php include_once('app_bridge.php'); ?>
|
||||
<script type="text/javascript" src="../assets/js/custom.js?v=<?php echo filemtime('../assets/js/custom.js'); ?>"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="Polaris-Page Polaris-Page--fullWidth">
|
74
user/index.php
Normal file
74
user/index.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
include_once('header.php');
|
||||
?>
|
||||
<div class="Polaris-Page__Content">
|
||||
<div class="Polaris-Banner">
|
||||
<p class="Polaris-Heading">Need any other help?</p>
|
||||
<p>We are always here to help you. Please <a class="Polaris-Link" href="mailto:<?php echo SITE_EMAIL; ?>" target="_blank">email us</a></p>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="Polaris-Banner-hol">
|
||||
<div class="Polaris-Banner-head"><span>Banner Settings</span>
|
||||
<p class="grey-text">Enable/disable banner in just one click.</p>
|
||||
</div>
|
||||
<div class="Polaris-Banner">
|
||||
<label>Domain URL:</label>
|
||||
<input class="input-text" type = "text" name="user_doamin" id="user_doamin" readonly value="<?php if(!empty($current_user['user_domain'])){ echo $current_user['user_domain']; }else{ echo $current_user['domain']; } ?>">
|
||||
<label>Email: *</label>
|
||||
<input class="input-text" type = "email" name="user_email" id="user_email" value="<?php if(!empty($current_user['user_email'])){ echo $current_user['user_email']; }else{ echo $current_user['email']; } ?>">
|
||||
<label>Domain Group ID:</label>
|
||||
<input class="input-text" type = "text" name="data_key" id="user_key" value="<?php echo @$current_user['data_key']; ?>" readonly>
|
||||
<p class="cooloes-text">CONSENT </p>
|
||||
<p class="cooloes-text">
|
||||
By using this plugin, you agree to the <a href='https://seersco.com/terms-and-conditions.html' target='_blank'>terms and condition</a> and <br> <a href='https://seersco.com/privacy-policy.html' target='_blank'>privacy policy</a>, and also agree Seers to use my email and url to <br> create an account and power the cookie banner.
|
||||
</p>
|
||||
<hr style="margin:0 auto 10px; border-bottom:.5px dotted #c1c1c1; width:95%">
|
||||
<p class="cooloes-text">You must enter Domain Url and Email to get a Consent Banner.</p>
|
||||
<?php if($current_user['toggle_status']==1){ ?>
|
||||
<p class="enable-banner"><span class ="banner-tick"></span> Banner is enabled on your store.<br><span style="margin-left:18px;"></span>Please refresh your store home page to see the effect. </p>
|
||||
<?php }else{?>
|
||||
<p class="enable-banner">Banner is disabled on your store.</p>
|
||||
<?php } ?>
|
||||
<div class="onoffswitch">
|
||||
<?php if($current_user['toggle_status']==1){ ?>
|
||||
|
||||
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked tabindex="0">
|
||||
<?php }else{ ?>
|
||||
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" tabindex="0">
|
||||
<?php } ?>
|
||||
<label class="onoffswitch-label" for="myonoffswitch">
|
||||
<span class="onoffswitch-inner"></span>
|
||||
<span class="onoffswitch-switch"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include_once('footer.php'); ?>
|
||||
<script>
|
||||
var switchStatus = false;
|
||||
|
||||
$("#myonoffswitch").on('change', function() {
|
||||
if ($(this).is(':checked')) {
|
||||
switchStatus = $(this).is(':checked');
|
||||
var user_doamin = $('#user_doamin').val();
|
||||
var user_email = $('#user_email').val();
|
||||
var data_key = $('#user_key').val();
|
||||
toggleCheckedVal(switchStatus,user_doamin,user_email,data_key);
|
||||
}
|
||||
else {
|
||||
switchStatus = $(this).is(':checked');
|
||||
var user_doamin = $('#user_doamin').val();
|
||||
var user_email = $('#user_email').val();
|
||||
var data_key = $('#user_key').val();
|
||||
toggleCheckedVal(switchStatus,user_doamin,user_email,data_key);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
224
user/user_functions.php
Normal file
224
user/user_functions.php
Normal file
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
|
||||
/* include common function */
|
||||
include_once (ABS_PATH . '/include/common_function.php');
|
||||
|
||||
class User_functions extends common_function {
|
||||
|
||||
/**
|
||||
* the function "__construct()" automatically starts whenever an object of this class is created,
|
||||
*/
|
||||
public function __construct($shop = '') {
|
||||
/* call parent's (common_function) constructor */
|
||||
parent::__construct($shop);
|
||||
}
|
||||
|
||||
/* When undefined method call that time this function will run */
|
||||
|
||||
public function __call($method, $args) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function remove_code($storeuserid = 0, $curshop = '') {
|
||||
|
||||
$store_user_id = $this->store_user_id;
|
||||
|
||||
if($storeuserid) {
|
||||
$store_user_id = $storeuserid;
|
||||
}
|
||||
|
||||
$response = array('result' => 'fail', 'msg' => 'Something went wrong');
|
||||
if (isset($store_user_id) && is_numeric($store_user_id) && $store_user_id > 0) {
|
||||
//by Shoaib actually in Post data_key is not coming then I will get the data_key from database of this current user
|
||||
$datakey = ((!empty($_POST['data_key'])) ? $_POST['data_key'] : "" );
|
||||
$token = '';
|
||||
$shop = '';
|
||||
|
||||
|
||||
if (empty($datakey)) {
|
||||
$selected_field = 'data_key, token, shop';
|
||||
$where = array('store_user_id' => $store_user_id);
|
||||
$user_store = $this->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
if (!empty($user_store)) {
|
||||
$datakey = $user_store['data_key'];
|
||||
$token = $user_store['token'];
|
||||
$shop = $user_store['shop'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$script = '<script data-key="' . $datakey . '" data-name="CookieXray" src="https://cmp.seersco.com/script/cb.js" type="text/javascript"></script>';
|
||||
//fix by Shoaib for scripts added in old way start
|
||||
$script = '<script(.*?)src="https://cmp.seersco.com/script/cb.js"(.*?)>(.*?)</script>';
|
||||
$script2 = '<script(.*?)src="https://seersco.com/script/cb.js"(.*?)>(.*?)</script>';
|
||||
|
||||
$themes = $this->prepare_api_condition(array('themes'), array('role' => 'main'), 'GET', '0', '', $curshop);
|
||||
if (!empty($themes['body']['themes'])) {
|
||||
|
||||
$theme_id = $themes['body']['themes'][0]['id'];
|
||||
|
||||
$url_param_arr = array('asset' => array('key' => 'layout/theme.liquid'));
|
||||
$theme_responce = $this->prepare_api_condition(array('themes', $theme_id, 'assets'), $url_param_arr, 'GET', '0', '', $curshop);
|
||||
$theme_value = $theme_responce['body']['asset']['value'];
|
||||
|
||||
//$html = str_replace($script, "", $theme_value);
|
||||
$html = preg_replace('#'. $script . '#is', '', $theme_value);
|
||||
$html = preg_replace('#'. $script2 . '#is', '', $html);
|
||||
$url_param_arr = array('asset' => array('key' => 'layout/theme.liquid', 'value' => $html));
|
||||
$theme_update = $this->prepare_api_condition(array('themes', $theme_id, 'assets'), $url_param_arr, 'PUT', '0', '', $curshop);
|
||||
|
||||
}
|
||||
// old way fix end.
|
||||
|
||||
// ----- new way remove tags start ---------
|
||||
$arrsrc = ['https://cmp.seersco.com/script/cb.js', 'https://seers-application-assets.s3.amazonaws.com/scripts/cbattributes.js?key=' . $datakey . '&name=CookieXray'];
|
||||
$cbattrjspath = 'https://seers-application-assets.s3.amazonaws.com/scripts/cbattributes.js';
|
||||
|
||||
|
||||
//get all avialable tags
|
||||
$allscriptags = $this->prepare_api_condition(array('script_tags'), array(), 'GET', '0', $token, $shop);
|
||||
|
||||
//print_r($allscriptags);
|
||||
|
||||
if(!empty($allscriptags['body']) && !empty($allscriptags['body']['script_tags'])) {
|
||||
|
||||
foreach ($allscriptags['body']['script_tags'] as $thescript) {
|
||||
|
||||
if (strcasecmp($thescript['src'], $arrsrc[0]) === 0) {
|
||||
//remove the script
|
||||
$scriptdel = $this->prepare_api_condition(array('script_tags', $thescript['id']), array(), 'DELETE', '0', $token, $shop);
|
||||
} else if (stripos($thescript['src'], $cbattrjspath) !== false && strcasecmp($thescript['src'], $arrsrc[1]) !== 0) {
|
||||
//remove the script
|
||||
$scriptdel = $this->prepare_api_condition(array('script_tags', $thescript['id']), array(), 'DELETE', '0', $token, $shop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ----- new way remove tags end ---------
|
||||
|
||||
|
||||
$response = array('result' => 'success', 'msg' => 'Code Remove successfully.');
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function change_appStatus(){
|
||||
|
||||
$cf_obj = new common_function();
|
||||
$shop = isset($_POST['shop']) ? $_POST['shop'] : $_GET['shop'];
|
||||
$store_user_id = $this->store_user_id;
|
||||
$data_status = $_POST['data_status'];
|
||||
$user_domain = $_POST['user_name'];
|
||||
$user_email = $_POST['user_email'];
|
||||
|
||||
$user_key = $_POST['data_key'];
|
||||
|
||||
if($data_status=='true')
|
||||
{
|
||||
$data_status = '1';
|
||||
}else{
|
||||
$data_status = '0';
|
||||
}
|
||||
|
||||
|
||||
$selected_field = '*';
|
||||
$where = array('shop' => $shop,'store_user_id' => $store_user_id);
|
||||
$is_store_exist = $cf_obj->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
|
||||
$already_toggle_status = $is_store_exist['toggle_status'];
|
||||
$domain = $is_store_exist['domain'];
|
||||
$email = $is_store_exist['email'];
|
||||
$token = $is_store_exist['token'];
|
||||
$shop = $is_store_exist['shop'];
|
||||
if(!empty($is_store_exist)){
|
||||
// SEND API CALL
|
||||
$data = array(
|
||||
'domain' => $domain,
|
||||
'user_domain' => $domain,
|
||||
'email' => $email,
|
||||
'user_email' => $email,
|
||||
'secret' => '$2y$10$9ygTfodVBVM0XVCdyzEUK.0FIuLnJT0D42sIE6dIu9r/KY3XaXXyS',
|
||||
'platform' => 'shopify',
|
||||
'status'=>$data_status,
|
||||
);
|
||||
|
||||
// /******* Curl call start *****/
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://seersco.com/api/banner-settings",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$error_number = curl_errno($curl);
|
||||
$error_message = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$result = json_decode($response, TRUE);
|
||||
|
||||
//var_dump($result);
|
||||
//exit;
|
||||
//by Shoaib in reponse there is no element of banner_enable
|
||||
// {"key":"$2y$10$ZtDil0sCM95w..QVVdqOielWh7YRbySFOPDgzR.K4iukb5I7ewF4G","status":0,"message":"success"}
|
||||
|
||||
//$banner_status = $result['banner_enable'];
|
||||
$banner_status = ((!empty($result['banner_enable'])) ? $result['banner_enable'] : ((isset($result['status'])) ? $result['status'] : $already_toggle_status ) );
|
||||
|
||||
if(!empty($result['key'])){
|
||||
$user_key = $result['key'];
|
||||
}else{
|
||||
$user_key = $_POST['data_key'];
|
||||
}
|
||||
|
||||
//$banner_status = '1';
|
||||
$jsonresponse = array('result' => 'fail', 'msg' => 'Something went wrong');
|
||||
|
||||
if($banner_status=='1'){
|
||||
$jsonresponse = array('result' => 'success', 'key'=>$user_key, 'msg' => "<p><span class ='banner-tick'></span>Banner is enabled on your store. <br> <span style='margin-left:18px;'></span>Please refresh your store home page to see the effect.</p>");
|
||||
$this->snippest_insert($shop, $token, $domain, $email);
|
||||
}else{
|
||||
$jsonresponse = array('result' => 'success', 'key'=>$user_key, 'msg' => 'Banner is disabled on your store');
|
||||
$this->remove_code();
|
||||
}
|
||||
/** Update Banner Status */
|
||||
$this->updateToogelStatus($cf_obj, $shop, $banner_status,$user_domain,$user_email,$user_key);
|
||||
|
||||
if (!empty($result['message']) && strcasecmp($result['message'], 'success') === 0)
|
||||
{
|
||||
return $jsonresponse;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateToogelStatus($cf_obj, $shop, $banner_status,$user_domain,$user_email,$user_key){
|
||||
|
||||
|
||||
$shop_details = array(
|
||||
'status'=>'1',
|
||||
'updated_on'=>DATE,
|
||||
'toggle_status'=>$banner_status,
|
||||
'domain'=>$user_domain,
|
||||
'email'=>$user_email,
|
||||
'data_key'=>$user_key
|
||||
);
|
||||
|
||||
$where = array('shop' => $shop,'store_user_id' => $this->store_user_id);
|
||||
$last_id = $cf_obj->update(TABLE_USER_STORES, $shop_details, $where);
|
||||
}
|
||||
}
|
70
webhook/app-uninstalled.php
Normal file
70
webhook/app-uninstalled.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
include_once '../include/config.php';
|
||||
include_once '../include/common_function.php';
|
||||
include_once '../user/user_functions.php';
|
||||
|
||||
if (MODE == 'dev') {
|
||||
$shop = $_GET['shop'];
|
||||
} else {
|
||||
$shop = isset($_SERVER['X-Shopify-Shop-Domain']) ? $_SERVER['X-Shopify-Shop-Domain'] : $_SERVER['HTTP_X_SHOPIFY_SHOP_DOMAIN'];
|
||||
}
|
||||
|
||||
$cf_obj = new common_function();
|
||||
$us_obj = new User_functions($shop);
|
||||
|
||||
$shop_name = $email = $store_user_id = '';
|
||||
$where = array('shop' => $shop);
|
||||
$shop_detail = $cf_obj->select_row(TABLE_USER_STORES, 'store_user_id, name, shop, email', $where);
|
||||
if(!empty($shop_detail)){
|
||||
$store_user_id = $shop_detail['store_user_id'];
|
||||
$shop_name = $shop_detail['name'];
|
||||
$shopdom = $shop_detail['shop'];
|
||||
$email = $shop_detail['email'];
|
||||
|
||||
//save plugin is deactive on plugins db this plugin
|
||||
$cf_obj->plugin_active_inactive($shop_detail, 0);
|
||||
|
||||
//remove the js script from html
|
||||
// SEND API CALL
|
||||
$data = array(
|
||||
'domain' => $shopdom,
|
||||
'user_domain' => $shopdom,
|
||||
'email' => $email,
|
||||
'user_email' => $email,
|
||||
'secret' => '$2y$10$9ygTfodVBVM0XVCdyzEUK.0FIuLnJT0D42sIE6dIu9r/KY3XaXXyS',
|
||||
'platform' => 'shopify',
|
||||
'status'=>'0'
|
||||
);
|
||||
|
||||
// /******* Curl call start *****/
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://seersco.com/api/banner-settings",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$error_number = curl_errno($curl);
|
||||
$error_message = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$result = json_decode($response, TRUE);
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'status' => '0',
|
||||
'app_status' => '0',
|
||||
'toggle_status' => '0'
|
||||
);
|
||||
$where = array('shop' => $shop);
|
||||
$cf_obj->update(TABLE_USER_STORES, $fields, $where);
|
||||
?>
|
48
webhook/customer-data.php
Normal file
48
webhook/customer-data.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
include_once '../include/config.php';
|
||||
include_once '../include/common_function.php';
|
||||
|
||||
/* Common function object */
|
||||
$cf_obj = new common_function();
|
||||
|
||||
$shop_info = file_get_contents('php://input');
|
||||
|
||||
/* shop info array */
|
||||
$shop_info = json_decode($shop_info, TRUE);
|
||||
|
||||
$selected_field = 'store_user_id,email';
|
||||
$where = array('shop' => $shop_info['shop_domain']);
|
||||
$table_shop_info = $cf_obj->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
|
||||
if ($table_shop_info != '' && !empty($table_shop_info) && $table_shop_info['email'] != '') {
|
||||
$fields = array(
|
||||
'domain' => '',
|
||||
'owner' => '',
|
||||
'shop_plan' => '',
|
||||
'money_format' => '',
|
||||
'currency' => '',
|
||||
'address1' => '',
|
||||
'address2' => '',
|
||||
'city' => '',
|
||||
'country_name' => '',
|
||||
'phone' => '',
|
||||
'province' => '',
|
||||
'zip' => '',
|
||||
'timezone' => '',
|
||||
'iana_timezone' => '',
|
||||
'weight_unit' => ''
|
||||
);
|
||||
|
||||
$where = array('shop' => $shop_info['shop_domain']);
|
||||
$cf_obj->update(TABLE_USER_STORES, $fields, $where);
|
||||
|
||||
/**
|
||||
* Declare array table data deleted after app uninstall rule GDPR
|
||||
*/
|
||||
$table_array = array();
|
||||
|
||||
foreach ($table_array as $table) {
|
||||
$where = array('store_user_id' => $table_shop_info['store_user_id']);
|
||||
$cf_obj->delete($table, $where);
|
||||
}
|
||||
}
|
48
webhook/customer-request.php
Normal file
48
webhook/customer-request.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
include_once '../include/config.php';
|
||||
include_once '../include/common_function.php';
|
||||
|
||||
/* Common function object */
|
||||
$cf_obj = new common_function();
|
||||
|
||||
$shop_info = file_get_contents('php://input');
|
||||
|
||||
/* shop info array */
|
||||
$shop_info = json_decode($shop_info, TRUE);
|
||||
|
||||
$selected_field = 'store_user_id,email';
|
||||
$where = array('shop' => $shop_info['shop_domain']);
|
||||
$table_shop_info = $cf_obj->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
|
||||
if ($table_shop_info != '' && !empty($table_shop_info) && $table_shop_info['email'] != '') {
|
||||
$fields = array(
|
||||
'domain' => '',
|
||||
'owner' => '',
|
||||
'shop_plan' => '',
|
||||
'money_format' => '',
|
||||
'currency' => '',
|
||||
'address1' => '',
|
||||
'address2' => '',
|
||||
'city' => '',
|
||||
'country_name' => '',
|
||||
'phone' => '',
|
||||
'province' => '',
|
||||
'zip' => '',
|
||||
'timezone' => '',
|
||||
'iana_timezone' => '',
|
||||
'weight_unit' => ''
|
||||
);
|
||||
|
||||
$where = array('shop' => $shop_info['shop_domain']);
|
||||
$cf_obj->update(TABLE_USER_STORES, $fields, $where);
|
||||
|
||||
/**
|
||||
* Declare array table data deleted after app uninstall rule GDPR
|
||||
*/
|
||||
$table_array = array();
|
||||
|
||||
foreach ($table_array as $table) {
|
||||
$where = array('store_user_id' => $table_shop_info['store_user_id']);
|
||||
$cf_obj->delete($table, $where);
|
||||
}
|
||||
}
|
11
webhook/index.html
Normal file
11
webhook/index.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
38
webhook/shop-info-remove.php
Normal file
38
webhook/shop-info-remove.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
include_once '../include/config.php';
|
||||
include_once '../include/common_function.php';
|
||||
|
||||
/* Common function object */
|
||||
$cf_obj = new common_function();
|
||||
|
||||
$shop_info = file_get_contents('php://input');
|
||||
|
||||
/* shop info array */
|
||||
$shop_info = json_decode($shop_info, TRUE);
|
||||
|
||||
$selected_field = 'store_user_id,email';
|
||||
$where = array('shop' => $shop_info['shop_domain']);
|
||||
$table_shop_info = $cf_obj->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
|
||||
if ($table_shop_info != '' && !empty($table_shop_info) && $table_shop_info['email'] != '') {
|
||||
$fields = array(
|
||||
'domain' => '',
|
||||
'owner' => '',
|
||||
'shop_plan' => '',
|
||||
'money_format' => '',
|
||||
'currency' => '',
|
||||
'address1' => '',
|
||||
'address2' => '',
|
||||
'city' => '',
|
||||
'country_name' => '',
|
||||
'phone' => '',
|
||||
'province' => '',
|
||||
'zip' => '',
|
||||
'timezone' => '',
|
||||
'iana_timezone' => '',
|
||||
'weight_unit' => ''
|
||||
);
|
||||
|
||||
$where = array('shop' => $shop_info['shop_domain']);
|
||||
$cf_obj->update(TABLE_USER_STORES, $fields, $where);
|
||||
}
|
42
webhook/shop-update.php
Normal file
42
webhook/shop-update.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
include_once '../include/config.php';
|
||||
include_once '../include/common_function.php';
|
||||
|
||||
$shop = $_SERVER['HTTP_X_SHOPIFY_SHOP_DOMAIN'];
|
||||
|
||||
$cf_obj = new common_function($shop);
|
||||
|
||||
$hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];
|
||||
|
||||
/* Here we get all information about customer */
|
||||
$shop_update = file_get_contents('php://input');
|
||||
|
||||
/* Todo: checked verify_webhook response(return type ) than set condition according to it */
|
||||
$verified = $cf_obj->verify_webhook($shop_update, $hmac_header);
|
||||
|
||||
if (!empty($cf_obj) && $verified && $cf_obj->is_json($shop_update)) {
|
||||
/* shop detail array */
|
||||
$shop_detail_arr = json_decode($shop_update, TRUE);
|
||||
$fields = array(
|
||||
'currency' => $shop_detail_arr['currency'],
|
||||
'money_format' => mysqli_real_escape_string($cf_obj->db_connection, $shop_detail_arr['money_format']),
|
||||
'owner' => $shop_detail_arr['shop_owner'],
|
||||
'shop_plan' => $shop_detail_arr['plan_name'],
|
||||
'address1' => $shop_detail_arr['address1'],
|
||||
'address2' => $shop_detail_arr['address2'],
|
||||
'city' => $shop_detail_arr['city'],
|
||||
'country_name' => $shop_detail_arr['country_name'],
|
||||
'phone' => $shop_detail_arr['phone'],
|
||||
'province' => $shop_detail_arr['province'],
|
||||
'zip' => $shop_detail_arr['zip'],
|
||||
'timezone' => $shop_detail_arr['timezone'],
|
||||
'iana_timezone' => $shop_detail_arr['iana_timezone'],
|
||||
'domain' => $shop_detail_arr['domain'],
|
||||
'weight_unit' => $shop_detail_arr['weight_unit'],
|
||||
);
|
||||
|
||||
$selected_field = 'shop_plan, store_user_id';
|
||||
$where = array('shop' => $shop);
|
||||
$shop_info_db = $cf_obj->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue