queryFirstField() public static method

public static queryFirstField ( )
コード例 #1
0
 function getPrizeValue($rid = "")
 {
     if (empty($rid)) {
         $rid = $this->raffle_id;
     }
     return DB::queryFirstField("select sum(tp_price)\n                                   from raffle_prizes p, gw2_items i\n                                   where p.item_id = i.id\n                                     and raffle_id = %i", $rid);
 }
コード例 #2
0
ファイル: List.php プロジェクト: lhsmath/lhsmath.org
function show_page()
{
    // If the Registration page does not exist, add it
    if (DB::queryFirstField('SELECT COUNT(*) FROM pages WHERE page_id="-1"') == 0) {
        $new_order_num = DB::queryFirstField('SELECT (MIN(order_num) - 1) AS new_order FROM pages');
        DB::insert('pages', array('page_id' => '-1', 'name' => 'Registration', 'content' => '', 'order_num' => $new_order_num));
    }
    lmt_page_header('Page List');
    $delete_alert = fetch_alert('deletePage');
    echo <<<HEREDOC
      <h1>Page List</h1>
      {$delete_alert}
      <a href="Add"><img src="../../../res/icons/add.png" alt="+" /> Add a Page</a><br />
      <a href="Add_Separator?xsrf_token={$_SESSION['xsrf_token']}"><img src="../../../res/icons/add.png" alt="+" /> Add a Separator</a><br />
      <br />
      <h4 class="smbottom">Pages</h4>
HEREDOC;
    $table = lmt_db_table('SELECT page_id, name, order_num FROM pages ORDER BY order_num', array('name' => ''), array('<img src="../../../res/icons/eye.png" alt="View" />' => 'View?ID={page_id}', '<img src="../../../res/icons/edit.png" alt="Edit" />' => 'Edit?ID={page_id}', '<img src="../../../res/icons/delete.png" alt="Delete" />' => 'Delete?ID={page_id}'), 'No Pages', 'contrasting indented', array('page' => 'Order', 'field' => 'page_id'));
    //Make the Separators come out nicely
    $search = '#<td></td>(\\s+)<td><a href="View\\?ID=(\\d+)"><img src="../../../res/icons/eye.png" alt="View" /></a></td>(\\s+)<td><a href="Edit\\?ID=(\\d+)"><img src="../../../res/icons/edit.png" alt="Edit" /></a></td>(\\s+)<td><a href="Delete\\?ID=(\\d+)"><img src="../../../res/icons/delete.png" alt="Delete" /></a></td>(\\s+)</tr>#';
    $replace = '<td>[Separator]</td>${1}<td></td>${1}<td></td>${1}<td><a href="Delete_Separator?ID=${2}&amp;xsrf_token=' . $_SESSION['xsrf_token'] . '"><img src="../../../res/icons/delete.png" alt="Delete" /></a></td>${1}</tr>';
    $table = preg_replace($search, $replace, $table);
    // Make Registration uneditable
    $search = '#<td><a href="View\\?ID=-1"><img src="../../../res/icons/eye.png" alt="View" /></a></td>(\\s+)<td><a href="Edit\\?ID=-1"><img src="../../../res/icons/edit.png" alt="Edit" /></a></td>(\\s+)<td><a href="Delete\\?ID=-1"><img src="../../../res/icons/delete.png" alt="Delete" /></a></td>(\\s+)</tr>#';
    $replace = '<td></td>${1}<td></td>${1}<td></td>${1}</tr>';
    $table = preg_replace($search, $replace, $table);
    echo $table;
}
コード例 #3
0
ファイル: coin_wallets.php プロジェクト: nachatate/synala
 public function get_rows($start = 0)
 {
     // Get rows to display
     $bip32 = new bip32();
     $rows = DB::query("SELECT * FROM coin_wallets WHERE status = 'active' ORDER BY id");
     // Go through rows
     $results = array();
     foreach ($rows as $row) {
         $row['checkbox'] = "<center><input type=\"checkbox\" name=\"wallet_id[]\" value=\"{$row['id']}\"></center>";
         $row['balance'] = $bip32->get_balance($row['id']) . ' BTC';
         if ($row['address_type'] == 'multisig') {
             $row['address_type'] = 'Multisig - ' . $row['sigs_required'] . ' of ' . $row['sigs_total'];
         } else {
             $row['address_type'] = 'Standard';
         }
         array_push($results, $row);
     }
     // Add total
     $total = DB::queryFirstField("SELECT count(*) FROM coin_wallets WHERE status = 'active'");
     if ($total > 1) {
         // Get balance
         $total_balance = DB::queryFirstField("SELECT sum(amount) FROM coin_inputs WHERE is_spent = 0");
         if ($total_balance == '') {
             $total_balance = 0;
         }
         // Set vars
         $vars = array('checkbox' => "&nbsp;", 'id' => "&nbsp;", 'display_name' => '<b>Total</b>', 'address_type' => "&nbsp;", 'balance' => '<b>' . fmoney_coin($total_balance) . ' BTC</b>');
         array_push($results, $vars);
     }
     // Return
     return $results;
 }
コード例 #4
0
ファイル: html_tags.php プロジェクト: nachatate/synala
 public function current_date($attr)
 {
     // Get value
     $value = isset($attr['value']) ? $attr['value'] : DB::queryFirstField("SELECT DATE(now())");
     list($year, $month, $day) = explode("-", $value);
     // Add months
     $options = "<span><select name=\"" . $attr['name'] . "_month\" style=\"width: 120px; float: left;\">";
     for ($x = 1; $x <= 12; $x++) {
         $chk = $x == $month ? 'selected="selected"' : '';
         $options .= "<option value=\"{$x}\" {$chk}>" . date('F', mktime(0, 0, 0, $x + 1, 0, 0));
     }
     $options .= "</select> <select name=\"" . $attr['name'] . "_day\" style=\"width: 60px; float: left;\">";
     // Add days
     for ($x = 1; $x <= 31; $x++) {
         $chk = $x == $day ? 'selected="selected"' : '';
         $options .= "<option value=\"{$x}\" {$chk}>{$x}";
     }
     $options .= "</select> <select name=\"" . $attr['name'] . "_year\" style=\"width: 80px; float: left;\">";
     // Add years
     $start_year = date('Y');
     for ($x = $start_year - 2; $x <= $start_year + 5; $x++) {
         $chk = $x == $year ? 'selected="selected"' : '';
         $options .= "<option value=\"{$x}\" {$chk}>{$x}";
     }
     $options .= "</select>";
     // Return
     return $options;
 }
コード例 #5
0
ファイル: orders.php プロジェクト: nachatate/synala
 public function get_rows($start = 0)
 {
     // Initialize
     global $template;
     // Get rows to display
     if ($this->userid > 0) {
         $rows = DB::query("SELECT * FROM orders WHERE userid = %d ORDER BY date_added DESC LIMIT {$start},{$this->rows_per_page}", $this->userid);
     } else {
         $rows = DB::query("SELECT * FROM orders WHERE status = %s ORDER BY date_added DESC LIMIT {$start},{$this->rows_per_page}", $this->status);
     }
     // Go through rows
     $results = array();
     foreach ($rows as $row) {
         $row['checkbox'] = "<center><input type=\"checkbox\" name=\"order_id[]\" value=\"{$row['id']}\"></center>";
         $row['date_added'] = fdate($row['date_added'], true);
         $row['product'] = DB::queryFirstField("SELECT display_name FROM products WHERE id = %d", $row['product_id']);
         $row['amount'] = fmoney_coin($row['amount_btc']) . ' BTC (' . fmoney($row['amount']) . ')';
         $row['status'] = ucwords($row['status']);
         // Get manage URL
         $url = $template->theme == 'public' ? SITE_URI . "/account/view_order?order_id={$row['id']}" : SITE_URI . "/admin/financial/orders_manage?order_id={$row['id']}";
         $row['manage'] = "<center><a href=\"{$url}\" class=\"btn btn-primary btn-xs\">Manage</a></center>";
         $username = get_user($row['userid']);
         $row['username'] = "******"" . SITE_URI . "/admin/user/manage2?username={$username}\">{$username}</a>";
         array_push($results, $row);
     }
     // Return
     return $results;
 }
コード例 #6
0
ファイル: commons.php プロジェクト: azizjonm/OpenCTF-1
function generateDeskAnokhaID()
{
    $lastID = DB::queryFirstField("SELECT dvalue FROM datastore WHERE dkey = 'desk_anokha_id_count' LIMIT 1");
    $number = str_pad(9999 - intval($lastID), 4, '0', STR_PAD_LEFT);
    DB::query("UPDATE datastore SET dvalue = %s WHERE dkey = 'desk_anokha_id_count'", intval($lastID) + 1);
    return "AD15" . $number;
}
コード例 #7
0
ファイル: coin_addresses.php プロジェクト: nachatate/synala
 public function get_rows($start = 0)
 {
     // Get rows to display
     if (isset($_POST['search']) && $_POST['search'] != '') {
         $rows = DB::query("SELECT * FROM coin_addresses WHERE address LIKE %ss ORDER BY date_added DESC LIMIT {$start},{$this->rows_per_page}", $_POST['search']);
     } elseif ($this->userid > 0) {
         $rows = DB::query("SELECT * FROM coin_addresses WHERE userid = %d ORDER BY date_added DESC LIMIT {$start},{$this->rows_per_page}");
     } else {
         $rows = DB::query("SELECT * FROM coin_addresses ORDER BY date_added DESC LIMIT {$start},{$this->rows_per_page}");
     }
     // Go through rows
     $results = array();
     foreach ($rows as $row) {
         // Get balance
         $balance = DB::queryFirstField("SELECT sum(amount) FROM coin_inputs WHERE is_spent = 0 AND address = %s", $row['address']);
         $row['balance'] = fmoney_coin($balance);
         // Set variables
         $row['checkbox'] = "<center><input type=\"checkbox\" name=\"input_id[]\" value=\"{$row['id']}\"></center>";
         $row['address'] = "<a href=\"" . SITE_URI . "/admin/financial/addresses_view?address={$row['address']}\">{$row['address']}</a>";
         $row['date_added'] = fdate($row['date_added'], true);
         $row['received'] = fmoney_coin($row['total_input']);
         array_push($results, $row);
     }
     // Return
     return $results;
 }
コード例 #8
0
ファイル: connection.php プロジェクト: mircowidmer/geonews
function printLoggedInUser()
{
    if (isset($_COOKIE['geonews'])) {
        $finds = DB::queryFirstField("SELECT finds FROM user WHERE username = %s", $_COOKIE['geonews']);
        echo $_COOKIE['geonews'] . " ({$finds})";
    } else {
        echo "<i class='fa fa-user'></i> Log in";
    }
}
コード例 #9
0
ファイル: Home.php プロジェクト: lhsmath/lhsmath.org
function find_school($id)
{
    $school_id = DB::queryFirstField('SELECT school FROM teams WHERE team_id=%i AND deleted="0"', $id);
    if (is_null($school_id)) {
        alert('School not found', -1);
        return;
    }
    lmt_location("Backstage/Checkin/School?ID=" . $id);
}
コード例 #10
0
 public function get_total()
 {
     // Get total rows
     $total = DB::queryFirstField("SELECT count(*) FROM coin_unauthorized_sends");
     if ($total == '') {
         $total = 0;
     }
     // Return
     return $total;
 }
コード例 #11
0
ファイル: products.php プロジェクト: nachatate/synala
 public function get_total()
 {
     // Get total rows
     $total = DB::queryFirstField("SELECT count(*) FROM products WHERE is_enabled = %d", $this->is_enabled);
     if ($total == '') {
         $total = 0;
     }
     // Return
     return $total;
 }
コード例 #12
0
ファイル: coin_sends.php プロジェクト: nachatate/synala
 public function get_total()
 {
     // Get total rows
     $total = DB::queryFirstField("SELECT count(*) FROM coin_sends WHERE status = %s", $this->status);
     if ($total == '') {
         $total = 0;
     }
     // Return
     return $total;
 }
コード例 #13
0
ファイル: notifications.php プロジェクト: nachatate/synala
 public function get_total()
 {
     // Get total
     $this->total = DB::queryFirstField("SELECT count(*) FROM notifications");
     if ($this->total == '') {
         $this->total = 0;
     }
     // Return
     return $this->total;
 }
コード例 #14
0
 public function get_total()
 {
     // Get total rows
     $total = DB::queryFirstField("SELECT count(*) FROM coin_overpayments");
     if ($total == '') {
         $total = 0;
     }
     // Return
     return $total;
 }
コード例 #15
0
 public function get_total()
 {
     // Get total
     $this->total = DB::queryFirstField("SELECT count(*) FROM users_custom_fields");
     if ($this->total == '') {
         $this->total = 0;
     }
     // Return
     return $this->total;
 }
コード例 #16
0
ファイル: Signin.php プロジェクト: lhsmath/lhsmath.org
function process_login()
{
    // Validate credentials
    $sid = DB::queryFirstField('SELECT school_id FROM schools WHERE school_id=%i AND access_code=%s LIMIT 1', $_GET['ID'], $_GET['Code']);
    if (!$sid) {
        trigger_error('Incorrect login data', E_USER_ERROR);
    }
    // ** CREDENTIALS ARE VALIDATED AT THIS POINT ** //
    lmt_set_login_data($sid);
    header('Location: Home');
}
コード例 #17
0
ファイル: gl_functions.php プロジェクト: rylsteel/phpledger
function voucher_ref_exists($voucher_ref)
{
    $sql = "SELECT count(*) FROM " . DB_PREFIX . $_SESSION['co_prefix'] . "journal_vouchers \n\t\t\t\tWHERE voucher_ref_no='" . $voucher_ref . "'";
    $journal_voucher_exists = DB::queryFirstField($sql);
    $sql2 = "SELECT count(*) FROM " . DB_PREFIX . $_SESSION['co_prefix'] . "voucher_expense \n\t\t\t\tWHERE voucher_ref_no='" . $voucher_ref . "'";
    $expense_voucher_exists = DB::queryFirstField($sql2);
    if ($journal_voucher_exists == 0 and $expense_voucher_exists == 0) {
        return false;
    } else {
        return true;
    }
}
コード例 #18
0
ファイル: fix_tags_count.php プロジェクト: chibimiku/tsdmtag
function do_base()
{
    //get tags
    $tagsinfo = DB::query('SELECT * FROM ' . tblname_tags);
    $docount = 0;
    foreach ($tagsinfo as $tag) {
        if ($docount % 2000 == 0) {
            echo "Proc... {$docount} \n";
        }
        $num = DB::queryFirstField('SELECT count(*) FROM ' . tblname_index . " WHERE tag_id=" . $tag['id']);
        DB::update(tblname_tags, array('count' => $num), "id=" . $tag['id']);
        ++$docount;
    }
}
コード例 #19
0
 function test_3_transaction_rollback_all()
 {
     DB::$nested_transactions = true;
     DB::query("UPDATE accounts SET age=%i WHERE username=%s", 200, 'Abe');
     $depth = DB::startTransaction();
     $this->assert($depth === 1);
     DB::query("UPDATE accounts SET age=%i WHERE username=%s", 300, 'Abe');
     $depth = DB::startTransaction();
     $this->assert($depth === 2);
     DB::query("UPDATE accounts SET age=%i WHERE username=%s", 400, 'Abe');
     $depth = DB::rollback(true);
     $this->assert($depth === 0);
     $age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
     $this->assert($age == 200);
     DB::$nested_transactions = false;
 }
コード例 #20
0
ファイル: users.php プロジェクト: nachatate/synala
 public function get_total()
 {
     // Get total rows
     if ($this->is_search == 1) {
         $total = DB::queryFirstField("SELECT count(*) FROM users WHERE username LIKE %ss OR email LIKE %ss", $_POST['username'], $_POST['usernme']);
         if ($total == '') {
             $total = 0;
         }
     } else {
         $total = DB::queryFirstField("SELECT count(*) FROM users");
         if ($total == '') {
             $total = 0;
         }
     }
     // Return
     return $total;
 }
コード例 #21
0
ファイル: 2fa.php プロジェクト: nachatate/synala
 public function __construct($parts = array())
 {
     // Check for row
     if (!($row = DB::queryFirstRow("SELECT * FROM auth_sessions WHERE 2fa_hash = %s AND 2fa_status = 0", $parts[1]))) {
         echo "Invalid 2FA request.  Please check the URL, and try again.";
         exit(0);
     }
     // Update
     DB::query("UPDATE auth_sessions SET 2fa_hash = '', 2fa_status = 1 WHERE id = %d", $row['id']);
     // Redirect, as needed
     $group_id = DB::queryFirstField("SELECT group_id FROM users WHERE id = %d", $row['userid']);
     if ($group_id == 1) {
         header("Location: " . SITE_URI . "/admin/");
     } else {
         header("Location: " . SITE_URI);
     }
     // Exit
     exit(0);
 }
コード例 #22
0
ファイル: Home.php プロジェクト: lhsmath/lhsmath.org
function show_logged_in_page()
{
    //If there's no such school, we're in the middle of adding it or something.
    if (DB::queryFirstField('SELECT COUNT(*) FROM teams WHERE school=%i', $_SESSION['LMT_user_id']) == 0) {
        header('Location: Team?Add');
        die;
    }
    lmt_page_header('Team Registration');
    $lmt_year = htmlentities(map_value('year'));
    $school_name = htmlentities($_SESSION['LMT_school_name']);
    $table = lmt_db_table('SELECT team_id, name, school, (SELECT COUNT(*) FROM individuals WHERE individuals.team = teams.team_id AND individuals.deleted="0")' . ' AS size FROM teams WHERE school="' . mysqli_real_escape_string(DB::get(), $_SESSION['LMT_user_id']) . '" AND deleted="0" ORDER BY size, name', array('name' => 'Name', 'size' => 'Size'), array('<img src="../../res/icons/edit.png" alt="Edit" />' => 'Team?Edit={team_id}', '<img src="../../res/icons/delete.png" alt="Delete" />' => 'Team?Delete={team_id}'), 'No Teams', 'contrasting indented');
    echo <<<HEREDOC
      <h1>Team Registration</h1>
      
      <h3 class="smbottom">Teams for {$school_name}</h3>
      <span class="small">&nbsp;<a href="Team?Add">Add a Team</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="Signout">Sign Out</a></span><br /><br />
      {$table}
HEREDOC;
}
コード例 #23
0
 function test_1_transactions()
 {
     DB::$nested_transactions = false;
     DB::query("UPDATE accounts SET age=%i WHERE username=%s", 600, 'Abe');
     $depth = DB::startTransaction();
     $this->assert($depth === 1);
     DB::query("UPDATE accounts SET age=%i WHERE username=%s", 700, 'Abe');
     $depth = DB::startTransaction();
     $this->assert($depth === 1);
     DB::query("UPDATE accounts SET age=%i WHERE username=%s", 800, 'Abe');
     $depth = DB::rollback();
     $this->assert($depth === 0);
     $age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
     $this->assert($age == 700);
     $depth = DB::rollback();
     $this->assert($depth === 0);
     $age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
     $this->assert($age == 700);
 }
コード例 #24
0
ファイル: alerts.php プロジェクト: nachatate/synala
 public function get_rows($start = 0)
 {
     // Initailize
     global $template;
     // Get rows to display
     $rows = DB::query("SELECT * FROM alerts WHERE type = %s AND userid = %d ORDER BY date_added DESC LIMIT {$start},{$this->rows_per_page}", $this->type, $GLOBALS['userid']);
     // Go through rows
     $results = array();
     foreach ($rows as $row) {
         // Get URLs
         $addr_url = $template->theme == 'public' ? SITE_URI . "/account/address?address={$row['address']}" : SITE_URI . "/admin/financial/addresses_view?address={$row['address']}";
         // Set variables
         $row['checkbox'] = "<center><input type=\"checkbox\" name=\"alert_id[]\" value=\"{$row['id']}\"></center>";
         $row['date_added'] = fdate($row['date_added'], true);
         // Type specific variables
         if ($this->type == 'new_user') {
             $user_row = DB::queryFirstRow("SELECT * FROM users WHERE id = %d", $row['reference_id']);
             $row['username'] = $user_row['username'];
             $row['email'] = $user_row['email'];
         } else {
             $input = DB::queryFirstRow("SELECT * FROM coin_inputs WHERE id = %d", $row['reference_id']);
             $row['username'] = get_user($input['userid']);
             $row['amount'] = fmoney_coin($input['amount']) . ' BTC';
             $row['viewtx'] = "<center><a href=\"" . SITE_URI . "/admin/financial/tx?txid=" . $input['txid'] . "\" class=\"btn btn-primary btn-xs\">View Tx</a></center>";
             if ($this->type == 'product_purchase') {
                 $row['product'] = DB::queryFirstField("SELECT display_name FROM products WHERE id = %d", $input['product_id']);
                 $row['manage'] = "<center><a href=\"" . SITE_URI . "/admin/financial/orders_manage?order_id=" . $input['order_id'] . "\" class=\"btn btn-primary btn-xs\">Manage</a></center>";
             } elseif ($this->type == 'invoice_paid') {
                 $irow = DB::queryFirstRow("SELECT * FROM invoices WHERE id = %d", $input['invoice_id']);
                 $row['invoice'] = "ID# {$input['invoice_id']} (added: " . fdate($invoice['date_added']) . ")";
                 $row['manage'] = "<center><a href=\"" . SITE_URI . "/admin/financial/invoices_manage?invoice_id=" . $input['invoice_id'] . "\" class=\"btn btn-primary btn-xs\">Manage</a></center>";
             }
         }
         //$row['address'] = "<a href=\"$addr_url\">$row[address]</a>";
         $row['username'] = "******"" . SITE_URI . "/admin/user/manage2?username={$row['username']}\">{$row['username']}</a>";
         array_push($results, $row);
     }
     // Return
     return $results;
 }
コード例 #25
0
ファイル: Show_Page.php プロジェクト: lhsmath/lhsmath.org
function show_page()
{
    $name = str_replace('_', ' ', $_GET['Name']);
    //Why?
    if ($name == "Register") {
        header("Location: Registration");
        die;
    }
    $content = DB::queryFirstField('SELECT content FROM pages WHERE name=%s', $name);
    if (!$content) {
        header("HTTP/1.1 404 Not Found");
        require 'Error.php';
        die;
    }
    $name = htmlentities($name);
    $content = "      " . str_replace("\n", "\n      ", $content);
    global $LMT_EMAIL;
    $content = str_replace('{CONTACT_LINK}', email_obfuscate($LMT_EMAIL, null, '<span class="b">Please email us at:</span> '), $content);
    global $use_rel_external_script;
    $use_rel_external_script = true;
    lmt_page_header($name);
    echo $content;
}
コード例 #26
0
ファイル: Verify_Email.php プロジェクト: lhsmath/lhsmath.org
function show_page()
{
    // Fetch email
    $email = DB::queryFirstField('SELECT email FROM users WHERE id=%i', $_SESSION['user_id']);
    // the message that's shown after you click the button
    $resent_text = '';
    if (isset($_SESSION['ACCOUNT_resent_confirmation_email'])) {
        $resent_text = "\n        <div class=\"alert\">The verification email has just been re-sent</div><br /><br />\n        \n        ";
        unset($_SESSION['ACCOUNT_resent_confirmation_email']);
    }
    page_header('Verify Email');
    echo <<<HEREDOC
        <h1>Verify Your Email Address</h1>
        {$resent_text}
        To complete registration, you must verify your email address. A message has been sent to
        <span class="b">{$email}</span>. Please click on the link in the message to continue.<br />
        <br />
        <br />
        <form method="post" action="{$_SERVER['REQUEST_URI']}">
          <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}"/>
          <input type="submit" name="do_resend_verification_email" value="Resend the Verification Email"/>
        </form>
HEREDOC;
}
コード例 #27
0
ファイル: auth.php プロジェクト: nachatate/synala
 public function check_login($type = 'public', $login_required = false)
 {
     // Initialize
     global $config;
     // Expire needed sessions
     DB::query("DELETE FROM auth_sessions WHERE last_active < %d", time() - $config['session_expire_mins'] * 60);
     // Check for session
     $cookie_name = COOKIE_NAME . 'auth_hash';
     if (isset($_COOKIE[$cookie_name]) && ($row = DB::queryFirstRow("SELECT * FROM auth_sessions WHERE auth_hash = %s", hash('sha512', $_COOKIE[$cookie_name])))) {
         // Check 2FA
         if ($row['2fa_status'] == 0) {
             $group_id = DB::queryFirstField("SELECT group_id FROM users WHERE id = %d", $row['userid']);
             $route = $group_id == 1 ? 'admin/2fa' : '2fa';
             $template = new template($route);
             echo $template->parse();
             exit(0);
         }
         // Update session
         DB::query("UPDATE auth_sessions SET last_active = %d WHERE id = %d", time(), $row['id']);
         return $row['userid'];
     } elseif ((isset($_POST['submit']) && $_POST['submit'] == tr('Login Now') || preg_match("/login\$/", $_GET['route'])) && $_SERVER['REQUEST_METHOD'] == 'POST') {
         return $this->login($type);
     } elseif ($login_required === true) {
         if ($type == 'admin') {
             $template = new template('admin/login', 'admin');
             echo $template->parse();
             exit(0);
         } else {
             $template = new template('login');
             echo $template->parse();
             exit(0);
         }
     }
     // Return
     return false;
 }
コード例 #28
0
function attempt_login_user($user_name, $password, $company_id, $superadmin)
{
    // build a check here to put appropriate fields in the session
    $is_logged = DB::queryFirstRow("SELECT * FROM " . DB_PREFIX . "test_users u WHERE (u.`user_name`='" . $user_name . "' OR u.`user_email`='" . $user_name . "') AND u.`password`='" . $password . "' AND u.`company_id`='" . $company_id . "' AND u.`user_status`='active'");
    if ($is_logged) {
        $company = get_company_details($company_id);
        $_SESSION['is_logged'] = 1;
        $_SESSION['company_id'] = $company_id;
        $_SESSION['user_id'] = $is_logged['user_id'];
        $_SESSION['user_name'] = $is_logged['user_name'];
        $_SESSION['role_id'] = 1;
        $_SESSION['co_prefix'] = get_db_co_prefix($company_id);
        $_SESSION['company_name'] = $company['company_name'];
        $_SESSION['default_expense_account'] = 1;
        // get default Expense Account Company
        return true;
    } else {
        $prefix = DB_PREFIX;
        $is_company_admin = DB::queryFirstField("SELECT COUNT(*) FROM " . $prefix . "companies WHERE super_admin_user = '******' AND super_admin_password = '******' ");
        if ($is_company_admin) {
            $company = get_company_details($company_id);
            $_SESSION['is_logged'] = 1;
            $_SESSION['company_id'] = $company_id;
            $_SESSION['user_id'] = 1;
            $_SESSION['user_name'] = $user_name;
            $_SESSION['role_id'] = 1;
            $_SESSION['co_prefix'] = get_db_co_prefix($company_id);
            $_SESSION['company_name'] = $company['company_name'];
            $_SESSION['default_expense_account'] = 1;
            // get default Expense Account Company
            return true;
        } else {
            return '<h4 style="color:red;">Invalid User Name or Password</h4>';
        }
    }
}
コード例 #29
0
ファイル: add_coa_3.php プロジェクト: rylsteel/phpledger
if (isset($_POST['parent_account'])) {
    $parent_account_id = $_POST['parent_account'];
}
if (isset($_POST['account_type'])) {
    $account_type = $_POST['account_type'];
}
$current_level = get_account_level($parent_account_id) + 1;
$company_max_account_levels = DB::queryFirstField("SELECT coa_levels FROM " . DB_PREFIX . "companies where company_id = " . $_SESSION['company_id']);
$field = "coa_level_" . $current_level . "_length";
$current_level_length = DB::queryFirstField("SELECT " . $field . " FROM " . DB_PREFIX . "companies where company_id = " . $_SESSION['company_id']);
$parent_code = DB::queryFirstField("SELECT account_code FROM " . DB_PREFIX . $_SESSION['co_prefix'] . "coa WHERE account_id =" . $parent_account_id);
$company_max_coa_length = 0;
$i = 1;
while ($i <= $company_max_account_levels) {
    $col = "coa_level_" . $i . "_length";
    $result = DB::queryFirstField("SELECT " . $col . " FROM " . DB_PREFIX . "companies where company_id = " . $_SESSION['company_id']);
    $company_max_coa_length += $result;
    $i++;
}
echo $company_max_coa_length;
//echo $parent_code;
$parent_level_length = strlen($parent_code);
$remaining_length = $company_max_coa_length - $parent_level_length;
echo $remaining_length;
print_r($_POST);
// we need to get company's Level data here
if ($account_type == "consolidate_only") {
    // TODO:if current_level >= company_max_levels then you cannot create consolidate only account. user has to go back and select activity_account type
    if ($parent_account_id == 0) {
        $mask = "";
        //we are defining a level 1 account
コード例 #30
0
ファイル: processFile.php プロジェクト: mircowidmer/geonews
    $terrain = (int) $cache->terrain;
    $country = (string) $cache->country;
    $url = (string) $wpt->url;
    foreach ($cache->logs->log as $log) {
        $gc = (string) $wpt->name;
        $name = (string) $cache->name;
        $username = (string) $log->finder;
        $logtext = (string) $log->text;
        $logType = (string) $log->type;
        $logDate = substr((string) $log->date, 0, 10);
        if ($inserted == 0) {
            DB::insertIgnore('user', array('username' => $username));
            $inserted = 1;
            $userId = DB::queryFirstField("SELECT id FROM user WHERE username=%s LIMIT 1", $username);
            $logIds = DB::queryFirstColumn("SELECT log.id FROM image, log WHERE image.log = log.id AND log.user = %i", $userId);
            foreach ($logIds as $logId) {
                DB::delete('image', "log=%i", $logId);
            }
            DB::delete('log', "user=%i", $userId);
        }
        DB::insertUpdate('geocache', array('gc' => $gc, 'name' => $name, 'type' => $typeId, 'lat' => $lat, 'lon' => $lon, 'difficulty' => $difficulty, 'terrain' => $terrain, 'country' => $country, 'url' => $url));
        $geocacheId = DB::queryFirstField("SELECT id FROM geocache WHERE gc = %s LIMIT 1", $gc);
        $logTypeId = DB::queryFirstField("SELECT id FROM logtype WHERE type = %s LIMIT 1", $logType);
        DB::insert('log', array('user' => $userId, 'geocache' => $geocacheId, 'created' => $logDate, 'type' => $logTypeId, 'log' => $logtext));
    }
    $finds++;
}
DB::update('user', array('finds' => $finds), "username=%s", $username);
//  echo "</div>";
unlink(realpath(dirname(__FILE__)) . "/pocketquery.gpx");
Header('Location: map.php');