Beispiel #1
0
 protected function random_number($digits, $leading_zeros = FALSE)
 {
     if (defined('STRICT_TYPES') && CAMEL_CASE == '1') {
         return self::parameters(['digits' => DT::UINT64, 'leading_zeros' => DT::BOOL])->call(__FUNCTION__)->with($digits, $leading_zeros)->returning([DT::UINT64, DT::STRING]);
     } else {
         return random_number($digits, $leading_zeros);
     }
 }
Beispiel #2
0
    if (!$success) {
        logfile($errorInfo);
        $errors = true;
    }
}
if (!isset($_REQUEST['accept'])) {
    header("Location: ../index.php?disagreedGPL=1");
    exit;
}
include '../includes/basics.php';
$db_layer = $kga['server_conn'];
if ($db_layer == '') {
    $db_layer = $_REQUEST['db_layer'];
}
date_default_timezone_set($_REQUEST['timezone']);
$randomAdminID = random_number(9);
logfile("-- begin install ----------------------------------");
// if any of the queries fails, this will be true
$errors = false;
$p = $kga['server_prefix'];
$query = "CREATE TABLE `{$p}usr` (\n  `usr_ID` int(10) NOT NULL,\n  `usr_name` varchar(160) NOT NULL,\n  `usr_alias` varchar(10),\n  `usr_grp` int(5) NOT NULL default '1',\n  `usr_sts` tinyint(1) NOT NULL default '2',\n  `usr_trash` tinyint(1) NOT NULL default '0',\n  `usr_active` tinyint(1) NOT NULL default '1',\n  `usr_mail` varchar(160) NOT NULL DEFAULT '',\n  `pw` varchar(254) NULL DEFAULT NULL,\n  `ban` int(1) NOT NULL default '0',\n  `banTime` int(10) NOT NULL default '0',\n  `secure` varchar(60) NOT NULL default '0',\n  `lastProject` int(10) NOT NULL default '1',\n  `lastEvent` int(10) NOT NULL default '1',\n  `lastRecord` int(10) NOT NULL default '0',\n  `timespace_in` varchar(60) NOT NULL default '0',\n  `timespace_out` varchar(60) NOT NULL default '0',\n  PRIMARY KEY  (`usr_name`)\n);";
exec_query($query);
$query = "CREATE TABLE `{$p}preferences` (\n  `userID` int(10) NOT NULL,\n  `var` varchar(255) NOT NULL,\n  `value` varchar(255) NOT NULL,\n  PRIMARY KEY (`userID`,`var`)\n);";
exec_query($query);
$query = "CREATE TABLE `{$p}evt` (\n  `evt_ID` int(10) NOT NULL auto_increment,\n  `evt_name` varchar(255) NOT NULL,\n  `evt_comment` TEXT NOT NULL,\n  `evt_visible` TINYINT(1) NOT NULL DEFAULT '1',\n  `evt_filter` TINYINT(1) NOT NULL DEFAULT '0',\n  `evt_trash` TINYINT(1) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`evt_ID`)\n) AUTO_INCREMENT=1;";
exec_query($query);
$query = "CREATE TABLE `{$p}grp` (\n  `grp_ID` int(10) NOT NULL auto_increment,\n  `grp_name` varchar(160) NOT NULL,\n  `grp_trash` TINYINT(1) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`grp_ID`)\n) AUTO_INCREMENT=1;";
exec_query($query);
// leader/group cross-table (leaders n:m groups)
$query = "CREATE TABLE `{$p}ldr` (`uid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `grp_ID` int(10) NOT NULL, `grp_leader` int(10) NOT NULL, UNIQUE (`grp_ID` ,`grp_leader`));";
exec_query($query);
Beispiel #3
0
 /**
  * Adds a new user
  *
  * @param array $data  username, email, and other data of the new user
  * @return boolean|integer     false on failure, otherwise the new user id
  * @author th
  */
 public function user_create($data)
 {
     // find random but unused user id
     do {
         $data['userID'] = random_number(9);
     } while ($this->user_get_data($data['userID']));
     $data = $this->clean_data($data);
     $values['name'] = MySQL::SQLValue($data['name']);
     $values['userID'] = MySQL::SQLValue($data['userID'], MySQL::SQLVALUE_NUMBER);
     $values['globalRoleID'] = MySQL::SQLValue($data['globalRoleID'], MySQL::SQLVALUE_NUMBER);
     $values['active'] = MySQL::SQLValue($data['active'], MySQL::SQLVALUE_NUMBER);
     // 'mail' and 'password' are just set when actually provided because of compatibility reasons
     if (array_key_exists('mail', $data)) {
         $values['mail'] = MySQL::SQLValue($data['mail']);
     }
     if (array_key_exists('password', $data)) {
         $values['password'] = MySQL::SQLValue($data['password']);
     }
     $table = $this->kga['server_prefix'] . "users";
     $result = $this->conn->InsertRow($table, $values);
     if ($result === false) {
         $this->logLastError('user_create');
         return false;
     }
     if (isset($data['rate'])) {
         if (is_numeric($data['rate'])) {
             $this->save_rate($data['userID'], NULL, NULL, $data['rate']);
         } else {
             $this->remove_rate($data['userID'], NULL, NULL);
         }
     }
     return $data['userID'];
 }
function usr_create($data)
{
    global $kga, $conn;
    // find random but unused user id
    do {
        $data['usr_ID'] = random_number(9);
    } while (usr_get_data($data['usr_ID']));
    $data = clean_data($data);
    $values['usr_name'] = MySQL::SQLValue($data['usr_name']);
    $values['usr_ID'] = MySQL::SQLValue($data['usr_ID'], MySQL::SQLVALUE_NUMBER);
    $values['usr_grp'] = MySQL::SQLValue($data['usr_grp'], MySQL::SQLVALUE_NUMBER);
    $values['usr_sts'] = MySQL::SQLValue($data['usr_sts'], MySQL::SQLVALUE_NUMBER);
    $values['usr_active'] = MySQL::SQLValue($data['usr_active'], MySQL::SQLVALUE_NUMBER);
    $table = $kga['server_prefix'] . "usr";
    $result = $conn->InsertRow($table, $values);
    if ($result === false) {
        return false;
    } else {
        if (isset($data['usr_rate'])) {
            if (is_numeric($data['usr_rate'])) {
                save_rate($usr_id, NULL, NULL, $data['usr_rate']);
            } else {
                remove_rate($usr_id, NULL, NULL);
            }
        }
        return $data['usr_ID'];
    }
}
Beispiel #5
0
 public function captchaforgetpwd_get()
 {
     //		$this->load->library('kqsms');
     //
     //		$mobile = $this->get('mobile');
     //
     //		$captcha = random_number();
     //
     //		$response = $this->kqsms->send_forgetpwd_sms($mobile,$captcha);
     //
     //
     //
     //		if ($response === true){
     //			$query = $this->db->query("insert into s_sms (type,code,mobile) values ('forget',$response,$mobile)");
     //
     //			$captchaMd5 = md5($captcha);
     //
     //			return $this->output_results(array('captcha'=>$captchaMd5));
     //		}
     //		else{
     //
     ////			echo 'failure';
     //
     //			log_message('error','SMS Forget error #'.$response.', mobiel # '.$mobile);
     //
     //			return $this->output_error(ErrorFailureSMS);
     //		}
     $this->load->library('kqsms');
     $mobile = $this->get('mobile');
     $captcha = random_number();
     $response = $this->kqsms->send_forgetpwd_sms($mobile, $captcha);
     if ($response === true) {
         $query = $this->db->query("insert into s_sms (type,code,mobile) values ('forget',{$response},{$mobile})");
         $captchaMd5 = md5($captcha);
         return $this->output_results(array('captcha' => $captchaMd5));
     } else {
         //			echo 'failure';
         log_message('error', 'SMS Forget error #' . $response . ', mobile # ' . $mobile);
         if ($response == ErrorSMSZero || $response == ErrorSMSCaptchaLimit) {
             return $this->output_error($response);
         } else {
             return $this->output_error(ErrorSMSUnknown);
         }
     }
 }
Beispiel #6
0
 public function captchaforgetpwd_get()
 {
     $this->load->library('kqsms');
     $mobile = $this->get('mobile');
     $captcha = random_number();
     //		$response = $this->kqsms->mock_send_forgetpwd_sms($mobile,$captcha);
     $response = $this->kqsms->send_forgetpwd_sms($mobile, $captcha);
     $xml = simplexml_load_string($response);
     $code = $xml->code;
     $query = $this->db->query("insert into s_sms (type,code,mobile) values ('forget',{$code},{$mobile})");
     if ($code == 2) {
         //			echo 'success';
         $captchaMd5 = md5($captcha);
         return $this->output_results(array('captcha' => $captchaMd5));
     } else {
         //			echo 'failure';
         return $this->output_error(ErrorFailureSMS);
     }
 }
Beispiel #7
0
function generate_client_id()
{
    return random_number(9);
}
Beispiel #8
0
/**
 * Adds a new user
 *
 * @param array $data         username, email, and other data of the new user
 * @global array $kga         kimai-global-array
 * @return boolean            true on success, false on failure
 * @author ob
 */
function usr_create($data)
{
    global $kga, $pdo_conn;
    $p = $kga['server_prefix'];
    // find random but unused user id
    do {
        $data['usr_ID'] = random_number(9);
    } while (usr_get_data($data['usr_ID']));
    $data = clean_data($data);
    $pdo_query = $pdo_conn->prepare("INSERT INTO {$p}usr (\n    `usr_ID`,\n    `usr_name`,\n    `usr_grp`,\n    `usr_sts`,\n    `usr_active`\n    ) VALUES (?, ?, ?, ?, ?)");
    $result = $pdo_query->execute(array($data['usr_ID'], $data['usr_name'], $data['usr_grp'], $data['usr_sts'], $data['usr_active']));
    if ($result == true) {
        if (isset($data['usr_rate'])) {
            if (is_numeric($data['usr_rate'])) {
                save_rate($usr_id, NULL, NULL, $data['usr_rate']);
            } else {
                remove_rate($usr_id, NULL, NULL);
            }
        }
        return $data['usr_ID'];
    } else {
        return false;
    }
}