How to use phoromatic_users class

Best Phoronix-test-suite code snippet using phoromatic_users

phoromatic_users.php

Source:phoromatic_users.php Github

copy

Full Screen

...14 GNU General Public License for more details.15 You should have received a copy of the GNU General Public License16 along with this program. If not, see <http://www.gnu.org/licenses/>.17*/18class phoromatic_users implements pts_webui_interface19{20 public static function page_title()21 {22 return 'Account Administrator';23 }24 public static function page_header()25 {26 return null;27 }28 public static function preload($PAGE)29 {30 return true;31 }32 public static function render_page_process($PATH)33 {34 if($_SESSION['AdminLevel'] > 3)35 {36 echo phoromatic_error_page('Unauthorized Access', 'You aren\'t an account administrator!');37 return;38 }39 if(isset($_POST['group_name']))40 {41 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_accounts SET GroupName = :group_name WHERE AccountID = :account_id');42 $stmt->bindValue(':group_name', $_POST['group_name']);43 $stmt->bindValue(':account_id', $_SESSION['AccountID']);44 $result = $stmt->execute();45 }46 if(isset($_POST['username']) && isset($_POST['password']) && isset($_POST['confirm_password']) && isset($_POST['email']))47 {48 // REGISTER NEW USER49 if(strlen($_POST['username']) < 4 || strpos($_POST['username'], ' ') !== false)50 {51 phoromatic_error_page('Oops!', 'Please go back and ensure the supplied username is at least four characters long and contains no spaces.');52 return false;53 }54 if(in_array(strtolower($_POST['username']), array('admin', 'administrator')))55 {56 phoromatic_error_page('Oops!', $_POST['username'] . ' is a reserved and common username that may be used for other purposes, please make a different selection.');57 return false;58 }59 if(strlen($_POST['password']) < 6)60 {61 phoromatic_error_page('Oops!', 'Please go back and ensure the supplied password is at least six characters long.');62 return false;63 }64 if($_POST['password'] != $_POST['confirm_password'])65 {66 phoromatic_error_page('Oops!', 'Please go back and ensure the supplied password matches the password confirmation.');67 return false;68 }69 if($_POST['email'] == null || filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) == false)70 {71 phoromatic_error_page('Oops!', 'Please enter a valid email address.');72 return false;73 }74 $valid_user_name_chars = '1234567890-_.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';75 for($i = 0; $i < count($_POST['username']); $i++)76 {77 if(strpos($valid_user_name_chars, substr($_POST['username'], $i, 1)) === false)78 {79 phoromatic_error_page('Oops!', 'Please go back and ensure a valid user-name. The character <em>' . substr($_POST['username'], $i, 1) . '</em> is not allowed.');80 return false;81 }82 }83 $matching_users = phoromatic_server::$db->querySingle('SELECT UserName FROM phoromatic_users WHERE UserName = \'' . SQLite3::escapeString($_POST['username']) . '\'');84 if(!empty($matching_users))85 {86 phoromatic_error_page('Oops!', 'The user-name is already taken.');87 return false;88 }89 if(!isset($_POST['admin_level']) || $_POST['admin_level'] == 1 || !is_numeric($_POST['admin_level']))90 {91 phoromatic_error_page('Oops!', 'Invalid administration level.');92 return false;93 }94 $stmt = phoromatic_server::$db->prepare('SELECT Salt FROM phoromatic_accounts WHERE AccountID = :account_id');95 $stmt->bindValue(':account_id', $_SESSION['AccountID']);96 $result = $stmt->execute();97 $row = $result->fetchArray();98 $account_salt = $row['Salt'];99 $user_id = pts_strings::random_characters(4, true);100 $salted_password = hash('sha256', $account_salt . $_POST['password']);101 pts_logger::add_to_log($_SERVER['REMOTE_ADDR'] . ' created a new account: ' . $user_id . ' - ' . $_SESSION['AccountID']);102 $stmt = phoromatic_server::$db->prepare('INSERT INTO phoromatic_users (UserID, AccountID, UserName, Email, Password, CreatedOn, LastIP, AdminLevel) VALUES (:user_id, :account_id, :user_name, :email, :password, :current_time, :last_ip, :admin_level)');103 $stmt->bindValue(':user_id', $user_id);104 $stmt->bindValue(':account_id', $_SESSION['AccountID']);105 $stmt->bindValue(':user_name', $_POST['username']);106 $stmt->bindValue(':email', $_POST['email']);107 $stmt->bindValue(':password', $salted_password);108 $stmt->bindValue(':last_ip', $_SERVER['REMOTE_ADDR']);109 $stmt->bindValue(':current_time', phoromatic_server::current_time());110 $stmt->bindValue(':admin_level', $_POST['admin_level']);111 $result = $stmt->execute();112 $stmt = phoromatic_server::$db->prepare('INSERT INTO phoromatic_user_settings (UserID, AccountID) VALUES (:user_id, :account_id)');113 $stmt->bindValue(':user_id', $user_id);114 $stmt->bindValue(':account_id', $_SESSION['AccountID']);115 $result = $stmt->execute();116 phoromatic_add_activity_stream_event('users', $_POST['username'], 'added');117 }118 if($_SESSION['AdminLevel'] == 1 && isset($_POST['update_user_levels']))119 {120 foreach(explode(',', $_POST['update_user_levels']) as $user_id)121 {122 if(isset($_POST['admin_level_' . $user_id]) && is_numeric($_POST['admin_level_' . $user_id]))123 {124 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_users SET AdminLevel = :admin_level WHERE AccountID = :account_id AND UserID = :user_id');125 $stmt->bindValue(':admin_level', $_POST['admin_level_' . $user_id]);126 $stmt->bindValue(':user_id', $user_id);127 $stmt->bindValue(':account_id', $_SESSION['AccountID']);128 $result = $stmt->execute();129 }130 }131 }132 $main = '<h2>Users</h2>133 <p>Users associated with this account. Phoromatic users can be one of several tiers with varying privileges:</p>134 <ol>135 <li><strong>Group Administrator:</strong> The user with full control over the account, the one who originally signed up for the Phoromatic account.</li>136 <li><strong>Administrator:</strong> Additional users created by the group administrator with the same access rights as the group administrator.</li>137 <li><strong>Power Users:</strong> Additional users created by the group administrator with read/write/modify access to all standard Phoromatic functionality, aside from being able to create additional users.</li>138 <li><strong>Viewer:</strong> Additional users created by the group administrator that have access to view data but not to create new schedules, alter system settings, etc.</li>139 </ol>140 <div class="pts_phoromatic_info_box_area">141 <div style="margin: 0 1%;"><form action="' . $_SERVER['REQUEST_URI'] . '" name="edit_user" id="edit_user" method="post">142 <ul>143 <li><h1>All Users</h1></li>';144 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_users WHERE AccountID = :account_id ORDER BY UserName ASC');145 $stmt->bindValue(':account_id', $_SESSION['AccountID']);146 $result = $stmt->execute();147 $row = $result->fetchArray();148 $user_ids = array();149 do150 {151 switch($row['AdminLevel'])152 {153 case 1:154 $level = 'Group Administrator';155 break;156 case 2:157 $level = 'Administrator';158 break;...

Full Screen

Full Screen

phoromatic_admin.php

Source:phoromatic_admin.php Github

copy

Full Screen

...37 }38 $main = null;39 if(isset($_POST['disable_user']))40 {41 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_users SET AdminLevel = (AdminLevel * -1) WHERE UserName = :user_name');42 $stmt->bindValue(':user_name', $_POST['disable_user']);43 $result = $stmt->execute();44 $main .= '<h2>Disabled Account: ' . $_POST['disable_user'] . '</h2>';45 }46 else if(isset($_POST['change_user_password']))47 {48 $account_salt = phoromatic_server::$db->querySingle('SELECT Salt FROM phoromatic_accounts WHERE AccountID = (SELECT AccountID FROM phoromatic_users WHERE UserName = \'' . $_POST['change_user_password'] . '\')');49 if($account_salt != null)50 {51 if(strlen($_POST['new_user_password']) < 6)52 {53 phoromatic_error_page('Oops!', 'Please go back and ensure the supplied password is at least six characters long.');54 return false;55 }56 $new_salted_password = hash('sha256', $account_salt . $_POST['new_user_password']);57 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_users SET Password = :new_password WHERE UserName = :user_name');58 $stmt->bindValue(':new_password', $new_salted_password);59 $stmt->bindValue(':user_name', $_POST['change_user_password']);60 $result = $stmt->execute();61 $main .= '<h2>Updated Password For Account: ' . $_POST['change_user_password'] . '</h2>';62 }63 }64 else if(isset($_POST['register_username']) && isset($_POST['register_password']) && isset($_POST['register_password_confirm']) && isset($_POST['register_email']))65 {66 $new_account = create_new_phoromatic_account($_POST['register_username'], $_POST['register_password'], $_POST['register_password_confirm'], $_POST['register_email'], (isset($_POST['seed_accountid']) ? $_POST['seed_accountid'] : null));67 }68 else if(isset($_POST['email_all_subject']) && isset($_POST['email_all_message']) && !empty($_POST['email_all_message']))69 {70 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_users ORDER BY UserName ASC');71 $result = $stmt->execute();72 while($row = $result->fetchArray())73 {74 $user = $row['UserName'];75 $email = $row['email'];76 phoromatic_server::send_email($email, $_POST['email_all_subject'], $_POST['email_all_reply_to'], $_POST['email_all_message']);77 }78 echo '<h2>Emails sent to all Phoromatic users.</h2>';79 }80 $main .= '<h1>Phoromatic Server Administration</h1>';81 $main .= '<hr /><h2>Server Information</h2>';82 $main .= '<p><strong>HTTP Server Port:</strong> ' . getenv('PTS_WEB_PORT') . '<br /><strong>WebSocket Server Port:</strong> ' . getenv('PTS_WEBSOCKET_PORT') . '<br /><strong>Phoromatic Server Path:</strong> ' . phoromatic_server::phoromatic_path() . '<br /><strong>Configuration File:</strong>: ' . pts_config::get_config_file_location() . '</p>';83 $main .= '<hr /><h2>Statistics</h2>';84 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(Title) AS SystemCount FROM phoromatic_systems WHERE State >= 0');85 $result = $stmt->execute();86 $row = $result->fetchArray();87 $stats['Total System Count'] = $row['SystemCount'];88 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(Title) AS ScheduleCount FROM phoromatic_schedules WHERE State >= 1');89 $result = $stmt->execute();90 $row = $result->fetchArray();91 $stats['Total Schedule Count'] = $row['ScheduleCount'];92 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(UploadID) AS ResultCount FROM phoromatic_results');93 $result = $stmt->execute();94 $row = $result->fetchArray();95 $stats['Total Result Count'] = $row['ResultCount'];96 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(ActivityTime) AS ActivityCount FROM phoromatic_activity_stream');97 $stmt->bindValue(':today_date', date('Y-m-d') . '%');98 $result = $stmt->execute();99 $row = $result->fetchArray();100 $stats['Total Activity Count'] = $row['ActivityCount'];101 $main .= '<p>';102 foreach($stats as $what => $c)103 $main .= '<strong>' . $what . ':</strong> ' . $c . '<br />';104 $main .= '<hr /><h2>Account Topology</h2>';105 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_users ORDER BY AccountID,AdminLevel ASC');106 $result = $stmt->execute();107 $plevel = -1;108 $user_list = array();109 while($row = $result->fetchArray())110 {111 switch($row['AdminLevel'])112 {113 case 1:114 $level = 'Group Administrator';115 $offset = null;116 break;117 case 2:118 $level = 'Administrator';119 $offset = str_repeat('-', 10);...

Full Screen

Full Screen

phoromatic_users

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic_users.php');2require_once('phoromatic_accounts.php');3require_once('phoromatic_systems.php');4require_once('phoromatic_results.php');5require_once('phoromatic_schedules.php');6require_once('phoromatic_server.php');7require_once('phoromatic_settings.php');8require_once('phoromatic_websocket.php');9require_once('phoromatic_websocket_server.php');10require_once('phoromatic_websocket_client.php');11require_once('phoromatic_websocket_server_client.php');12require_once('phoromatic_websocket_server_client_interface.php');13require_once('phoromatic_websocket_server_client_interface.php');14require_once('phoromatic_websocket_server_client_interface.php');15require_once('phoromatic_websocket_server_client_interface.php');16require_once('phoromatic_websocket_server_client_interface.php');17require_once('phoromatic_websocket_server_client_interface.php');

Full Screen

Full Screen

phoromatic_users

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/phoromatic_users.php');2$phoromatic_users = new phoromatic_users;3require_once('pts-core/phoromatic_server.php');4$phoromatic_server = new phoromatic_server;5require_once('pts-core/phoromatic_account.php');6$phoromatic_account = new phoromatic_account;7require_once('pts-core/phoromatic_systems.php');8$phoromatic_systems = new phoromatic_systems;9require_once('pts-core/phoromatic_results.php');10$phoromatic_results = new phoromatic_results;11require_once('pts-core/phoromatic_schedules.php');12$phoromatic_schedules = new phoromatic_schedules;13require_once('pts-core/phoromatic_upload.php');14$phoromatic_upload = new phoromatic_upload;15require_once('pts-core/phoromatic_settings.php');16$phoromatic_settings = new phoromatic_settings;17require_once('pts-core/phoromatic_webui.php');18$phoromatic_webui = new phoromatic_webui;19require_once('pts-core/phoromatic_results_viewer.php');20$phoromatic_results_viewer = new phoromatic_results_viewer;21require_once('pts-core/phoromatic_account_viewer.php');22$phoromatic_account_viewer = new phoromatic_account_viewer;23require_once('pts-core/phoromatic_systems_viewer.php');24$phoromatic_systems_viewer = new phoromatic_systems_viewer;

Full Screen

Full Screen

phoromatic_users

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic_users.php');2require_once('phoromatic_server.php');3require_once('phoromatic_systems.php');4require_once('phoromatic_account.php');5require_once('phoromatic_results.php');6require_once('phoromatic_schedules.php');7require_once('phoromatic_schedules.php');8require_once('phoromatic_schedule.php');9require_once('phoromatic_test_profile.php');10require_once('phoromatic_test_suite.php');11require_once('phoromatic_test_profile.php');12require_once('phoromatic_test_result.php');13require_once('pho

Full Screen

Full Screen

phoromatic_users

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic_users.php');2$phoromatic_users = new phoromatic_users();3if($phoromatic_users->is_logged_in() == false)4{5 header('Location: login.php');6 exit;7}8$user_id = $phoromatic_users->user_id();9$user_name = $phoromatic_users->user_name();10$user_email = $phoromatic_users->user_email();11$user_password = $phoromatic_users->user_password();12$user_status = $phoromatic_users->user_status();13$user_type = $phoromatic_users->user_type();14$user_created_date = $phoromatic_users->user_created_date();15echo 'user id: '.$user_id.'<br/>';16echo 'user name: '.$user_name.'<br/>';17echo 'user email: '.$user_email.'<br/>';18echo 'user password: '.$user_password.'<br/>';19echo 'user status: '.$user_status.'<br/>';20echo 'user type: '.$user_type.'<br/>';21echo 'user created date: '.$user_created_date.'<br/>';22require_once('phoromatic_users.php');23$phoromatic_users = new phoromatic_users();24if($phoromatic_users->is_logged_in() == true)25{26 header('Location: 2.php');27 exit;28}29if(isset($_POST['login']))30{31 $user_email = $_POST['user_email'];32 $user_password = $_POST['user_password'];33 $user_login = $phoromatic_users->login($user_email, $user_password);34 if($user_login == true)35 {36 header('Location: 2.php');37 exit;38 }39 {

Full Screen

Full Screen

phoromatic_users

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/pts-core.php');2require_once('phoromatic_users.php');3$username = $_POST['username'];4$password = $_POST['password'];5$user = new phoromatic_users();6if($user->checkUser($username, $password)){7 $_SESSION['username'] = $username;8 $_SESSION['password'] = $password;9 header('Location: index.php');10}11else{12 header('Location: login.php');13}14require_once('pts-core/pts-core.php');15require_once('phoromatic_users.php');16$user = new phoromatic_users();17$user_info = $user->getUserInfo($_SESSION['username']);18echo 'User Name: '.$user_info['user_name'].'<br />';19echo 'User Email: '.$user_info['user_email'].'<br />';20echo 'User Status: '.$user_info['user_status'].'<br />';21session_start();22session_destroy();23header('Location: login.php');24session_start();25if(isset($_SESSION['username'])){26 header('Location: index.php');27}

Full Screen

Full Screen

phoromatic_users

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/phoromatic_users.php');2if(!phoromatic_user::is_logged_in())3{4 header('Location: login.php');5 exit;6}7 <p>Logged in as <?php echo phoromatic_user::current_user(); ?></p>8require_once('pts-core/phoromatic_users.php');9phoromatic_user::logout();10header('Location: login.php');11exit;12require_once('pts-core/phoromatic_users.php');13if(phoromatic_user::is_logged_in())14{15 header('Location: 2.php');16 exit;17}18 if(isset($_POST['user']) && isset($_POST['pass']))19 {20 if(phoromatic_user::login($_POST['user'], $_POST['pass']))21 {22 header('Location: 2.php');23 exit;24 }

Full Screen

Full Screen

phoromatic_users

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic_users.php');2if(phoromatic_users::is_valid_user($_POST['username'], $_POST['password']))3{4 $_SESSION['username'] = $_POST['username'];5 header('Location: home.php');6}7{8 header('Location: index.php');9}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in phoromatic_users

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful