Beispiel #1
0
 public function guardar($id = null)
 {
     $this->_rules();
     $action = $id ? "guardar" : "nuevo";
     if ($this->form_validation->run() == false) {
         if ($action == 'nuevo') {
             $this->nuevo();
         } else {
             $this->editar($id);
         }
     } else {
         $FECHA_INGRESO = $this->input->post('FECHA_INGRESO', true);
         $data = array('NOMBRE_DOCENTE' => $this->input->post('NOMBRE_DOCENTE', true), 'AP_DOCENTE' => $this->input->post('AP_DOCENTE', true), 'AM_DOCENTE' => $this->input->post('AM_DOCENTE', true), 'DIRECCION' => $this->input->post('DIRECCION', true), 'TELEFONO' => $this->input->post('TELEFONO', true), 'SEXO' => $this->input->post('SEXO', true), 'DNI' => $this->input->post('DNI', true), 'EMAIL' => $this->input->post('EMAIL', true), 'FECHA_INGRESO' => mktime(0, 0, 0, $FECHA_INGRESO['mes'], $FECHA_INGRESO['dia'], $FECHA_INGRESO['anio']));
         if ($action == 'nuevo') {
             $CODIGO_DOCENTE = $this->model_docentes->insert($data);
             $usr = $this->input->post('EMAIL', true);
             $pwd = genKey(6, 'numeric');
             $data = array('NOMBRE' => $this->input->post('NOMBRE_DOCENTE', true), 'APELLIDOS' => $this->input->post('AP_DOCENTE', true) . " " . $this->input->post('AM_DOCENTE', true), 'EMAIL' => $usr, 'FECHA_REGISTRO' => date('Y-m-d H:m:s'), 'ESTATUS' => 1, 'TIPO' => 'Docente', 'ROL' => 3, 'PASSWORD' => md5($pwd), 'CODIGO_MIEMBRO' => $CODIGO_DOCENTE);
             /*Crea un nuevo usuario para el alumno */
             $this->model_usuarios->SaveUsuarios($data);
             $this->session->set_flashdata('msg', "Se registró al docente satisfactoriamente, Usuario: {$usr}   Password: {$pwd}");
             redirect(site_url('docentes'));
         } else {
             $this->model_docentes->update($id, $data);
             $this->session->set_flashdata('message', 'Se actualizó');
             redirect(site_url('docentes'));
         }
     }
 }
 function auth()
 {
     $fid = $_POST['fid'];
     $key = $_POST['key'];
     $sql = "SELECT `accesstoken`,`name` from players where `fid`=? LIMIT 1";
     $query = $this->db->query($sql, array($fid));
     if ($query->num_rows() > 0) {
         $row = $query->row();
         $akey = genKey($fid, $row->accesstoken);
         echo strcmp($akey, $key) == 0 ? "OK," . $row->name : "";
     }
 }
 function createGiftCards()
 {
     global $user;
     $temp_shorts = array("price" => $_POST["fields"]["cost"], "value" => $_POST["fields"]["face_value"]);
     $restrictions = $_POST["fields"]["restrictions"];
     foreach ($temp_shorts as $key => $value) {
         $restrictions = str_replace("[" . $key . "]", $value, $restrictions);
     }
     $query_statement = "INSERT INTO `" . GC_TABLE_NAME . "` (`name`,`value`,`price`,`quantity`,`date_submitted`,`admin`,`marketplace_id`,`restrictions`) VALUES ('" . addslashes($_POST["fields"]["name"]) . "','" . $_POST["fields"]["face_value"] . "','" . $_POST["fields"]["cost"] . "','" . $_POST["fields"]["quantity"] . "','" . TODAY . "','" . $user->user_info[0] . "','" . $this->id . "','" . addslashes($restrictions) . "');";
     mysql_query($query_statement);
     $gc_id = mysql_insert_id();
     for ($i = 1; $i <= $_POST["fields"]["quantity"]; $i++) {
         $query_statement = "INSERT INTO `" . GC_CARDS_NAME . "` (`category`,`value`,`price`,`giftcard_id`,`status`,`key`,`admin`,`date_created`) VALUES ('" . $_POST["fields"]["category"] . "','" . $_POST["fields"]["face_value"] . "','" . $_POST["fields"]["cost"] . "','" . $gc_id . "','1','" . genKey(80) . "','" . $user->user_info[0] . "','" . TODAY . "');";
         mysql_query($query_statement);
     }
     return;
 }
 public function index()
 {
     $app_id = $this->config->item('fb_appid');
     $canvas_page = "http://sleepbot.kicks-ass.net:8081/";
     $auth_url = "http://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" . urlencode($canvas_page) . "&scope=offline_access,read_friendlists,user_birthday";
     $signed_request = $_REQUEST["signed_request"];
     list($encoded_sig, $payload) = explode('.', $signed_request, 2);
     $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
     if (empty($data["user_id"])) {
         echo "<script> top.location.href='" . $auth_url . "'</script>";
     } else {
         $config = array('appId' => $this->config->item('fb_appid'), 'secret' => $this->config->item('fb_appsecret'), 'cookie' => $this->config->item('fb_cookie'), 'domain' => $this->config->item('fb_domain'));
         $facebook = $this->facebook;
         $facebook->init($config);
         $atoken = $facebook->getAccessToken();
         $gid = postlogin($facebook, $this->db, $atoken);
         $this->session->set_userdata(array("fid" => $facebook->getUser(), "key" => genKey($facebook->getUser(), $atoken)));
         header('Location: /game_list');
     }
 }
Beispiel #5
0
    $p_cipher = 3;
}
if ($p_encoding == 0) {
    $p_encoding = 2;
}
if ($p_mode == 0) {
    $p_mode = 1;
}
$cipherList = mcrypt_list_algorithms();
$cipher = $cipherList[$p_cipher - 1];
$modeList = mcrypt_list_modes();
$mode = $modeList[$p_mode - 1];
$key_iv_list = getKeySettings();
$keysize = intval(mcrypt_get_key_size($cipher, $mode));
$blocksize = intval(mcrypt_get_block_size($cipher, $mode));
$key = genKey($keysize);
$iv = genIV($blocksize);
$encoding_list = list_encoding();
function list_encoding()
{
    $encodings = array("base64", "lower hex", "upper hex", "websafe base64");
    return $encodings;
}
function encode($text, $mode = 2)
{
    switch ($mode) {
        case 1:
            return urlencode(base64_encode($text));
            break;
        case 2:
            return @array_shift(array_values(unpack("H*", $text)));
Beispiel #6
0
                $p .= chr(mt_rand(97, 122));
                break;
            case 7:
                $len = strlen($p);
                if ($underscores > 0 && $len > 0 && $len < 9 && $p[$len - 1] != "_") {
                    $p .= "_";
                    $underscores--;
                } else {
                    $i--;
                    continue;
                }
                break;
        }
    }
    return $p;
}
$temp_username = rand();
$private_key = genKey();
$q = $dbh->prepare("INSERT INTO `cm_users` (`id`, `first_name`, `last_name`, `email`, `mobile_phone`, `office_phone`, `home_phone`, `grp`, `username`, `password`, `supervisors`, `picture_url`, `timezone_offset`, `status`, `new`, `date_created`, `pref_case`, `pref_journal`, `pref_case_prof`, `evals`, `private_key`, `force_new_password`) VALUES (NULL, '', '', '', '', '', '', '', '{$temp_username}', '', '', 'people/no_picture.png', '1', 'inactive', '', CURRENT_TIMESTAMP, 'on', 'on', 'on', '', '{$private_key}', '0');");
$q->execute();
$error = $q->errorInfo();
if ($error[1]) {
    print_r($error);
    die;
    $response = array('error' => true, "message" => "Sorry, there was an error creating the new user.");
    echo json_encode($response);
} else {
    $last_id = $dbh->lastInsertId();
    $response = array('id' => $last_id);
    echo json_encode($response);
}
    $builddeployment = false;
} else {
    $deployment = '';
    $builddeployment = $_SESSION['deployment'];
}
$deployDesc = isset($viewData->deployInfo['desc']) ? $viewData->deployInfo['desc'] : '';
$deployAuthGrps = isset($viewData->deployInfo['authgroups']) ? preg_replace('/,\\s?/', ', ', $viewData->deployInfo['authgroups']) : '';
$deployAuthGrpTitle = isset($viewData->authtitle) ? $viewData->authtitle : 'Unknown Group Authorization:';
$deployNagiosHead = isset($viewData->deployInfo['nagioshead']) ? $viewData->deployInfo['nagioshead'] : '';
$deployNagiosNegate = isset($viewData->deployInfo['deploynegate']) ? $viewData->deployInfo['deploynegate'] : '';
$deployType = isset($viewData->deployInfo['type']) && !empty($viewData->deployInfo['type']) ? $viewData->deployInfo['type'] : false;
$deployRev = isset($viewData->deployInfo['revision']) && !empty($viewData->deployInfo['revision']) ? $viewData->deployInfo['revision'] : false;
$deployNextRev = isset($viewData->deployInfo['nextrevision']) && !empty($viewData->deployInfo['nextrevision']) ? $viewData->deployInfo['nextrevision'] : false;
$deployAliasTemp = isset($viewData->deployInfo['aliastemplate']) ? $viewData->deployInfo['aliastemplate'] : 'host-dc';
$deployEnSharding = isset($viewData->deployInfo['ensharding']) ? $viewData->deployInfo['ensharding'] : 'off';
$deployShardKey = isset($viewData->deployInfo['shardkey']) ? $viewData->deployInfo['shardkey'] : genKey();
$deployShardCount = isset($viewData->deployInfo['shardcount']) ? $viewData->deployInfo['shardcount'] : '1';
$deployStyle = isset($viewData->deployInfo['deploystyle']) ? $viewData->deployInfo['deploystyle'] : 'both';
$deployCRepo = isset($viewData->deployInfo['commonrepo']) ? $viewData->deployInfo['commonrepo'] : 'common';
?>
<link type="text/css" rel="stylesheet" href="static/css/tables.css" />
<script type="text/javascript">
var searchList = new Array(<?php 
echo count($viewData->locations);
?>
)
searchList["empty"] = ["Select a Parameter"];
<?php 
foreach ($viewData->locations as $srchLoc => $slArray) {
    $keysArray = array_values($slArray);
    ?>
Beispiel #8
0
 public function crear_token($alumno, $semestre)
 {
     $data = array('TOKEN' => genKey(60), 'CODIGO_ALUMNO' => $alumno, 'SEMESTRE' => $semestre);
     $this->model_alumnos->create_token($data);
     return $this->get_token($alumno, $semestre);
 }
        $database = 'captain_vahab';
        $user = '******';
        $password = '******';
        $host = 'localhost';
        $connection = mysql_connect($host, $user, $password);
        $db = mysql_select_db('captain_vahab', $connection);
        if (!$connection) {
            die('Connection Failed' . mysql_error());
        }
        if (!$db) {
            die('Database connection Failed' . mysql_error());
        }
        $password = $_POST['password'];
        $email = $_GET['email'];
        // encrypt password
        $encryptedPassword = crypt($password, genKey(60));
        $query = "UPDATE users SET password = \"{$encryptedPassword}\" WHERE email = \"{$email}\"";
        $result = mysql_query($query);
        if ($result) {
            $return_sign_in = "New Password sets successfully. <a href='signin.php'>Sign In Here</a></h1>";
        }
        $_SESSION['logged_in'] = false;
    } else {
        $error_quote = "Please fill all the fields.";
    }
}
?>

</head>
<body>
            echo json_encode($return);
            die;
        } else {
            $q = $dbh->prepare("UPDATE cm_users SET password = :new_pass WHERE id = :id");
            $new_hash = pbkdf2($_POST['new_pword'], $salt, 1000, 32);
            $new_pass = base64_encode($new_hash);
            $data = array('id' => $_POST['id'], 'new_pass' => $new_pass);
            $q->execute($data);
        }
        $error = $q->errorInfo();
        break;
    case 'change_picture':
        //Not yet implemented.  Admin must change picture now.
        break;
    case 'change_private_key':
        $new_key = genKey();
        $q = $dbh->prepare('UPDATE cm_users SET private_key = :private_key WHERE id = :id');
        $data = array('private_key' => $new_key, 'id' => $_POST['id']);
        $q->execute($data);
        $error = $q->errorInfo();
        break;
}
if ($error[1]) {
    $return = array('error' => true, 'message' => $error[1]);
    echo json_encode($return);
} else {
    switch ($action) {
        case 'update_profile':
            $return = array('error' => false, 'message' => 'Your profile has been updated.');
            echo json_encode($return);
            break;
Beispiel #11
0
" />
				<input type="hidden" name="pass" value="<?php 
            echo $pass;
            ?>
" />
				Цена ваучера: <input type="text" name="price" value="100" /><br>
				Символы: <input type="text" name="symb" value="ABCDEF1234567890" /><br>
				Длина: <input type="text" name="len" value="8" /><br>
				Количество: <input type="text" name="col" value="50" /><br>
				<input type="submit">
			</form> <?php 
        } else {
            if ($action == 'addkeys') {
                for ($i = 0; $i < $_GET['col']; $i++) {
                    $amount = $_GET['price'];
                    $key = genKey($_GET['len']);
                    $stmt = $db->prepare("INSERT INTO sashok724_launcher_keys (`key`,`amount`) VALUES (:key, :amount)");
                    $stmt->bindValue(':key', $key);
                    $stmt->bindValue(':amount', $amount);
                    $stmt->execute();
                }
                echo "Успешно";
            } else {
                if ($action == "setmoney" && (empty($_GET['unick']) || empty($_GET['money']))) {
                    ?>
			<form action="">
				<input type="hidden" name="action" value="<?php 
                    echo $action;
                    ?>
" />
				<input type="hidden" name="pass" value="<?php 
Beispiel #12
0
function main()
{
    global $g_conf;
    $G_RAW_POST = file_get_contents("php://input");
    // 获取post原始字符串
    $ret = array('code' => 0, 'value' => '');
    $key = genKey();
    if (!$G_RAW_POST) {
        $ret['code'] = 1;
        $ret['value'] = "miss post data";
        return $ret;
    }
    $_v = array('time' => date("Y-m-d H:i:s", time()), 'points' => array());
    if (isset($_GET['name'])) {
        $_v['name'] = $_GET['name'];
    }
    $arr = explode("\n", $G_RAW_POST);
    $index = 0;
    foreach ($arr as $line) {
        $line = trim($line);
        if (!$line) {
            continue;
        }
        $_sp = explode("\t", $line);
        if (count($_sp) > 1) {
            $_point = fmtTimePoint($_sp[0], $_sp[1]);
            if (!$_point) {
                $ret['code'] = 2;
                $ret['value'] = "contain invalide point:" . $line;
                return $ret;
            }
            $_v['points'][] = $_point;
        } else {
            $_v['points'][] = array($index, intval($_sp[0]));
        }
        $index++;
    }
    $j_v = json_encode($_v);
    if (!set_local($key, $j_v)) {
        $ret['code'] = 2;
        $ret['value'] = "save fail";
        return $ret;
    }
    $ret['value'] = getWebAddr($key);
    return $ret;
}