<?php global $user; tzbase_include_proto_classes(); $account = user_load(array('name' => 'Johan Heander')); if ($account) { TZIntellitimeBot::destroy_session_data($account->intellitime_session_data); user_save($account, array('intellitime_session_data' => NULL)); } // Login and logout to refresh cookie $form_state = array('values' => array('name' => 'Johan Heander', 'pass' => '0733623516', 'op' => t('Log in'))); drupal_execute('user_login', $form_state); // Destroy the current session: session_destroy(); // Only variables can be passed by reference workaround. $null = NULL; user_module_invoke('logout', $null, $user); // Load the anonymous user $user = drupal_anonymous_user(); tzintellitime_sync_synchronize_users(); TZIntellitimeBot::destroy_session_data($account->intellitime_session_data);
<?php $intelli_url = "http://my2.intelliplan.se/IntelliplanWeb/v2005/Portal/Login.aspx?Gw27UDttLdgps9TM4HqqoQ%3d%3d"; $bot = new TZIntellitimeBot($intelli_url); $ok = $bot->login("Johan Heander", "0733623516"); if (!$ok) { echo "Login failed!\n"; exit; } $result = $bot->load_week(); print_r($result); $reports = $result['reports']; // Change report[3] and update it again $reports[1]->begin = "10:10"; $reports[1]->end = "16:32"; $reports[1]->state = TZIntellitimeReport::STATE_OPEN; $reports[1]->comment = "Slapsgiving"; print_r($bot->update_report($reports[1]));
<?php /** * Script meant for fast testing of intellitime login code. It should be run with "drush scr login.php". * It boots drupal, inserts our intellitime module, and tries to login to intellitime using that module. */ //$intelli_url = "http://my2.intelliplan.se/IntelliplanWeb/v2005/Portal/Login.aspx?Gw27UDttLdgps9TM4HqqoQ%3d%3d"; $intelli_url = "http://localhost/IntelliplanWeb/Portal/Login.aspx"; $bot = new TZIntellitimeBot($intelli_url); $ok = $bot->login("test user", "test password"); if ($ok) { echo "Login successful!\n"; } else { echo "Login failed!\n"; }
<?php $intelli_url = "https://my2.intelliplan.se/IntelliplanWeb/v2005/Portal/Login.aspx?Gw27UDttLdgps9TM4HqqoQ%3d%3d"; $bot = new TZIntellitimeBot($intelli_url); $ok = $bot->login("Johan Heander", "0733623516"); if (!$ok) { echo "Login failed!\n"; exit; } $session_data = $bot->get_session_data(); print_r($session_data); unset($bot); readfile($session_data['cookiejar']);
<?php $date = date_make_date('now'); if ($_SERVER['argc'] == 5) { $date = date_make_date($_SERVER['argv'][4]); } $intelli = array('url' => "https://my2.intelliplan.eu/IntelliplanWeb/v2005/Portal/Login.aspx?Gw27UDttLdgps9TM4HqqoQ%3d%3d", 'user' => "Johan Heander", 'pass' => "0733623516"); /* $intelli = array( 'url' => "http://localhost/demo/v2005/Portal/Login.aspx?Gw27UDttLdgps9TM4HqqoQ%3d%3d", 'user' => "test user", 'pass' => "test password", );*/ $start_time = microtime(TRUE); $bot = new TZIntellitimeBot($intelli['url']); if ($bot->login($intelli['user'], $intelli['pass'])) { $data = $bot->load_week($date); print_r($data); } else { print 'Login failed!'; } $stop_time = microtime(TRUE); print "\nDuration: " . ($stop_time - $start_time) . "\n";
require_once dirname(__FILE__) . '/../tzintellitime.class.inc'; $date = date_make_date('now'); if ($_SERVER['argc'] == 5) { $date = date_make_date($_SERVER['argv'][4]); } $intelli_url = "http://my2.intelliplan.se/IntelliplanWeb/v2005/Portal/Login.aspx?Gw27UDttLdgps9TM4HqqoQ%3d%3d"; // Look somewhere within one hour $highest_success = 0; $lowest_failure = 3600; $attempts = 0; // Precision 30 seconds while ($lowest_failure - $highest_success > 30) { $next_delay = round(($highest_success + $lowest_failure) / 2); print "Starting attempt for {$next_delay} seconds\n"; $bot = new TZIntellitimeBot($intelli_url); $ok = $bot->login("Johan Heander", "0733623516"); if (!$ok) { echo "Login failed!\n"; break; } print " Login OK, starting sleep ... "; sleep($next_delay); try { $bot->load_week($date); print "session still alive, raising bar!\n"; $highest_success = $next_delay; } catch (TZAuthenticationFailureException $e) { print "session died, lowering bar!\n"; $lowest_failure = $next_delay; }