public function checkCode($code)
 {
     $gen = new Gen();
     $data = $gen->readDataFile();
     foreach ($data as $key => $user_id) {
         if ($key == $code) {
             return $user_id;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 /** 
 * Travel each column and check each cell
 * 
 * For non-matching values rows/objects are assumed to be missing resp. surplus
 * For unique values that match rows/objects are asumed to match
 * For non-unique values that match next column is searched 
 * Rows with parse errors are ignoored (unless already matched by a previous column)
 * Objects with errors are marked surplus (unless already matched by a previous column)
 * Limitations:
 * - ::eSort and ::cSort use parsed values as key, array will error if they are objects or arrays
 * - a single errorneous value may result in a mismatch
 *
 * inherited from PHPFIT_Fixture_Row , copyricht (c) 2002-2005 Cunningham & Cunningham, Inc.:
 * @param array of PHPFIT_Parse $expected 
 * @param array of targetClass $computed 
 * @param integer $col colunm index
 
 protected function match($expected, $computed, $col) {
     if ($col >= count($this->columnBindings)) {
         $this->checkList($expected, $computed); //no more columns, check and annotate
     } elseif ($this->columnBindings[$col] == null) {
         $this->match($expected, $computed, $col+1); //no adapter, skip column
     } else {
         $eColumn = $this->eSort($expected, $col); // expected column, result contains arrays of complete rows by value
         $cColumn = $this->cSort($computed, $col); // computed column, result contains arrays of domain objects by value
         $keys = array_merge(array_keys($eColumn), array_keys($cColumn));
         $keys = array_unique($keys);
         foreach ($keys as $key) {
             $eList = $cList = null;
             if (array_key_exists($key, $eColumn))
 					$eList = $eColumn[$key];
             if (array_key_exists($key, $cColumn))
 					$cList = $cColumn[$key];
 
             if (!$eList) {
                 $this->surplus = array_merge($this->surplus, $cList);
             } elseif (!$cList) {
                 $this->missing = array_merge($this->missing, $eList);
             } else if ((count($eList) == 1) && (count($cList) == 1)) {
                 $this->checkList($eList, $cList); //unique value, check and annotate
             } else {
                 $this->match($eList, $cList, $col+1); //use next column for matching non-unique values
             }
 
         }
     }
 }
 */
 function showCounts($array)
 {
     $counts = array();
     foreach ($array as $key => $nestedArray) {
         $counts[$key] = count($nestedArray);
     }
     Gen::show($counts);
     //like print_r
 }
Exemplo n.º 3
0
/**
 * 同一オブジェクトを生成する為のメソッド
 */
function &get_instance()
{
    return Gen::get_instance();
}
Exemplo n.º 4
0
<?php

require_once 'config.php';
require DIR_CLASSES . 'Gen.php';
$gen = new Gen();
$code = $gen->getUserCode($user_id);
if (null !== $code) {
    echo 'Ваш код: ' . $code . '<br/>Напишите его боту вконтакте';
} else {
    if (isset($_GET['generate'])) {
        $gen->generateCodeForUser($user_id);
        header("Location: " . BASE_URL . "gen.php");
    } else {
        echo 'У вас еще нет кода. <a href="' . BASE_URL . 'gen.php?generate=1">Сгенерировать</a>';
    }
}