/**
  * Insert data array into mysql database
  *
  * @param PDO handle $handle, array $answers, Symfony\Component\Console\Output\OutputInterface $output
  * @return null
  */
 public function insertDataArray($handle, $answers, OutputInterface $output)
 {
     $fields = getKeys($answers);
     $statement = $this->getStatement($handle, $fields, $output);
     foreach ($answers as $answer) {
         $this->executeStatement($statement, $answer, $output);
     }
 }
 function getKeys($element)
 {
     $data = array();
     foreach ($element as $key => $value) {
         if ($key !== '_id') {
             if (is_array($value)) {
                 $data[$key] = getKeys($value);
             } else {
                 $data[] = $key;
             }
         }
     }
     return $data;
 }
Exemple #3
0
    $users = getFollowers($nick, null, $client);
    insertFollowers($users, $user['id'], $conn);
} catch (Exception $e) {
    $throttled = true;
    error_log("<br>" . $e->getMessage());
}
if (!$users) {
    $users = getFollowers($nick, $connfb);
}
// keys
try {
    $keys = getKeys($nick, null, $client);
} catch (Exception $e) {
    $throttled = true;
    error_log($e->getMessage());
    $keys = getKeys($nick, $conn);
}
// turtle
$rank = getRank($users);
$ledger = getLedger($webid, $conn);
$project = getProject($ledger);
$main = 'http://gitpay.org/' . $user['login'] . '#this';
$githubaccount = 'http://github.com/' . $user['login'];
if ($webid && $webid['bitcoin']) {
    $bitcoin = $webid['bitcoin'];
}
if ($webid && $webid['preferredURI']) {
    $preferredURI = $webid['preferredURI'];
}
$turtle = getTurtle($user, $webid, $users, $keys);
insertKeys($keys, $nick, $conn);
/**
 * Returns an unique Identifier for a record in a table
 *
 * @param string $db     Database
 * @param string $table  Table
 * @param array  &$record Complete records
 *
 * @return string Where-Condition to identify the record
 */
function getRecordIdentifier($db, $table, &$record)
{
    global $table_infos;
    $where = '';
    if (!isset($table_infos[$db]['tables'][$table]['keys'])) {
        $table_infos = getTableInfo($db, $table);
        $keys = getKeys($db, $table);
        $table_infos[$db]['tables'][$table]['keys'] = $keys;
    }
    if (isset($table_infos[$db]['tables'][$table]['keys']['PRIMARY'])) {
        // table has a primary key -> we can build the identifier by it
        foreach ($table_infos[$db]['tables'][$table]['keys']['PRIMARY'] as $column => $val) {
            $where .= $where > '' ? ' AND ' : '';
            $where .= '`' . $column . '` = \'' . $record[$column] . '\'';
        }
    } else {
        // shame on the table design -> no key given -> build key from all values of record
        foreach ($record as $column => $val) {
            $where .= $where > '' ? ' AND ' : '';
            $where .= '`' . $column . '` = \'' . $record[$column] . '\'';
        }
    }
    return $where;
}
Exemple #5
0
function getKeys($array)
{
    static $result_array = array();
    foreach ($array as $key => $value) {
        if (is_array($value)) {
            getKeys($value);
        } else {
            $result_array[] = $key;
        }
    }
    return $result_array;
}
Exemple #6
0
 function rest($routes, $name, $subs = [], $nest = [], $rels = [])
 {
     $lcName = strtolower($name);
     $routeOptions = [];
     foreach (getKeys($name) as $key) {
         $routeOptions['pass'][] = $key;
         $routeOptions[$key] = '[0-9]+';
     }
     $path = ':' . implode('/:', $routeOptions['pass']);
     $url = '/' . $lcName . '/' . $path;
     $map = ['index' => ['_method' => 'GET', 'path' => 0], 'add' => ['_method' => 'PUT', 'path' => 0], 'view' => ['_method' => 'GET', 'path' => 1], 'edit' => ['_method' => 'PUT', 'path' => 1], 'delete' => ['_method' => 'DELETE', 'path' => 1]];
     foreach ($map as $method => $options) {
         // hacky special case #1
         if ($name == 'Characters' && $method == 'add') {
             continue;
         }
         $defaults['_method'] = $options['_method'];
         $defaults['controller'] = $name;
         $defaults['action'] = $method;
         if ($options['path'] == 0) {
             $routes->connect('/' . $lcName, $defaults, []);
         } else {
             $routes->connect($url, $defaults, $routeOptions);
         }
         // hacky special case #2
         if ($name == 'Characters' && $method == 'index') {
             $defaults['action'] = 'playersIndex';
             $routes->connect('/characters/:plin', $defaults, ['pass' => ['plin'], 'plin' => '[0-9]+']);
         }
     }
     foreach ($subs as $controller) {
         $defaults = [];
         $defaults['_method'] = 'GET';
         $defaults['controller'] = $controller;
         $defaults['action'] = $lcName . 'Index';
         $urlNest = $url . '/' . strtolower($controller);
         $routes->connect($urlNest, $defaults, $routeOptions);
     }
     foreach ($nest as $sub) {
         $controller = [$name, $sub];
         sort($controller);
         $controller = implode($controller);
         $defaults = [];
         $defaults['_method'] = 'GET';
         $defaults['controller'] = $controller;
         $defaults['action'] = $lcName . 'Index';
         $urlNest = $url . '/' . strtolower($sub);
         $routes->connect($urlNest, $defaults, $routeOptions);
     }
     foreach ($rels as $rel) {
         $routeOptions2 = $routeOptions;
         $path = [];
         foreach (getKeys($rel) as $key) {
             $routeOptions2['pass'][] = $key;
             $routeOptions2[$key] = '[0-9]+';
             $path[] = $key;
         }
         $path = ':' . implode('/:', $path);
         $map = ['index' => ['_method' => 'GET', 'path' => 0], 'add' => ['_method' => 'PUT', 'path' => 0], 'view' => ['_method' => 'GET', 'path' => 1], 'edit' => ['_method' => 'PUT', 'path' => 1], 'delete' => ['_method' => 'DELETE', 'path' => 1]];
         $controller = [$name, $rel];
         sort($controller);
         $controller = implode($controller);
         $lcNest = strtolower($rel);
         foreach ($map as $method => $options) {
             $defaults = [];
             $defaults['_method'] = $options['_method'];
             $defaults['controller'] = $controller;
             $defaults['action'] = $lcName . ucfirst($method);
             $urlNest = $url . '/' . $lcNest;
             if ($options['path'] == 0) {
                 $routes->connect($urlNest, $defaults, $routeOptions);
             } else {
                 $urlNest .= '/' . $path;
                 $routes->connect($urlNest, $defaults, $routeOptions2);
             }
         }
     }
     // hacky special case #3
     if ($name == 'Players') {
         $defaults = [];
         $defaults['_method'] = 'PUT';
         $defaults['controller'] = 'Characters';
         $defaults['action'] = 'add';
         $routeOptions = ['pass' => ['plin'], 'plin' => '[0-9]+'];
         $routes->connect('/players/:plin/characters', $defaults, $routeOptions);
     }
 }
Exemple #7
0
 /**
  * Verifies if a key exists
  * @param  string $key Key to look for
  * @return bool        Returns true if the key exists
  */
 public function keyExists($key)
 {
     if (!self::isMultidimensional()) {
         foreach (getKeys() as $i) {
             if (trim($i) === trim($key)) {
                 return true;
             }
         }
     } else {
         foreach (self::parse() as $i) {
             foreach ($i as $key2 => $i2) {
                 if (trim($key) === trim($key2)) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
Exemple #8
0
<?php

session_start();
if (!isset($_SESSION['id'])) {
    header("Location: /");
    die;
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] == "for=0.0.0.0; proto=http; by=253.254.255.256" && isset($_POST['passcode']) && $_POST['passcode'] != "") {
    require_once "functions.php";
    $conn = connect_to_db();
    $results = getKeys($conn, $_POST['passcode']);
    if ($results[1] == "" && !!$results[0]) {
        echo "Be careful formatting. Inspect element might be useful.<br>\n";
        echo "key:<br><br>\n";
        while ($row = $results[0]->fetch_assoc()) {
            echo $row['privkey'] . "\n\n<br><br>";
        }
    } else {
        echo "go away.";
    }
    $conn->close();
} else {
    header("Location: /");
    die;
}