function _get_nsid($flickr_user, $more = array())
{
    # TO DO: put this all in a function somewhere and
    # call/queue it when a user signs up...
    # As db_main:Users
    $user = users_get_by_id($flickr_user['user_id']);
    if (!$user) {
        return;
    }
    $method = 'flickr.people.getInfo';
    $args = array('user_id' => $flickr_user['nsid']);
    $ret = flickr_api_call($method, $args);
    if (!$ret['ok']) {
        dumper($args);
        dumper($ret);
        return;
    }
    $rsp = $ret['rsp']['person'];
    $path_alias = $rsp['path_alias'];
    $username = $rsp['username']['_content'];
    echo "[{$user['id']}] path alias: {$path_alias} screen name: {$username}\n";
    if ($path_alias != $flickr_user['path_alias']) {
        $update = array('path_alias' => $path_alias);
        $rsp = flickr_users_update_user($flickr_user, $update);
        echo "[{$user['id']}] update path alias: {$rsp['ok']}\n";
        # just let this fail silently if there's a duplicate
        flickr_users_path_aliases_create($user, $path_alias);
    }
    if ($username != $user['username']) {
        $update = array('username' => $username);
        $rsp = users_update_user($user, $update);
        echo "[{$user['id']}] update username: {$rsp['ok']}\n";
    }
}
Ejemplo n.º 2
0
 function dump()
 {
     $s = $this->smarty;
     unset($this->smarty);
     dumper($this);
     $this->smarty = $s;
 }
Ejemplo n.º 3
0
 public function sender($to, $subject, $message, $html = false, $reply_to = false, $name = false)
 {
     $to = trim($to);
     $debug = $this->debug;
     if ($reply_to == '') {
         $reply_to = false;
     }
     if ($name == '') {
         $name = false;
     }
     if (!$reply_to) {
         $reply_to = '*****@*****.**';
     }
     $this->load->library('Amazon_ses');
     $this->amazon_ses->debug($debug);
     $this->amazon_ses->to($to);
     $this->amazon_ses->subject($subject);
     if ($name) {
         $this->amazon_ses->from($reply_to, $name);
     } else {
         $this->amazon_ses->from($reply_to);
     }
     if ($html) {
         $this->amazon_ses->message($html);
     }
     $this->amazon_ses->message_alt($message);
     // $this->amazon_ses->message($message);
     if ($debug) {
         $ret = PHP_EOL . 'reply_to: ' . $reply_to . PHP_EOL;
         $ret .= 'name: ' . $name . PHP_EOL;
         $ret .= 'to: ' . $to . PHP_EOL;
         $ret .= 'subject: ' . $subject . PHP_EOL;
         $ret .= 'message: ' . $message . PHP_EOL;
         $ret .= 'html: ' . $html . PHP_EOL;
         $ret .= 'SES debug: ' . $this->amazon_ses->send();
         dumper($ret);
     } else {
         // log the despatch
         // $param['to'] = $to;
         // $param['subject'] = $to;
         // $param['reply_to'] = $to;
         // $param['name'] = $to;
         // $param['message'] = $to;
         // $param['html'] = $to;
         // $this->db->insert('email_log', $param);
         $ret = $this->amazon_ses->send();
     }
     return $ret;
 }
Ejemplo n.º 4
0
 /**
  *  default method
  */
 public function index()
 {
     if (isset($_SESSION['__sessiondata']['loggedin'])) {
         $this->initDB();
         try {
             $stmt = $this->DB->prepare("SELECT id, service, username, image, active, created FROM socialaccounts WHERE user_id = :userid AND service = 'twitter'");
             $stmt->execute(array(':userid' => $_SESSION['__sessiondata']['user_id']));
             $this->services = $stmt->fetchAll();
         } catch (Exception $e) {
             dumper($e->getMessage());
             return FALSE;
         }
     }
     //dumper($_SERVER);
 }
Ejemplo n.º 5
0
 public function cmd_option($args = null)
 {
     $cnt = null === $args ? 0 : count($args);
     $opts = $this->option();
     if ($opts == null) {
         logger("Crap, something when wrong!\n");
         return -1;
     }
     switch ($cnt) {
         case 1:
         case 2:
         case 3:
         default:
             dumper($opts);
             break;
         case 4:
             $opt = $this->option($args[2], $args[3]);
             logger(sprintf("%30s => %s\n", $args[2], $opt[$args[2]]));
             break;
     }
     return 0;
 }
Ejemplo n.º 6
0
 /**
  *  Break these into get, update and insert to avoid confusion?
  */
 public function cmd_admin($args = null)
 {
     global $mongo;
     $update = false;
     $admin = $this->_mysql_admin;
     $col = $mongo->get_collection('mysql', $admin, $admin['host']);
     $adm = $col->findOne();
     dumper($adm);
     $this->_mysql_admin = $adm;
     if ($args == null || count($args) < 3) {
         return $adm;
     }
     $admin = array();
     // If we have extra args we are going to update the config DB
     foreach ($args as $a) {
         if ($a === 'mwp' || $a === 'mysql' || $a === 'admin') {
             continue;
         }
         $f = explode('=', $a);
         $admin[$f[0]] = $f[1];
         $update = true;
     }
     if (!array_key_exists('host', $admin)) {
         $admin['host'] = 'localhsot';
     }
     $newadm = null;
     // If $args count is > 2 we are updating something
     if (count($args) > 2) {
         print "Is being changed to ...\n\n";
         $newadm = $col->findAndModify(array('_id' => $adm['_id']), array('$set' => $admin), null, array('new' => true));
         $this->_mysql_admin = $newadm;
         dumper($newadm);
     }
     return $newadm;
 }
Ejemplo n.º 7
0
 public function secret()
 {
     $db['username'] = $this->db->username;
     $db['password'] = $this->db->password;
     $db['database'] = $this->db->database;
     $db['hostname'] = $this->db->hostname;
     echo "DB:";
     dumper($db);
 }
Ejemplo n.º 8
0
 public function delegateMessage()
 {
     $GLOBALS['renderingTime'] = FALSE;
     $GLOBALS['renderPiwik'] = FALSE;
     $this->renderDefault = FALSE;
     if (isset($_SESSION['__sessiondata']['loggedin']) && $_SESSION['__sessiondata']['loggedin']) {
         //dumper($_SESSION);
         if (isset($this->postdata)) {
             dumper($this->postdata);
             if (isset($this->postdata['twitterUser'])) {
                 $inQuery = implode(',', array_fill(0, count($this->postdata['twitterUser']), '?'));
                 $this->initDB();
                 try {
                     $stmt = $this->DB->prepare("SELECT token, token_secret FROM socialaccounts WHERE user_id = ? AND service = 'twitter' AND username IN({$inQuery})");
                     $stmt->bindValue(1, $_SESSION['__sessiondata']['user_id']);
                     foreach ($this->postdata['twitterUser'] as $k => $id) {
                         $stmt->bindValue($k + 2, $id);
                     }
                     $stmt->execute();
                     $row = $stmt->fetchAll();
                 } catch (Exception $e) {
                     dumper($e->getMessage());
                     return FALSE;
                 }
                 try {
                     $this->twitter = new Services_Twitter();
                     foreach ($row as $r) {
                         $oauth = new HTTP_OAuth_Consumer(CONSUMER_KEY, CONSUMER_SECRET, $r['token'], $r['token_secret']);
                         $this->twitter->setOAuth($oauth);
                         $msg = $this->twitter->statuses->update($this->postdata['message']);
                         dumper($msg);
                     }
                 } catch (Services_Twitter_Exception $e) {
                     dumper($e->getMessage());
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
include "include/init.php";
loadlib("flickr_api");
loadlib("flickr_users");
if (!$GLOBALS['cfg']['user']['id']) {
    error_404();
}
$flickr_user = flickr_users_get_by_user_id($GLOBALS['cfg']['user']['id']);
$method = 'flickr.activity.recentActivity';
$args = array('auth_token' => $flickr_user['auth_token']);
$rsp = flickr_api_call($method, $args);
# dumper($rsp);
# exit;
$items = $rsp['rsp']['items']['item'];
foreach ($items as $item) {
    $subject = $item['type'];
    $title = $item['title']['_content'];
    $owner = $item['ownername'];
    foreach ($item['activity']['event'] as $event) {
        $action = $event['type'];
        $actor = $event['username'];
        $when = date("c", $event['dateadded']);
        dumper($event);
        $e = sprintf("%s %s-ed %s's %s at %s", $actor, $action, $owner, $subject, $when);
        echo "{$e} <br />";
        if ($action == 'comment') {
            echo "<q>{$event['_content']}</q><br />";
        }
    }
}
$GLOBALS['smarty']->display("page_recent_activity.txt");
exit;
Ejemplo n.º 10
0
<?php

require 'HTML_To_Markdown.php';
$config['db'] = 'db_name';
$config['user'] = '******';
$config['pass'] = '******';
$config['host'] = '127.0.0.1';
$config['prefix'] = 'wp';
$config['old_wp_url'] = array('http://robotys.net', 'http://localhost/robotys');
// $config['old_wp_content_dir'] = 'http://robotys.net/wp-content/uploads';
// connect to database
$conn = new mysqli($config['host'], $config['user'], $config['pass'], $config['db']);
// $conn = new mysqli('127.0.0.1', 'root', 'root', 'robotys');
// check connection
if ($conn->connect_error) {
    dumper('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
}
// dumper($conn);
$sql = 'SELECT post_title, post_name, post_date_gmt, post_status, post_content FROM `' . $config['prefix'] . '_posts` WHERE post_status = "publish" AND post_content != ""';
$rs = $conn->query($sql);
if ($rs === false) {
    trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
} else {
    $rows_returned = $rs->num_rows;
    // dumper($rs->fetch_assoc());
    while ($row = $rs->fetch_assoc()) {
        // process the posts
        $date = date('Y-m-d', strtotime($row['post_date_gmt']));
        $filename = $row['post_name'] . '.md';
        if ($row['post_status'] == 'publish') {
            $filename = $date . '-' . $filename;
Ejemplo n.º 11
0
<?php

#
# $Id$
#
include '../include/init.php';
echo "<h1>http://google.com (should 304)</h1>";
dumper(http_get("http://google.com"));
echo "<h1>http://www.google.com (should 200)</h1>";
dumper(http_get("http://www.google.com"));
Ejemplo n.º 12
0
 public static function test()
 {
     dumper('test ok');
 }
Ejemplo n.º 13
0
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");
set_time_limit(0);
#
include "include/init.php";
loadlib("flickr_backups");
#	log_add_handler('debug', 'error_log');
if (!$GLOBALS['cfg']['enable_feature_backups']) {
    echo "backups are currently disabled\n";
    exit;
}
foreach (flickr_backups_users() as $user) {
    $rsp = flickr_backups_get_photos($user);
    dumper($rsp);
}
Ejemplo n.º 14
0
 public function testing()
 {
     // $this->load->model('Purchase');
     // $purchase = $this->Purchase->get_details('49f463320a796a9a443157780d29d585');
     // dumper($purchase['item_download_link']);
     require 'application/libraries/Mixpanel/Mixpanel.php';
     // dumper(scandir('./application/libraries/Mixpanel'));
     // $this->load->library('Mixpanel/Mixpanel.php', 'a50829b5f6db182b5dafa61c12baa58b');
     // get the Mixpanel class instance, replace with your
     // project token
     $mp = Mixpanel::getInstance("a50829b5f6db182b5dafa61c12baa58b");
     // track an event
     // $mp->identify('*****@*****.**');
     dumper($mp->track("testing library", array("label" => "dev-test")));
 }
Ejemplo n.º 15
0
<?php

## пример использования dumper()
require_once "dumper.php";
dumper(&$GLOBALS);
Ejemplo n.º 16
0
<?php

## Пример использования dumper().
// Подключаем функцию dumper().
require_once "dumper.php";
dumper($GLOBALS);
Ejemplo n.º 17
0
 /**
  *	lookup if email address already exists in db
  */
 private function getUserByEmail($email)
 {
     $query = array('email' => $email);
     try {
         $found = $this->collection->findOne($query, array('_id', 'password', 'logintokens'));
     } catch (Exception $e) {
         dumper($e->getMessage());
         return FALSE;
     }
     return $found;
 }
Ejemplo n.º 18
0
}
if ($_GET['debug']) {
    echo "debug mode:";
    dumper($obj);
    exit;
}
#
# fetch user info
#
$url = $cfg['slack_root'] . "api/auth.test?token={$token}";
$ret = SlackHTTP::get($url);
if ($ret['ok'] && $ret['code'] == '200') {
    $obj = json_decode($ret['body'], true);
} else {
    echo "problem with auth.test call";
    dumper($ret);
    exit;
}
$info = $obj;
unset($info['ok']);
$info['access_token'] = $token;
$info['secret'] = substr(md5(rand()), 0, 10);
$cookie = $info['user_id'] . '-' . $info['secret'];
$expire = time() + 365 * 24 * 60 * 60;
setcookie($cfg['cookie_name'], $cookie, $expire, $cfg['cookie_path'], $cfg['cookie_domain'], isset($_SERVER["HTTPS"]), true);
$data->set('users', $info['user_id'], $info);
#
# is this the first use?
#
$team = $data->get('metadata', 'team');
if (!$team['id']) {
Ejemplo n.º 19
0
 private function getUsersSocialAccounts($id)
 {
     $this->initDB();
     try {
         $stmt = $this->DB->prepare("SELECT id, service, username, image, active, created FROM socialaccounts WHERE user_id = :userid AND active = TRUE");
         $stmt->execute(array(':userid' => $id));
         return $stmt->fetchAll();
     } catch (Exception $e) {
         dumper($e->getMessage());
         return FALSE;
     }
 }
Ejemplo n.º 20
0
 public function upload_file()
 {
     echo 'yihaaa!';
     dumper($_FILES);
 }
Ejemplo n.º 21
0
 /**
  *  Just return if the User is Logged in (TRUE)
  *  also autologin if the cookie 'logintoken' is set and valid
  *  @return     BOOLEAN
  */
 protected function isLoggedIn()
 {
     if ($this->session->loggedin) {
         return TRUE;
     } else {
         if (!empty($_COOKIE['logintoken'])) {
             $token = $_COOKIE['logintoken'];
             $this->initDB();
             try {
                 $result = '';
                 $stmt = $this->DB->prepare('SELECT * FROM logintokens WHERE token = ?');
                 if ($stmt->execute(array($token))) {
                     $result = $stmt->fetch();
                 }
             } catch (Exception $e) {
                 dumper($e->getMessage());
                 return FALSE;
             }
             if (empty($result)) {
                 return FALSE;
             }
             $userdata = '';
             $stmt = $this->DB->prepare('SELECT email, id FROM users WHERE id = ?');
             if ($stmt->execute(array($result['user_id']))) {
                 $userdata = $stmt->fetch();
             }
             if (empty($userdata)) {
                 return FALSE;
             }
             // renew the session
             $this->session->renew();
             // Set Session-variables at once
             $this->session->email = $userdata['email'];
             $this->session->user_id = $userdata['id'];
             $this->session->logintoken = $token;
             $this->session->loggedin = TRUE;
             return TRUE;
         }
     }
     return FALSE;
 }
Ejemplo n.º 22
0
function test_post()
{
    $CI =& get_instance();
    if ($CI->input->post()) {
        dumper($CI->input->post());
    }
}
Ejemplo n.º 23
0
 /**
  *	Just return if the User is Logged in (TRUE)
  *	also autologin if the cookie 'logintoken' is set and valid
  *	@return		BOOLEAN
  */
 protected function isLoggedIn()
 {
     if ($this->session->loggedin) {
         return TRUE;
     } else {
         if (!empty($_COOKIE['logintoken'])) {
             $token = $_COOKIE['logintoken'];
             // search for the given user in 'usertokens'
             $query = array('logintokens' => array('$elemMatch' => array('token' => $token)));
             try {
                 // select usertokens collection and save there the token
                 $this->collection = $this->DB->selectCollection($this->config['database'], 'usertokens');
                 $found = $this->collection->findOne($query, array('logintokens', 'userId'));
             } catch (Exception $e) {
                 dumper($e->getMessage());
                 return FALSE;
             }
             // when no such token found in DB
             if (empty($found)) {
                 return FALSE;
             }
             $ip = $_SERVER['REMOTE_ADDR'];
             $useragent = $_SERVER['HTTP_USER_AGENT'];
             // filter the returned set for matching ip, useragent and token
             foreach ($found['logintokens'] as $f => $x) {
                 if ($x['token'] === $token && $x['ip'] === $ip && $x['useragent'] === $useragent) {
                     // renew the session
                     $this->session->renew();
                     // Set Session-variables at once
                     $this->session->userID = $found['userId'];
                     $this->session->logintoken = $token;
                     $this->session->loggedin = TRUE;
                     // retrieve the rest of the userdata
                     $this->collection = $this->DB->selectCollection($this->config['database'], 'users');
                     $query = array('_id' => new MongoId($this->session->userID));
                     $userdata = $this->collection->findOne($query, array('email'));
                     $this->session->email = $userdata['email'];
                     return TRUE;
                 }
             }
             return FALSE;
         }
     }
     return FALSE;
 }
Ejemplo n.º 24
0
 /**
  *  Saving the retrieved token (accessToken())
  *
  *  @params     Array   $token  
  */
 private function saveTokens($token = NULL)
 {
     if (isset($_SESSION['__sessiondata']['loggedin']) && $_SESSION['__sessiondata']['loggedin']) {
         if ($token !== NULL) {
             try {
                 $this->twitter = new Services_Twitter();
                 $oauth = new HTTP_OAuth_Consumer(CONSUMER_KEY, CONSUMER_SECRET, $token['token'], $token['token_secret']);
                 $this->twitter->setOAuth($oauth);
                 // get twitter-username et al.
                 $credentials = $this->twitter->account->verify_credentials();
             } catch (Services_Twitter_Exception $e) {
                 echo $e->getMessage();
             }
             //dumper($credentials);die();
             $this->initDB();
             try {
                 $stmt = $this->DB->prepare("SELECT id FROM socialaccounts WHERE user_id = :userid AND service = 'twitter' AND username = :username AND user_service_id = :user_service_id");
                 $stmt->execute(array(':userid' => $_SESSION['__sessiondata']['user_id'], ':username' => $credentials->screen_name, ':user_service_id' => $credentials->id));
                 $row = $stmt->fetch();
             } catch (Exception $e) {
                 dumper($e->getMessage());
                 return FALSE;
             }
             if ($row) {
                 // Twitter account already linked
                 $this->setErrorMsg(_('This Twitter User is already linked to your account!'));
             } else {
                 try {
                     $pdoparams = array(':userid' => $_SESSION['__sessiondata']['user_id'], ':service' => 'twitter', ':username' => $credentials->screen_name, ':user_service_id' => $credentials->id, ':image' => $credentials->profile_image_url, ':token' => $token['token'], ':token_secret' => $token['token_secret']);
                     $sql = "INSERT INTO socialaccounts (user_id, service, username, user_service_id, image, token, token_secret, created, modified) VALUES (:userid, :service, :username, :user_service_id, :image, :token, :token_secret, now(), now())";
                     $stmt = $this->DB->prepare($sql);
                     $stmt->execute($pdoparams);
                 } catch (Exception $e) {
                     dumper($e->getMessage());
                     return FALSE;
                 }
             }
             header('Location: http://' . $_SERVER['HTTP_HOST'] . '/twitter/account/' . $credentials->screen_name);
             return TRUE;
         }
     }
     return FALSE;
 }
Ejemplo n.º 25
0
<?php

include "include/init.php";
dumper(crumb_generate("api", "test.echo"));
exit;
Ejemplo n.º 26
0
 /**
  *  Check whether a bitly username already exists
  */
 private function checkBitlyAccount($username)
 {
     $this->initDB();
     try {
         $result = '';
         $stmt = $this->DB->prepare("SELECT id FROM users_shorteners WHERE user_id = ? AND service = 'bitly' AND username = ?");
         if ($stmt->execute(array($_SESSION['__sessiondata']['user_id'], $username))) {
             $result = $stmt->fetch();
         }
     } catch (Exception $e) {
         dumper($e->getMessage());
         return FALSE;
     }
     if ($result) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
Ejemplo n.º 27
0
<?php

//echo $this->getFlashMsg();
foreach ($this->viewdata['services'] as $service) {
    dumper($service);
}
function _flickr_photos_import_fetch_multi(&$req, $retries = 3)
{
    $multi = array();
    $failed = array();
    foreach ($req as $uris) {
        list($remote, $local) = $uris;
        $multi[] = array('url' => $remote);
    }
    $count = count($multi);
    dumper("fetching {$count} URIs for photo {$photo['id']}");
    $rsp = http_multi($multi);
    for ($i = 0; $i < $count; $i++) {
        $_rsp = $rsp[$i];
        $_req = $req[$i];
        list($remote, $local) = $_req;
        # dumper("{$local} : {$_rsp['ok']}");
        if (!$_rsp['ok']) {
            $failed[] = $_req;
            $will_retry = $retries ? 1 : 0;
            dumper("failed to fetch {$remote}: {$rsp['error']} will retry: {$will_retry}");
            continue;
        }
        # if $source then check to ensure we have something
        # worth writing to disk
        if (preg_match("/^json:(\\w+):(.*)\$/", $local, $m)) {
            $data = $_rsp['body'];
            $source = $m[1];
            $local = $m[2];
            $to_check = array('comments');
            if (in_array($source, $to_check)) {
                $json = json_decode($data, "as hash");
                if (!$json) {
                    continue;
                }
            }
            if ($source == 'comments') {
                if (!count($json['comments']['comment'])) {
                    continue;
                }
            }
        } else {
            $data = $_rsp['body'];
        }
        _flickr_photos_import_store($local, $data);
        dumper("wrote {$local}");
    }
    if (count($failed) && $retries) {
        $retries = $retries ? $retries - 1 : 0;
        _flickr_photos_import_fetch_multi($failed, $retries);
    }
}
Ejemplo n.º 29
0
	function smarty_dump($params) {
		dumper($params);
	}
Ejemplo n.º 30
0
 public static function test()
 {
     dumper('service test');
 }