/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $user = User::find($id); DB::table('users')->where('id', $id)->delete(); $firebase = new \Firebase\FirebaseLib(env('FIREBASE_URL'), env('FIREBASE_SECRET')); $firebase->delete('presence/' . $id); $ban = Ban::create(['facebook_id' => $user->facebook_id]); return redirect('cms/user')->withSuccess('User successfully banned.'); }
public function commissions() { $firebase = new \Firebase\FirebaseLib(env('FIREBASE_URL'), env('FIREBASE_SECRET')); $commissions = json_decode($firebase->get('users/' . Auth::user()->id)); //dd($commissions); $total_earned = number_format((double) $commissions->total_own_time * 0.013888889, 2); return view('user.commissions', compact('total_earned')); }
public function main() { try { $DEFAULT_URL = 'https://ens.firebaseio.com/'; $DEFAULT_TOKEN = Configure::read('Firebase.token'); $DEFAULT_PATH = '/sms'; $firebase = new \Firebase\FirebaseLib($DEFAULT_URL, $DEFAULT_TOKEN); if (!isset($this->args[0])) { throw new \Exception('Missing queue ID'); } $this->out('Start...'); $sendQueueTable = TableRegistry::get('SendQueues'); $numberTable = TableRegistry::get('Numbers'); $dateTimeUtc = new \DateTimeZone('UTC'); $now = new \DateTime('now', $dateTimeUtc); $sendQueue = $sendQueueTable->find('all', ['conditions' => ['type' => 1, 'send_queue_id' => $this->args[0], 'OR' => ['next_try_datetime IS NULL', 'next_try_datetime <=' => $now]]]); if (!$sendQueue->count()) { throw new \Exception('No more queue'); } $firstQueue = $sendQueue->first(); // Mark as being processed... $firebase->set($DEFAULT_PATH . '/' . $firstQueue->send_queue_id . '/status', 1); $firstQueue->status = 1; $firstQueue->start_datetime = $now; $sendQueueTable->save($firstQueue); // Mark as sending... $firebase->set($DEFAULT_PATH . '/' . $firstQueue->send_queue_id . '/status', 2); $firstQueue->status = 2; $sendQueueTable->save($firstQueue); $page = 1; while (true) { $numbers = $numberTable->find('all', ['fields' => ['number_id', 'number_list_id', 'country_code', 'phone_number'], 'conditions' => ['number_list_id' => $firstQueue->number_list_id], 'limit' => 5000, 'page' => $page]); $list = $numbers->toArray(); if (!count($list)) { break; } // Format the number for Firebase $numberForFb = Hash::combine($list, '{n}.number_id', '{n}'); $this->out(json_encode($numberForFb)); $this->out($page); // Put the all the number on Firebase $firebase->update($DEFAULT_PATH . '/' . $firstQueue->send_queue_id . '/numbers', $numberForFb); // Send SMS foreach ($numbers as $number) { shell_exec(ROOT . DS . 'bin' . DS . 'cake SendSmsBackground ' . $firstQueue->send_queue_id . ' ' . $number->number_id . ' ' . $number->country_code . ' ' . $number->phone_number . ' "THIS IS A TEST! ' . $firstQueue->message . '" > /dev/null 2>/dev/null &'); usleep(10000); } $page++; } // Mark as done... $firebase->set($DEFAULT_PATH . '/' . $firstQueue->send_queue_id . '/status', 3); $firstQueue->status = 3; $firstQueue->end_datetime = new \DateTime('now', $dateTimeUtc); $sendQueueTable->save($firstQueue); } catch (\Exception $ex) { $this->out($ex->getMessage()); } }
/** * 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"); }
public function untrashPost($postId) { $post = get_post($postId); if ($post->post_type !== 'poll') { return; } $secret = get_field('agreable_poll_plugin_settings_firebase_secret', 'options'); $firebase = new \Firebase\FirebaseLib('https://senti.firebaseio.com/', $secret); $path = $this->getPath($postId); $firebase->update($path, array('trashed' => false)); }
function get_taste_profile($uID) { $token = FB_TOKEN; $url = 'https://phoodbuddy.firebaseio.com'; $firebase = new \Firebase\FirebaseLib($url, $token); $data = $firebase->get('/users/facebook:1119368504753440/taste'); $taste_array = json_decode($data, true); echo '<pre>'; print_r($taste_array); $tase = get_dominant_taste($taste_array); echo "<br>" . $tase . "<br>"; }
public function postCashExchange(Request $request) { $firebase = new \Firebase\FirebaseLib(env('FIREBASE_URL'), env('FIREBASE_SECRET')); $commissions = json_decode($firebase->get('users/' . Auth::user()->id)); //dd($commissions); $total_earned = (double) $commissions->total_own_time * 0.013888889; if ($total_earned < 250000) { return view('product.sorry'); } $new_own_time = ($total_earned - 250000) / 0.013888889; $dollars = ["total_own_time" => $new_own_time]; $firebase->update('users/' . Auth::user()->id, $dollars); $cashout = Cashout::create(['user_id' => Auth::user()->id]); return view('product.cashout-thanks'); }
public function live() { $firebase = new \Firebase\FirebaseLib(env('FIREBASE_URL'), env('FIREBASE_SECRET')); $online_users = json_decode($firebase->get('presence/')); $online = collect([]); if ($online_users != null) { foreach ($online_users as $key => $value) { if ($value) { $user = User::find($key); $online->push($user); } } } $users = User::count(); $users_today = User::whereRaw('date(created_at) = curdate()')->count(); return view('base.partials.live', compact('online', 'users_today', 'users')); }
public function main() { try { $DEFAULT_URL = 'https://ens.firebaseio.com/'; $DEFAULT_TOKEN = Configure::read('Firebase.token'); $DEFAULT_PATH = '/sms'; $firebase = new \Firebase\FirebaseLib($DEFAULT_URL, $DEFAULT_TOKEN); if (!isset($this->args[0])) { throw new \Exception('Missing queue ID'); } if (!isset($this->args[1])) { throw new \Exception('Missing number ID'); } if (!isset($this->args[2])) { throw new \Exception('Missing country code'); } if (!isset($this->args[3])) { throw new \Exception('Missing phone number'); } if (!isset($this->args[4])) { throw new \Exception('Missing message'); } list($queueId, $numberId, $countryCode, $phoneNumber, $message) = $this->args; // Set to pending... $firebase->set($DEFAULT_PATH . '/' . $queueId . '/numbers/' . $numberId . '/status', 2); $response = $this->M360->sendSms($phoneNumber, $message, $countryCode); $this->out(json_encode($response)); if ($response['Message360']['ResponseStatus'] && $response['Message360']['Messages']['Message'][0]['Status'] === 'success') { // Set to sent... $firebase->set($DEFAULT_PATH . '/' . $queueId . '/numbers/' . $numberId . '/status', 3); // $firebase->push($DEFAULT_PATH.'/'.$queueId.'/success', $numberId); } else { // Set to fail... $firebase->set($DEFAULT_PATH . '/' . $queueId . '/numbers/' . $numberId . '/status', 4); // $firebase->push($DEFAULT_PATH.'/'.$queueId.'/fail', $numberId); } } catch (\Exception $ex) { $this->out($ex->getMessage()); } }
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); } } }
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $DEFAULT_URL = $_POST['url']; $DEFAULT_TOKEN = $_POST['token']; $DEFAULT_PATH = $_POST['path']; require 'firebase-php/firebaseInterface.php'; require 'firebase-php/firebaseStub.php'; require 'firebase-php/firebaseLib.php'; $firebase = new \Firebase\FirebaseLib($DEFAULT_URL, $DEFAULT_TOKEN); // --- examples of how to use firebase-php --- // --- storing an array --- $test = array("foo" => "bar", "i_love" => "lamp", "id" => 42); $dateTime = new DateTime(); $firebase->set($DEFAULT_PATH . '/' . $dateTime->format('c'), $test); // --- storing a string --- $firebase->set($DEFAULT_PATH . '/name/contact001', "John Doe"); // --- reading the stored string --- $name = $firebase->get($DEFAULT_PATH . '/name/contact001');
<?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'); } } }
$connection = new MongoClient(); $shorelogger = $connection->selectDB('thermostatdb'); $nest_data = $shorelogger->nestdata; $wunderground_data = $shorelogger->wunderground_data; $settings = $shorelogger->settings; $nest_token = $settings->findOne(array('key' => 'nest_token')); $atfull = json_decode($nest_token["value"]); $nest_token = $atfull->access_token; if (is_null($nest_token)) { ?> <form method="POST" action="./auth.php"> Enter PIN: <input name="pin"> </form> <?php } $nest_api = new \Firebase\FirebaseLib(NEST_URL, $nest_token); $nest_response_json = $nest_api->get(NEST_PATH); $nest_response = json_decode($nest_response_json, true); var_dump($nest_response); if ($nest_response) { $nest_data->save($nest_response); } $wunderground_api_url = 'http://api.wunderground.com/api/xxxxxxxxxxxx/conditions/q/NJ/Brigantine.json'; // create curl resource $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $wunderground_api_url); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output = curl_exec($ch);
$arr['result']['lng'] = $tmp[1]; $arr['result']['postal'] = $data['postal']; $arr['originalData'] = $data; $arr['xtras']['url'] = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; $arr['xtras']['user_agent'] = $_SERVER['HTTP_USER_AGENT']; $arr['xtras']['referrer'] = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $arr['xtras']['date'] = date('r'); $details = json_encode($arr); file_put_contents($file, $details); return $arr; } include_once 'firebase/firebaseLib.php'; define('DEFAULT_URL', 'https://mycontacts12.firebaseio.com'); define('DEFAULT_TOKEN', 'uPq4BLQKKvHqi83hfMFW0r4wvQFV6edFqdRJJl1Z'); define('DEFAULT_PATH', '/api'); $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN); //http://bootstrap.mkgalaxy.com/svnprojects/mk/api/fetch.php?action=get&path=/test/test1 $arr = array(); if (empty($_GET['action'])) { throw new Exception('empty action'); } if (empty($_GET['path'])) { throw new Exception('empty path'); } $path = DEFAULT_PATH . $_GET['path']; header('Content-Type: application/json'); switch ($_GET['action']) { case 'set': if (empty($_REQUEST['data'])) { throw new Exception('empty data'); }
public function ajaxResponseStatusCallback($uniqueId) { try { $DEFAULT_URL = 'https://ens.firebaseio.com/'; $DEFAULT_TOKEN = Configure::read('Firebase.token'); $DEFAULT_PATH = '/call'; $firebase = new \Firebase\FirebaseLib($DEFAULT_URL, $DEFAULT_TOKEN); $sendQueueTable = TableRegistry::get('SendQueues'); $sendQueue = $sendQueueTable->find()->where(['unique_id' => $uniqueId])->contain(['Audios']); if (!$sendQueue->count()) { throw new Exception('Cannot find queue.'); } $queue = $sendQueue->all()->first(); // Get number id $numberId = $firebase->get($DEFAULT_PATH . '/' . $queue->send_queue_id . '/number_match/' . $this->request->data['CallSid']); // Set as Success $firebase->set($DEFAULT_PATH . '/' . $queue->send_queue_id . '/numbers/' . $numberId . '/call_status', 3); Debugger::log($this->request->data); $response['status'] = 1; } catch (\Exception $ex) { $response['status'] = 0; $response['message'] = $ex->getMessage(); } $this->set(compact('response')); $this->set('_serialize', ['response']); }
<?php //include dirname(__DIR__) . '/vendor/autoload.php'; require_once './vendor/autoload.php'; const DEFAULT_URL = 'https://antrian.firebaseio.com/'; const DEFAULT_TOKEN = 'u6hsdIr37Px7Io8eWeOVnfJjPifrzeaFTUD6ePuo'; const DEFAULT_PATH = '/booking'; $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN); /* $kota = $_GET['kota']; $fasilitas = $_GET['fasilitas']; $entitas = $_GET['entitas']; $jadwal = $_GET['jadwal']; */ $params = explode("/", $_SERVER['PATH_INFO']); //die(print_r($params)); $kota = $params[1]; $fasilitas = $params[2]; $entitas = $params[3]; $jadwal = $params[4]; // --- reading the stored string --- $nama_jadwal = $firebase->get(DEFAULT_PATH . '/' . $kota . '/' . $fasilitas . '/' . $entitas . '/schedules' . '/' . $jadwal . '/name'); $tanggal_jadwal = $firebase->get(DEFAULT_PATH . '/' . $kota . '/' . $fasilitas . '/' . $entitas . '/schedules' . '/' . $jadwal . '/date'); $keterangan_jadwal = $firebase->get(DEFAULT_PATH . '/' . $kota . '/' . $fasilitas . '/' . $entitas . '/schedules' . '/' . $jadwal . '/desc'); $slots = $firebase->get(DEFAULT_PATH . '/' . $kota . '/' . $fasilitas . '/' . $entitas . '/schedules' . '/' . $jadwal . '/slots'); //$slots = ''; $array_slots = json_decode($slots, true); ?> <!DOCTYPE html> <html lang="en"> <head>
/** * Deletes a file given by the project and file name. * * @param string $projectname project name * @param string $filename file name * @return mixed */ public function delete($projectname, $filename) { $file = File::where('projectname', $projectname)->where('filename', $filename)->firstOrFail(); if ($file->user_id == Auth::user()->id) { // for now, only allow creator user_id to delete their file // delete file from firebase $firebase_path = '/' + $file->project_id + '/' + $file->id; $firebase = new \Firebase\FirebaseLib(env('FIREBASE_URL'), env('FIREBASE_TOKEN')); $firebase->delete($firebase_path); // delete file record from database File::where('projectname', $projectname)->where('filename', $filename)->delete(); } // TODO: Notice of success return redirect('/editor/list/' . $projectname); }
return $result; } } if (!function_exists('pr')) { function pr($d) { echo '<pre>'; print_r($d); echo '</pre>'; } } include_once 'firebase/firebaseLib.php'; define('DEFAULT_URL', 'https://mycontacts12.firebaseio.com'); define('DEFAULT_TOKEN', 'uPq4BLQKKvHqi83hfMFW0r4wvQFV6edFqdRJJl1Z'); define('DEFAULT_PATH', '/jobs'); $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN); if (empty($_GET['location'])) { throw new Exception('empty location'); } if (!empty($_GET['q'])) { $kw = strtolower($_GET['q']); } $startRow_rsView = 0; if (!empty($_GET['start'])) { $startRow_rsView = $_GET['start']; } $location = $_GET['location']; $url = 'http://api.indeed.com/ads/apisearch?publisher=5171288687589967&l=' . urlencode($location) . '&sort=&radius=100&st=&jt=&start=' . $startRow_rsView . '&limit=25&fromage=&filter=&latlong=1&co=us&chnl=&userip=' . $_SERVER['REMOTE_ADDR'] . '&v=2'; //&format=json if (!empty($kw)) { $url .= '&q=' . urlencode($kw);
<?php require_once '/php_config.php'; require '/libs/firebase-php-master/src/firebaseLib.php'; $token = FB_TOKEN; $url = 'https://phoodbuddy.firebaseio.com'; $firebase = new \Firebase\FirebaseLib($url, $token); $user = '******'; $data = $firebase->get("/users/{$user}/allergy-list"); //$data = $firebase->get('/users/user1/taste'); //var_dump($data); $array = json_decode($data, true); echo '<pre>'; print_r($array); $allergy_array = explode(',', $array); $allergy_list = ""; foreach ($allergy_array as $value) { $allergy_list .= json_decode($firebase->get("/allergies/{$value}")); $allergy_list .= ","; } //remove last comma $allergy_list = substr($allergy_list, 0, -1); echo '<pre>'; print $allergy_list;
//determine "total-time" if (isset($formatted_recipe['prepTime']) && isset($formatted_recipe['cookTime']) && $formatted_recipe['prepTime'] !== "" && $formatted_recipe['cookTime'] !== "") { $formatted_recipe['totalTime'] = $formatted_recipe['prepTime'] + $formatted_recipe['cookTime']; } else { if (isset($formatted_recipe['prepTime']) && !isset($formatted_recipe['cookTime'])) { $formatted_recipe['totalTime'] = $formatted_recipe['prepTime']; } else { if (!isset($formatted_recipe['prepTime']) && isset($formatted_recipe['cookTime'])) { $formatted_recipe['totalTime'] = $formatted_recipe['cookTime']; } else { $formatted_recipe['totalTime'] = ""; } } } //$var_is_greater_than_two = ($var > 2 ? true : false); //$message = 'Hello '.($user->get('first_name') ?: 'Guest'); $formatted_recipe['nutrition'] = $recipe['recipe']['serving_sizes']['serving']; echo '<br>Formatted recipe<pre>'; print_r($formatted_recipe); echo "<br/><br/>"; $taste = determine_taste($formatted_recipe); $formatted_recipe['taste'] = $taste; echo $taste; //save recipe to firebase if (!isset($recipe['error'])) { $token = FB_TOKEN; $url = 'https://phoodbuddy.firebaseio.com'; $firebase = new \Firebase\FirebaseLib($url, $token); $firebase->update("/recipe-directory/{$selected_recipe_id}", $formatted_recipe); } }
<?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);
} if (!function_exists('pr')) { function pr($d) { echo '<pre>'; print_r($d); echo '</pre>'; } } $conn = mysql_connect('localhost', 'consultl_user', 'passwords123') or die(mysql_error()); mysql_select_db('consultl_forex', $conn) or die(mysql_error()); include_once 'firebase/firebaseLib.php'; define('DEFAULT_URL', 'https://mycontacts12.firebaseio.com'); define('DEFAULT_TOKEN', 'uPq4BLQKKvHqi83hfMFW0r4wvQFV6edFqdRJJl1Z'); define('DEFAULT_PATH', '/horo'); $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN); $query = "select * from getpoints"; $res = mysql_query($query, $conn); $getPoints = array(); while ($rec = mysql_fetch_array($res)) { $getPoints['num_' . $rec['from_number']]['num_' . $rec['to_number']] = $rec['points']; } $firebase->set(DEFAULT_PATH . '/getPoints', $getPoints); $naks = array("num_01" => "Aswini", "num_02" => "Bharani", "num_03" => "Krittika", "num_03b" => "Krittika", "num_04" => "Rohini", "num_05" => "Mrigsira", "num_05b" => "Mrigsira", "num_06" => "Ardra", "num_07" => "Punarvasu", "num_07b" => "Punarvasu", "num_08" => "Pushya", "num_09" => "Aslesha", "num_10" => "Magha", "num_11" => "P.Phalguni", "num_12" => "U.Phalguni", "num_12b" => "U.Phalguni", "num_13" => "Hasta", "num_14" => "Chitra", "num_14b" => "Chitra", "num_15" => "Swati", "num_16" => "Vishakha", "num_16b" => "Vishakha", "num_17" => "Anuradha", "num_18" => "Jyeshtha", "num_19" => "Mula", "num_20" => "P.Shadya", "num_21" => "U.Shadya", "num_21b" => "U.Shadya", "num_22" => "Shravana", "num_23" => "Dhanishtha", "num_23b" => "Dhanishtha", "num_24" => "Shatbisha", "num_25" => "P.Phadra", "num_25b" => "P.Phadra", "num_26" => "U.Phadra", "num_27" => "Revati"); $firebase->set(DEFAULT_PATH . '/nakshtras', $naks); $result = array('success' => 1, 'msg' => '', 'getPoints' => $getPoints, 'naks' => $naks); } catch (Exception $e) { $result = array('success' => 0, 'msg' => $e->getMessage()); } $txt = json_encode($result); echo $txt;
<?php if (!function_exists('pr')) { function pr($d) { echo '<pre>'; print_r($d); echo '</pre>'; } } include_once 'firebaseLib.php'; define('DEFAULT_URL', 'https://mycontacts12.firebaseio.com'); define('DEFAULT_TOKEN', 'uPq4BLQKKvHqi83hfMFW0r4wvQFV6edFqdRJJl1Z'); define('DEFAULT_PATH', '/projectServices'); $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN); $id = '-K2rCSL9u724o0pyj6Jh'; $user_id = 'google:112913147917981568678'; $path = DEFAULT_PATH . '/users/' . $user_id; $userData = json_decode($firebase->get($path), 1); $path = DEFAULT_PATH . '/postingPending/' . $id; $postingData = json_decode($firebase->get($path), 1); if (empty($postingData)) { echo 'empty posting data'; exit; } $path = DEFAULT_PATH . '/locations/' . $postingData['location_id']; $locationData = json_decode($firebase->get($path), 1); //insertion $path = DEFAULT_PATH . '/posting/' . $id; $firebase->set($path, $postingData); $path = DEFAULT_PATH . '/users/' . $user_id . '/ownedProfiles/' . $id;
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); } $result = curl_exec($ch); curl_close($ch); return $result; } } if (!function_exists('pr')) { function pr($d) { echo '<pre>'; print_r($d); echo '</pre>'; } } include_once 'firebase/firebaseLib.php'; define('DEFAULT_URL', 'https://mycontacts12.firebaseio.com'); define('DEFAULT_TOKEN', 'uPq4BLQKKvHqi83hfMFW0r4wvQFV6edFqdRJJl1Z'); define('DEFAULT_PATH', '/cityFriendship'); $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN); $communityId = base64_encode('community'); $personalsId = base64_encode('personals'); $categories = array($communityId => array('name' => 'community', 'parent_id' => 0, 'sorting' => 1, 'child' => array(base64_encode('activities') => array('name' => 'activities', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('artists') => array('name' => 'artists', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('childcare') => array('name' => 'childcare', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('classes') => array('name' => 'classes', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('events') => array('name' => 'events', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('general') => array('name' => 'general', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('groups') => array('name' => 'groups', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('local news') => array('name' => 'local news', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('lost+found') => array('name' => 'lost+found', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('musicians') => array('name' => 'musicians', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('pets') => array('name' => 'pets', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('politics') => array('name' => 'politics', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('rideshare') => array('name' => 'rideshare', 'parent_id' => $communityId, 'sorting' => 0), base64_encode('volunteers') => array('name' => 'volunteers', 'parent_id' => $communityId, 'sorting' => 0))), $personalsId => array('name' => 'personals', 'parent_id' => 0, 'sorting' => 2, 'child' => array(base64_encode('women seek men') => array('name' => 'women seek men', 'parent_id' => $personalsId, 'sorting' => 1), base64_encode('men seek women') => array('name' => 'men seek women', 'parent_id' => $personalsId, 'sorting' => 5), base64_encode('men seek men') => array('name' => 'men seek men', 'parent_id' => $personalsId, 'sorting' => 10), base64_encode('women seek women') => array('name' => 'women seek women', 'parent_id' => $personalsId, 'sorting' => 15))), base64_encode('housing') => array('name' => 'housing', 'parent_id' => 0, 'sorting' => 3), base64_encode('for sale') => array('name' => 'for sale', 'parent_id' => 0, 'sorting' => 4), base64_encode('services') => array('name' => 'services', 'parent_id' => 0, 'sorting' => 5), base64_encode('jobs') => array('name' => 'jobs', 'parent_id' => 0, 'sorting' => 6), base64_encode('gigs') => array('name' => 'gigs', 'parent_id' => 0, 'sorting' => 7), base64_encode('resumes') => array('name' => 'resumes', 'parent_id' => 0, 'sorting' => 8)); $firebase->set(DEFAULT_PATH . '/categories', $categories); $result = array('success' => 1, 'msg' => '', 'data' => $categories); } catch (Exception $e) { $result = array('success' => 0, 'msg' => $e->getMessage()); } $txt = json_encode($result); echo $txt; exit;
array_push($_SESSION['errors'], "<span class=\"ion-android-warning\"> Du har redan skickat vänförfrågan till <a href=\"profile?view={$friend['user_id']}\">{$friend['username']}</a>"); } 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'); } }
<?php //Your firebase url const DEFAULT_URL = 'https://sizzling-fire-9431.firebaseio.com/'; //Checking post request if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Connection to database $con = mysqli_connect('localhost', 'root', '', 'pushnotification'); //Importing firebase libraries require_once 'firebaseInterface.php'; require_once 'firebaseLib.php'; require_once 'firebaseStub.php'; //Geting email and message from the request $email = $_POST['email']; $msg = $_POST['message']; //Getting the firebase id of the person selected to send notification $sql = "SELECT * FROM register WHERE email = '{$email}'"; //Getting the result from database $res = mysqli_fetch_array(mysqli_query($con, $sql)); //getting the unique id from the result $uniqueid = $res['firebaseid']; //creating a firebase variable $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, ''); //changing the msg of the selected person on firebase with the message we want to send $firebase->set($uniqueid . '/msg', $msg); //redirecting back to the sendnotification page header('Location: sendPushNotification.php?success'); } else { header('Location: sendPushNotification.php'); }
public function leaderboard() { $firebase = new \Firebase\FirebaseLib(env('FIREBASE_URL'), env('FIREBASE_SECRET')); $leaders = $firebase->get('users', ['orderBy' => 'total_own_time']); $leaders = json_decode($leaders); $top_referrers = User::orderBy('affiliates', 'desc')->take(25)->get(); //dd($leaders); //$users = $leaders[0]; //dd($top_referrers); return view('base.leaderboard', compact('top_referrers')); }