How to use phoromatic_path method of phoromatic_server class

Best Phoronix-test-suite code snippet using phoromatic_server.phoromatic_path

phoromatic_server.php

Source:phoromatic_server.php Github

copy

Full Screen

...30 return -1;31 $result = $result->fetchArray();32 return isset($result['user_version']) && is_numeric($result['user_version']) ? $result['user_version'] : 0;33 }34 public static function phoromatic_path()35 {36 $PHOROMATIC_PATH = pts_strings::parse_for_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Server/PhoromaticStorage', ''));37 if(empty($PHOROMATIC_PATH) || ((is_dir($PHOROMATIC_PATH) && !is_writable($PHOROMATIC_PATH)) || !is_writable(dirname($PHOROMATIC_PATH))))38 {39 $PHOROMATIC_PATH = PTS_USER_PATH . 'phoromatic/';40 }41 pts_file_io::mkdir($PHOROMATIC_PATH);42 return $PHOROMATIC_PATH;43 }44 public static function find_download_cache()45 {46 if(is_file(PTS_DOWNLOAD_CACHE_PATH . 'pts-download-cache.json'))47 {48 $dc_file = PTS_DOWNLOAD_CACHE_PATH . 'pts-download-cache.json';49 }50 else if(is_file('/var/cache/phoronix-test-suite/download-cache/pts-download-cache.json'))51 {52 $dc_file = '/var/cache/phoronix-test-suite/download-cache/pts-download-cache.json';53 }54 else if(is_file(PTS_SHARE_PATH . 'download-cache/pts-download-cache.json'))55 {56 $dc_file = PTS_SHARE_PATH . 'download-cache/pts-download-cache.json';57 }58 else59 {60 $dc = pts_strings::add_trailing_slash(pts_strings::parse_for_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH)));61 if(is_file($dc . 'pts-download-cache.json'))62 {63 $dc_file = $dc . 'pts-download-cache.json';64 }65 }66 return $dc_file;67 }68 public static function is_phoromatic_account_path($account_id)69 {70 return $account_id != null && is_dir(self::phoromatic_path() . 'accounts/' . $account_id);71 }72 public static function phoromatic_account_path($account_id)73 {74 return self::phoromatic_path() . 'accounts/' . $account_id . '/';75 }76 public static function phoromatic_account_result_path($account_id, $result_id = null)77 {78 return self::phoromatic_account_path($account_id) . 'results/' . ($result_id != null ? $result_id . '/' : null);79 }80 public static function phoromatic_account_suite_path($account_id, $suite_id = null)81 {82 return self::phoromatic_account_path($account_id) . 'suites/' . ($suite_id != null ? $suite_id . '/' : null);83 }84 public static function phoromatic_account_system_path($account_id, $system_id = null)85 {86 return self::phoromatic_account_path($account_id) . 'systems/' . ($system_id != null ? $system_id . '/' : null);87 }88 public static function phoromatic_account_stress_log_path($account_id, $ticket_id = null)89 {90 return self::phoromatic_account_path($account_id) . 'stress-logs/' . ($ticket_id != null ? $ticket_id . '/' : null);91 }92 public static function read_setting($setting)93 {94 return pts_storage_object::read_from_file(self::$json_storage, $setting);95 }96 public static function save_setting($setting, $value)97 {98 return pts_storage_object::set_in_file(self::$json_storage, $setting, $value);99 }100 public static function close_database()101 {102 if(self::$db != null)103 {104 self::$db->close();105 self::$db = null;106 }107 }108 public static function prepare_database($read_only = false)109 {110 self::$json_storage = self::phoromatic_path() . 'phoromatic-settings.pt2so';111 if(!is_file(self::$json_storage))112 {113 $pt2so = new pts_storage_object();114 $pt2so->save_to_file(self::$json_storage);115 }116 $db_file = self::phoromatic_path() . 'phoromatic.db';117 $db_flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE;118 if($read_only && is_file($db_file))119 {120 $db_flags = SQLITE3_OPEN_READONLY;121 }122 self::$db = new SQLite3($db_file, $db_flags);123 self::$db->busyTimeout(10000);124 if($read_only && is_file($db_file))125 {126 return true;127 }128 // TODO XXX make this a rootadmin option or something129 self::$db->exec('PRAGMA journal_mode = WAL');130 self::$db->exec('PRAGMA synchronous = NORMAL');131 switch(self::read_database_version())132 {133 case 0:134 // Account Database135 self::$db->exec('CREATE TABLE phoromatic_accounts (AccountID TEXT PRIMARY KEY, ValidateID TEXT NOT NULL, CreatedOn TEXT NOT NULL, Salt TEXT NOT NULL)');136 self::$db->exec('CREATE TABLE phoromatic_account_settings (AccountID TEXT PRIMARY KEY, ArchiveResultsLocally INTEGER, UploadSystemLogs INTEGER DEFAULT 1, RunInstallCommand INTEGER DEFAULT 1, ForceInstallTests INTEGER, SystemSensorMonitoring INTEGER)');137 self::$db->exec('CREATE TABLE phoromatic_users (UserID TEXT PRIMARY KEY, AccountID TEXT NOT NULL, UserName TEXT UNIQUE, Email TEXT, Password TEXT NOT NULL, CreatedOn TEXT NOT NULL, LastLogin TEXT, LastIP TEXT)');138 self::$db->exec('CREATE TABLE phoromatic_schedules (AccountID TEXT, ScheduleID INTEGER, Title TEXT, Description TEXT, State INTEGER, ActiveOn TEXT, RunAt TEXT, SetContextPreInstall TEXT, SetContextPostInstall TEXT, SetContextPreRun TEXT, SetContextPostRun TEXT, LastModifiedBy TEXT, LastModifiedOn TEXT, PublicKey TEXT, UNIQUE(AccountID, ScheduleID) ON CONFLICT IGNORE)');139 //self::$db->exec('CREATE TABLE phoromatic_schedules_systems (AccountID TEXT UNIQUE, ScheduleID INTEGER UNIQUE, SystemID TEXT UNIQUE)');140 self::$db->exec('CREATE TABLE phoromatic_schedules_tests (AccountID TEXT, ScheduleID INTEGER, TestProfile TEXT, TestArguments TEXT, TestDescription TEXT, UNIQUE(AccountID, ScheduleID, TestProfile, TestArguments) ON CONFLICT REPLACE)');141 self::$db->exec('CREATE TABLE phoromatic_schedules_triggers (AccountID TEXT, ScheduleID INTEGER, Trigger TEXT, TriggerTarget TEXT, TriggeredOn TEXT, UNIQUE(AccountID, ScheduleID, Trigger) ON CONFLICT IGNORE)');142 self::$db->exec('CREATE TABLE phoromatic_user_settings (AccountID TEXT, UserID TEXT, NotifyOnResultUploads INTEGER, NotifyOnWarnings INTEGER, NotifyOnNewSystems INTEGER, UNIQUE(AccountID, UserID) ON CONFLICT IGNORE)');143 self::$db->exec('CREATE TABLE phoromatic_systems (AccountID TEXT, SystemID TEXT, Title TEXT, Description TEXT, Groups TEXT, Hardware TEXT, Software TEXT, ClientVersion TEXT, GSID TEXT, CurrentTask TEXT, EstimatedTimeForTask TEXT, CreatedOn TEXT, LastCommunication TEXT, LastIP TEXT, State INTEGER, LocalIP TEXT, NetworkMAC TEXT, Flags TEXT, UNIQUE(AccountID, SystemID) ON CONFLICT IGNORE)');144 self::$db->exec('CREATE TABLE phoromatic_system_warnings (AccountID TEXT, SystemID TEXT, Warning TEXT, WarningTime TEXT)');145 self::$db->exec('CREATE TABLE phoromatic_results (AccountID TEXT, UploadID INTEGER, ScheduleID INTEGER, Trigger TEXT, UploadTime TEXT, Title TEXT, OpenBenchmarkingID TEXT, SystemID TEXT, UNIQUE(AccountID, UploadID) ON CONFLICT IGNORE)');146 self::$db->exec('CREATE TABLE phoromatic_groups (AccountID TEXT, GroupName TEXT, Description TEXT, UNIQUE(AccountID, GroupName) ON CONFLICT IGNORE)');147 self::$db->exec('PRAGMA user_version = 1');148 case 1:149 // phoromatic_results changes for schema mostly from OB150 // Changes made 20 September / post 5.4-M1151 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN Description TEXT');152 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN SystemCount INTEGER');153 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN ResultCount INTEGER');154 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN DisplayStatus INTEGER DEFAULT 1');155 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN TimesViewed INTEGER DEFAULT 0');156 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN XmlUploadHash TEXT');157 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN ComparisonHash TEXT');158 // Add phoromatic_results_results as test_results_results equivalent from OB159 self::$db->exec('CREATE TABLE phoromatic_results_results (AccountID TEXT, UploadID INTEGER, AbstractID INTEGER, TestProfile TEXT, ComparisonHash TEXT, UNIQUE(AccountID, UploadID, AbstractID) ON CONFLICT IGNORE)');160 self::$db->exec('CREATE TABLE phoromatic_results_systems (AccountID TEXT, UploadID INTEGER, SystemIdentifier TEXT, Hardware TEXT, Software TEXT, UNIQUE(AccountID, UploadID, SystemIdentifier) ON CONFLICT IGNORE)');161 self::$db->exec('PRAGMA user_version = 2');162 case 2:163 // Change made 4 October to introduce machine self ID as a new identifier for local systems without Internet not having OpenBenchmarking.org GSID, etc164 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN MachineSelfID TEXT');165 self::$db->exec('PRAGMA user_version = 3');166 case 3:167 // Change made 8 October for targeting the SystemID / GroupNames of systems to test in schedules168 self::$db->exec('ALTER TABLE phoromatic_schedules ADD COLUMN RunTargetSystems TEXT');169 self::$db->exec('ALTER TABLE phoromatic_schedules ADD COLUMN RunTargetGroups TEXT');170 self::$db->exec('PRAGMA user_version = 4');171 case 4:172 // Change made 11 October for administrative level173 self::$db->exec('ALTER TABLE phoromatic_users ADD COLUMN AdminLevel INTEGER DEFAULT 1');174 self::$db->exec('PRAGMA user_version = 5');175 case 5:176 self::$db->exec('CREATE TABLE phoromatic_activity_stream (AccountID TEXT, ActivityTime TEXT, ActivityCreator TEXT, ActivityCreatorType TEXT, ActivityEvent TEXT, ActivityEventID TEXT, ActivityEventType TEXT)');177 self::$db->exec('PRAGMA user_version = 6');178 case 6:179 self::$db->exec('CREATE TABLE phoromatic_system_client_errors (AccountID TEXT, SystemID TEXT, UploadTime TEXT, ScheduleID INTEGER, TriggerID TEXT, ErrorMessage TEXT, TestIdentifier TEXT, TestArguments TEXT)');180 self::$db->exec('PRAGMA user_version = 7');181 case 7:182 // Change made 11 October for administrative level183 self::$db->exec('ALTER TABLE phoromatic_account_settings ADD COLUMN UploadResultsToOpenBenchmarking INTEGER DEFAULT 0');184 self::$db->exec('PRAGMA user_version = 8');185 case 8:186 // Change made 24 November 2014 Wake On LAN info for client systems187 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN NetworkWakeOnLAN TEXT');188 self::$db->exec('PRAGMA user_version = 9');189 case 9:190 // Change made 24 November 2014 for new user/account settings191 self::$db->exec('ALTER TABLE phoromatic_user_settings ADD COLUMN NotifyOnHungSystems INTEGER DEFAULT 0');192 self::$db->exec('ALTER TABLE phoromatic_account_settings ADD COLUMN PowerOffWhenDone INTEGER DEFAULT 0');193 self::$db->exec('ALTER TABLE phoromatic_account_settings ADD COLUMN NetworkPowerUpWhenNeeded INTEGER DEFAULT 0');194 self::$db->exec('PRAGMA user_version = 10');195 case 10:196 // Change made 25 November for user context logging197 self::$db->exec('CREATE TABLE phoromatic_system_context_logs (AccountID TEXT, SystemID TEXT, UploadTime TEXT, ScheduleID INTEGER, TriggerID TEXT, UserContextStep TEXT, UserContextLog TEXT)');198 self::$db->exec('PRAGMA user_version = 11');199 case 11:200 // Change made 27 November for time elapsed during benchmarking201 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN ElapsedTime INTEGER DEFAULT 0');202 self::$db->exec('PRAGMA user_version = 12');203 case 12:204 // Change made 27 November for IP/MAC address claiming to accounts205 self::$db->exec('CREATE TABLE phoromatic_system_association_claims (AccountID TEXT, IPAddress TEXT, NetworkMAC TEXT, CreationTime TEXT, UNIQUE(IPAddress, NetworkMAC) ON CONFLICT IGNORE)');206 self::$db->exec('PRAGMA user_version = 13');207 case 13:208 // Change made 30 November for percent complete209 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN TaskPercentComplete INTEGER DEFAULT 0');210 self::$db->exec('PRAGMA user_version = 14');211 case 14:212 // Change made 1 December for more reporting features213 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN CurrentProcessSchedule INTEGER');214 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN TimeToNextCommunication INTEGER DEFAULT 0');215 self::$db->exec('PRAGMA user_version = 15');216 case 15:217 // Change made 1 December for maintenance mode218 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN MaintenanceMode INTEGER DEFAULT 0');219 self::$db->exec('PRAGMA user_version = 16');220 case 16:221 // Change made 31 January for group name222 self::$db->exec('ALTER TABLE phoromatic_accounts ADD COLUMN GroupName TEXT');223 self::$db->exec('PRAGMA user_version = 17');224 case 17:225 // Change made 31 January for Phoromatic Public Result ID226 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN PPRID TEXT');227 self::$db->exec('PRAGMA user_version = 18');228 case 18:229 // Change made 31 January for Phoromatic Public Result ID230 self::rebuild_pprid_entries();231 self::$db->exec('CREATE UNIQUE INDEX IF NOT EXISTS public_result_id ON phoromatic_results (PPRID)');232 self::$db->exec('PRAGMA user_version = 19');233 case 19:234 // Change made 31 January235 self::$db->exec('ALTER TABLE phoromatic_account_settings ADD COLUMN LetOtherGroupsViewResults INTEGER DEFAULT 0');236 self::$db->exec('PRAGMA user_version = 20');237 case 20:238 // Change made 4 February239 self::$db->exec('ALTER TABLE phoromatic_account_settings ADD COLUMN PreSeedTestInstalls INTEGER DEFAULT 0');240 self::$db->exec('PRAGMA user_version = 21');241 case 21:242 // Change made 8 February243 self::$db->exec('CREATE TABLE phoromatic_benchmark_tickets (AccountID TEXT, TicketID INTEGER, TicketIssueTime TEXT, Title TEXT, ResultIdentifier TEXT, SuiteToRun TEXT, Description TEXT, State INTEGER DEFAULT 1, LastModifiedBy TEXT, LastModifiedOn TEXT, RunTargetSystems TEXT, RunTargetGroups TEXT, UNIQUE(AccountID, TicketID) ON CONFLICT IGNORE)');244 self::$db->exec('PRAGMA user_version = 22');245 case 22:246 // Change made 8 February247 self::$db->exec('ALTER TABLE phoromatic_results ADD COLUMN BenchmarkTicketID INTEGER');248 self::$db->exec('PRAGMA user_version = 23');249 case 23:250 // Change made 24 February251 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN SystemVariables TEXT');252 self::$db->exec('PRAGMA user_version = 24');253 case 24:254 // Change made 24 February255 self::$db->exec('ALTER TABLE phoromatic_benchmark_tickets ADD COLUMN EnvironmentVariables TEXT');256 self::$db->exec('PRAGMA user_version = 25');257 case 25:258 // Change made 10 March259 self::$db->exec('CREATE TABLE phoromatic_annotations (AccountID TEXT, Type TEXT, ID TEXT, SecondaryID TEXT, AnnotatedTime TEXT, AnnotatedBy TEXT, Annotation TEXT)');260 self::$db->exec('PRAGMA user_version = 26');261 case 26:262 // Change made 26 March263 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN BlockPowerOffs INTEGER DEFAULT 0');264 self::$db->exec('PRAGMA user_version = 27');265 case 27:266 // Change made 27 March267 self::$db->exec('ALTER TABLE phoromatic_account_settings ADD COLUMN PowerOnSystemDaily INTEGER DEFAULT 0');268 self::$db->exec('PRAGMA user_version = 28');269 case 28:270 // Change made 13 April271 self::$db->exec('ALTER TABLE phoromatic_account_settings ADD COLUMN LetPublicViewResults INTEGER DEFAULT 0');272 self::$db->exec('PRAGMA user_version = 29');273 case 29:274 // Change made 12 May275 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN TickThreadEvent TEXT');276 self::$db->exec('PRAGMA user_version = 30');277 case 30:278 // Change made 3 June279 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN CoreVersion INTEGER');280 self::$db->exec('PRAGMA user_version = 31');281 case 31:282 // Change made 5 June283 self::$db->exec('CREATE TABLE phoromatic_schedules_trigger_skips (AccountID TEXT, ScheduleID INTEGER, Trigger TEXT, UNIQUE(AccountID, ScheduleID, Trigger) ON CONFLICT IGNORE)');284 self::$db->exec('PRAGMA user_version = 32');285 case 32:286 // Change made 10 June287 self::$db->exec('ALTER TABLE phoromatic_schedules_triggers ADD COLUMN SubTarget TEXT');288 self::$db->exec('PRAGMA user_version = 33');289 case 33:290 // Change made 4 October291 self::$db->exec('ALTER TABLE phoromatic_account_settings ADD COLUMN AutoApproveNewSystems INTEGER DEFAULT 0');292 self::$db->exec('PRAGMA user_version = 34');293 case 34:294 // Change made 7 January 2016295 self::$db->exec('ALTER TABLE phoromatic_account_settings ADD COLUMN LimitNetworkCommunication INTEGER DEFAULT 0');296 self::$db->exec('PRAGMA user_version = 35');297 case 35:298 // Change made 15 April 2016299 self::$db->exec('ALTER TABLE phoromatic_systems ADD COLUMN CurrentProcessTicket INTEGER DEFAULT 0');300 self::$db->exec('PRAGMA user_version = 36');301 }302 chmod($db_file, 0600);303 if(!defined('PHOROMATIC_DB_INIT'))304 {305 define('PHOROMATIC_DB_INIT', true);306 }307 }308 public static function generate_result_export_dump($account_id)309 {310 ini_set('memory_limit', '4G');311 pts_file_io::mkdir(self::phoromatic_path() . 'result-export/');312 $export_path = self::phoromatic_path() . 'result-export/' . $account_id . '/';313 pts_file_io::mkdir($export_path);314 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND State = 1 AND (SELECT COUNT(*) FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = phoromatic_schedules.ScheduleID) > 0 AND (SELECT COUNT(*) FROM phoromatic_results WHERE AccountID = :account_id AND ScheduleID = phoromatic_schedules.ScheduleID) > 4 ORDER BY Title ASC');315 $stmt->bindValue(':account_id', $account_id);316 $result = $stmt->execute();317 $exported_result_index = array('phoromatic' => array());318 $error_index = array('phoromatic' => array());319 while($result && $row = $result->fetchArray())320 {321 $id = str_replace(' ', '-', strtolower($row['Title']));322 $triggers = array();323 $first_time = time();324 $latest_time = 0;325 $stmt2 = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY UploadTime DESC');326 $stmt2->bindValue(':account_id', $row['AccountID']);327 $stmt2->bindValue(':schedule_id', $row['ScheduleID']);328 $result2 = $stmt2->execute();329 pts_file_io::mkdir($export_path);330 while($result2 && $row2 = $result2->fetchArray())331 {332 $composite_xml = phoromatic_server::phoromatic_account_result_path($row2['AccountID'], $row2['UploadID']) . 'composite.xml';333 if(is_file($composite_xml))334 {335 pts_file_io::mkdir($export_path . $id . '/' . $row2['Trigger']);336 pts_file_io::mkdir($export_path . $id . '/' . $row2['Trigger'] . '/' . phoromatic_server::system_id_to_name($row2['SystemID'], $row2['AccountID']));337 copy($composite_xml, $export_path . $id . '/' . $row2['Trigger'] . '/' . phoromatic_server::system_id_to_name($row2['SystemID'], $row2['AccountID']) . '/composite.xml');338 }339 pts_arrays::unique_push($triggers, $row2['Trigger']);340 $utime = strtotime($row2['UploadTime']);341 $first_time = min($first_time, $utime);342 $latest_time = max($latest_time, $utime);343 }344 $exported_result_index['phoromatic'][$id] = array(345 'title' => $row['Title'],346 'id' => $id,347 'description' => $row['Description'],348 'triggers' => $triggers,349 'first_result_time' => $first_time,350 'last_result_time' => $latest_time351 );352 $stmt2 = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_system_client_errors WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY UploadTime DESC');353 $stmt2->bindValue(':account_id', $row['AccountID']);354 $stmt2->bindValue(':schedule_id', $row['ScheduleID']);355 $result2 = $stmt2->execute();356 $error_index['phoromatic'][$id] = array();357 while($result2 && $row2 = $result2->fetchArray())358 {359 // Only show last month of errors for now360 if(strtotime('-1 month') > strtotime($row2['UploadTime']))361 continue;362 $error_index['phoromatic'][$id][] = array(363 'system' => phoromatic_server::system_id_to_name($row2['SystemID'], $row2['AccountID']),364 'trigger' => $row2['TriggerID'],365 'test' => $row2['TestIdentifier'],366 'test_description' => $row2['TestArguments'],367 'error' => $row2['ErrorMessage'],368 'error_time' => strtotime($row2['UploadTime']),369 );370 }371 }372 $exported_result_index = json_encode($exported_result_index, JSON_PRETTY_PRINT);373 $error_index = json_encode($error_index, JSON_PRETTY_PRINT);374 file_put_contents($export_path . '/export-index.json', $exported_result_index);375 file_put_contents($export_path . '/export-test-errors.json', $error_index);376 }377 public static function send_email($to, $subject, $from, $body)378 {379 // return;380 $msg = '<html><body>' . $body . '381 <hr />382 <p><img src="http://www.phoronix-test-suite.com/web/pts-logo-60.png" /></p>383 <h6><em>The <a href="http://www.phoronix-test-suite.com/">Phoronix Test Suite</a>, <a href="http://www.phoromatic.com/">Phoromatic</a>, and <a href="http://openbenchmarking.org/">OpenBenchmarking.org</a> are products of <a href="http://www.phoronix-media.com/">Phoronix Media</a>.<br />The Phoronix Test Suite is open-source under terms of the GNU GPL. Commercial support, custom engineering, and other services are available by contacting Phoronix Media.<br />&copy; ' . date('Y') . ' Phoronix Media.</em></h6>384 </body></html>';385 $headers = "MIME-Version: 1.0\r\n";386 $headers .= "Content-type:text/html;charset=UTF-8\r\n";387 $headers .= "From: Phoromatic - Phoronix Test Suite <no-reply@phoromatic.com>\r\n";388 $headers .= "Reply-To: " . $from . " <" . $from . ">\r\n";389 mail($to, $subject, $msg, $headers);390 }391 protected static function rebuild_pprid_entries()392 {393 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results ORDER BY UploadTime ASC');394 $result = $stmt ? $stmt->execute() : false;395 while($result && ($row = $result->fetchArray()))396 {397 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_results SET PPRID = :pprid WHERE AccountID = :account_id AND UploadID = :upload_id');398 $stmt->bindValue(':account_id', $row['AccountID']);399 $stmt->bindValue(':upload_id', $row['UploadID']);400 $stmt->bindValue(':pprid', phoromatic_server::compute_pprid($row['AccountID'], $row['SystemID'], $row['UploadTime'], $row['XmlUploadHash']));401 $stmt->execute();402 }403 }404 public static function compute_pprid($account_id, $system_id, $upload_time, $xml_upload_hash)405 {406 return base_convert(sha1($account_id . ' ' . $system_id . ' ' . $xml_upload_hash . ' ' . $upload_time), 10, 36);407 }408 public static function system_id_to_name($system_id, $aid = false)409 {410 static $system_names;411 if(!isset($system_names[$system_id]) || empty($system_names[$system_id]))412 {413 $stmt = phoromatic_server::$db->prepare('SELECT Title FROM phoromatic_systems WHERE AccountID = :account_id AND SystemID = :system_id');414 $stmt->bindValue(':account_id', ($aid ? $aid : $_SESSION['AccountID']));415 $stmt->bindValue(':system_id', $system_id);416 $result = $stmt->execute();417 $row = $result ? $result->fetchArray() : false;418 $system_names[$system_id] = isset($row['Title']) ? $row['Title'] : false;419 }420 return $system_names[$system_id];421 }422 public static function system_id_variables($system_id, $aid = false)423 {424 $stmt = phoromatic_server::$db->prepare('SELECT SystemVariables FROM phoromatic_systems WHERE AccountID = :account_id AND SystemID = :system_id');425 $stmt->bindValue(':account_id', ($aid ? $aid : $_SESSION['AccountID']));426 $stmt->bindValue(':system_id', $system_id);427 $result = $stmt->execute();428 $row = $result ? $result->fetchArray() : false;429 return isset($row['SystemVariables']) ? $row['SystemVariables'] : null;430 }431 public static function schedule_id_to_name($schedule_id, $aid = false)432 {433 static $schedule_names;434 if(!isset($schedule_names[$schedule_id]) || empty($schedule_names[$schedule_id]))435 {436 $stmt = phoromatic_server::$db->prepare('SELECT Title FROM phoromatic_schedules WHERE AccountID = :account_id AND ScheduleID = :schedule_id');437 $stmt->bindValue(':account_id', ($aid ? $aid : $_SESSION['AccountID']));438 $stmt->bindValue(':schedule_id', $schedule_id);439 $result = $stmt->execute();440 $row = $result ? $result->fetchArray() : false;441 $schedule_names[$schedule_id] = isset($row['Title']) ? $row['Title'] : false;442 }443 return $schedule_names[$schedule_id];444 }445 public static function ticket_id_to_name($ticket_id, $aid = false)446 {447 static $ticket_names;448 if(!isset($ticket_names[$ticket_id]) || empty($ticket_names[$ticket_id]))449 {450 $stmt = phoromatic_server::$db->prepare('SELECT Title FROM phoromatic_benchmark_tickets WHERE AccountID = :account_id AND TicketID = :ticket_id');451 $stmt->bindValue(':account_id', ($aid ? $aid : $_SESSION['AccountID']));452 $stmt->bindValue(':ticket_id', $ticket_id);453 $result = $stmt->execute();454 $row = $result ? $result->fetchArray() : false;455 $ticket_names[$ticket_id] = isset($row['Title']) ? $row['Title'] : false;456 }457 return $ticket_names[$ticket_id];458 }459 public static function account_id_to_group_admin_email($account_id)460 {461 $stmt = phoromatic_server::$db->prepare('SELECT Email FROM phoromatic_users WHERE AccountID = :account_id AND AdminLevel = 1 ORDER BY CreatedOn ASC LIMIT 1');462 $stmt->bindValue(':account_id', $account_id);463 $result = $stmt->execute();464 $row = $result ? $result->fetchArray() : false;465 return isset($row['Email']) ? $row['Email'] : false;466 }467 public static function account_id_to_group_name($account_id)468 {469 static $group_names;470 if(!isset($group_names[$account_id]) || empty($group_names[$account_id]))471 {472 $stmt = phoromatic_server::$db->prepare('SELECT GroupName FROM phoromatic_accounts WHERE AccountID = :account_id');473 $stmt->bindValue(':account_id', $account_id);474 $result = $stmt->execute();475 $row = $result ? $result->fetchArray() : false;476 $group_names[$account_id] = isset($row['GroupName']) ? $row['GroupName'] : null;477 }478 return $group_names[$account_id];479 }480 public static function recently_active_systems($account_id)481 {482 $systems = array();483 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 ORDER BY LastCommunication DESC');484 $stmt->bindValue(':account_id', $account_id);485 $result = $stmt->execute();486 while($result && $row = $result->fetchArray())487 {488 if(strtotime($row['LastCommunication']) < (time() - 21600))489 break;490 if(stripos($row['CurrentTask'], 'shutdown') !== false || stripos($row['CurrentTask'], 'exit') !== false)491 continue;492 $systems[] = $row;493 }494 return $systems;495 }496 public static function check_for_benchmark_ticket_result_match($benchmark_id, $account_id, $system_id, $ticket_issue_time)497 {498 $stmt = phoromatic_server::$db->prepare('SELECT UploadID FROM phoromatic_results WHERE AccountID = :account_id AND SystemID = :system_id AND BenchmarkTicketID = :benchmark_id AND UploadTime > :ticket_issue_time');499 $stmt->bindValue(':account_id', $account_id);500 $stmt->bindValue(':system_id', $system_id);501 $stmt->bindValue(':benchmark_id', $benchmark_id);502 $stmt->bindValue(':ticket_issue_time', $ticket_issue_time);503 $result = $stmt->execute();504 if($result && $result->fetchArray() != false)505 {506 return true;507 }508 return false;509 }510 public static function check_for_triggered_result_match($schedule_id, $trigger_id, $account_id, $system_id)511 {512 $stmt = phoromatic_server::$db->prepare('SELECT UploadID FROM phoromatic_results WHERE AccountID = :account_id AND ScheduleID = :schedule_id AND Trigger = :trigger AND SystemID = :system_id');513 $stmt->bindValue(':account_id', $account_id);514 $stmt->bindValue(':system_id', $system_id);515 $stmt->bindValue(':schedule_id', $schedule_id);516 $stmt->bindValue(':trigger', $trigger_id);517 $result = $stmt->execute();518 if($result && $result->fetchArray() != false)519 {520 return true;521 }522 // See if the system attempted to run the trigger/schedule combination but reported an error during the process....523 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(ErrorMessage) AS ErrorCount FROM phoromatic_system_client_errors WHERE AccountID = :account_id AND SystemID = :system_id AND ScheduleID = :schedule_id AND TriggerID = :trigger');524 $stmt->bindValue(':account_id', $account_id);525 $stmt->bindValue(':system_id', $system_id);526 $stmt->bindValue(':schedule_id', $schedule_id);527 $stmt->bindValue(':trigger', $trigger_id);528 $result = $stmt->execute();529 if($result != false && ($row = $result->fetchArray()) != false)530 {531 $error_count = $row['ErrorCount'];532 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(*) AS TestCount FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = :schedule_id');533 $stmt->bindValue(':account_id', $account_id);534 $stmt->bindValue(':schedule_id', $schedule_id);535 $result = $stmt->execute();536 $row = $result ? $result->fetchArray() : null;537 // See if error count was greater than test count, meaning all of the tests might have failed538 if($error_count >= $row['TestCount'])539 {540 return true;541 }542 }543 $stmt = phoromatic_server::$db->prepare('SELECT ScheduleID FROM phoromatic_schedules_trigger_skips WHERE AccountID = :account_id AND ScheduleID = :schedule_id AND Trigger = :trigger');544 $stmt->bindValue(':account_id', $account_id);545 $stmt->bindValue(':schedule_id', $schedule_id);546 $stmt->bindValue(':trigger', $trigger_id);547 $result = $stmt->execute();548 if($result && $result->fetchArray() != false)549 {550 return true;551 }552 return false;553 }554 public static function user_friendly_timedate($time)555 {556 return date('j F H:i', strtotime($time));557 }558 public static function get_system_details($account_id, $system_id)559 {560 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_systems WHERE AccountID = :account_id AND SystemID = :system_id LIMIT 1');561 $stmt->bindValue(':account_id', $account_id);562 $stmt->bindValue(':system_id', $system_id);563 $result = $stmt->execute();564 $row = $result ? $result->fetchArray() : null;565 return $row;566 }567 public static function systems_associated_with_schedule($account_id, $schedule_id)568 {569 $system_ids = array();570 $stmt = phoromatic_server::$db->prepare('SELECT RunTargetSystems, RunTargetGroups FROM phoromatic_schedules WHERE AccountID = :account_id AND ScheduleID = :schedule_id LIMIT 1');571 $stmt->bindValue(':account_id', $account_id);572 $stmt->bindValue(':schedule_id', $schedule_id);573 $result = $stmt->execute();574 if($result && $row = $result->fetchArray())575 {576 foreach(explode(',', $row['RunTargetSystems']) as $sys)577 {578 if(empty($sys))579 continue;580 $system_ids[] = $sys;581 }582 foreach(explode(',', $row['RunTargetGroups']) as $group)583 {584 if(empty($group))585 continue;586 $stmt = phoromatic_server::$db->prepare('SELECT SystemID FROM phoromatic_systems WHERE AccountID = :account_id AND Groups LIKE :sgroup AND State > 0 ORDER BY Title ASC');587 $stmt->bindValue(':account_id', $account_id);588 $stmt->bindValue(':sgroup', '%#' . $group . '#%');589 $result = $stmt->execute();590 while($result && $row = $result->fetchArray())591 {592 $system_ids[] = $row['SystemID'];593 }594 }595 }596 return array_unique($system_ids);597 }598 public static function schedules_that_run_on_system($account_id, $system_id)599 {600 $schedules = array();601 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND State = 1 ORDER BY TITLE ASC');602 $stmt->bindValue(':account_id', $account_id);603 $result = $stmt->execute();604 while($result && $row = $result->fetchArray())605 {606 // Make sure this test schedule is supposed to work on given system607 if(!in_array($system_id, explode(',', $row['RunTargetSystems'])))608 {609 $stmt = phoromatic_server::$db->prepare('SELECT Groups FROM phoromatic_systems WHERE AccountID = :account_id AND SystemID = :system_id LIMIT 1');610 $stmt->bindValue(':account_id', $account_id);611 $stmt->bindValue(':system_id', $system_id);612 $sys_result = $stmt->execute();613 $sys_row = $sys_result ? $sys_result->fetchArray() : null;614 $matches_to_group = false;615 foreach(explode(',', $row['RunTargetGroups']) as $group)616 {617 if(stripos($sys_row['Groups'], '#' . $group . '#') !== false)618 {619 $matches_to_group = true;620 break;621 }622 }623 if($matches_to_group == false)624 continue;625 }626 $schedules[] = $row;627 }628 return $schedules;629 }630 public static function system_has_outstanding_jobs($account_id, $system_id, $time_offset = 0)631 {632 $stmt = phoromatic_server::$db->prepare('SELECT Groups FROM phoromatic_systems WHERE AccountID = :account_id AND SystemID = :system_id LIMIT 1');633 $stmt->bindValue(':account_id', $account_id);634 $stmt->bindValue(':system_id', $system_id);635 $sys_result = $stmt->execute();636 $sys_row = $sys_result ? $sys_result->fetchArray() : null;637 // See if there's an open schedule to run for system638 $schedule_row = self::system_check_for_open_schedule_run($account_id, $system_id, $time_offset, $sys_row);639 if($schedule_row != false)640 {641 return $schedule_row;642 }643 // See if there's an open benchmark ticket for system644 $ticket_row = self::system_check_for_open_benchmark_ticket($account_id, $system_id, $sys_row);645 if($ticket_row != false)646 {647 return $ticket_row;648 }649 return false;650 }651 public static function system_check_for_open_schedule_run($account_id, $system_id, $time_offset = 0, &$sys_row)652 {653 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND State = 1 AND (SELECT COUNT(*) FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = phoromatic_schedules.ScheduleID) > 0');654 $stmt->bindValue(':account_id', $account_id);655 $result = $stmt->execute();656 $day_of_week_int = date('N') - 1;657 while($result && $row = $result->fetchArray())658 {659 // Make sure this test schedule is supposed to work on given system660 if(!in_array($system_id, explode(',', $row['RunTargetSystems'])))661 {662 $matches_to_group = false;663 foreach(explode(',', $row['RunTargetGroups']) as $group)664 {665 if(stripos($sys_row['Groups'], '#' . $group . '#') !== false)666 {667 $matches_to_group = true;668 break;669 }670 }671 if($matches_to_group == false)672 continue;673 }674 // See if test is a time-based schedule due to run today and now or past the time scheduled to run675 if(strpos($row['ActiveOn'], strval($day_of_week_int)) !== false)676 {677 if($row['RunAt'] <= date('H.i', (time() + $time_offset)))678 {679 $trigger_id = date('Y-m-d');680 if(!phoromatic_server::check_for_triggered_result_match($row['ScheduleID'], $trigger_id, $account_id, $system_id))681 {682 return $row;683 }684 }685 }686 // See if custom trigger...687 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules_triggers WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY TriggeredOn DESC');688 $stmt->bindValue(':account_id', $account_id);689 $stmt->bindValue(':schedule_id', $row['ScheduleID']);690 $trigger_result = $stmt->execute();691 while($trigger_result && $trigger_row = $trigger_result->fetchArray())692 {693 // See if any sub-targeting is happening694 if($trigger_row['SubTarget'] !== null)695 {696 $sub_targets = explode(',', $trigger_row['SubTarget']);697 if(!empty($sub_targets) && !in_array($system_id, $sub_targets))698 {699 // This system isn't part of the sub-targeted trigger700 continue;701 }702 }703 if(substr($trigger_row['TriggeredOn'], 0, 10) == date('Y-m-d') || substr($trigger_row['TriggeredOn'], 0, 10) == date('Y-m-d', (time() - 60 * 60 * 24)))704 {705 if(!phoromatic_server::check_for_triggered_result_match($row['ScheduleID'], $trigger_row['Trigger'], $account_id, $system_id))706 {707 $row['Trigger'] = $trigger_row['Trigger'];708 return $row;709 }710 }711 }712 }713 return false;714 }715 public static function system_check_for_open_benchmark_ticket($account_id, $system_id, &$sys_row)716 {717 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_benchmark_tickets WHERE AccountID = :account_id AND State = 1 AND TicketIssueTime < :current_time AND TicketIssueTime > :yesterday ORDER BY TicketIssueTime ASC');718 //echo phoromatic_server::$db->lastErrorMsg();719 $stmt->bindValue(':account_id', $account_id);720 $stmt->bindValue(':current_time', time());721 $stmt->bindValue(':yesterday', (time() - (60 * 60 * 24)));722 $result = $stmt->execute();723 while($result && $row = $result->fetchArray())724 {725 // Make sure this test schedule is supposed to work on given system726 if(!in_array($system_id, explode(',', $row['RunTargetSystems'])))727 {728 $matches_to_group = false;729 foreach(explode(',', $row['RunTargetGroups']) as $group)730 {731 if(stripos($sys_row['Groups'], '#' . $group . '#') !== false)732 {733 $matches_to_group = true;734 break;735 }736 }737 if($matches_to_group == false)738 continue;739 }740 if(!phoromatic_server::check_for_benchmark_ticket_result_match($row['TicketID'], $account_id, $system_id, $row['TicketIssueTime']))741 {742 if(strpos($row['EnvironmentVariables'], 'PTS_CONCURRENT_TEST_RUNS') !== false && is_file(phoromatic_server::phoromatic_account_stress_log_path($account_id, $row['TicketID']) . $system_id . '.log') && filemtime(phoromatic_server::phoromatic_account_stress_log_path($account_id, $row['TicketID']) . $system_id . '.log') > $row['TicketIssueTime'])743 {744 // Stress log uploaded745 continue;746 }747 return $row;748 }749 }750 return false;751 }752 public static function time_to_next_scheduled_job($account_id, $system_id)753 {754 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND State = 1 AND (SELECT COUNT(*) FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = phoromatic_schedules.ScheduleID) > 0');755 $stmt->bindValue(':account_id', $account_id);756 $result = $stmt->execute();757 $scheduled_times = array();758 while($result && $row = $result->fetchArray())759 {760 // Make sure this test schedule is supposed to work on given system761 if(!in_array($system_id, explode(',', $row['RunTargetSystems'])))762 {763 $stmt = phoromatic_server::$db->prepare('SELECT Groups FROM phoromatic_systems WHERE AccountID = :account_id AND SystemID = :system_id LIMIT 1');764 $stmt->bindValue(':account_id', $account_id);765 $stmt->bindValue(':system_id', $system_id);766 $sys_result = $stmt->execute();767 $sys_row = $sys_result ? $sys_result->fetchArray() : null;768 $matches_to_group = false;769 foreach(explode(',', $row['RunTargetGroups']) as $group)770 {771 if(stripos($sys_row['Groups'], '#' . $group . '#') !== false)772 {773 $matches_to_group = true;774 break;775 }776 }777 if($matches_to_group == false)778 continue;779 }780 foreach(explode(',', $row['ActiveOn']) as $active_day)781 {782 list($hour, $minute) = explode('.', $row['RunAt']);783 $scheduled_times[] = (($active_day * 1440) + ($hour * 60) + $minute );784 }785 }786 sort($scheduled_times);787 $now_time = ((date('N') - 1) * 1440) + (date('G') * 60) + date('i');788 foreach($scheduled_times as $i => $time_to_next_job)789 {790 if($now_time > $time_to_next_job)791 unset($scheduled_times[$i]);792 }793 if(!empty($scheduled_times))794 return array_shift($scheduled_times) - $now_time;795 return false;796 }797 public static function estimated_time_remaining_diff($estimated_minutes, $last_comm)798 {799 if($estimated_minutes > 0)800 {801 $estimated_completion = strtotime($last_comm) + ($estimated_minutes * 60);802 // Positive if ahead, negative number if the task elapsed803 return ceil(($estimated_completion - time()) / 60);804 }805 return 0;806 }807 public static function systems_appearing_down($account_id = null)808 {809 if(isset($_SESSION['AccountID']))810 $account_id = $_SESSION['AccountID'];811 $systems = array();812 $stmt = phoromatic_server::$db->prepare('SELECT SystemID, Title, LastCommunication, CurrentTask FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 ORDER BY LastCommunication DESC');813 $stmt->bindValue(':account_id', $account_id);814 $result = $stmt->execute();815 while($result && $row = $result->fetchArray())816 {817 if(phoromatic_server::system_check_if_down($_SESSION['AccountID'], $row['SystemID'], $row['LastCommunication'], $row['CurrentTask']))818 {819 $systems[] = $row['SystemID'];820 }821 }822 return $systems;823 }824 public static function schedules_today($account_id)825 {826 $schedules = array();827 $show_day_of_week = date('N') - 1;828 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND State = 1 AND (SELECT COUNT(*) FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = phoromatic_schedules.ScheduleID) > 0 AND ActiveOn LIKE :active_day ORDER BY RunAt ASC');829 $stmt->bindValue(':account_id', $account_id);830 $stmt->bindValue(':active_day', '%' . $show_day_of_week . '%');831 $result = $stmt->execute();832 while($result && $row = $result->fetchArray())833 {834 $schedules[] = $row;835 }836 return $schedules;837 }838 public static function schedules_total($account_id)839 {840 $schedules = array();841 $show_day_of_week = date('N') - 1;842 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND State = 1 AND (SELECT COUNT(*) FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = phoromatic_schedules.ScheduleID) > 0 ORDER BY RunAt ASC');843 $stmt->bindValue(':account_id', $account_id);844 $result = $stmt->execute();845 while($result && $row = $result->fetchArray())846 {847 $schedules[] = $row;848 }849 return $schedules;850 }851 public static function benchmark_tickets_today($account_id)852 {853 $tickets = array();854 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_benchmark_tickets WHERE AccountID = :account_id AND State >= 0 AND TicketIssueTime > :time_cutoff ORDER BY TicketIssueTime DESC');855 $stmt->bindValue(':account_id', $account_id);856 $stmt->bindValue(':time_cutoff', (time() - (60 * 60 * 24 * 14)));857 $result = $stmt->execute();858 while($result && $row = $result->fetchArray())859 {860 $tickets[] = $row;861 }862 return $tickets;863 }864 public static function systems_idling($account_id)865 {866 $systems = array();867 $stmt = phoromatic_server::$db->prepare('SELECT SystemID FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 AND CurrentTask LIKE \'%Idling%\' ORDER BY LastCommunication DESC');868 $stmt->bindValue(':account_id', $account_id);869 $result = $stmt->execute();870 while($result && $row = $result->fetchArray())871 {872 $systems[] = $row;873 }874 return $systems;875 }876 public static function systems_shutdown($account_id)877 {878 $systems = array();879 $stmt = phoromatic_server::$db->prepare('SELECT SystemID FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 AND CurrentTask LIKE \'%Shutdown%\' ORDER BY LastCommunication DESC');880 $stmt->bindValue(':account_id', $account_id);881 $result = $stmt->execute();882 while($result && $row = $result->fetchArray())883 {884 $systems[] = $row;885 }886 return $systems;887 }888 public static function systems_running_tests($account_id)889 {890 $systems = array();891 $stmt = phoromatic_server::$db->prepare('SELECT SystemID FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 AND (CurrentTask LIKE \'%Running%\' OR CurrentTask LIKE \'%Installing%\' OR CurrentTask LIKE \'%Benchmark%\') ORDER BY LastCommunication DESC');892 $stmt->bindValue(':account_id', $account_id);893 $result = $stmt->execute();894 while($result && $row = $result->fetchArray())895 {896 $systems[] = $row;897 }898 return $systems;899 }900 public static function systems_total($account_id)901 {902 $systems = array();903 $stmt = phoromatic_server::$db->prepare('SELECT SystemID FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 ORDER BY LastCommunication DESC');904 $stmt->bindValue(':account_id', $account_id);905 $result = $stmt->execute();906 while($result && $row = $result->fetchArray())907 {908 $systems[] = $row;909 }910 return $systems;911 }912 public static function test_result_count_for_test_profile($account_id, $test_profile)913 {914 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(*) As TotalCount FROM phoromatic_results_results WHERE AccountID = :account_id AND TestProfile LIKE :tp');915 $stmt->bindValue(':account_id', $account_id);916 $stmt->bindValue(':tp', $test_profile . '%');917 $result = $stmt->execute();918 if($result && $row = $result->fetchArray())919 {920 return $row['TotalCount'];921 }922 return 0;923 }924 public static function test_result_count_for_test_profiles($account_id)925 {926 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(*) As Count, TestProfile FROM phoromatic_results_results WHERE AccountID = :account_id GROUP BY TestProfile ORDER BY TestProfile ASC');927 $stmt->bindValue(':account_id', $account_id);928 $result = $stmt->execute();929 $tests = array();930 while($result && $row = $result->fetchArray())931 {932 $tests[$row['TestProfile']] = $row['Count'];933 }934 return $tests;935 }936 public static function test_results($account_id, $time_limit = false)937 {938 $results = array();939 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE AccountID = :account_id ORDER BY UploadTime DESC');940 $stmt->bindValue(':account_id', $account_id);941 $result = $stmt->execute();942 while($result && $row = $result->fetchArray())943 {944 if($time_limit != false && strtotime($row['UploadTime']) < $time_limit)945 {946 break;947 }948 $results[] = $row;949 }950 return $results;951 }952 public static function test_results_total($account_id)953 {954 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(*) As ResultCount FROM phoromatic_results WHERE AccountID = :account_id');955 $stmt->bindValue(':account_id', $account_id);956 $result = $stmt->execute();957 if($result && $row = $result->fetchArray())958 {959 return $row['ResultCount'];960 }961 return 0;962 }963 public static function test_results_benchmark_count($account_id)964 {965 $results = array();966 $stmt = phoromatic_server::$db->prepare('SELECT COUNT(*) AS BenchmarkCount FROM phoromatic_results_results WHERE AccountID = :account_id');967 $stmt->bindValue(':account_id', $account_id);968 $result = $stmt->execute();969 if($result && $row = $result->fetchArray())970 {971 return $row['BenchmarkCount'];972 }973 return 0;974 }975 public static function system_check_if_down($account_id, $system_id, $last_communication, $current_task)976 {977 $last_comm = strtotime($last_communication);978 return ((phoromatic_server::system_has_outstanding_jobs($account_id, $system_id, -600) && (($last_comm < (time() - 5400) && stripos($current_task, 'Running') === false) || $last_comm < (time() - 7200) || ($last_comm < (time() - 600) && stripos($current_task, 'Shutdown') !== false))) || ($last_comm < (time() -7200) && (stripos($current_task, 'running') !== false || stripos($current_task, 'setting') !== false))) || $current_task == 'Unknown';979 }980}981if(!is_dir(phoromatic_server::phoromatic_path() . 'accounts'))982{983 mkdir(phoromatic_server::phoromatic_path() . 'accounts');984}985?>...

Full Screen

Full Screen

phoromatic_path

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2phoromatic_server::phoromatic_path('2.php');3require_once('phoromatic.php');4phoromatic_server::phoromatic_path('3.php');5require_once('phoromatic.php');6phoromatic_server::phoromatic_path('4.php');7require_once('phoromatic.php');8phoromatic_server::phoromatic_path('5.php');9require_once('phoromatic.php');10phoromatic_server::phoromatic_path('6.php');11require_once('phoromatic.php');12phoromatic_server::phoromatic_path('7.php');13require_once('phoromatic.php');14phoromatic_server::phoromatic_path('8.php');15require_once('phoromatic.php');16phoromatic_server::phoromatic_path('9.php');17require_once('phoromatic.php');18phoromatic_server::phoromatic_path('10.php');19require_once('phoromatic.php');20phoromatic_server::phoromatic_path('11.php');21require_once('phoromatic.php');22phoromatic_server::phoromatic_path('12.php');23require_once('

Full Screen

Full Screen

phoromatic_path

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$phoromatic_path = phoromatic_server::phoromatic_path();3echo $phoromatic_path;4require_once('phoromatic.php');5$phoromatic_saved_results = phoromatic_server::phoromatic_saved_results();6echo $phoromatic_saved_results;7require_once('phoromatic.php');8$phoromatic_server_id = phoromatic_server::phoromatic_server_id();9echo $phoromatic_server_id;10require_once('phoromatic.php');11$phoromatic_server_name = phoromatic_server::phoromatic_server_name();12echo $phoromatic_server_name;13require_once('phoromatic.php');14$phoromatic_server_url = phoromatic_server::phoromatic_server_url();15echo $phoromatic_server_url;16require_once('phoromatic.php');17$phoromatic_server_version = phoromatic_server::phoromatic_server_version();18echo $phoromatic_server_version;

Full Screen

Full Screen

phoromatic_path

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$phoromatic = new phoromatic_server();3require_once('phoromatic.php');4$phoromatic = new phoromatic_server();5require_once('phoromatic.php');6$phoromatic = new phoromatic_server();7require_once('phoromatic.php');8$phoromatic = new phoromatic_server();9require_once('phoromatic.php');10$phoromatic = new phoromatic_server();11require_once('phoromatic.php');12$phoromatic = new phoromatic_server();13require_once('phoromatic.php');14$phoromatic = new phoromatic_server();

Full Screen

Full Screen

phoromatic_path

Using AI Code Generation

copy

Full Screen

1require_once 'phoromatic_server.php';2$phoromatic_path = phoromatic_server::phoromatic_path();3echo $phoromatic_path;4require_once 'phoromatic_server.php';5$phoromatic_web_path = phoromatic_server::phoromatic_web_path();6echo $phoromatic_web_path;7require_once 'phoromatic_server.php';8$phoromatic_results_path = phoromatic_server::phoromatic_results_path();9echo $phoromatic_results_path;10require_once 'phoromatic_server.php';11$phoromatic_results_web_path = phoromatic_server::phoromatic_results_web_path();12echo $phoromatic_results_web_path;13require_once 'phoromatic_server.php';14$phoromatic_results_web_path = phoromatic_server::phoromatic_results_web_path('user_name');15echo $phoromatic_results_web_path;16require_once 'phoromatic_server.php';

Full Screen

Full Screen

phoromatic_path

Using AI Code Generation

copy

Full Screen

1echo $phoromatic_server->phoromatic_path();2### phoromatic_server::phoromatic_url()3echo $phoromatic_server->phoromatic_url();4### phoromatic_server::phoromatic_version()5echo $phoromatic_server->phoromatic_version();6### phoromatic_server::phoromatic_version_id()7echo $phoromatic_server->phoromatic_version_id();8### phoromatic_server::phoromatic_version_name()9echo $phoromatic_server->phoromatic_version_name();10### phoromatic_server::phoromatic_version_major()

Full Screen

Full Screen

phoromatic_path

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$phoromatic_server = new phoromatic_server();3$phoromatic_server->phoromatic_path('test.txt');4$phoromatic_server = new phoromatic_server();5$phoromatic_server->phoromatic_path('');6$phoromatic_server = new phoromatic_server();7$phoromatic_server->phoromatic_path('data');8$phoromatic_server = new phoromatic_server();9$phoromatic_server->phoromatic_path('data');10$phoromatic_server = new phoromatic_server();11$phoromatic_server->phoromatic_path('data');12$phoromatic_server = new phoromatic_server();13$phoromatic_server->phoromatic_path('data');

Full Screen

Full Screen

phoromatic_path

Using AI Code Generation

copy

Full Screen

1$phoromatic_path = phoromatic_path();2include_once($phoromatic_path . 'phoromatic_server.php');3$phoromatic_server = new phoromatic_server();4$phoromatic_path = phoromatic_path();5include_once($phoromatic_path . 'phoromatic_server.php');6$phoromatic_server = new phoromatic_server();7$phoromatic_path = phoromatic_path();8include_once($phoromatic_path . 'phoromatic_server.php');9$phoromatic_server = new phoromatic_server();10$phoromatic_path = phoromatic_path();11include_once($phoromatic_path . 'phoromatic_server.php');12$phoromatic_server = new phoromatic_server();13$phoromatic_path = phoromatic_path();14include_once($phoromatic_path . 'phoromatic_server.php');

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.

Trigger phoromatic_path code on LambdaTest Cloud Grid

Execute automation tests with phoromatic_path on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

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