本文整理汇总了PHP中SS_Log类的典型用法代码示例。如果您正苦于以下问题:PHP SS_Log类的具体用法?PHP SS_Log怎么用?PHP SS_Log使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SS_Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: placeOrder
public function placeOrder(SS_HTTPRequest $request)
{
$eventbrite_event_header = $request->getHeader('X-Eventbrite-Event');
if (!$eventbrite_event_header) {
return $this->httpError(403);
}
if ($eventbrite_event_header !== 'order.placed') {
return $this->httpError(403);
}
if (!$this->isJson()) {
return $this->httpError(403);
}
$json_request = $this->getJsonRequest();
if (!isset($json_request['config']) || !isset($json_request['api_url'])) {
return $this->httpError(403);
}
$config = $json_request['config'];
if (!isset($config['action']) || $config['action'] !== 'order.placed') {
return $this->httpError(403);
}
$current_local_url = Controller::join_links(Director::absoluteBaseURL(), $request->getURL());
if (!isset($config['endpoint_url']) || $config['endpoint_url'] !== $current_local_url) {
return $this->httpError(403);
}
try {
$this->manager->registerEvent('ORDER_PLACED', $json_request['api_url']);
} catch (Exception $ex) {
SS_Log::log($ex->getMessage(), SS_Log::ERR);
return $this->httpError(500);
}
return true;
}
示例2: InstaTagMedia
public function InstaTagMedia($tag = false, $num = false, $shuffle = true)
{
$instagram = new Instagram(array('apiKey' => $this->InstagramApiKey, 'apiSecret' => $this->InstagramApiSecret, 'apiCallback' => $this->InstagramApiCallback));
$media = false;
$output = false;
$out = array();
if (!$tag) {
$tag = $this->InstagramSearchTerm;
}
if (!$num) {
$num = $this->InstagramItemsCount;
}
try {
$media = $instagram->getTagMedia($tag, 50);
} catch (Exception $e) {
SS_Log::log(new Exception(print_r($e, true)), SS_Log::ERR);
}
if (is_object($media) && isset($media->data)) {
foreach ($media->data as $data) {
if (is_object($data)) {
$item = array('caption' => $data->caption ? $data->caption->text : "", 'thumb' => $data->images->thumbnail->url, 'image' => $data->images->standard_resolution->url, 'username' => $data->user->username);
array_push($out, $item);
}
}
if ($shuffle) {
shuffle($out);
}
$output = ArrayList::create($out);
$output = $output->limit($num);
}
return $output;
}
示例3: stageChildren
public function stageChildren($showAll = false)
{
$children = new ArrayList();
$repo = $this->source->getRemoteRepository();
try {
if ($repo->isConnected()) {
$ssId = $this->getSS_ID();
if (!$ssId) {
$ssId = '0';
}
$kids = $repo->getChildren(array('ClassName' => ClassInfo::baseDataClass($this->getType()), 'ParentID' => $this->getSS_ID()));
if (!$kids) {
throw new Exception("No kids and null object returned for children of " . $this->getSS_ID());
}
// Even though it returns actual dataobjects, we need to wrap them for sanity and safety's sake
foreach ($kids as $childItem) {
$item = $this->source->getObject($childItem);
$children->push($item);
}
}
} catch (Exception $fre) {
SS_Log::log($fre, SS_Log::WARN);
return $children;
}
return $children;
}
开发者ID:helpfulrobot,项目名称:silverstripe-australia-silverstripe-connector,代码行数:26,代码来源:SilverStripeContentItem.php
示例4: send
/** Send the email out to the Recipient */
public function send($newsletter = null, $recipient = null)
{
// fetch from database again to make sure the sent flag is not set yet
if (!$this->ID || self::get()->byID($this->ID)->Status != 'Sent') {
if (empty($newsletter)) {
$newsletter = $this->Newsletter();
}
if (empty($recipient)) {
$recipient = $this->Recipient();
}
//check recipient not blacklisted and verified
if ($recipient && empty($recipient->Blacklisted) && !empty($recipient->Verified)) {
$email = new NewsLetterEmail($newsletter, $recipient);
if (!empty($newsletter->ReplyTo)) {
$email->addCustomHeader('Reply-To', $newsletter->ReplyTo);
}
$success = $email->send();
if ($success) {
$this->Status = 'Sent';
$recipient->ReceivedCount = $recipient->ReceivedCount + 1;
} else {
$this->Status = 'Failed';
$recipient->BouncedCount = $recipient->BouncedCount + 1;
}
$recipient->write();
} else {
$this->Status = 'BlackListed';
}
$this->write();
} else {
SS_Log::log(new Exception("prevented sending of SendRecipientQueue #{$this->ID} because it has already been sent"), SS_Log::ERR);
}
}
示例5: process
public function process()
{
$post = $this->getObject();
if ($post) {
$author = $post->Owner();
$balance = $author->Balance;
if (self::$api_key && $post->Content != self::SPAM_CONTENT) {
require_once Director::baseFolder() . '/microblog/thirdparty/defensio/Defensio.php';
$defensio = new Defensio(self::$api_key);
$document = array('type' => 'comment', 'content' => $post->Content, 'platform' => 'silverstripe_microblog', 'client' => 'MicroBlog Defensio-PHP | 0.1 | Marcus Nyeholt | marcus@silverstripe.com.au', 'async' => 'false');
try {
$result = $defensio->postDocument($document);
if ($result && isset($result[1])) {
if ($result[1]->allow == 'false') {
$post->Content = self::SPAM_CONTENT;
$post->Down += self::SPAM_DOWN;
$post->write();
$author->Down += self::SPAM_DOWN;
$author->write();
}
}
} catch (Exception $e) {
SS_Log::log($e, SS_Log::WARN);
}
}
if ($post->Content != self::SPAM_CONTENT) {
$post->analyseContent();
$post->write();
}
}
$this->isComplete = true;
}
示例6: getLocationsByDay
public function getLocationsByDay(SS_HTTPRequest $request)
{
try {
$query_string = $request->getVars();
$summit_id = intval($request->param('SUMMIT_ID'));
$day = strtolower(Convert::raw2sql($query_string['day']));
$summit = $this->summit_repository->getById($summit_id);
if (is_null($summit)) {
throw new NotFoundEntityException('Summit', sprintf(' id %s', $summit_id));
}
if (!$summit->isDayBelongs($day)) {
throw new EntityValidationException(sprintf('day %s does not belongs to summit id %s', $day, $summit_id));
}
$response = array('day' => $day, 'summit_id' => intval($summit_id), 'locations' => array());
foreach ($summit->getTopVenues() as $venue) {
$class_name = $venue->ClassName;
if ($class_name != 'SummitVenue' && $class_name != 'SummitExternalLocation' && $class_name != 'SummitHotel') {
continue;
}
$count = $summit->getPublishedEventsCountByDateLocation($day, $venue);
array_push($response['locations'], array('id' => intval($venue->ID), 'events_count' => intval($count)));
if ($class_name == 'SummitVenue') {
foreach ($venue->Rooms() as $room) {
$count = $summit->getPublishedEventsCountByDateLocation($day, $room);
array_push($response['locations'], array('id' => intval($room->ID), 'events_count' => intval($count)));
}
}
}
return $this->ok($response);
} catch (Exception $ex) {
SS_Log::log($ex->getMessage(), SS_Log::ERR);
return $this->serverError();
}
}
示例7: regenerateToken
/**
* Attempt to regenerate the current security token.
*/
public function regenerateToken()
{
// Restrict this functionality to administrators.
$user = Member::currentUserID();
if (Permission::checkMember($user, 'ADMIN')) {
// Attempt to create a random hash.
$regeneration = $this->service->generateHash();
if ($regeneration) {
// Instantiate the new security token.
$token = APIwesomeToken::create();
$token->Hash = $regeneration['hash'];
$token->AdministratorID = $user;
$token->write();
// Temporarily use the session to display the new security token key.
Session::set('APIwesomeToken', "{$regeneration['key']}:{$regeneration['salt']}");
} else {
// Log the failed security token regeneration.
SS_Log::log('APIwesome security token regeneration failed.', SS_Log::ERR);
Session::set('APIwesomeToken', -1);
}
// Determine where the request came from.
$from = $this->getRequest()->getVar('from');
$redirect = $from ? $from : 'admin/json-xml/';
return $this->redirect($redirect);
} else {
return $this->httpError(404);
}
}
示例8: sendToUser
/**
* Send a notification directly to a single user
*
* @param SystemNotification $notification
* @param string $email
* @param array $data
*/
public function sendToUser($notification, $context, $user, $data)
{
$subject = $notification->format($notification->Title, $context, $user, $data);
if (Config::inst()->get('SystemNotification', 'html_notifications')) {
$message = $notification->format($notification->NotificationContent(), $context, $user, $data);
} else {
$message = $notification->format(nl2br($notification->NotificationContent()), $context, $user, $data);
}
if ($template = $notification->getTemplate()) {
$templateData = $notification->getTemplateData($context, $user, $data);
$templateData->setField('Body', $message);
try {
$body = $templateData->renderWith($template);
} catch (Exception $e) {
$body = $message;
}
} else {
$body = $message;
}
$from = $this->config()->get('send_notifications_from');
$to = $user->Email;
if (!$to && method_exists($user, 'getEmailAddress')) {
$to = $user->getEmailAddress();
}
// log
$message = "Sending {$subject} to {$to}";
SS_Log::log($message, SS_Log::NOTICE);
// send
$email = new Email($from, $to, $subject);
$email->setBody($body);
$this->extend('onBeforeSendToUser', $email);
$email->send();
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-notifications,代码行数:40,代码来源:EmailNotificationSender.php
示例9: StartSurvey
function StartSurvey($data, $form)
{
try {
$data = SQLDataCleaner::clean($data);
$data['MembershipType'] = 'community';
Session::set("FormInfo.{$form->FormName()}.data", $data);
$profile_page = EditProfilePage::get()->first();
$member = $this->member_manager->registerMobile($data, new MemberRegistrationSenderService());
//Get profile page
if (!is_null($profile_page)) {
//Redirect to profile page with success message
Session::clear("FormInfo.{$form->FormName()}.data");
$request = Controller::curr()->getRequest();
$back_url = $request->postVar('BackURL');
$link = $profile_page->Link('?success=1');
if (!empty($back_url)) {
$link .= "&BackURL=" . $back_url;
}
return OpenStackIdCommon::loginMember($member, $link);
}
} catch (EntityValidationException $ex1) {
Form::messageForForm($form->FormName(), $ex1->getMessage(), 'bad');
//Return back to form
SS_Log::log($ex1->getMessage(), SS_Log::WARN);
return Controller::curr()->redirectBack();
} catch (Exception $ex) {
Form::messageForForm($form->FormName(), "There was an error with your request, please contact your admin.", 'bad');
//Return back to form
SS_Log::log($ex->getMessage(), SS_Log::ERR);
return Controller::curr()->redirectBack();
}
}
示例10: addressFromIP
protected function addressFromIP($ip)
{
$geocoder = AddressGeocoding::get_geocoder();
$geodata = array();
try {
if ($ip) {
$geodata = $geocoder->geocode($ip)->toArray();
}
} catch (Exception $e) {
SS_Log::log($e, SS_Log::ERR);
}
$geodata = array_filter($geodata);
$datamap = array('Country' => 'countryCode', 'County' => 'county', 'State' => 'region', 'PostalCode' => 'zipcode', 'Latitude' => 'latitude', 'Longitude' => 'longitude');
$mappeddata = array();
foreach ($datamap as $addressfield => $geofield) {
if (is_array($geofield)) {
if ($data = implode(" ", array_intersect_key($geodata, array_combine($geofield, $geofield)))) {
$mappeddata[$addressfield] = $data;
}
} elseif (isset($geodata[$geofield])) {
$mappeddata[$addressfield] = $geodata[$geofield];
}
}
return $mappeddata;
}
示例11: storeThemeFile
/**
* Store the contents of a folder on a CDN.
*
* If processReferences is set, relative URL references are attempted to be
* detected and stored remotely as well, with the file to be stored rewritten
* to refer to the CDN value. This really is only useful for CSS
*
* @param string $folder
* @param boolean $processReferences
*/
public function storeThemeFile($toCdn, $file, $forceUpdate = false, $processReferences = false)
{
$mtime = @filemtime($file);
$relativeName = self::CDN_THEME_PREFIX . '/' . $mtime . '/' . trim(str_replace(Director::baseFolder(), '', $file), '/');
if (!$forceUpdate) {
// see if the file already exists, if not we do NOT do an update
$reader = $this->contentService->findReaderFor($toCdn, $relativeName);
if ($reader && $reader->exists()) {
return $reader->getURL();
}
}
$clear = false;
if ($processReferences) {
$clear = true;
$file = $this->processFileReferences($toCdn, $file, $forceUpdate);
}
// otherwise, lets get a content writer
$writer = $this->contentService->getWriter($toCdn);
try {
$writer->write($file, $relativeName);
} catch (Exception $e) {
SS_Log::log($e, SS_Log::WARN);
}
if ($clear && strpos($file, '.cdn') > 0) {
@unlink($file);
}
$id = $writer->getContentId();
return $writer->getReader()->getURL();
}
示例12: run
/**
* @return void
*/
public function run()
{
try {
$init_time = time();
$processed_events = 0;
$events = array();
$current_summit = Summit::get_active();
if ($current_summit) {
$events = $current_summit->getSchedule();
}
foreach ($events as $event) {
$processed_events++;
$rate_sum = 0;
$rate_count = 0;
foreach ($event->Feedback as $feedback) {
$rate_count++;
$rate_sum = $rate_sum + $feedback->Rate;
}
$rate_avg = $rate_count > 0 ? $rate_sum / $rate_count : 0;
try {
$event->setAvgRate(round($rate_avg, 2));
$event->write(true);
} catch (Exception $ex) {
SS_Log::log($ex, SS_Log::ERR);
echo $ex->getMessage();
}
}
$finish_time = time() - $init_time;
echo 'processed events ' . $processed_events . ' - time elapsed : ' . $finish_time . ' seconds.';
} catch (Exception $ex) {
SS_Log::log($ex->getMessage(), SS_Log::ERR);
}
}
示例13: run
function run()
{
try {
$election_input_path = Director::baseFolder() . '/' . ELECTION_VOTERS_INGEST_PATH;
$files = scandir($election_input_path);
$manager = new ElectionManager(new SapphireElectionRepository(), new SapphireFoundationMemberRepository(), new SapphireVoteRepository(), new SapphireVoterFileRepository(), new VoteFactory(), new VoterFileFactory(), new ElectionFactory(), SapphireTransactionManager::getInstance());
foreach ($files as $file_name) {
if ($this->isCSV($file_name) && (list($election_id, $open_date, $close_date) = $this->isValidElectionFileName($file_name))) {
try {
echo printf('processing file %s' . PHP_EOL, $file_name);
list($count, $not_processed) = $manager->ingestVotersForElection($election_input_path . '/' . $file_name, $election_id, $open_date, $close_date);
echo printf('file %s - processed %d rows - not processed %d rows' . PHP_EOL, $file_name, $count, count($not_processed));
if (count($not_processed) > 0) {
echo 'not processed details ... ' . PHP_EOL;
echo var_dump($not_processed) . PHP_EOL;
}
echo printf('deleting file %s ...' . PHP_EOL, $file_name);
unlink($election_input_path . '/' . $file_name);
} catch (Exception $ex) {
SS_Log::log($ex, SS_Log::ERR);
echo $ex->getMessage();
}
}
}
return 'OK';
} catch (Exception $ex) {
SS_Log::log($ex, SS_Log::ERR);
echo $ex->getMessage();
}
}
示例14: run
/**
* Implement this method in the task subclass to
* execute via the TaskRunner
*/
public function run($request)
{
if (!($adminEmail = $this->config()->get('administrator_email'))) {
$contenders = $this->extend('feedMeAdminEmail') ?: [];
$adminEmail = reset($contenders);
}
if ($adminEmail) {
SS_Log::add_writer(new SS_LogEmailWriter($adminEmail, SS_Log::INFO));
}
// anything like a warning or above
SS_Log::add_writer(new SS_LogEmailWriter(Security::findAnAdministrator()->Email), SS_Log::WARN);
$excludedFeedClasses = $this->config()->get('excluded_feed_class_names');
// for each implementor of the FeedMeFeedInterface check if it's not excluded then for each
// instance of that model call feedMeImport on it.
$implementors = ClassInfo::implementorsOf('FeedMeFeedModelInterface');
foreach ($implementors as $className) {
// chance to disable a feed by setting config.excluded_feed_class_names
if (!in_array($className, $excludedFeedClasses)) {
/** @var FeedMeFeedModelExtension $feedModel */
foreach ($className::get() as $feedModel) {
$feedModel->feedMeImport();
}
}
}
}
示例15: run
/**
* @return void
*/
public function run()
{
try {
$batch_size = 100;
$init_time = time();
$summit = null;
if (isset($_GET['batch_size'])) {
$batch_size = intval(trim(Convert::raw2sql($_GET['batch_size'])));
echo sprintf('batch_size set to %s', $batch_size) . PHP_EOL;
}
if (isset($_GET['summit_id'])) {
$summit = Summit::get()->byID(intval($_GET['summit_id']));
}
if (is_null($summit)) {
throw new Exception('summit_id is not valid!');
}
$manager = Injector::inst()->get('SpeakerSecondBreakoutAnnouncementSenderManager');
if (!$manager instanceof ISpeakerSecondBreakoutAnnouncementSenderManager) {
return;
}
$processed = $manager->send($summit, $batch_size);
$finish_time = time() - $init_time;
echo 'processed records ' . $processed . ' - time elapsed : ' . $finish_time . ' seconds.';
} catch (Exception $ex) {
SS_Log::log($ex->getMessage(), SS_Log::ERR);
}
}