Example #1
0
 /**
  * Fetches locale for a certain language application combo
  *
  * @param  string $language
  * @param  string $application
  *
  * @return array
  */
 protected function getLocale($language, $application)
 {
     return (array) $this->database->getRecords('SELECT type, module, name, value
          FROM locale
          WHERE language = ? AND application = ?
          ORDER BY type ASC, name ASC, module ASC', array($language, $application));
 }
 public function load(\SpoonDatabase $database)
 {
     $galleryId = $database->getVar('SELECT id
          FROM slideshow_galleries
          WHERE title = :title AND language = :language
          LIMIT 1', array('title' => 'Slideshow for functional tests', 'language' => 'en'));
     $database->insert('slideshow_images', array('id' => 1, 'gallery_id' => $galleryId, 'language' => 'en', 'title' => 'Slideshow image for functional tests', 'caption' => '<p>caption of the slideshow image</p>', 'filename' => 'slideshow-image-for-functional-tests'));
 }
Example #3
0
 public function load(\SpoonDatabase $database)
 {
     $metaId = $database->insert('meta', array('keywords' => 'Is this a working test?', 'description' => 'Is this a working test?', 'title' => 'Is this a working test?', 'url' => 'is-this-a-working-test'));
     $categoryId = $database->getVar('SELECT id
          FROM faq_categories
          WHERE title = :title AND language = :language
          LIMIT 1', array('title' => 'Faq for tests', 'language' => 'en'));
     $database->insert('faq_questions', array('meta_id' => $metaId, 'category_id' => $categoryId, 'user_id' => 1, 'language' => 'en', 'question' => 'Is this a working test?', 'answer' => '<p>I hope so.</p>', 'created_on' => '2015-02-23 00:00:00', 'hidden' => 'N', 'sequence' => 1));
 }
Example #4
0
 /**
  * @param \SpoonDatabase $database
  */
 public function load(\SpoonDatabase $database)
 {
     $metaId = $database->insert('meta', array('keywords' => 'Blogpost for functional tests', 'description' => 'Blogpost for functional tests', 'title' => 'Blogpost for functional tests', 'url' => 'blogpost-for-functional-tests'));
     $categoryId = $database->getVar('SELECT id
          FROM blog_categories
          WHERE title = :title AND language = :language
          LIMIT 1', array('title' => 'BlogCategory for tests', 'language' => 'en'));
     $database->insert('blog_posts', array('id' => 1, 'meta_id' => $metaId, 'category_id' => $categoryId, 'user_id' => 1, 'language' => 'en', 'title' => 'Blogpost for functional tests', 'introduction' => '<p>Lorem ipsum dolor sit amet</p>', 'text' => '<p>Lorem ipsum dolor sit amet</p>', 'status' => 'active', 'publish_on' => '2015-02-23 00:00:00', 'created_on' => '2015-02-23 00:00:00', 'edited_on' => '2015-02-23 00:00:00', 'num_comments' => 0));
     $database->insert('search_index', array('module' => 'Blog', 'other_id' => 1, 'field' => 'title', 'value' => 'Blogpost for functional tests', 'language' => 'en', 'active' => 'Y'));
 }
 public function load(\SpoonDatabase $database)
 {
     $metaId = $database->insert('meta', array('keywords' => 'Slideshow for functional tests', 'description' => 'Slideshow for functional tests', 'title' => 'Slideshow for functional tests', 'url' => 'slideshow-for-functional-tests'));
     $categoryId = $database->getVar('SELECT id
          FROM slideshow_categories
          WHERE title = :title AND language = :language
          LIMIT 1', array('title' => 'SlideshowCategory for tests', 'language' => 'en'));
     $database->insert('slideshow_galleries', array('id' => 1, 'meta_id' => $metaId, 'category_id' => $categoryId, 'user_id' => 1, 'language' => 'en', 'title' => 'Slideshow for functional tests', 'description' => '<p>Description of the slideshow</p>', 'width' => 200, 'height' => 200, 'publish_on' => '2015-03-27 00:00:00', 'created_on' => '2015-03-27 00:00:00', 'edited_on' => '2015-03-27 00:00:00'));
     $database->insert('search_index', array('module' => 'Slideshow', 'other_id' => 1, 'field' => 'title', 'value' => 'Slideshow for functional tests', 'language' => 'en', 'active' => 'Y'));
 }
Example #6
0
    /**
     * Build the language files
     *
     * @return	void
     * @param	SpoonDatabase $db		The database connection instance.
     * @param	string $language		The language to build the locale-file for.
     * @param	string $application		The application to build the locale-file for.
     */
    public function buildCache(SpoonDatabase $db, $language, $application)
    {
        // get types
        $types = $db->getEnumValues('locale', 'type');
        // get locale for backend
        $locale = (array) $db->getRecords('SELECT type, module, name, value
											FROM locale
											WHERE language = ? AND application = ?
											ORDER BY type ASC, name ASC, module ASC', array((string) $language, (string) $application));
        // start generating PHP
        $value = '<?php' . "\n";
        $value .= '/**' . "\n";
        $value .= ' *' . "\n";
        $value .= ' * This file is generated by the Installer, it contains' . "\n";
        $value .= ' * more information about the locale. Do NOT edit.' . "\n";
        $value .= ' * ' . "\n";
        $value .= ' * @author		Installer' . "\n";
        $value .= ' * @generated	' . date('Y-m-d H:i:s') . "\n";
        $value .= ' */' . "\n";
        $value .= "\n";
        // loop types
        foreach ($types as $type) {
            // default module
            $modules = array('core');
            // continue output
            $value .= "\n";
            $value .= '// init var' . "\n";
            $value .= '$' . $type . ' = array();' . "\n";
            $value .= '$' . $type . '[\'core\'] = array();' . "\n";
            // loop locale
            foreach ($locale as $i => $item) {
                // types match
                if ($item['type'] == $type) {
                    // new module
                    if (!in_array($item['module'], $modules)) {
                        $value .= '$' . $type . '[\'' . $item['module'] . '\'] = array();' . "\n";
                        $modules[] = $item['module'];
                    }
                    // parse
                    if ($application == 'backend') {
                        $value .= '$' . $type . '[\'' . $item['module'] . '\'][\'' . $item['name'] . '\'] = \'' . str_replace('\\"', '"', addslashes($item['value'])) . '\';' . "\n";
                    } else {
                        $value .= '$' . $type . '[\'' . $item['name'] . '\'] = \'' . str_replace('\\"', '"', addslashes($item['value'])) . '\';' . "\n";
                    }
                    // unset
                    unset($locale[$i]);
                }
            }
        }
        // close php
        $value .= "\n";
        $value .= '?>';
        // store
        SpoonFile::setContent(PATH_WWW . '/' . $application . '/cache/locale/' . $language . '.php', $value);
    }
Example #7
0
 /**
  * Validate if a database connection can be made
  *
  * @param InstallationData          $data    The form data
  * @param ExecutionContextInterface $context The forms validation context
  *
  * @todo   Replace SpoonDatabase
  */
 public function checkDatabaseConnection(InstallationData $data, ExecutionContextInterface $context)
 {
     try {
         // create instance
         $db = new \SpoonDatabase('mysql', $data->getDbHostname(), $data->getDbUsername(), $data->getDbPassword(), $data->getDbDatabase(), $data->getDbPort());
         // test table
         $table = 'test' . time();
         // attempt to create table
         $db->execute('DROP TABLE IF EXISTS ' . $table);
         $db->execute('CREATE TABLE ' . $table . ' (id int(11) NOT NULL) ENGINE=MyISAM');
         // drop table
         $db->drop($table);
     } catch (\Exception $e) {
         $context->addViolation('Problem with database credentials');
     }
 }
Example #8
0
 /**
  * Save the link list
  *
  * @param  array  $navigation The full navigation array
  * @param  array  $keys       The page keys
  * @param  string $language   The language to save the file for
  * @return string             The full content for the cache file
  */
 protected function dumpEditorLinkList($navigation, $keys, $language)
 {
     // get the order
     foreach (array_keys($navigation) as $type) {
         $order[$type] = $this->getOrder($navigation, $type, 0);
     }
     // start building the cache file
     $editorLinkListString = $this->getCacheHeader('the links that can be used by the editor');
     // init var
     $links = array();
     // init var
     $cachedTitles = (array) $this->database->getPairs('SELECT i.id, i.navigation_title
          FROM pages AS i
          WHERE i.id IN(' . implode(',', array_keys($keys)) . ')
          AND i.language = ? AND i.status = ?', array($language, 'active'));
     // loop the types in the order we want them to appear
     foreach (array('page', 'meta', 'footer', 'root') as $type) {
         // any pages?
         if (isset($order[$type])) {
             // loop pages
             foreach ($order[$type] as $pageId => $url) {
                 // skip if we don't have a title
                 if (!isset($cachedTitles[$pageId])) {
                     continue;
                 }
                 // get the title
                 $title = \SpoonFilter::htmlspecialcharsDecode($cachedTitles[$pageId]);
                 // split into chunks
                 $urlChunks = explode('/', $url);
                 // remove the language chunk
                 $hasMultiLanguages = BackendModel::getContainer()->getParameter('site.multilanguage');
                 $urlChunks = $hasMultiLanguages ? array_slice($urlChunks, 2) : array_slice($urlChunks, 1);
                 // subpage?
                 if (count($urlChunks) > 1) {
                     // loop while we have more then 1 chunk
                     while (count($urlChunks) > 1) {
                         // remove last chunk of the url
                         array_pop($urlChunks);
                         // build the temporary URL, so we can search for an id
                         $tempUrl = implode('/', $urlChunks);
                         // search the pageID
                         $tempPageId = array_search($tempUrl, $keys);
                         // prepend the title
                         if (!isset($cachedTitles[$tempPageId])) {
                             $title = ' > ' . $title;
                         } else {
                             $title = $cachedTitles[$tempPageId] . ' > ' . $title;
                         }
                     }
                 }
                 // add
                 $links[] = array($title, $url);
             }
         }
     }
     // add JSON-string
     $editorLinkListString .= 'var linkList = ' . json_encode($links) . ';';
     return $editorLinkListString;
 }
Example #9
0
 /**
  * Set the number of results.
  */
 private function setNumResults()
 {
     // based on resultsQuery
     if ($this->numResultsQuery != '') {
         $this->numResults = (int) $this->db->getVar($this->numResultsQuery, $this->numResultsQueryParameters);
     } else {
         $this->numResults = (int) $this->db->getNumRows($this->query, $this->queryParameters);
     }
 }
Example #10
0
 /**
  * Validate the form based on the variables in $_POST
  */
 private function validateForm()
 {
     // form submitted
     if ($this->frm->isSubmitted()) {
         // database settings
         $this->frm->getField('hostname')->isFilled('This field is required.');
         $this->frm->getField('database')->isFilled('This field is required.');
         $this->frm->getField('username')->isFilled('This field is required.');
         $this->frm->getField('password')->isFilled('This field is required.');
         // all filled out
         if ($this->frm->getField('hostname')->isFilled() && $this->frm->getField('database')->isFilled() && $this->frm->getField('username')->isFilled() && $this->frm->getField('password')->isFilled()) {
             // test the database connection details
             try {
                 // get port
                 $port = $this->frm->getField('port')->isFilled() ? $this->frm->getField('port')->getValue() : 3306;
                 // create instance
                 $db = new SpoonDatabase('mysql', $this->frm->getField('hostname')->getValue(), $this->frm->getField('username')->getValue(), $this->frm->getField('password')->getValue(), $this->frm->getField('database')->getValue(), $port);
                 // test table
                 $table = 'test' . time();
                 // attempt to create table
                 $db->execute('DROP TABLE IF EXISTS ' . $table);
                 $db->execute('CREATE TABLE ' . $table . ' (id int(11) NOT NULL) ENGINE=MyISAM');
                 // drop table
                 $db->drop($table);
             } catch (Exception $e) {
                 // add errors
                 $this->frm->addError('Problem with database credentials');
                 // show error
                 $this->tpl->assign('formError', $e->getMessage());
             }
             // all valid
             if ($this->frm->isCorrect()) {
                 // update session
                 SpoonSession::set('db_hostname', $this->frm->getField('hostname')->getValue());
                 SpoonSession::set('db_database', $this->frm->getField('database')->getValue());
                 SpoonSession::set('db_username', $this->frm->getField('username')->getValue());
                 SpoonSession::set('db_password', $this->frm->getField('password')->getValue());
                 SpoonSession::set('db_port', $this->frm->getField('port')->getValue());
                 // redirect
                 SpoonHTTP::redirect('index.php?step=6');
             }
         }
     }
 }
Example #11
0
 public function index()
 {
     //die();
     $this->load->model("clientdb");
     include __DIR__ . "/../../../../clientManager_new/cm_includes/spoon/spoon.php";
     $mysql = new SpoonDatabase("mysql", "localhost", "root", "", "clienthub");
     $source = $mysql->getRecords("SELECT * FROM profiles");
     /*for($i=1; $i<=1683; $i++){
     			$gravatar = null;
     			if(isset($source[$i-1]["photo"])){
     				$gravatar = $source[$i-1]['photo'].".".$source[$i-1]['photoext'];
     			}
     			$this->db->insert('clients', array('name' => $source[$i-1]['name'], "gravatar" => $gravatar, "status" => ($source[$i-1]['status'] == "trash" ? "trash" : "active")));
     		}*/
     foreach ($source as $num => $row) {
         $data = array('id' => $row["id"], 'file' => $row["file"], 'case' => $row["case"], 'ic' => $row["ic"], 'sex' => $row["gender"] == null ? null : ($row["gender"] == "male" ? "男" : "女"), 'placeofbirth' => $row["placeofbirth"], 'education' => $row["education"], 'language' => $row["language"], 'race' => $row["race"], 'faith' => $row["faith"], 'maritalstatus' => $row["maritalstatus"] == "Married" ? "已婚" : ($row["maritalstatus"] == "Singer" ? "单身" : "不详"), 'nationality' => $row["nationality"], 'profession' => $row["profession"], 'address' => $row["address"], 'epf' => $row["epf"], 'banker' => $row["banker"], 'contactno' => $row["contactno"], 'email' => $row["email"], 'platesno' => $row["platesno"], 'asset' => $row["assets"], 'height' => $row["height"], 'weight' => $row["weight"], 'blood' => $row["blood"], 'eye' => $row["eye"], 'hair' => $row["hair"], 'skin' => $row["skin"], 'dna' => $row["dna"], 'case' => $row["casereport"], 'family' => $row["family"], 'company' => implode(" ", explode(", ", $row["company"])), 'remarks' => $row["remarks"]);
         $this->db->insert('clientsdata', $data);
     }
 }
Example #12
0
date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// do I know you?
if (SpoonSession::exists('public_uid')) {
    $tpl->assign('oLogout', true);
    $tpl->assign('oNavMe', true);
    $uid = SpoonSession::get('public_uid');
    $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
    $user = $db->getRecord('SELECT * FROM users WHERE user_id = ?', $uid);
    $tpl->assign('uname', $user['username']);
    if ($user['fb_uid'] != null) {
        $tpl->assign('fbu', $user['fb_uid']);
    } else {
        $tpl->assign('fbu', 1);
    }
    $lastChecking = $db->getRecord('SELECT * FROM checkins WHERE user_id = ? ORDER BY timestamp DESC', $uid);
    $lastPub = $db->getRecord('SELECT * FROM pubs WHERE pub_id = ?', $lastChecking['pub_id']);
    $tpl->assign('lastPub', $lastPub['name']);
    $tpl->assign('lastPubId', $lastPub['pub_id']);
    $tpl->assign('lastDate', SpoonDate::getTimeAgo(strtotime($lastChecking['timestamp'])));
    /*code max*/
    $recentDrinks = PublicApp::getRecentDrinks();
    $recentCheckins = PublicApp::getRecentCheckins();
Example #13
0
date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// do I know you?
if (SpoonSession::exists('public_uid')) {
    $tpl->assign('oLogout', true);
    $tpl->assign('oNavMe', true);
    $uid = SpoonSession::get('public_uid');
    $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
    $checkins = $db->getRecords('SELECT * FROM checkins WHERE user_id = ?', $uid);
    $user = new User($uid);
    $tpl->assign('daysActive', 'NOT ENOUGH DATA');
    $tpl->assign('checkins', count($checkins));
    $tpl->assign('avgDrinks', 'NOT ENOUGH DATA');
    $tpl->assign('avgDay', 'NOT ENOUGH DATA');
    $tpl->assign('topFriends', 'NOT ENOUGH DATA');
    if ($user->GetTopPubs(5) !== null) {
        $tpl->assign('oTopPubs', true);
        $tpl->assign('iTopPubs', $user->GetTopPubs(5));
    } else {
        $tpl->assign('oNoTopPubs', true);
    }
} else {
    //GTFO!!!
Example #14
0
 /**
  * @param \SpoonDatabase $database
  */
 public function load(\SpoonDatabase $database)
 {
     $metaId = $database->insert('meta', array('keywords' => 'Faq for tests', 'description' => 'Faq for tests', 'title' => 'Faq for tests', 'url' => 'faqcategory-for-tests'));
     $database->insert('faq_categories', array('meta_id' => $metaId, 'extra_id' => 0, 'language' => 'en', 'title' => 'Faq for tests', 'sequence' => 1));
 }
Example #15
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
// facebook php
require_once 'facebook/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array('appId' => '177481728946474', 'secret' => '6d5db3a0e538eb5aa7bebe6ae0bb2efe', 'cookie' => true));
$session = $facebook->getSession();
// Session based API call.
if ($session) {
    try {
        $fb_uid = $facebook->getUser();
        $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
        $var = $db->getRecord('SELECT * FROM users WHERE fb_uid = ?', $fb_uid);
        if (!empty($var)) {
            spoonSession::start();
            SpoonSession::set('public_uid', $var['user_id']);
            SpoonHTTP::redirect('dashboard.php');
        } else {
            SpoonHTTP::redirect('register.php');
        }
    } catch (FacebookApiException $e) {
        error_log($e);
    }
}
Example #16
0
 /**
  * @param \SpoonDatabase $database
  */
 public function load(\SpoonDatabase $database)
 {
     $metaId = $database->insert('meta', array('keywords' => 'BlogCategory for tests', 'description' => 'BlogCategory for tests', 'title' => 'BlogCategory for tests', 'url' => 'blogcategory-for-tests'));
     $database->insert('blog_categories', array('meta_id' => $metaId, 'language' => 'en', 'title' => 'BlogCategory for tests'));
 }
Example #17
0
date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// do I know you?
if (SpoonSession::exists('public_uid')) {
    $tpl->assign('oLogout', true);
    // show the output of get()
    $uid = SpoonSession::get('public_uid');
    // make a connection
    $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
    $user = $db->getRecord('SELECT * FROM users WHERE user_id = ?', $uid);
    //Spoon::dump($user);
    if ($user['fb_uid'] != null) {
        $tpl->assign('fbu', $user['fb_uid']);
    } else {
        $tpl->assign('fbu', 1);
    }
    $tpl->assign('uname', $user['username']);
    $tpl->assign('firstname', $user['first_name']);
    $tpl->assign('lastname', $user['last_name']);
    $tpl->assign('email', $user['mail']);
    //spoon::dump($user);
    //$tpl->assign('gender', $user['gender']);
    //$tpl->assign('weight', $user['weight']);
    //  $tpl->assign('birth', $user['birth_date']);
 /**
  * @depends testExecute
  */
 public function testTruncate()
 {
     $this->db->truncate('users');
     $this->db->truncate(array('users'));
     $this->assertEquals(0, $this->db->getNumRows('SELECT id FROM users'));
 }
Example #19
0
 public function __construct()
 {
     parent::__construct($this->driver, $this->hostname, $this->username, $this->password, $this->database);
 }
Example #20
0
 /**
  * Executes sql in the database
  *
  * @param \SpoonDatabase $database
  * @param string $sql
  */
 protected function importSQL($database, $sql)
 {
     $database->execute(trim($sql));
 }
 /**
  * @throws SpoonDatabaseException
  */
 public function testGetNumRows()
 {
     $this->assertEquals(self::NUMBER_OF_ROWS, $this->db->getNumRows('SELECT id FROM users'));
     $this->assertEquals(10000, $this->db->getNumRows('SELECT id FROM users LIMIT ?', array(10000)));
 }
Example #22
0
 /**
  * @param InstallationData $data
  */
 protected function buildDatabase(InstallationData $data)
 {
     // put a new instance of the database in the container
     $database = new \SpoonDatabase('mysql', $data->getDbHostname(), $data->getDbUsername(), $data->getDbPassword(), $data->getDbDatabase(), $data->getDbPort());
     $database->execute('SET CHARACTER SET :charset, NAMES :charset, time_zone = "+0:00"', array('charset' => 'utf8'));
     $this->container->set('database', $database);
 }
Example #23
0
 /**
  * Get (or create and get) a database-connection
  * @later split the write and read connection
  *
  * @param bool[optional] $write Do you want the write-connection or not?
  * @return SpoonDatabase
  */
 public static function getDB($write = false)
 {
     $write = (bool) $write;
     // do we have a db-object ready?
     if (!Spoon::exists('database')) {
         // create instance
         $db = new SpoonDatabase(DB_TYPE, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT);
         // utf8 compliance & MySQL-timezone
         $db->execute('SET CHARACTER SET utf8, NAMES utf8, time_zone = "+0:00"');
         // store
         Spoon::set('database', $db);
     }
     // return db-object
     return Spoon::get('database');
 }
Example #24
0
    die('BASE_URL config error in config.php. (Should not contain "\\" or "/" in last word!)');
}
if (!isset($_SESSION)) {
    session_start();
}
//authentication
if (!defined('IN_API') && !defined('IN_LOGIN')) {
    if (!isset($_SESSION['expired']) || time() > $_SESSION['expired'] || !isset($_SESSION['logined']) || $_SESSION['logined'] != true || $_SESSION['adminname'] != ADMINNAME || $_SESSION['adminpw'] != ADMINPASSWORD) {
        if (defined(IN_PHOTO)) {
            die;
        }
        header('Location: ' . BASE_URL . '/login.php');
    }
}
//loading mysql system
$mysql = new SpoonDatabase('mysql', MYSQL_HOST, MYSQL_UN, MYSQL_PW, MYSQL_DB);
if (defined('LOAD_TEMPLATE')) {
    //loading template system
    $tpl = new SpoonTemplate();
    $tpl->setForceCompile(true);
    $tpl->setCompileDirectory(COMPILE_PATH);
    //loading
    $tpl->assign('title', SITE_TITLE);
    $tpl->assign('base_url', BASE_URL);
    $tpl->assign('css_path', BASE_URL . '/' . CONTENTS_PATH . '/css/style.css');
    $tpl->assign('jquery_path', BASE_URL . '/' . CONTENTS_PATH . '/js/jquery-1.6.4.min.js');
    $tpl->assign('profiles_total', count($mysql->getRecords('SELECT `id` FROM `profiles` WHERE `status` !=  \'trash\'')));
    $tpl->assign('expired', round(($_SESSION['expired'] - time()) / 60, 1));
    //expired time in minutes
    $tpl->assign('adminname', md5(ADMINNAME));
    $tpl->assign('adminpw', md5(ADMINPASSWORD));
Example #25
0
// facebook php
require_once 'facebook/facebook.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// check if the key exists
if (SpoonSession::exists('public_uid')) {
    // Create our Application instance (replace this with your appId and secret).
    $facebook = new Facebook(array('appId' => '118234134911012', 'secret' => 'a83b1fbf766dcf41a8238a13f53690bd', 'cookie' => true));
    //$facebook->setSession(null);
    $session = $facebook->getSession();
    //spoon::dump($session);
    // Session based API call.
    if ($session) {
        try {
            $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
            $record = array();
            //$record['fb_access_token'] = $facebook->getAccessToken();
            $record['fb_uid'] = $facebook->getUser();
            $record['fb_publish_stream'] = true;
            $uid = SpoonSession::get('public_uid');
            $rows = $db->update('users', $record, 'user_id = ?', $uid);
            SpoonHTTP::redirect('dashboardSettings.php');
        } catch (FacebookApiException $e) {
            error_log($e);
        }
    } else {
        $tpl->assign('fbcbutton', '<fb:login-button perms="email,publish_stream"></fb:login-button>');
        //http://developers.facebook.com/docs/authentication/permissions
    }
    // facebook javascript