public function createWhereClausule($infoarray, $table) { $whereclausule = ""; $types = ""; $params = array(); foreach ($infoarray as $key => $value) { if (!array_key_exists(strtolower($key), $table->fields)) { die("wrong row used, row {$key} does not exist in table {$table->name}."); } if (gettype($value) == "array") { die("not supported yet: " . xdebug($value)); } if ($whereclausule === "") { $isfirst = false; $whereclausule .= " WHERE `{$key}`=?"; } else { $whereclausule .= " && `{$key}`=?"; } $type = gettype($value); $types .= substr($type, 0, 1); $params[] =& $infoarray[$key]; } $func_args = array_merge(array($types), $params); return array('bind_param' => $func_args, 'where_clausule' => $whereclausule); }
function __construct() { parent::__construct(); // It really is best to auto-load this library! $this->load->library('tweet'); // Enabling debug will show you any errors in the calls you're making, e.g: $this->tweet->enable_debug(TRUE); // If you already have a token saved for your user // (In a db for example) - See line #37 // // You can set these tokens before calling logged_in to try using the existing tokens. // $tokens = array('oauth_token' => 'foo', 'oauth_token_secret' => 'bar'); // $this->tweet->set_tokens($tokens); if (!$this->tweet->logged_in()) { // This is where the url will go to after auth. // ( Callback url ) $this->tweet->set_callback(site_url('tweet_test/auth')); // Send the user off for login! $this->tweet->login(); } else { $tokens = $this->tweet->get_tokens(); // $user = $this->tweet->call('get', 'account/verify_credentiaaaaaaaaals'); // Will throw an error with a stacktrace. $user = $this->tweet->call('get', 'account/verify_credentials'); xdebug($user); } }
function get() { $this->load->library('yahoo'); if (!$this->yahoo->logged_in()) { $this->yahoo->login(); } else { exit; $url = 'https://www.google.com/m8/feeds/contacts/default/full'; do { $result = $this->google->simple_call('get', $url); $data = $result->__resp->data; foreach ($data->entry as $entry) { $email = $entry->xpath('gd:email/@address'); $email = (string) @$email[0]['address']; if (!empty($email)) { xdebug((string) $entry->title, 1); xdebug($email, 1); } } xdebug('page===='); $url = ''; foreach ($data->link as $link) { if ($link['rel'] == 'next') { $url = @$link['href']; break; } } } while ($url); // foreach($data->entry as $entry) { // xdebug($entry, 1); // } } exit; }
/** * Create a prepared, protected query. **/ function prepared($query, $binding_and_val) { $prepped = $this->pdo->prepare($query); // bind the keys to the dummy strings... // and the values as the values. foreach ($binding_and_val as $bind => $val) { $prepped->bindParam("{$bind}", $val, PDO::PARAM_STR); } $this->rows = $prepped->execute(); $this->result = $prepped->fetch(PDO::FETCH_BOTH); if (DEBUG) { xdebug(); } return $this->result; }
public function update($where, $info) { $insert_string = ""; $isfirst = true; $types = ""; foreach ($info as $field => $value) { if (!array_key_exists(strtolower($field), $this->fields)) { die("wrong row used in '.insert()'; row {$name} does not exist in table {$this->name}."); } if (gettype($value) == "array") { die("not supported yet: " . xdebug($value)); } if ($isfirst) { $isfirst = false; $insert_string .= "`{$field}` = ?"; } else { $insert_string .= ", `{$field}` = ?"; } $type = gettype($value); $types .= substr($type, 0, 1); $params[] =& $info[$field]; } $where = $this->database->createWhereClausule($where, $this); $bind_param_args = $where['bind_param']; $whereclausule = $where['where_clausule']; $bind_param_args = array_merge(array($types . $bind_param_args[0]), $params, array_slice($bind_param_args, 1)); $sql_query = "UPDATE `{$this->name}` SET {$insert_string}{$whereclausule}"; $func_args = array_merge(array($types), $params); if (!($mysqli_exec = $this->connection->prepare($sql_query))) { die(mysqli_error($this->connection)); } call_user_func_array(array($mysqli_exec, 'bind_param'), makeValuesReferenced($bind_param_args)); $mysqli_exec->execute(); $id = $this->connection->insert_id; return $id; }
function _normalize_php($file) { @unlink($file . '.new'); $warnings = array(); $view_detected = false; $content = file_get_contents($file); $f = fopen($file, 'r'); $line = fgets($f); if (trim($line) != '<?php') { $warnings['VIEW_DETECTED'] = 'NO PHP TAG OPENING, MAYBE VIEW?'; } if (!isset($warnings['VIEW_DETECTED'])) { while ($line = fgets($f)) { $line = trim($line); if (!empty($line)) { $found = preg_match('/^\\/\\*/', $line); if ($found) { $warnings['FILE_COMMENT_DETECTED'] = 'FILE COMMENT IS DETECTED'; } break; } } if (isset($warnings['FILE_COMMENT_DETECTED'])) { $found = false; $found_else = false; $ftellpos = ftell($f); while ($line = fgets($f)) { $line = trim($line); $endl = preg_match('/\\*\\//', $line); if ($endl) { break; } $pos = strpos($line, 'This software is the proprietary information of PT Sagara Xinix Solusitama'); if ($pos !== FALSE) { $found = true; break; } } fseek($f, $ftellpos); while ($line = fgets($f)) { $line = trim($line); $endl = preg_match('/\\*\\//', $line); if ($endl) { break; } $pos = strpos($line, '@copyright'); if ($pos !== FALSE) { $found_else = true; break; } } if (!$found) { $warnings['XINIX_COPYRIGHT_NOT_FOUND'] = 'XINIX COPYRIGHT NOT FOUND'; if ($found_else) { $warnings['OTHER_COPYRIGHT_FOUND'] = 'OTHER COPYRIGHT FOUND'; } } } else { $warnings['XINIX_COPYRIGHT_NOT_FOUND'] = 'XINIX COPYRIGHT NOT FOUND'; } } else { // FIXME if view detected } fclose($f); if (isset($warnings['OTHER_COPYRIGHT_FOUND'])) { return; } if (!isset($warnings['VIEW_DETECTED'])) { $if = fopen($file, 'r'); $of = fopen($file . '.new', 'w'); if (!isset($warnings['OTHER_COPYRIGHT_FOUND'])) { $line = trim(fgets($if)); fputs($of, $line . "\n"); $start = false; // default variables for copyright $nopath = str_replace(dirname($file) . '/', '', $file); $created_time = '2011/11/21 00:00:00'; $author = 'xinixman <*****@*****.**>'; $now_year = '2011'; $copyright = "Copyright(c) {$now_year} PT Sagara Xinix Solusitama. All Rights Reserved."; // default variables for copyright if (isset($warnings['FILE_COMMENT_DETECTED'])) { $copyright_set = false; $author_set = false; while ($line = fgets($if)) { $line = trim($line); if (!$start && preg_match('/^\\/\\*/', $line)) { $start = true; continue; } elseif ($start && preg_match('/\\*\\//', $line)) { break; } if (isset($warnings['XINIX_COPYRIGHT_NOT_FOUND'])) { $matches = array(); $match = preg_match('/^.+(@copyright\\s+)(.*)$/i', $line, $matches); if ($match) { $copyright = $matches[2]; $copyright_set = true; } $matches = array(); $match = preg_match('/^.+(@author\\s+)(.*)$/i', $line, $matches); if ($match) { $author = explode('<', $matches[2]); if (count($author) > 1) { $x = explode('>', $author[1]); $author[1] = '<' . trim($x[0]) . '>'; } else { $author[1] = '<' . $author[0] . '@xinix.co.id>'; } $author = trim(trim($author[0]) . ' ' . trim($author[1])); $author_set = true; } } else { $lines = explode("\n", $content); foreach ($lines as $index => $line) { $matches = ''; if (preg_match('/Copyright\\(c\\).*/', $line, $matches)) { $copyright = $matches[0]; } if (strpos($line, 'History') !== FALSE) { break; } } $match = preg_match('/(\\d+\\/\\d+\\/\\d+\\s+\\d+(:\\d+)+)\\s+(.*)/', $lines[$index + 3], $matches); if ($match) { // $matches[1] = explode(' ', $matches[1]); // $matches[1][0] = explode('/', $matches[1][0]); // $matches[1][1] = explode(':', $matches[1][1]); // if (count($matches[1][1]) < 3) { // $matches[1][1][] = '00'; // } $matches[3] = explode(' ', trim($matches[3])); $matches[3] = $matches[3][0]; $created_time = $matches[1] = '2011/11/21 00:00:00'; //implode('/', $matches[1][0]).' '.implode(':', $matches[1][1]); $author = $matches[3] . ' <' . $matches[3] . '@xinix.co.id>'; $copyright_set = true; } } } if (!$copyright_set) { $matches = array(); $lines = explode("\n", $content); foreach ($lines as $line) { $matches = array(); $match = preg_match('/^.+(@copyright\\s+)(.*)$/i', $line, $matches); if ($match) { $copyright = $matches[2]; $copyright_set = true; } $matches = array(); $match = preg_match('/^.+(@author\\s+)(.*)$/i', $line, $matches); if ($match) { $author = explode('<', $matches[2]); if (count($author) > 1) { $x = explode('>', $author[1]); $author[1] = '<' . trim($x[0]) . '>'; } else { $author[1] = '<' . $author[0] . '@xinix.co.id>'; } $author = trim(trim($author[0]) . ' ' . trim($author[1])); $author_set = true; } } } } $copyright_string = "\n/**\n * {$nopath}\n *\n * @package arch-php\n * @author {$author}\n * @copyright {$copyright}\n *\n * Created on {$created_time}\n *\n * This software is the proprietary information of PT Sagara Xinix Solusitama.\n *\n * History\n * =======\n * (dd/mm/yyyy hh:mm:ss) (author)\n * {$created_time} {$author}\n *\n *\n */\n\n"; fputs($of, $copyright_string); } while ($line = fgets($if)) { $_line = trim($line); if (!empty($_line)) { fputs($of, $line); break; } } // copy rest of lines to new file while ($line = fgets($if)) { fputs($of, $line); } fclose($of); fclose($if); unlink($file); copy($file . '.new', $file); xdebug($file, 1); unlink($file . '.new'); } }
public function get() { $token = $this->_find_token(); if (empty($token)) { return NULL; } // $user = $this->_get('user'); // if ( !empty($user) ) return $user; try { $data = array('realm' => 'yahooapis.com', 'oauth_consumer_key' => $this->_lib->consumer_key, 'oauth_nonce' => md5(uniqid()), 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_timestamp' => time(), 'oauth_token' => $this->_get('token')->oauth_token, 'oauth_version' => '1.0'); $secret = $this->_lib->consumer_secret . '&' . $this->_get('oauth_token_secret'); // $result = $this->connection->get_auth($this->_lib->user_url, $secret, $data); $result = $this->connection->get_auth('http://social.yahooapis.com/v1/user/abcdef123/profile', $secret, $data); xdebug($result, 1); exit; ksort($data); xdebug($data, 1); xdebug($this->_lib->user_url, 1); $param = array(); foreach ($data as $k => $v) { $param[] = $k . '=' . $v; } $a = array('POST', $this->_lib->user_url, implode('&', $param)); $a1 = ''; foreach ($a as $v) { $a1[] = urlencode($v); } $base_string = implode('&', $a1); xdebug($base_string, 1); $a = base64_encode(hash_hmac('sha1', $base_string, $secret, true)); xdebug($a, 1); $data['oauth_signature'] = $a; try { $params = array(); foreach ($data as $k => $v) { $params[] = $k . '=' . urlencode($v); } xdebug('<a href="' . $this->_lib->user_url . '?' . implode('&', $params) . '">token</a>', 1); $user = @$this->connection->get($this->_lib->user_url, $data); } catch (Exception $e) { xdebug($e->getMessage() . "\n" . $e->getTraceAsString(), 1); } xdebug($user, 1); // exit; } catch (yahooException $e) { $this->logout(); return NULL; } // $this->_set('user', $user); return $user; }
function profile($user_id) { $user = $this->ion_auth->user($user_id)->row(); xdebug($user); }
function xprint($value) { echo xdebug($value); }