/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
     $test = $request->all();
     $d = new \DateTime();
     $firebase->push(DEFAULT_PATH . '/ads', $test);
     // --- storing a string ---
     return redirect("dashboard");
 }
示例#2
0
<?php

if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    session_start();
    require '../../../mysql/query.php';
    require '../../../lang/config.php';
    if (isset($_SESSION['user']) && isset($_GET['id']) && is_numeric($_GET['id']) && isset($_GET['friend']) && is_numeric($_GET['friend'])) {
        if (sqlAction("DELETE FROM friends WHERE friend_request_id = {$_GET['id']} AND user_id = {$_GET['friend']} AND friend_user_id = {$_SESSION['user']['id']} AND status = 0 AND sender != {$_SESSION['user']['id']};")) {
            require '../../../lib/Firebase/url.php';
            getFirebase($require = true);
            $firebase = new Firebase\FirebaseLib($url, $token);
            $firebaseArray = array('from' => array('user_id' => $_SESSION['user']['id'], 'user_name' => "{$_SESSION['user']['name']}"), 'group' => 'false', 'story' => 'false', 'time' => time(), 'type' => 'rejected_friend_request', 'unread' => 'true');
            $firebase->push(usersNewsFeed($_GET['friend']), $firebaseArray);
            if (isset($_GET['return_to_profile'])) {
                header("Location: ../../../profile?view={$_GET['friend']}");
            }
            header('Location: ../../../profile?view=friends');
        }
    }
}
示例#3
0
                }
            }
            $firebase->update($path, $data);
            // updates data in Firebase
            break;
        case 'push':
            if (empty($_REQUEST['data'])) {
                throw new Exception('empty data');
            }
            $data = $_REQUEST['data'];
            if (!is_array($data)) {
                $data = json_decode($_REQUEST['data'], 1);
            }
            if (!empty($_REQUEST['saveIP'])) {
                $ip = !empty($_REQUEST['ip']) ? $_REQUEST['ip'] : $_SERVER['REMOTE_ADDR'];
                $ipDetails = iptocity($ip);
                if (!empty($ipDetails['result'])) {
                    $data['currentLocation'] = $ipDetails['result'];
                }
            }
            $firebase->push($path, $data);
            // push data to Firebase
            break;
    }
    $result = array('success' => 1, 'arr' => $arr);
} catch (Exception $e) {
    $result = array('success' => 0, 'msg' => $e->getMessage());
}
$txt = json_encode($result);
echo $txt;
exit;
示例#4
0
                    }
                    if ($friend['status'] == 0 && $friend['sender'] != $_SESSION['user']['id']) {
                        array_push($_SESSION['errors'], "<span class=\"ion-android-warning\"><a href=\"profile?view={$friend['user_id']}\">{$friend['username']}</a> har redan skickat vänförfrågan till dig");
                    }
                }
            }
        }
    }
    if ($_SESSION['errors']) {
        header('Location: ../../../profile?view=friends');
    }
    if (!$_SESSION['errors']) {
        require '../../../lib/Firebase/url.php';
        getFirebase($require = true);
        $firebase = new Firebase\FirebaseLib($url, $token);
        $firebaseArray = array('from' => array('user_id' => $_SESSION['user']['id'], 'user_name' => "{$_SESSION['user']['name']}"), 'group' => 'false', 'story' => 'false', 'time' => time(), 'type' => 'friend_request', 'unread' => 'true');
        $friend_request = "INSERT INTO friends (user_id, friend_user_id, status, sender, date) VALUES ";
        foreach ($users as $friend) {
            $friend_request .= "({$_SESSION['user']['id']}, {$friend['user_id']}, 0, {$_SESSION['user']['id']}, now()), ";
        }
        $friend_request = rtrim($friend_request, ', ');
        $friend_request .= ';';
        foreach ($users as $new_friend) {
            $firebase->push(usersNewsFeed($new_friend['user_id']), $firebaseArray);
        }
        if (sqlAction($friend_request)) {
            $_SESSION['noty_message'] = array('text' => $translate['noty_message']['friend_request_sent']['text'], 'type' => $translate['noty_message']['friend_request_sent']['type'], 'dismissQueue' => $translate['noty_message']['friend_request_sent']['dismissQueue'], 'layout' => $translate['noty_message']['friend_request_sent']['layout'], 'theme' => $translate['noty_message']['friend_request_sent']['theme'], 'timeout' => $translate['noty_message']['friend_request_sent']['timeout']);
            header('Location: ../../../profile?view=friends');
        }
    }
}
示例#5
0
文件: send.php 项目: seeyIT/NoYes
<?php

$f3 = (require 'lib/base.php');
require 'src/firebaseLib.php';
$name = $f3->get('POST.Name');
$surname = $f3->get('POST.Surname');
$age = $f3->get('POST.Age');
$url = 'https://project-8047891479059242296.firebaseio.com/';
$token = '30nl1qnVnGJMYJarCCZZYz703TOQxoeNbv8Tuklq';
$firebase = new Firebase\FirebaseLib($url, $token);
$user = array('Name' => $name, 'Surname' => $surname, 'Age' => $age);
$data = $firebase->get('/');
echo $data;
$firebase->push('/', $user);
 public function save_post($post_id)
 {
     $post = get_post($post_id);
     if ($post_id == 'options' || !isset($post->post_type) || $post->post_type !== 'poll' || isset($_POST['acf']) === false) {
         return;
     }
     //Both user and secret set in the WP settings.
     $userId = get_field('agreable_poll_plugin_settings_senti_user_id', 'options');
     $secret = get_field('agreable_poll_plugin_settings_firebase_secret', 'options');
     if (empty($secret) || empty($userId)) {
         return false;
     }
     $firebase = new \Firebase\FirebaseLib('https://senti.firebaseio.com/', $secret);
     $path = 'polls';
     $acf = $_POST['acf'];
     // Empty poll obj.
     $poll = array('question' => html_entity_decode(get_the_title($post_id), ENT_QUOTES, 'UTF-8'), 'userId' => $userId, 'answers' => array());
     $answers = get_field('agreable_poll_definition_answers', $post_id);
     // Loop through answers in ACF.
     foreach ($answers as $answer) {
         array_push($poll['answers'], array('text' => $answer['answer_text'], 'votes' => $answer['answer_votes']));
     }
     $firebasePollId = get_field('agreable_poll_definition_firebase_id', $post_id);
     // Update or insert based on presence of firebase_id.
     if (empty($firebasePollId) === false) {
         // Update.
         $return = $firebase->update($path . '/' . $userId . '/' . $firebasePollId, $poll);
     } else {
         // Insert.
         $poll['entries'] = 0;
         $poll['created_at'] = round(microtime(true) * 1000);
         $return = $firebase->push($path . '/' . $userId, $poll);
         // Insert object contains firebase id.
         $returnJSON = json_decode($return);
         update_field('agreable_poll_definition_firebase_id', $returnJSON->name, $post_id);
         $post_answers = $_POST['acf']['agreable_poll_definition_answers'];
         for ($i = 0; $i < count($post_answers); $i++) {
             update_post_meta($post_id, "poll_answers_{$i}_answer_index", $i);
         }
     }
 }