Permalink
Browse files

Fix chrome html5 push notifications

  • Loading branch information...
r04r committed Sep 4, 2016
1 parent 8b86064 commit ef7b0a511a46300d340dcaab5c5bcd80d3c74596
Showing with 149 additions and 150 deletions.
  1. +14 −19 includes/functions.php
  2. +135 −131 push.php
@@ -244,15 +244,15 @@ function print_statistics($uid, $public = true)
$query['replies_to_your_topics'] = "SELECT AVG(replies) FROM topics WHERE author = '$uid' AND deleted = 0";
$query['replies_to_your_topics_all'] = "SELECT AVG(replies) FROM topics WHERE author = '$uid'";
foreach ($query as $k => $q) {
if(!($data = apcu_fetch($q))) {
$result = $link->db_exec($q);
$row = $link->fetch_row($result);
$data = $row[0];
apcu_store($q, $data, 600);
}
$statistics[$k] = $data;
}
@@ -262,13 +262,13 @@ function print_statistics($uid, $public = true)
if ($days_since_first_seen == 0) {
$days_since_first_seen = 1;
}
$num_topics_all = $num_topics + $num_topics_deleted;
$num_replies_all = $num_replies + $num_replies_deleted;
$your_topics_all = $your_topics + $your_topics_deleted;
$your_replies_all = $your_replies + $your_replies_deleted;
$posts_per_user = $topics_per_user + $replies_per_user;
$replies_per_topic_all = round($num_replies_all / $num_topics_all, 2);
$replies_per_topic = round($num_replies / $num_topics, 2);
@@ -394,7 +394,7 @@ function print_statistics($uid, $public = true)
<td>We went live on <?php echo date('Y-m-d', SITE_FOUNDED).', '.calculate_age(SITE_FOUNDED) ?> ago.</td>
</tr>
</table>
<?php
<?php
}
?>
<table>
@@ -425,7 +425,7 @@ function print_statistics($uid, $public = true)
<td class="minimal"><?php echo format_number($your_replies) ?></td>
<td><span class="unimportant"><?php echo format_number($your_replies_all_anon) ?> anonymous, <?php echo format_number($your_replies_deleted) ?> deleted.</span></td>
</tr>
<?php
<?php
}
?>
<tr>
@@ -482,8 +482,6 @@ function sendMessageToChrome($uid, $type, $data)
return;
}
var_dump($subscriptions);
$headers = array(
'Authorization: key='.CHROME_TOKEN,
'Content-Type: application/json',
@@ -505,11 +503,8 @@ function sendMessageToChrome($uid, $type, $data)
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
$response = curl_exec($ch);
var_dump(curl_error($ch));
curl_close($ch);
var_dump($response);
return $response;
}
@@ -710,7 +705,7 @@ function detect_spam($haystack)
foreach ($arrChars as $to => $chars) {
$haystack = str_replace($chars, $to, $haystack);
}
foreach ($spam_phrases as $phrase) {
if (detect_phrase($phrase, $haystack)) {
return true;
@@ -724,7 +719,7 @@ function detect_phrase($needle, $haystack)
{
//$needle = preg_replace('/((?<!\\\\)[a-z])/m', '\1{1,2}.{0,2}', $needle);
$needle = str_replace('/', '\\/', $needle);
if (preg_match('/'.$needle.'/si', $haystack)) {
return true;
} else {
@@ -971,7 +966,7 @@ function create_id()
/*if(ENABLE_RECAPTCHA_ON_BOT){
$link->db_exec("SELECT 1 FROM users WHERE ip_address = %1 AND last_seen > (UNIX_TIMESTAMP()-3600)", $_SERVER['REMOTE_ADDR']);
$uids_recent = $link->num_rows();
if($uids_recent > RECAPTHCA_MAX_UIDS_PER_HOUR) {
if($uids_recent > RECAPTHCA_MAX_UIDS_PER_HOUR) {
recaptcha("Please enable cookies for this site. Enter the following captcha to continue. If you have cookies enabled and keep getting this message, try removing the ones set for <b>minichan.org</b> and <b>.minichan.org</b>. We apologize for the inconvience.");
}
}*/
@@ -1081,7 +1076,7 @@ function force_id($proxy_value = null, $redirect = true, $allow = false)
echo "<input type='hidden' name='$k' value='$v' />";
}
echo '<input type="submit" value="Click me!"></body></html>';
die();
*/
}
@@ -1133,7 +1128,7 @@ function remove_ip_ban($ip)
}
function fetch_ignore_list()
{ // For ostrich mode.
{ // For ostrich mode.
global $link, $user_settings;
if (!$user_settings['ostrich_mode']) {
@@ -1432,7 +1427,7 @@ function dummy_form()
echo "\n".'<form id="dummy_form" class="noscreen" action="" method="post">'.indent().'<div class="noscreen"> <input type="hidden" name="CSRF_token" value="'.$_SESSION['token'].'" /> </div> <div> <input type="hidden" name="some_var" value="" /> </div>'."\n".'</form>'."\n";
}
// To redirect to index, use redirect($notice, ''). To redirect back to referrer,
// To redirect to index, use redirect($notice, ''). To redirect back to referrer,
// use redirect($notice). To redirect to /topic/1, use redirect($notice, 'topic/1')
function redirect($notice = '', $location = null)
{
@@ -2015,4 +2010,4 @@ function template($name)
return "includes/templates/$name.php";
}
?>
?>
Oops, something went wrong.

0 comments on commit ef7b0a5

Please sign in to comment.