Jump to content

Andy_Kemp

Members
  • Content Count

    21
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Andy_Kemp

  • Rank
    Member
  1. In Wordpress there is this code <?php $user_info = get_userdata(1); echo 'Username: ' . $user_info->user_login . "\n"; echo 'User roles: ' . implode(', ', $user_info->roles) . "\n"; echo 'User ID: ' . $user_info->ID . "\n"; ?> My question is how they get this? $user_info->user_login My code class Config { private $db; public function __construct($db) { $this->db = $db; } public function get() { $query = 'SELECT * FROM config'; $select = $this->db->query($query); $config = array(); while ($row = $
  2. <?php declare(strict_types = 1); function test(string $username, int $age, float $price) : array { return array('Username' => $username, 'Age' => $age, 'Price' => $price); } $_get = array( 'username' => '', 'age' => '', 'price' => '', ); $_get = array_merge($_get, $_GET); print_r(test($_get['username'], $_get['age'], $_get['price'])); I am new with php7 So when i looked those examples i see test('test_username', 20, 20.01) but int and float are absolutely useless with $_POST, $_GET, Its always error. WITH int - must be of the type integer, string
  3. Whats the best method to determine who can access to admin panel? <?php if (!defined('Test_script')) { exit('You don\'t have right permission to access this file directly.'); } if (!is_logged_in($ui)) { redirect_to('../index.php?do=login'); } # By user role if (!user_has_role($db, $ui['id'], return_role_id($db, 'user'))) { redirect_to('../index.php?do=home'); } # Or by permission if (!user_has_permission($db, $ui['id'], return_permission_id($db, 'admin_access'))) { redirect_to('../index.php?do=home'); } /* ............................... */ ?>
  4. Added role_id to user table + -- + -------- + --------- + --------------- + ------- + ---------- + ----------- + + ------- + -------- + | id | username | password | email | last_ip | last_login | last_active | ......... | role_id | status | + -- + -------- + --------- + --------------- + ------- + ---------- + ----------- + + ------- + -------- + | 1 | user_1 | long_hash | email@email.com | ::1 | 0123456789 | 0123456789 | ......... | 1 | active | + -- + -------- + --------- + --------------- + ------- + ---------- + ----------- + + -
  5. Admin panel login. Am I doing it right? $query = 'SELECT a.id, a.username, b.password AS admin_password, b.status AS admin_status FROM user AS a INNER JOIN admin AS b ON a.id = b.user_id WHERE a.username = :username'; Table name: user status - active, inactive, un-verified, suspended + -- + -------- + --------- + --------------- + ------- + ---------- + ----------- + + -------- + | id | username | password | email | last_ip | last_login | last_active | ......... | status | + -- + -------- + --------- + --------------- + ------- + ---------- + -----------
  6. Its fixed now. I dont know why but i need to recreate those files. require ROOT_DIR . 'includes/language_changer/a_panel/index.php'; This index.php require ROOT_DIR . 'includes/template_changer/a_panel/index.php'; This index.php require_once ROOT_DIR . 'languages/a_panel/' . $language . '/main/index.php'; This index.php
  7. And blank line at the top of the page.
  8. Dont know what do do with this issue. Inside php <?php $smarty->display('test.tpl'); ?> Output When i put test.tpl content to test.html and open it to firefox. Then everything is ok.
  9. Where should i set setcookie() to remember what language is selected? includes/configs/a_panel/index.php <?php /* ---------------------------------- */ require ROOT_DIR . 'includes/language_changer/a_panel/index.php'; if (is_file(ROOT_DIR . 'languages/a_panel/'.Language::get_language($db, $config).'/main/index.php') && file_exists(ROOT_DIR . 'languages/a_panel/'.Language::get_language($db, $config).'/main/index.php')) { $language = Language::get_language($db, $config); $charset = Language::get_charset($db, $language); require_once(ROOT_DIR . 'languages/a_panel/'.$
  10. How to automatically detect user timezone name? Like Europe/Stockholm How to automatically detect user locale? Like sv_SE Or its easier to let user to select their timezone and locale?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.