Пример #1
1
 public function upload($blobRestProxy, $container, $filePath)
 {
     $this->md5 = md5_file($filePath);
     //Get file hash
     $this->name = generateRandomString();
     //Generate file blob name
     $this->url = 'https://' . getConfigValue('azure_storage_account') . '.blob.core.windows.net/' . $container . '/' . $this->name;
     //Get Azure blob URL
     $this->fileHandle = fopen($filePath, 'r');
     $blobRestProxy->createBlockBlob($container, $this->name, $this->fileHandle);
     //Upload blob to Azure Blob Service
 }
Пример #2
0
 /**
  * 
  * Generate code using given parameters
  * @param array $paramsArray
  */
 public function generate(OTCConfig $config = null)
 {
     if ($config === null) {
         $config = new OTCConfig();
     }
     $paramsArray = $config->paramsArray;
     if (isset($paramsArray['r'])) {
         throw new RuntimeException("Key 'r' is not allowed to be present in \$paramsArray. Please remove or rename it.");
     }
     $paramsArray['r'] = generateRandomString(12);
     $keyValArray = array();
     $keysUniqueCheckArray = array();
     foreach ($paramsArray as $key => $value) {
         if (preg_match("/[:;]/", $key) or preg_match("/[:;]/", $value)) {
             throw new RuntimeException("Invalid characters in \$paramsArray. No ; or : characters are allowed!");
         }
         if (in_array($key, $keysUniqueCheckArray)) {
             throw new RuntimeException("Duplicate key '{$key}' in \$paramsArray. It's not allowed!");
         }
         array_push($keysUniqueCheckArray, $key);
         array_push($keyValArray, "{$key}:{$value}");
     }
     $stringToEncrypt = implode(";", $keyValArray);
     $encryptedString = AES256::encrypt($stringToEncrypt);
     if (strlen($encryptedString) > static::CODE_MAX_LENGTH) {
         throw new RuntimeException("Resulting code is longer than allowed " . static::CODE_MAX_LENGTH . " characters!");
     }
     $this->query->exec("INSERT INTO `" . Tbl::get('TBL_ONE_TIME_CODES') . "` \n\t\t\t\t\t\t\t\t\t(`code`, `multi`, `usage_limit`, `not_cleanable`, `valid_until`) \n\t\t\t\t\t\t\t\t\tVALUES(\t'{$encryptedString}', \n\t\t\t\t\t\t\t\t\t\t\t'" . ($config->multiUse ? '1' : '0') . "',\n\t\t\t\t\t\t\t\t\t\t\t" . ($config->usageLimit ? "'{$config->usageLimit}'" : "NULL") . ",\n\t\t\t\t\t\t\t\t\t\t\t'" . ($config->notCleanable ? '1' : '0') . "',\n\t\t\t\t\t\t\t\t\t\t\t" . ($config->validityTime ? "FROM_UNIXTIME(UNIX_TIMESTAMP(NOW()) + {$config->validityTime})" : 'NULL') . ")");
     return $encryptedString;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, MemberInputtedMailer $mailer)
 {
     $this->validate($request, ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:users']);
     $user = new User();
     $user->first_name = $request->get('first_name');
     $user->last_name = $request->get('last_name');
     $user->street_address = $request->get('address1');
     $user->city = $request->get('city');
     $user->state = $request->get('state_province');
     $user->zip = $request->get('postal_code');
     $user->phone_number = $request->get('phone');
     $user->email = $request->get('email');
     $user->membership_expires = date('Y-m-d', strtotime($request->get('membership_expires')));
     $user->birthday = date('Y-m-d', strtotime($request->get('birthday')));
     $user->anniversary = date('Y-m-d', strtotime($request->get('anniversary')));
     $user->plan_id = $request->get('plan_id');
     $user->temp_password = 1;
     $randomString = generateRandomString();
     $user->password = bcrypt($randomString);
     $user->save();
     $user->random_string = $randomString;
     $mailer->forward($user);
     Flash::success('This member was successfully added to the database.');
     return redirect('admin/membership');
 }
Пример #4
0
 public function update_categories($images)
 {
     if (empty($this->input->post('status'))) {
         $status = 0;
     } else {
         $status = 1;
     }
     $this->load->helper('rand_helper');
     foreach ($images as $key => $value) {
         if (!empty($value['name'])) {
             if (!empty($this->input->post('old_' . $key))) {
                 unlink(FCPATH . $this->input->post('old_' . $key));
             }
             $randomString = generateRandomString(14);
             $db_img_name[$key] = 'assets/uploads/system/images/catid_' . $this->input->post('id') . '_' . $randomString . '-' . $this->changeName($value['name']);
         } else {
             $db_img_name[$key] = $this->input->post('old_' . $key);
         }
         if ($this->input->post('delete_' . $key)) {
             unlink(FCPATH . $this->input->post('delete_' . $key));
             $db_img_name[$key] = '';
         }
         move_uploaded_file($value["tmp_name"], FCPATH . $db_img_name[$key]);
     }
     $categories_update_data = array('status' => $status, 'perma_link' => $this->input->post('perma_link'), 'perma_active' => $this->input->post('perma_active'), 'name' => $this->input->post('name'), 'description' => $this->input->post('description'), 'image' => $db_img_name['image'], 'banner' => $db_img_name['banner'], 'queue' => $this->input->post('queue'), 'list_layout' => $this->input->post('list_layout'), 'meta_description' => $this->input->post('meta_description'), 'meta_keyword' => $this->input->post('meta_keyword'), 'meta_title' => $this->input->post('meta_title'));
     $this->db->set($categories_update_data);
     $this->db->where('id', $this->input->post('id'));
     $this->db->update('categories');
 }
Пример #5
0
 /**
  * 
  * Generate code using given parameters
  * @param array $paramsArray
  */
 public function generate(OTCConfig $config = null)
 {
     if ($config === null) {
         $config = new OTCConfig();
     }
     $paramsArray = $config->paramsArray;
     if (isset($paramsArray['r'])) {
         throw new RuntimeException("Key 'r' is not allowed to be present in \$paramsArray. Please remove or rename it.");
     }
     $paramsArray['r'] = generateRandomString(12);
     $keyValArray = array();
     $keysUniqueCheckArray = array();
     foreach ($paramsArray as $key => $value) {
         if (preg_match("/[:;]/", $key) or preg_match("/[:;]/", $value)) {
             throw new RuntimeException("Invalid characters in \$paramsArray. No ; or : characters are allowed!");
         }
         if (in_array($key, $keysUniqueCheckArray)) {
             throw new RuntimeException("Duplicate key '{$key}' in \$paramsArray. It's not allowed!");
         }
         array_push($keysUniqueCheckArray, $key);
         array_push($keyValArray, "{$key}:{$value}");
     }
     $stringToEncrypt = implode(";", $keyValArray);
     $encryptedString = AES256::encrypt($stringToEncrypt);
     if (strlen($encryptedString) > static::CODE_MAX_LENGTH) {
         throw new RuntimeException("Resulting code is longer than allowed " . static::CODE_MAX_LENGTH . " characters!");
     }
     $qb = new QueryBuilder();
     $qb->insert(Tbl::get('TBL_ONE_TIME_CODES'))->values(array("code" => $encryptedString, "multi" => $config->multiUse ? 1 : 0, "usage_limit" => $config->usageLimit ? $config->usageLimit : new Literal("NULL"), "not_cleanable" => $config->notCleanable ? 1 : 0, "valid_until" => $config->validityTime ? new Func('FROM_UNIXTIME', $qb->expr()->sum(new Func('UNIX_TIMESTAMP', new Func('NOW')), $config->validityTime)) : new Literal("NULL")));
     $this->query->exec($qb->getSQL());
     return $encryptedString;
 }
Пример #6
0
function dummyUser($db)
{
    $pass = hashPassword("admin");
    $key = generateRandomString();
    $sql = "INSERT INTO users VALUES (NULL,'admin','{$pass}','{$key}',NULL);";
    execSql($db, $sql, "add admin user");
}
Пример #7
0
function insertKey($email, $IME, $deviceId, $type, $payerId, $dayLimit, $price)
{
    $keyCreate = generateRandomString();
    //231
    while (true) {
        if (checkKeyExist($keyCreate)) {
            $keyCreate = generateRandomString();
        } else {
            break;
        }
    }
    $conn = getConnection();
    $keygen = null;
    //check key exits
    $query = sprintf("insert into %s(email,IME_CODE,Device_id,Type,CreateDate,Key_Code,PayerId,DateLimit,Price) values('%s','%s','%s',%d,now(),'%s','%s',DATE_ADD(now(),INTERVAL %d DAY ),%f)", KEY_TABLE, mysql_real_escape_string($email), mysql_real_escape_string($IME), mysql_real_escape_string($deviceId), mysql_real_escape_string($type), mysql_real_escape_string($keyCreate), mysql_real_escape_string($payerId), $dayLimit, $price);
    $result = mysql_query($query, $conn);
    if (!$result) {
        $errMsg = "Error: " . mysql_error($conn);
        mysql_close($conn);
        throw new Exception("Error Processing Request:" . $errMsg, 1);
    }
    $recordId = mysql_insert_id($conn);
    mysql_close($conn);
    if ($recordId > 0) {
        return $keyCreate;
    }
    return null;
}
Пример #8
0
 function recover()
 {
     $return = array("rpta" => false, "message" => "Ingrese correo electronico.");
     $dataPost = $this->input->post();
     $notfind = false;
     if (isset($dataPost['data'])) {
         $rptaTmp = $this->recoverpass->checkmail($dataPost['data']);
         //var_dump("<pre>",$rptaTmp);exit;
         if ($rptaTmp['rpta'] == true) {
             while ($notfind == false) {
                 $string = generateRandomString();
                 $tmp = $this->recoverpass->Find($string);
                 // se comprueba que este codigo no exista en la bd
                 $notfind = $tmp['rpta'];
             }
             $arr = array("email" => $dataPost['data'], "generatecode" => $string);
             $message = "<p>Hemos recibido la solicitud de restaurar su contraseña.</p>" . "<p>Si usted ha solicitado este cambio de contraseña por favor de click <a href='" . site_url('Recoverpass/changePassMail') . "/" . $string . "'>AQUI</a> </p>" . "<p>Caso contrario, por favor ingrese a <a href='http://www.lifeleg.com/'>www.lifeleg.com</a>, y cambie su contraseña.</p>" . "<p>GRACIAS, por pertenecer a nuestra familia, seguiremos trabajando para ofrecerle lo mejor.</p>";
             $rptamail = send_email("Restaurar contraseña", $message, $dataPost['data'], false);
             if ($rptamail == true) {
                 $arr = array("email" => $dataPost['data'], "generatecode" => $string);
                 $this->recoverpass->insertRecover($arr);
                 $return['rpta'] = true;
                 $return['message'] = "Correo enviado correctamente, por favor ingresa a tu bandeja y sigue las instrucciones, Gracias!";
             }
         } else {
             $return['message'] = "E-mail no registrado, verifique y vuelva a intentarlo por favor.";
         }
     }
     echo json_encode($return);
 }
Пример #9
0
 public function generateCode($id)
 {
     $reg_code = '';
     $code = generateRandomString(8) . $id;
     $reg_code = substr($code, 2, 8);
     return $reg_code;
 }
Пример #10
0
 function blog_update($images)
 {
     $this->load->helper('rand_helper');
     $blog_update_data = array('pages_type' => $this->input->post('pages_type'), 'perma_link' => $this->input->post('perma_link'), 'perma_active' => $this->input->post('perma_active'), 'quick_link' => $this->input->post('quick_link'), 'blog_comments_enable' => $this->input->post('blog_comments_enable'), 'title' => $this->input->post('title'), 'content' => $this->input->post('content', FALSE), 'list_title' => $this->input->post('list_title'), 'list_content' => $this->input->post('list_content'), 'meta_description' => $this->input->post('meta_description'), 'meta_keyword' => $this->input->post('meta_keyword'), 'meta_title' => $this->input->post('meta_title'));
     $this->db->set($blog_update_data);
     $this->db->where('id', $this->input->post('id'));
     $this->db->update('blog');
     foreach ($images as $key => $value) {
         if (!empty($value['name'])) {
             if (!empty($this->input->post('old_' . $key))) {
                 unlink(FCPATH . $this->input->post('old_' . $key));
             }
             $randomString = generateRandomString(14);
             $db_img_name[$key] = 'assets/uploads/system/images/' . $key . '_' . $randomString . '-' . $this->changeName($value['name']);
         } else {
             $db_img_name[$key] = $this->input->post('old_' . $key);
         }
         if ($this->input->post('delete_' . $key)) {
             unlink(FCPATH . $this->input->post('delete_' . $key));
             $db_img_name[$key] = '';
         }
         move_uploaded_file($value["tmp_name"], FCPATH . $db_img_name[$key]);
         $blog_update_image = array('list_image' => $db_img_name[$key]);
         $this->db->set($blog_update_image);
         $this->db->where('id', $this->input->post('id'));
         $this->db->update('blog');
     }
 }
Пример #11
0
function randomID($location)
{
    global $conn;
    $x = 0;
    $result = true;
    while ($result) {
        $randomString = generateRandomString(16);
        //generera ett random id på 16 tecken och kolla så att det inte är taget. om taget
        $sql = "SELECT id FROM `users` WHERE `id` = '{$randomString}';";
        /*
        	select 1 
        	from (
        	    select username as username from tbl1
        	    union all
        	    select username from tbl2
        	    union all
        	    select username from tbl3
        	) a
        	where username = '******'
        */
        $result = $conn->query($sql);
        if ($result->num_rows == 0) {
            var_dump($randomString);
            $result = false;
        } else {
            echo "{$randomString}<br>";
        }
        $x++;
    }
}
Пример #12
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request, PropertyInterface $property, booking $booking, serviceBooking $serviceBooking, service $service)
 {
     $ownerId = $property->findOrFail($request->get('propertyId'))->owner->id;
     $orderRef = generateRandomString();
     $invoiceData = ['serviceId' => $request->get('selectedServiceIds'), 'payee_id' => $request->user()->id, 'seller_id' => $ownerId, 'orderRef' => $orderRef, 'amount' => $request->get('overallTotal')];
     $newInvoice = $this->invoices->create($invoiceData);
     $bookingData = ['user_id' => $request->user()->id, 'property_id' => $request->get('propertyId'), 'invoice_id' => $newInvoice->id, 'price' => $request->get('nightRate'), 'checkInDate' => convertToCarbonDate($request->get('checkInDate')), 'checkOutDate' => convertToCarbonDate($request->get('checkOutDate'))];
     $booking->create($bookingData);
     if (count($request->get('selectedServiceIds')) > 0) {
         $serviceData = [];
         foreach ($request->get('selectedServiceIds') as $serviceId) {
             $theService = $service->findOrFail($serviceId);
             $serviceData['service_id'] = $serviceId;
             $serviceData['user_id'] = $request->user()->id;
             if ($theService->type == 'onceoff') {
                 $serviceData['quantity'] = 1;
             }
             if ($theService->type == 'daily') {
                 $serviceData['quantity'] = $bookingData['checkOutDate']->diffInDays($bookingData['checkInDate']);
             }
             $serviceData['invoice_id'] = $newInvoice->id;
         }
         $serviceBooking->create($serviceData);
     }
     return ['response' => 'completed', 'orderRef' => $orderRef, 'propertyId' => $request->get('propertyId')];
 }
Пример #13
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_function_rand($params, &$smarty)
{
    $length = null;
    $type = null;
    extract($params);
    return generateRandomString($length, $type);
}
Пример #14
0
function createAccount($userInfo)
{
    //echo('creating...');
    if (!isset($userInfo['email'])) {
        $resp = array("status" => "fail", "reason" => "please send the email to create account");
        return $resp;
    }
    if (!isset($userInfo['passwd'])) {
        $resp = array("status" => "fail", "reason" => "please send password to create account");
        return $resp;
    }
    $userInfo['userId'] = generateRandomString();
    $unencrypted = $userInfo['passwd'];
    $userInfo['passwd'] = md5($userInfo['passwd']);
    $email = $userInfo['email'];
    $exists = dbMassData("SELECT * FROM users WHERE email = '{$email}'");
    if ($exists != NULL) {
        $account = loginUser($email, $unencrypted);
        return $account;
    }
    $passwd = $userInfo['passwd'];
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    dbQuery("INSERT INTO users (email, passwd, ip) VALUES('{$email}', '{$passwd}', '{$ip}')");
    //$resp = array("status"=>"success", "reason"=>"account created");
    //return $resp;
    $account = loginUser($email, $unencrypted);
    return $account;
}
Пример #15
0
function run()
{
    if (!isset($_POST["pw"])) {
        return;
    }
    if (md5($_POST["pw"]) !== $md5pw) {
        die("<!DOCTYPE html><html><head><meta charset=utf-8> <title> Add Song! </title> </head> <body> Wrong Password! </body> </html>");
    }
    $x = time() . "_" . generateRandomString(32);
    //hopefully not duplicate :)
    mkdir($x);
    $target_dir = $x . "/";
    $fp = fopen("songlist", "a");
    fwrite($fp, $x . "\n");
    fclose($fp);
    $fp = fopen($target_dir . "songdata", "w");
    echo htmlentities($_POST["music_name"], ENT_QUOTES, "UTF-8");
    echo "<br/>";
    echo htmlentities($_POST["composer"], ENT_QUOTES, "UTF-8");
    fwrite($fp, base64_encode(htmlentities($_POST["music_name"], ENT_QUOTES, "UTF-8")));
    fwrite($fp, "\n");
    fwrite($fp, base64_encode(htmlentities($_POST["composer"], ENT_QUOTES, "UTF-8")));
    fclose($fp);
    doFileUpload($target_dir . "song.mp3", $_FILES["mp3"]);
    doFileUpload($target_dir . "song.lrc", $_FILES["lrc"]);
    doFileUpload($target_dir . "folder.png", $_FILES["png"]);
}
Пример #16
0
function create_banklink($token, $amount, $description)
{
    $db = Db::getInstance()->getConnection();
    $banklink = generateRandomString();
    $query = "INSERT INTO banklinks (banklink, user_id, amount, description, timestamp)\n                    VALUES ('" . $banklink . "', (SELECT user_id FROM tokens WHERE token= '" . mysqli_real_escape_string($db, $token) . "'), {$amount}, '{$description}', NOW())";
    $db->query($query) or die("Couldn't create banklink");
    return $banklink;
}
Пример #17
0
function passwordCheck($password)
{
    $pwcheck = mysql_query("SELECT `id` FROM `classes` WHERE `password` = '{$password}'");
    if (mysql_num_rows($pwcheck) != 0) {
        $password = generateRandomString();
        passwordCheck();
        return;
    }
}
Пример #18
0
 public function generateCodeID($id)
 {
     var_dump($id);
     exit;
     $reg_code = '';
     $code = generateRandomString(8) . $id;
     $reg_code = substr($code, 2, 8);
     return $reg_code;
 }
function n2GoApiActivation()
{
    global $wp_rewrite;
    add_filter('query_vars', 'n2goAddQueryVars');
    add_filter('rewrite_rules_array', 'n2GoApiRewrites');
    $wp_rewrite->flush_rules();
    $authKey = generateRandomString();
    get_option('n2go_apikey', null) !== null ? update_option('n2go_apikey', $authKey) : add_option('n2go_apikey', $authKey);
}
Пример #20
0
 /**
  * Function get random username
  * @param string $prefix is name of current external plugin
  * @return string 
  */
 private static function findFreeRandomUsername($prefix)
 {
     $um = Reg::get(ConfigManager::getConfig("Users", "Users")->Objects->UserManager);
     $possibleUsername = $prefix . "_" . generateRandomString(6);
     if (!$um->isLoginExists($possibleUsername, 0)) {
         return $possibleUsername;
     } else {
         return static::findFreeRandomUsername($prefix);
     }
 }
Пример #21
0
 function exchange_point($coupon_id)
 {
     $this->load->helper("keygen");
     $uid = $this->get_user_id();
     $insert = array("user_id" => $uid, "coupon_id" => $coupon_id, "coupon_code" => generateRandomString());
     $this->model->insert_row($insert, "user_coupon");
     $point = $this->model->get_value("points_needed", "coupons", array("id" => $coupon_id));
     $this->subtract_point($uid, $point);
     redirect("user/view_coupons/" . $uid);
 }
Пример #22
0
 public function generateAccessToken($table_id, $object_id)
 {
     $session_id = $this->session->userdata('session_id');
     $ip_address = $this->input->ip_address();
     $secret_key = md5(generateRandomString(12) . "-" . $session_id . "-" . $ip_address);
     $access_token_str1 = md5(md5($table_id . "-" . $object_id) . "-" . $secret_key . "-" . time());
     $access_token_str2 = md5($secret_key . "-" . md5($table_id . "-" . $object_id) . "-" . time());
     $access_token_key = $access_token_str1 . $access_token_str2;
     return $access_token_key;
 }
Пример #23
0
function postex($conn)
{
    $query = $conn->prepare("SELECT 1 FROM posts WHERE postid = :rand");
    do {
        $random_string = generateRandomString(5);
        $query->bindValue(':rand', $random_string);
        $query->execute();
    } while ($query->rowCount() > 0);
    return $random_string;
}
Пример #24
0
 public function createUser($userName, $userEmail, $isApprover)
 {
     $userSecret = generateRandomString();
     $isApprover = $isApprover ? 't' : 'f';
     $userId = strtolower(str_replace(' ', '.', $userName));
     $userName = validateParam($userName, True, 'Invalid or Missing user name');
     $userEmail = validateParam($userEmail, True, 'Invalid or Missing user email');
     $userStatus = 'active';
     $userId = $this->createUserObDB($userId, $userName, $userEmail, $userStatus, $userSecret, $isApprover);
     return $userId;
 }
Пример #25
0
function rest_put($req, $dblink)
{
    $jsonText = file_get_contents('php://input');
    $idDash = generateRandomString();
    $query = "insert into stat (json, id_dash) values (?, ?)";
    $stmt = $dblink->prepare($query) or die("Prepare stmt die.");
    $stmt->bind_param("ss", $jsonText, $idDash);
    $stmt->execute();
    echo '{ "id":"' . $idDash . '"}';
    $stmt->close();
}
Пример #26
0
function checkString($com_code)
{
    include 'database.php';
    $rand = generateRandomString();
    $result = mysqli_query($connect, "SELECT * FROM `comments` WHERE `com_code`='{$com_code}'");
    $row_cnt = mysqli_num_rows($result);
    if ($row_cnt != 0) {
        return $rand;
    } else {
        checkString($rand);
    }
}
Пример #27
0
function generateParameters($dbhost, $dbport, $dbname, $dbusername, $dbpassword, $adminpassword)
{
    $currentUrl = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
    $lastSlach = strrpos($currentUrl, "/");
    $currentUrl = substr($currentUrl, 0, $lastSlach);
    $lastSlach = strrpos($currentUrl, "/");
    $currentUrl = substr($currentUrl, 0, $lastSlach);
    $url_param = '/app_dev.php/';
    $content = 'parameters:' . PHP_EOL . '    database_driver: pdo_mysql' . PHP_EOL . '    database_host: ' . $dbhost . PHP_EOL . '    database_port: ' . $dbport . PHP_EOL . '    database_name: ' . $dbname . PHP_EOL . '    database_user: '******'    database_password: '******'    database_path: ~' . PHP_EOL . '    url_base: ' . $currentUrl . PHP_EOL . '    url_param: ' . $url_param . PHP_EOL . '    mailer_transport: smtp' . PHP_EOL . '    mailer_host: localhost' . PHP_EOL . '    mailer_user: ~' . PHP_EOL . '    mailer_password: ~' . PHP_EOL . '    admin_password: '******'    locale: en' . PHP_EOL . '    secret: ' . generateRandomString() . PHP_EOL . '    installer: false' . PHP_EOL;
    writeFile($content, 'parameters.yml');
    header("Location: " . $currentUrl . $url_param);
    exit;
}
Пример #28
0
 public function add()
 {
     $capturado_por = $this->tank_auth->get_username();
     $qna_id = $this->input->post('qna_id');
     $empleado_id = $this->input->post('empleado_id');
     $qna_id = $this->input->post('qna_id');
     $empleado_id = $this->input->post('empleado_id');
     $fecha_inicial = $this->input->post('fecha_inicial');
     $fecha_final = $this->input->post('fecha_final');
     $token = generateRandomString();
     $fechaInicio = fecha_ymd($fecha_inicial);
     $fechaFin = fecha_ymd($fecha_final);
     $fechaInicio = strtotime($fechaInicio);
     $fechaFin = strtotime($fechaFin);
     $this->form_validation->set_rules('qna_id', 'qna id', 'trim|required|xss_clean|numeric');
     $this->form_validation->set_rules('incidencia_id', 'Incidencia', 'required|xss_clean|callback_require_dropdown');
     $this->form_validation->set_rules('fecha_inicial', 'Fecha Inicial', 'trim|xss_clean|required');
     $this->form_validation->set_rules('fecha_final', 'Fecha Final', 'trim|required|xss_clean|callback_validate_dates');
     $this->form_validation->set_message('validate_dates', 'Error en fechas intente nuevamente');
     $this->form_validation->set_rules('validar_ya_capturado', 'callback_validar_ya_capturado');
     //VALIDANDO PERIODO VACACIONAL
     $this->load->model('incidencia_model');
     $incidencia_id = $this->input->post('incidencia_id');
     $data['incidencia'] = $this->incidencia_model->where('id', $incidencia_id)->get();
     $periodo = $this->input->post('periodo_id');
     if ($data['incidencia']->incidencia_cod == 60 || $data['incidencia']->incidencia_cod == 62 || $data['incidencia']->incidencia_cod == 63) {
         $this->form_validation->set_rules('periodo_id', 'periodo', 'required|xss_clean|callback_require_dropdown2');
     } else {
         $periodo = 10;
     }
     ///////////////////////////////
     if ($this->form_validation->run() == FALSE) {
         $data = array('errors' => validation_errors());
         $this->session->set_flashdata($data);
         echo "Error intente de nuevo";
     } else {
         $test = $this->captura_model->verificar_ya_capturado($qna_id, $empleado_id, $incidencia_id, fecha_ymd($fecha_inicial), fecha_ymd($fecha_final));
         if ($test == NULL) {
             for ($i = $fechaInicio; $i <= $fechaFin; $i += 86400) {
                 $fecha = date("Y-m-d", $i);
                 $this->captura_model->insert(array('qna_id' => $qna_id, 'empleado_id' => $empleado_id, 'incidencia_id' => $incidencia_id, 'fecha_inicial' => $fecha, 'fecha_final' => fecha_ymd($fecha_final), 'periodo_id' => $periodo, 'token' => $token, 'capturado_por' => $capturado_por));
             }
             $data['capturas'] = $this->captura_model->get_incidencias($empleado_id, $qna_id);
             $this->load->view('capturar/ver_incidencias', $data);
         } else {
             $this->form_validation->set_message('', 'Incidencia ya Capturada');
             $this->session->set_flashdata($data);
             echo "Incidencia ya capturada";
         }
     }
 }
Пример #29
0
 public function loginSocial()
 {
     $input = Input::all();
     $user = User::where('facebook_id', $input['facebook_id'])->where('google_id', $input['google_id'])->first();
     if (!$user) {
         $sessionId = generateRandomString();
         $userId = User::create(['username' => $input['username'], 'facebook_id' => $input['facebook_id'], 'google_id' => $input['google_id'], 'status' => INACTIVE])->id;
         Device::create(['user_id' => $userId, 'session_id' => $sessionId, 'device_id' => $input['device_id']]);
     } else {
         $userId = $user->id;
         $sessionId = Common::getSessionId($input, $userId);
     }
     return Common::returnData(200, SUCCESS, $userId, $sessionId);
 }
 public function index()
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     $user = User::find($input['user_id']);
     //tao code phone
     $codePhone = generateRandomString(CODEPHONE);
     //luu code phone -> db
     $user->update(['code_phone' => $codePhone]);
     //gui code cho dau so
     //active user
     $user->update(['status' => ACTIVE]);
     return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId);
 }