示例#1
0
<?php

require 'boot.php';
$uid = $facebook->getUser();
$facepalm = Facepalm::fetchFromFacebookId($uid);
if ($facepalm) {
    $facepalm->clearFacebook();
}
header('location: index.php');
// allready logout
示例#2
0
<?php

require 'boot.php';
$facepalm = Facepalm::identify($_REQUEST);
if ($facepalm == null) {
    echo json_encode(array('errorcode' => 'invaliduser'));
} else {
    $facepalm->remove();
    echo '{}';
}
示例#3
0
<?php

require 'boot.php';
$uid = $facebook->getUser();
$session = $facebook->getSession();
$facepalm = new Facepalm($_GET['id']);
$facepalm->setFacebook($uid, $session['access_token']);
header('location: index.php');
示例#4
0
if (isset($_GET['lang'])) {
    setcookie('lang', $_COOKIE['lang'] = $_GET['lang']);
    header('location:index.php');
    die;
}
require 'boot.php';
require 'i18n/' . $lang . '.php';
if (count($_POST) > 0 || isset($_GET['borrar']) || isset($_GET['touch'])) {
    if ($_GET['touch'] > 0) {
        $facepalm = new Facepalm($_GET['touch']);
        $facepalm->touch($_GET['reason']);
        $_COOKIE['id-user'] = (int) $_GET['touch'] . '-' . $facepalm->name();
        setcookie('id-user', $_COOKIE['id-user'], time() + 30 * 24 * 60 * 60);
    }
    if ($_GET['borrar'] > 0) {
        $facepalm = new Facepalm($_GET['borrar']);
        $facepalm->remove();
        setcookie('id-user', '', time() - 1);
    }
    if ($_POST['nombre_nuevo']) {
        $id = Facepalm::create($_POST['nombre_nuevo']);
        $_COOKIE['id-user'] = $id . '-' . $_POST['nombre_nuevo'];
        setcookie('id-user', $_COOKIE['id-user'], time() + 30 * 24 * 60 * 60);
    }
    header('location:index.php');
    die;
}
$users = Facepalm::fetchlist();
$uid = 0;
if ($facebook->getSession()) {
    $uid = $facebook->getUser();
示例#5
0
<?php

require 'boot.php';
$name = trim($_REQUEST['name']);
if (empty($name)) {
    echo json_encode(array('errorcode' => 'invalidname'));
} else {
    $id = Facepalm::create($name);
    if (empty($id)) {
        echo json_encode(array('errormessage' => 'Failed to insert - probably user nickname'));
    } else {
        echo json_encode(array('id' => $id));
    }
}
示例#6
0
<?php

$config['base_url'] = 'http://facepalm.delapalo.net/';
$config['facebook_app_id'] = '146881561998534';
$config['facebook_app_secret'] = 'e70e5c589a57ee66a96796451a063330';
$config['default_timezone'] = 'America/Argentina/Buenos_Aires';
define('SOCIAL_NETWORK_FACEBOOK', 1);
$id = NULL;
if (isset($config['default_timezone'])) {
    date_default_timezone_set($config['default_timezone']);
}
$filename = dirname(__FILE__) . '/../db.sql';
$is_new_database = !is_file($filename);
$database = new PDO('sqlite:' . $filename);
if ($is_new_database) {
    $database->query('CREATE TABLE facepalm ( id INTEGER PRIMARY KEY, nombre TEXT unique, fecha NUMERIC )');
    $database->query('CREATE TABLE facepalm_log ( id INTEGER PRIMARY KEY, user_id NUMERIC, fecha NUMERIC, reason TEXT, vote_up NUMERIC, vote_down NUMERIC )');
    $database->query('CREATE TABLE user_mail ( id INTEGER PRIMARY KEY, user_id NUMERIC, email_hash TEXT unique )');
    $database->query('CREATE TABLE social_network (id INTEGER PRIMARY KEY,  facepalm_id INTEGER, network_id INTEGER, public_info TEXT NOT NULL, access_token TEXT NOT NULL )');
}
require dirname(__FILE__) . '/classes/Facepalm.php';
require 'classes/facebook.php';
$facebook = new Facebook(array('appId' => $config['facebook_app_id'], 'secret' => $config['facebook_app_secret'], 'cookie' => true));
$default_lang = 'es';
$lang = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : $default_lang;
if (!is_file('i18n/' . $lang . '.php')) {
    $lang = $default_lang;
}
Facepalm::$db = $database;
示例#7
0
<?php

require 'boot.php';
$query = $database->query('SELECT * FROM facepalm ORDER BY nombre ASC, id ASC');
header('Content-type:application/json');
echo json_encode(Facepalm::fetchlist());