public static function submit($shop_id, $shop_key, $host, $t_request) { $process = curl_init($host); $json = json_encode($t_request); Logger::getInstance()->write("Request to {$host}", Logger::DEBUG, get_class()); Logger::getInstance()->write("with Shop Id " . Settings::$shopId . " & Shop key " . Settings::$shopKey, Logger::DEBUG, get_class()); if (!empty($json)) { Logger::getInstance()->write("with message " . $json, Logger::DEBUG, get_class()); } if (!empty($t_request)) { curl_setopt($process, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-type: application/json')); curl_setopt($process, CURLOPT_POST, 1); curl_setopt($process, CURLOPT_POSTFIELDS, $json); } curl_setopt($process, CURLOPT_URL, $host); curl_setopt($process, CURLOPT_USERPWD, Settings::$shopId . ":" . Settings::$shopKey); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($process); $error = curl_error($process); curl_close($process); if ($response === false) { throw new \Exception("cURL error " . $error); } Logger::getInstance()->write("Response {$response}", Logger::DEBUG, get_class()); return $response; }
public function testTerminalLogger() { $config = Config::getInstance(); $config->setValue('log_location', false); $logger = Logger::getInstance(); // $logger->logStatus('Singleton logger should echo this', get_class($this)); }
public function setUp() { parent::setUp(); $this->logger = Logger::getInstance(); $this->DAO = new GroupMySQLDAO(); $this->builders = self::buildData(); }
public function setUp() { parent::setUp(); StreamMessageQueueFactory::$queue = null; $this->logger = Logger::getInstance(); $this->config = Config::getInstance(); }
/** * @return void */ public function shutdownStreams() { $logger = Logger::getInstance('stream_log_location'); $logger->logInfo("in TwitterRealtimePlugin->shutdownStreams()", __METHOD__ . ',' . __LINE__); $stream_master = new StreamMasterCollect(); $stream_master->shutdownStreams(); }
/** * * @param Instance $instance * @return GooglePlusCrawler */ public function __construct($instance, $access_token) { $this->instance = $instance; $this->logger = Logger::getInstance(); $this->access_token = $access_token; $this->api_accessor = new GooglePlusAPIAccessor(); }
/** * * @param Instance $instance * @return FacebookCrawler */ public function __construct($instance, $access_token, $max_crawl_time) { $this->instance = $instance; $this->logger = Logger::getInstance(); $this->access_token = $access_token; $this->max_crawl_time = $max_crawl_time; }
public function setUp() { parent::setUp(); $this->logger = Logger::getInstance(); $r = array('id' => 1, 'network_username' => 'Gina Trapani', 'network_user_id' => '606837591', 'network_viewer_id' => '606837591', 'last_post_id' => '0', 'last_page_fetched_replies' => 0, 'last_page_fetched_tweets' => '0', 'total_posts_in_system' => '0', 'total_replies_in_system' => '0', 'total_follows_in_system' => '0', 'is_archive_loaded_replies' => '0', 'is_archive_loaded_follows' => '0', 'crawler_last_run' => '', 'earliest_reply_in_system' => '', 'avg_replies_per_day' => '2', 'is_public' => '0', 'is_active' => '0', 'network' => 'facebook', 'last_favorite_id' => '0', 'last_unfav_page_checked' => '0', 'last_page_fetched_favorites' => '0', 'owner_favs_in_system' => '0', 'total_posts_by_owner' => 0, 'posts_per_day' => 1, 'posts_per_week' => 1, 'percentage_replies' => 50, 'percentage_links' => 50, 'earliest_post_in_system' => '01-01-2009', 'favorites_profile' => '0'); $this->instance = new Instance($r); }
public function start() { $c = Configurator::getInstance(); $l = Logger::getInstance(); if (isset($c->config['logfile'])) $l->setLogfile($c->config['logfile']); if ((!isset($c->config['debugmode'])) || ($c->config['debugmode'] == "false")) $l->debug(FALSE); elseif (is_numeric($c->config['debugmode'])) $l->debug($c->config['debugmode']); elseif ($c->config['debugmode'] == "true") $l->debug(3); else $l->debug(FALSE); if (isset($c->config['die'])) _die("Icarus: read the config file!"); $this->loadClients(); $this->loadServers(); $this->running = TRUE; $SH = SocketHandler::getInstance(); $SH->loop(); }
public function run() { if (!isset($this->cronToken)) { return; } if ($this->cronToken === "") { return; } if ($this->cronToken !== Config::getInstance()->getCronToken()) { return; } $database = Database::getInstance(); if (!$database->isConnected()) { return; } $site = Site::getInstance(); if (!$site->doesCronNeedToRun()) { return; } if ($site->isCronRunning()) { return; } $site->setCronRunning(true); $site->setLastCronRun(new DateTime()); $hookEngine = HookEngine::getInstance(); $hookEngine->runAction('cronRun'); $logger = Logger::getInstance(); $logger->logIt(new LogEntry(1, logEntryType::info, "Cron ran.", 0, new DateTime())); $site->setCronRunning(false); }
/** * * @return string parsed logger output */ protected function logger() { if (!(isset($this->config['logger']) && !$this->config['logger'])) { return '<div class="container">' . Logger::getInstance()->toString() . '</div>'; } return ''; }
public function run() { // Set up IRC connection $c = new IRCConnection(new IRCUser($this->config->readString('irc', 'nickname', 'KrokerdilBot'), $this->config->readString('irc', 'realname', NULL), $this->config->readString('irc', 'username', NULL), $this->config->readString('irc', 'hostname', 'localhost')), $this->config->readString('irc', 'server')); // Reset socket timeout to a better value for IRC (this // prevents IOExceptions being thrown over and over again) $c->sock->setTimeout(120); // Check if debug is wanted and *where* it's wanted if ($this->debug) { $c->setTrace(Logger::getInstance()->getCategory()->withAppender(new FileAppender('php://stderr'))); } // Connect and run the bot $c->addListener(new KrokerdilBotListener($this->config)); while (1) { try { $c->open(); $c->run(); $c->close(); } catch (IOException $e) { $e->printStackTrace(); // Fall through } // Wait for 10 seconds and then try to reconnect sleep(10); } }
function __construct($agency, $xml) { $this->xml = $xml; $this->agency = $agency; $this->logger = Logger::getInstance(); $this->appConfig = Configuration::getAppConfig(); }
function crawl() { global $db; global $conn; $config = Config::getInstance(); $api_key = $config->getValue('flickr_api_key'); if (isset($api_key) && $api_key != '') { $logger = Logger::getInstance(); $fa = new FlickrAPIAccessor($api_key); $ldao = DAOFactory::getDAO('LinkDAO'); $flickrlinkstoexpand = $ldao->getLinksToExpandByURL('http://flic.kr/'); if (count($flickrlinkstoexpand > 0)) { $logger->logStatus(count($flickrlinkstoexpand) . " Flickr links to expand", "Flickr Plugin"); } else { $logger->logStatus("No Flickr links to expand", "Flickr Plugin"); } foreach ($flickrlinkstoexpand as $fl) { $eurl = $fa->getFlickrPhotoSource($fl); if ($eurl["expanded_url"] != '') { $ldao->saveExpandedUrl($fl, $eurl["expanded_url"], '', 1); } elseif ($eurl["error"] != '') { $ldao->saveExpansionError($fl, $eurl["error"]); } } $logger->close(); # Close logging } }
public function setUp() { parent::setUp(); $this->logger = Logger::getInstance(); $r = array('id' => 1, 'network_username' => 'Gina Trapani', 'network_user_id' => '113612142759476883204', 'network_viewer_id' => '113612142759476883204', 'last_post_id' => '0', 'total_posts_in_system' => '0', 'total_replies_in_system' => '0', 'total_follows_in_system' => '0', 'is_archive_loaded_replies' => '0', 'is_archive_loaded_follows' => '0', 'crawler_last_run' => '', 'earliest_reply_in_system' => '', 'avg_replies_per_day' => '2', 'is_public' => '0', 'is_active' => '0', 'network' => 'google+', 'last_favorite_id' => '0', 'owner_favs_in_system' => '0', 'total_posts_by_owner' => 0, 'posts_per_day' => 1, 'posts_per_week' => 1, 'percentage_replies' => 50, 'percentage_links' => 50, 'earliest_post_in_system' => '2009-01-01 13:48:05', 'favorites_profile' => '0'); $this->profile1_instance = new Instance($r); }
public function setUp() { parent::setUp(); $this->logger = Logger::getInstance(); $r = array('id' => 1, 'network_username' => 'Gina Trapani', 'network_user_id' => '606837591', 'network_viewer_id' => '606837591', 'last_status_id' => '0', 'last_page_fetched_replies' => 0, 'last_page_fetched_tweets' => '0', 'total_posts_in_system' => '0', 'total_replies_in_system' => '0', 'total_follows_in_system' => '0', 'total_users_in_system' => '0', 'is_archive_loaded_replies' => '0', 'is_archive_loaded_follows' => '0', 'crawler_last_run' => '', 'earliest_reply_in_system' => '', 'api_calls_to_leave_unmade_per_minute' => 2, 'avg_replies_per_day' => '2', 'is_public' => '0', 'is_active' => '0', 'network' => 'facebook'); $this->instance = new Instance($r); }
/** * * @param Instance $instance * @return FacebookCrawler */ public function __construct($instance, $access_token) { $this->instance = $instance; $this->logger = Logger::getInstance(); $this->logger->setUsername($instance->network_username); $this->access_token = $access_token; }
public function crawl() { $config = Config::getInstance(); $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO'); $options = $plugin_option_dao->getOptionsHash('flickrthumbnails', true); $api_key = $options['flickr_api_key']->option_value; if (isset($api_key) && $api_key != '') { $logger = Logger::getInstance(); $fa = new FlickrAPIAccessor($api_key); $ldao = DAOFactory::getDAO('LinkDAO'); $flickrlinkstoexpand = $ldao->getLinksToExpandByURL('http://flic.kr/'); if (count($flickrlinkstoexpand > 0)) { $logger->logStatus(count($flickrlinkstoexpand) . " Flickr links to expand", "Flickr Plugin"); } else { $logger->logStatus("No Flickr links to expand", "Flickr Plugin"); } foreach ($flickrlinkstoexpand as $fl) { $eurl = $fa->getFlickrPhotoSource($fl); if ($eurl["expanded_url"] != '') { $ldao->saveExpandedUrl($fl, $eurl["expanded_url"], '', 1); } elseif ($eurl["error"] != '') { $ldao->saveExpansionError($fl, $eurl["error"]); } } $logger->close(); # Close logging } }
public function processTransaction($data) { $log = Logger::getInstance(); $log->LogDebug("process transaction stripe - "); $result = new stdClass(); $result->status = PAYMENT_ERROR; $result->payment_status = PAYMENT_STATUS_FAILURE; Stripe::setApiKey($this->SECRET_KEY); $result->amount = $data->cost > 0 ? $data->cost : $data->total; $data->stripeToken = JRequest::getVar('stripeToken', null); $log->LogDebug("process transaction stripe - token - " . $data->stripeToken); try { if (!isset($data->stripeToken)) { $result->error_message = "There was an error in processing your request. Please try again later."; $log->LogDebug("The Stripe Token was not generated correctly"); } else { Stripe_Charge::create(array("amount" => $result->amount, "currency" => strtolower($data->reservationData->hotel->hotel_currency), "card" => $data->stripeToken)); $result->status = PAYMENT_SUCCESS; $result->payment_status = PAYMENT_STATUS_PAID; } } catch (Exception $e) { $log->LogDebug($e->getMessage()); $result->error_message = $e->getMessage(); } $result->transaction_id = 0; $result->payment_date = date("Y-m-d"); $result->response_code = 0; $result->confirmation_id = $data->confirmation_id; $result->processor_type = $this->type; return $result; }
public static function reserveRoom($hotelId, $reservedItem, $current) { $log = Logger::getInstance(JPATH_COMPONENT . "/logs/site-log-" . date("d-m-Y") . '.log', 1); $log->LogDebug("reserveRoom hotelId= {$hotelId}, reservedItem = {$reservedItem}, current = {$current}"); $session = self::getJoomlaSession(); $userData = $_SESSION['userData']; //dmp($userData->reservedItems); //dmp($reservedItem); //remove all rooms that have same current $result = array(); foreach ($userData->reservedItems as $rsvItem) { $values = explode("|", $rsvItem); if ($values[2] != $current) { $result[] = $rsvItem; } } $userData->reservedItems = $result; //add new room $reservedItem = $reservedItem . "|" . $current; $userData->reservedItems[] = $reservedItem; $userData->hotelId = $hotelId; //dmp($userData->reservedItems); $log->LogDebug("Reserved items: " . serialize($userData->reservedItems)); $_SESSION['userData'] = $userData; return $reservedItem; }
/** * Constructor * @param str $access_token * @return InstagramAPIAccessor */ public function __construct($access_token, $max_api_calls = 2500) { $this->max_api_calls = $max_api_calls; $this->instagram = new Instagram\Instagram($access_token); $this->current_user = $this->instagram->getCurrentUser(); $this->logger = Logger::getInstance(); }
/** * handle admin overview request */ private function handleAdminOverview() { $view = ViewManager::getInstance(); $log = Logger::getInstance(); $logfile = $log->getLogFile(); if ($view->isType(self::VIEW_FILE)) { $request = Request::getInstance(); $extension = ".log"; $filename = $request->getDomain() . $extension; header("Content-type: application/{$extension}"); header("Content-Length: " . filesize($logfile)); // stupid bastards of microsnob: ie does not like attachment option $browser = $request->getValue('HTTP_USER_AGENT', Request::SERVER); if (strstr($browser, 'MSIE')) { header("Content-Disposition: filename=\"{$filename}\""); } else { header("Content-Disposition: attachment; filename=\"{$filename}\""); } readfile($logfile); exit; } else { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setVariable('logfile', nl2br(file_get_contents($logfile)), false); $url = new Url(true); $url->setParameter($view->getUrlId(), self::VIEW_FILE); $template->setVariable('href_export', $url->getUrl(true), false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; } }
/** * Start server * * @param string[] args */ public static function main(array $args) { $stor = new TestingStorage(); $stor->add(new TestingCollection('/', $stor)); $stor->add(new TestingCollection('/.trash', $stor)); $stor->add(new TestingElement('/.trash/do-not-remove.txt', $stor)); $stor->add(new TestingCollection('/htdocs', $stor)); $stor->add(new TestingElement('/htdocs/file with whitespaces.html', $stor)); $stor->add(new TestingElement('/htdocs/index.html', $stor, "<html/>\n")); $stor->add(new TestingCollection('/outer', $stor)); $stor->add(new TestingCollection('/outer/inner', $stor)); $stor->add(new TestingElement('/outer/inner/index.html', $stor)); $auth = newinstance('lang.Object', array(), '{ public function authenticate($user, $password) { return ("testtest" == $user.$password); } }'); $protocol = newinstance('peer.ftp.server.FtpProtocol', array($stor, $auth), '{ public function onShutdown($socket, $params) { $this->answer($socket, 200, "Shutting down"); $this->server->terminate= TRUE; } }'); isset($args[0]) && $protocol->setTrace(Logger::getInstance()->getCategory()->withAppender(new FileAppender($args[0]))); $s = new Server('127.0.0.1', 0); try { $s->setProtocol($protocol); $s->init(); Console::writeLinef('+ Service %s:%d', $s->socket->host, $s->socket->port); $s->service(); Console::writeLine('+ Done'); } catch (Throwable $e) { Console::writeLine('- ', $e->getMessage()); } }
public function crawl() { $logger = Logger::getInstance(); $config = Config::getInstance(); $instance_dao = DAOFactory::getDAO('InstanceDAO'); $owner_instance_dao = DAOFactory::getDAO('OwnerInstanceDAO'); $owner_dao = DAOFactory::getDAO('OwnerDAO'); $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO'); $options = $plugin_option_dao->getOptionsHash('googleplus', true); //get cached $current_owner = $owner_dao->getByEmail(Session::getLoggedInUser()); //crawl Google+ users $instances = $instance_dao->getActiveInstancesStalestFirstForOwnerByNetworkNoAuthError($current_owner, 'google+'); if (isset($options['google_plus_client_id']->option_value) && isset($options['google_plus_client_secret']->option_value)) { foreach ($instances as $instance) { $logger->setUsername(ucwords($instance->network) . ' | ' . $instance->network_username); $logger->logUserSuccess("Starting to collect data for " . $instance->network_username . "'s " . ucwords($instance->network), __METHOD__ . ',' . __LINE__); $tokens = $owner_instance_dao->getOAuthTokens($instance->id); $access_token = $tokens['oauth_access_token']; $refresh_token = $tokens['oauth_access_token_secret']; $instance_dao->updateLastRun($instance->id); $google_plus_crawler = new GooglePlusCrawler($instance, $access_token); $dashboard_module_cacher = new DashboardModuleCacher($instance); try { $google_plus_crawler->initializeInstanceUser($options['google_plus_client_id']->option_value, $options['google_plus_client_secret']->option_value, $access_token, $refresh_token, $current_owner->id); $google_plus_crawler->fetchInstanceUserPosts(); } catch (Exception $e) { $logger->logUserError('EXCEPTION: ' . $e->getMessage(), __METHOD__ . ',' . __LINE__); } $dashboard_module_cacher->cacheDashboardModules(); $instance_dao->save($google_plus_crawler->instance, 0, $logger); $logger->logUserSuccess("Finished collecting data for " . $instance->network_username . "'s " . ucwords($instance->network), __METHOD__ . ',' . __LINE__); } } }
protected function _buildRequestMessage() { $request = array('checkout' => array('version' => self::$version, 'transaction_type' => $this->getTransactionType(), 'order' => array('amount' => $this->money->getCents(), 'currency' => $this->money->getCurrency(), 'description' => $this->getDescription(), 'tracking_id' => $this->getTrackingId()), 'settings' => array('notification_url' => $this->getNotificationUrl(), 'success_url' => $this->getSuccessUrl(), 'decline_url' => $this->getDeclineUrl(), 'fail_url' => $this->getFailUrl(), 'cancel_url' => $this->getCancelUrl(), 'language' => $this->getLanguage(), 'customer_fields' => array('read_only' => $this->getReadonlyFields(), 'hidden' => $this->getHiddenFields())), 'customer' => array('email' => $this->customer->getEmail(), 'first_name' => $this->customer->getFirstName(), 'last_name' => $this->customer->getLastName(), 'country' => $this->customer->getCountry(), 'city' => $this->customer->getCity(), 'state' => $this->customer->getState(), 'zip' => $this->customer->getZip(), 'address' => $this->customer->getAddress(), 'phone' => $this->customer->getPhone(), 'birth_date' => $this->customer->getBirthDate()))); $request['checkout']['payment_method'] = $this->_getPaymentMethods(); Logger::getInstance()->write($request, Logger::DEBUG, get_class() . '::' . __FUNCTION__); return $request; }
public function processTransaction($data) { $log = Logger::getInstance(); $log->LogDebug("process transaction stripe - "); if ($_POST) { Stripe::setApiKey($this->SECRET_KEY); $error = ''; $success = ''; try { if (!isset($_POST['stripeToken'])) { throw new Exception("The Stripe Token was not generated correctly"); } Stripe_Charge::create(array("amount" => 1000, "currency" => "usd", "card" => $_POST['stripeToken'])); $success = 'Your payment was successful.'; } catch (Exception $e) { $error = $e->getMessage(); } } $log->LogDebug("process response authorize - " . serialize($response)); if (isset($response->approved) && $response->approved == 1) { $result->status = PAYMENT_SUCCESS; $result->payment_status = PAYMENT_STATUS_PAID; } else { $result->status = PAYMENT_ERROR; $result->payment_status = PAYMENT_STATUS_FAILURE; $result->error_message = $response->error_message; } $result->transaction_id = 0; $result->payment_date = date("Y-m-d"); $result->response_code = $response->approved; $result->confirmation_id = $data->confirmation_id; $result->processor_type = $this->type; return $result; }
public function setUp() { parent::setUp(); $this->builders = self::buildData(); $this->logger = Logger::getInstance(); $this->dao = new StreamDataMySQLDAO(); }
/** * Deletes old versions that were never active */ public static function deleteOldVersions() { $config = Configuration::getAppConfig(); $dbObj = DBPool::getInstance(); $maxVersionCount = $config['max version count']; $minVersionCount = $config['min version count']; if ($maxVersionCount <= $dbObj->get_var("SELECT COUNT(1) FROM version WHERE active=false AND was_active=false")) { $oldVersionsArray = array(); $oldVersions = $dbObj->get_results("SELECT id FROM version\n WHERE active=false AND was_active=false\n ORDER by id\n LIMIT " . ($maxVersionCount - $minVersionCount)); foreach ($oldVersions as $o) { $oldVersionsArray[] = $o->id; } if (count($oldVersionsArray) > 0) { $query = "DELETE FROM version WHERE id IN (" . implode(",", $oldVersionsArray) . ")"; $dbObj->query($query); //Delete data from the disk foreach ($oldVersionsArray as $version) { $dataDirPath = Configuration::getBasePath() . "www/data/" . Util::XML_FILE . "/{$version}"; $imageDirPath = Configuration::getBasePath() . "www/data/" . Util::IMAGE_FILE . "/{$version}"; $changeDirPath = Configuration::getBasePath() . "www/data/" . Util::CHANGE_FILE . "/{$version}"; Util::deleteAll($dataDirPath); Util::deleteAll($imageDirPath); Util::deleteAll($changeDirPath); } $logger = Logger::getInstance(); $logStr = "Deleted versions " . implode(",", $oldVersionsArray); $logger->log($logStr, Logger::INFO, Version::PACKAGE); } } }
public function setUp() { parent::setUp(); $this->logger = Logger::getInstance(); $this->config = Config::getInstance(); $this->table_prefix = $this->config->getValue('table_prefix'); }
static function getPaged($start, $direction, $limit, $filters) { $mysqli = MySQL\Connection::getInstance()->getHandle(); //sanitize input settype($start, "integer"); settype($limit, "integer"); $direction = $mysqli->real_escape_string($direction); $sql = " select a.*,l.name as user_name from sc_comment a,sc_login l "; $q = new MySQL\Query($mysqli); $q->setAlias("com\\indigloo\\sc\\model\\Comment", "a"); //raw condition $q->addCondition("l.id = a.login_id"); $q->filter($filters); $sql .= $q->get(); $sql .= $q->getPagination($start, $direction, "a.id", $limit); if (Config::getInstance()->is_debug()) { Logger::getInstance()->debug("sql => {$sql} \n"); } $rows = MySQL\Helper::fetchRows($mysqli, $sql); //reverse rows for 'before' direction if ($direction == 'before') { $results = array_reverse($rows); return $results; } return $rows; }