Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hosting_reviews
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Ali Arshad
hosting_reviews
Commits
87a7cb10
Commit
87a7cb10
authored
Dec 29, 2019
by
Muhammad Usman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generate share link
parent
7ec81660
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
13 deletions
+101
-13
functions.php
WWW_DATA/wp-content/themes/hostingreviews/functions.php
+16
-0
summary.php
WWW_DATA/wp-content/themes/hostingreviews/summary.php
+85
-13
No files found.
WWW_DATA/wp-content/themes/hostingreviews/functions.php
View file @
87a7cb10
...
@@ -265,6 +265,19 @@ function vq_add_review_subscribers() {
...
@@ -265,6 +265,19 @@ function vq_add_review_subscribers() {
exit
;
exit
;
}
}
function
vq_get_saved_speed_results
()
{
$batchId
=
$_POST
[
'batchId'
];
global
$wpdb
;
$speed_table_name
=
$wpdb
->
prefix
.
"speed_results"
;
$oldResutls
=
$wpdb
->
get_results
(
"SELECT server_response_time, page_load_time FROM
$speed_table_name
WHERE batch_id != '
$batchId
'"
);
$newResutls
=
$wpdb
->
get_results
(
"SELECT * FROM
$speed_table_name
WHERE batch_id = '
$batchId
'"
);
echo
json_encode
([
'oldData'
=>
$oldResutls
,
'newData'
=>
$newResutls
]);
exit
;
}
// Actions
// Actions
add_action
(
'customize_register'
,
'vq_theme_customize_register'
);
add_action
(
'customize_register'
,
'vq_theme_customize_register'
);
...
@@ -274,6 +287,9 @@ add_action( 'init', 'vq_add_theme_default_pages' );
...
@@ -274,6 +287,9 @@ add_action( 'init', 'vq_add_theme_default_pages' );
add_action
(
'wp_ajax_nopriv_get_speed_results'
,
'vq_get_hosting_speed'
);
add_action
(
'wp_ajax_nopriv_get_speed_results'
,
'vq_get_hosting_speed'
);
add_action
(
'wp_ajax_get_speed_results'
,
'vq_get_hosting_speed'
);
add_action
(
'wp_ajax_get_speed_results'
,
'vq_get_hosting_speed'
);
add_action
(
'wp_ajax_nopriv_get_saved_speed_results'
,
'vq_get_saved_speed_results'
);
add_action
(
'wp_ajax_get_saved_speed_results'
,
'vq_get_saved_speed_results'
);
add_action
(
'wp_ajax_nopriv_add_review_subscribers'
,
'vq_add_review_subscribers'
);
add_action
(
'wp_ajax_nopriv_add_review_subscribers'
,
'vq_add_review_subscribers'
);
add_action
(
'wp_ajax_add_review_subscribers'
,
'vq_add_review_subscribers'
);
add_action
(
'wp_ajax_add_review_subscribers'
,
'vq_add_review_subscribers'
);
...
...
WWW_DATA/wp-content/themes/hostingreviews/summary.php
View file @
87a7cb10
...
@@ -8,6 +8,11 @@ get_header();
...
@@ -8,6 +8,11 @@ get_header();
$domain
=
''
;
$domain
=
''
;
if
(
isset
(
$_GET
[
'domain'
]
)
)
{
if
(
isset
(
$_GET
[
'domain'
]
)
)
{
$domain
=
$_GET
[
'domain'
];
$domain
=
$_GET
[
'domain'
];
$domain
=
preg_replace
(
'#^https?://#'
,
''
,
$domain
);
}
else
if
(
isset
(
$_GET
[
'batchId'
]))
{
$batchId
=
$_GET
[
'batchId'
];
}
else
{
header
(
'Location: /'
);
}
}
?>
?>
...
@@ -99,11 +104,11 @@ if ( isset( $_GET['domain'] ) ) {
...
@@ -99,11 +104,11 @@ if ( isset( $_GET['domain'] ) ) {
</div>
</div>
</div>
</div>
<div
class=
"d-none d-sm-block d-md-block"
>
<div
class=
"d-none d-sm-block d-md-block"
>
<img
class=
"summarySocailIocn"
<img
class=
"summarySocailIocn"
onclick=
"shareToFacebook()"
src=
"
<?php
echo
get_template_directory_uri
();
?>
/assets/images/facebook-icon.jpg"
alt=
""
>
src=
"
<?php
echo
get_template_directory_uri
();
?>
/assets/images/facebook-icon.jpg"
alt=
""
>
<img
class=
"summarySocailIocn top-133"
<img
class=
"summarySocailIocn top-133"
onclick=
"shareOnTwitter()"
src=
"
<?php
echo
get_template_directory_uri
();
?>
/assets/images/twitter-icon.jpg"
alt=
""
>
src=
"
<?php
echo
get_template_directory_uri
();
?>
/assets/images/twitter-icon.jpg"
alt=
""
>
<img
class=
"summarySocailIocn top-177"
<img
class=
"summarySocailIocn top-177"
onclick=
"shareOnLinkedIn()"
src=
"
<?php
echo
get_template_directory_uri
();
?>
/assets/images/linked-icon.jpg"
alt=
""
>
src=
"
<?php
echo
get_template_directory_uri
();
?>
/assets/images/linked-icon.jpg"
alt=
""
>
</div>
</div>
<table
class=
"table table-striped radius"
>
<table
class=
"table table-striped radius"
>
...
@@ -261,7 +266,7 @@ if ( isset( $_GET['domain'] ) ) {
...
@@ -261,7 +266,7 @@ if ( isset( $_GET['domain'] ) ) {
<script>
<script>
var
domain_addr
=
'
<?php
echo
$domain
?>
'
;
var
domain_addr
=
'
<?php
echo
$domain
?>
'
;
var
requestId
=
'
<?php
echo
$batchId
?>
'
;
jQuery
(
document
).
ready
(
function
(
$
)
{
jQuery
(
document
).
ready
(
function
(
$
)
{
...
@@ -301,12 +306,34 @@ if ( isset( $_GET['domain'] ) ) {
...
@@ -301,12 +306,34 @@ if ( isset( $_GET['domain'] ) ) {
if
(
response
.
error
)
{
if
(
response
.
error
)
{
return
alert
(
response
.
error
);
return
alert
(
response
.
error
);
}
}
parseData
(
response
);
});
}
else
if
(
requestId
)
{
var
actData
=
{
'action'
:
'get_saved_speed_results'
,
'batchId'
:
requestId
};
resultLoader
.
style
.
display
=
'block'
;
reviewData
.
style
.
display
=
'none'
;
$
.
post
(
ajax_url
,
actData
,
function
(
response
)
{
if
(
response
.
error
)
{
return
alert
(
response
.
error
);
}
parseData
(
response
);
});
}
function
parseData
(
response
)
{
let
newResults
=
JSON
.
parse
(
response
).
newData
;
let
oldData
=
JSON
.
parse
(
response
).
oldData
;
reviewTableDetailsBody
.
innerHTML
=
''
;
reviewTableDetailsBody
.
innerHTML
=
''
;
reviewData
.
style
.
display
=
'flex'
;
reviewData
.
style
.
display
=
'flex'
;
resultLoader
.
style
.
display
=
'none'
;
resultLoader
.
style
.
display
=
'none'
;
let
newResults
=
JSON
.
parse
(
response
).
newData
;
let
oldData
=
JSON
.
parse
(
response
).
oldData
;
var
respTime
=
0
;
var
respTime
=
0
;
var
loadTime
=
0
;
var
loadTime
=
0
;
...
@@ -321,14 +348,19 @@ if ( isset( $_GET['domain'] ) ) {
...
@@ -321,14 +348,19 @@ if ( isset( $_GET['domain'] ) ) {
loadTime
+=
+
res
.
page_load_time
;
loadTime
+=
+
res
.
page_load_time
;
});
});
domainNameEl
.
innerText
=
newResults
[
0
].
domain_addr
;
var
singleRecord
=
newResults
[
0
];
domainIPEl
.
innerText
=
newResults
[
0
].
domain_ip
;
hostingNameEl
.
innerText
=
newResults
[
0
].
hosting_name
;
domainNameEl
.
innerText
=
singleRecord
.
domain_addr
;
domainIPEl
.
innerText
=
singleRecord
.
domain_ip
;
hostingNameEl
.
innerText
=
singleRecord
.
hosting_name
;
hostingNameEl
.
innerText
=
'-'
;
hostingNameEl
.
innerText
=
'-'
;
avgResTimeEl
.
innerText
=
Math
.
floor
(
respTime
/
newResults
.
length
).
toString
();
avgResTimeEl
.
innerText
=
Math
.
floor
(
respTime
/
newResults
.
length
).
toString
();
avgPageLoadTimeEl
.
innerText
=
Math
.
floor
(
loadTime
/
newResults
.
length
).
toString
();
avgPageLoadTimeEl
.
innerText
=
Math
.
floor
(
loadTime
/
newResults
.
length
).
toString
();
screenshotImgEl
.
src
=
newResults
[
0
].
imgPath
;
loadVideoEl
.
src
=
newResults
[
0
].
videoPath
;
const
imgPath
=
`
${
singleRecord
.
server_name
}
/
${
singleRecord
.
domain_addr
}
/
${
singleRecord
.
timestamp
}
/
${
singleRecord
.
screen_shot
}
`
;
const
videoPath
=
`
${
singleRecord
.
server_name
}
/
${
singleRecord
.
domain_addr
}
/
${
singleRecord
.
timestamp
}
/
${
singleRecord
.
video
}
`
;
screenshotImgEl
.
src
=
imgPath
;
loadVideoEl
.
src
=
videoPath
;
var
serverResTimes
=
oldData
.
map
(
o
=>
+
o
.
server_response_time
+
+
o
.
page_load_time
).
sort
((
o1
,
o2
)
=>
o1
-
o2
);
var
serverResTimes
=
oldData
.
map
(
o
=>
+
o
.
server_response_time
+
+
o
.
page_load_time
).
sort
((
o1
,
o2
)
=>
o1
-
o2
);
...
@@ -356,9 +388,7 @@ if ( isset( $_GET['domain'] ) ) {
...
@@ -356,9 +388,7 @@ if ( isset( $_GET['domain'] ) ) {
reviewGradeEl
.
innerText
=
grade
;
reviewGradeEl
.
innerText
=
grade
;
reviewPerformanceEl
.
innerText
=
Math
.
floor
(
rank
);
reviewPerformanceEl
.
innerText
=
Math
.
floor
(
rank
);
});
}
}
});
function
percentRank
(
arr
,
v
)
{
function
percentRank
(
arr
,
v
)
{
if
(
typeof
v
!==
'number'
)
throw
new
TypeError
(
'v must be a number'
);
if
(
typeof
v
!==
'number'
)
throw
new
TypeError
(
'v must be a number'
);
...
@@ -374,6 +404,48 @@ if ( isset( $_GET['domain'] ) ) {
...
@@ -374,6 +404,48 @@ if ( isset( $_GET['domain'] ) ) {
}
}
return
1
;
return
1
;
}
}
});
<?php
$base_url
=
(
isset
(
$_SERVER
[
'HTTPS'
])
&&
$_SERVER
[
'HTTPS'
]
==
'on'
?
'https'
:
'http'
)
.
'://'
.
$_SERVER
[
'HTTP_HOST'
];
$url
=
$base_url
.
$_SERVER
[
"REQUEST_URI"
];
$url
=
preg_replace
(
'#^https?://#'
,
''
,
$url
);
?>
var
pageUri
=
'
<?php
echo
$url
;
?>
'
;
function
shareToFacebook
()
{
var
a
=
document
.
createElement
(
'a'
);
a
.
href
=
`https://www.facebook.com/sharer/sharer.php?u=
${
decodeURI
(
pageUri
)}
`
;
a
.
target
=
'_blank'
;
a
.
click
();
document
.
body
.
append
(
a
);
setTimeout
(()
=>
{
a
.
remove
();
})
}
function
shareOnTwitter
(){
var
a
=
document
.
createElement
(
'a'
);
a
.
href
=
`https://twitter.com/intent/tweet?url=
${
pageUri
}
`
;
a
.
target
=
'_blank'
;
a
.
click
();
document
.
body
.
append
(
a
);
setTimeout
(()
=>
{
a
.
remove
();
});
}
function
shareOnLinkedIn
()
{
var
a
=
document
.
createElement
(
'a'
);
a
.
href
=
`https://www.linkedin.com/sharing/share-offsite/?url=
${
pageUri
}
`
;
a
.
target
=
'_blank'
;
a
.
click
();
document
.
body
.
append
(
a
);
setTimeout
(()
=>
{
a
.
remove
();
});
}
</script>
</script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment