function __construct() { $guid = getInput("guid"); $reply = getInput("reply"); if (!$reply) { new SystemMessage("Message body cannot be left empty."); forward(); } $message = getEntity($guid); $to = getLoggedInUserGuid() == $message->to ? $message->from : $message->to; $from = getLoggedInUserGuid(); $to_user = getEntity($to); $from_user = getEntity($from); $message_element = new Messageelement(); $message_element->message = $reply; $message_element->to = $to; $message_element->from = $from; $message_element->container_guid = $guid; $message_element->save(); $link = getSiteURL() . "messages"; notifyUser("message", $to, getLoggedInUserGuid(), $to); sendEmail(array("to" => array("name" => $to_user->full_name, "email" => $to_user->email), "from" => array("name" => getSiteName(), "email" => getSiteEmail()), "subject" => "You have a new message from " . getLoggedInUser()->full_name, "body" => "You have received a new message from " . getLoggedInUser()->full_name . "<br/><a href='{$link}'>Click here to view it.</a>", "html" => true)); new SystemMessage("Your message has been sent."); forward("messages/" . $message->guid); }
public function __construct() { gateKeeper(); $email_users = array(); $container_guid = getInput("container_guid"); $topic = getEntity($container_guid); $category_guid = $topic->container_guid; $category = getEntity($category_guid); $description = getInput("comment"); $comment = new Forumcomment(); $comment->description = $description; $comment->container_guid = $container_guid; $comment->category_guid = $category_guid; $comment->owner_guid = getLoggedInUserGuid(); $comment->save(); new SystemMessage("Your comment has been posted."); new Activity(getLoggedInUserGuid(), "forum:comment:posted", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $topic->getURL(), $topic->title, truncate($comment->description)), $container_guid, $category->access_id); $all_comments = getEntities(array("type" => "Forumcomment", "metadata_name" => "container_guid", "metadata_value" => $container_guid)); $notify_users = array($topic->owner_guid); $container_owner_guid = $topic->owner_guid; $container_owner = getEntity($container_owner_guid); if ($container_owner->notify_when_forum_comment_topic_i_own == "email" || $container_owner->notify_when_forum_comment_topic_i_own == "both") { $email_users[] = $container_guid; } foreach ($all_comments as $comment) { $user_guid = $comment->owner_guid; $user = getEntity($user_guid); switch ($user->notify_when_forum_comment_topic_i_own) { case "both": $notify_users[] = $comment->owner_guid; $email_users[] = $comment->owner_guid; break; case "email": $email_users[] = $comment->owner_guid; break; case "site": $notify_users[] = $comment->owner_guid; break; case "none": break; } } $notify_users = array_unique($notify_users); foreach ($notify_users as $user_guid) { notifyUser("forumcomment", $container_guid, getLoggedInUserGuid(), $user_guid); } foreach ($email_users as $user) { $params = array("to" => array($user->full_name, $user->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment. Click <a href='{$url}'>Here</a> to view it.", "html" => true); sendEmail($params); } forward(); }
public function __construct($data = NULL) { gateKeeper(); $logged_in_user = getLoggedInUser(); if (!$data) { // Get the comment body $comment_body = getInput("comment"); // Get container url $container_guid = getInput("guid"); } else { $comment_body = $data['comment_body']; $container_guid = $data['container_guid']; } $container = getEntity($container_guid); $container_owner_guid = $container->owner_guid; if ($container_owner_guid) { $container_owner = getEntity($container_owner_guid); } $url = $container->getURL(); if (!$url) { $url = getSiteURL(); } // Create the comment CommentsPlugin::createComment($container_guid, $comment_body); if ($container_owner_guid) { if ($container_owner_guid != getLoggedInUserGuid()) { $params = array("to" => array($container_owner->full_name, $container_owner->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment. Click <a href='{$url}'>Here</a> to view it.", "html" => true); switch ($logged_in_user->getSetting("notify_when_comment")) { case "email": sendEmail($params); break; case "none": break; case "site": notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid); break; case "both": sendEmail($params); notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid); break; } } } runHook("add:comment:after"); if (getLoggedInUserGuid() != $container_owner_guid && $container_owner_guid) { new Activity(getLoggedInUserGuid(), "activity:comment", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container_owner->getURL(), $container_owner->full_name, $container->getURL(), translate($container->type), truncate($comment_body))); } elseif (!$container_owner_guid) { new Activity(getLoggedInUserGuid(), "activity:comment:own", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container->getURL(), $container->title, translate($container->type), truncate($comment_body))); } // Return to container page. forward(); }
public function start($params) { exec("pgrep ffmpeg", $pids); if (empty($pids)) { $query = "SELECT video.guid FROM video LEFT JOIN file ON video.video_guid=file.guid WHERE (video.processed != 'true' && video.processed != 'processing' && video.video_type = 'upload');"; $results = Dbase::getResultsArray($query); foreach ($results as $result) { $video_guid = $result['guid']; $video = getEntity($video_guid, true); if (is_a($video, "SocialApparatus\\Video")) { $file_guid = $video->video_guid; if (!file_exists(SITEDATAPATH . "videos/{$file_guid}/video.mp4")) { $file = getEntity($file_guid, true); FileSystem::makePath(SITEDATAPATH . "videos/" . $file_guid, 0777); $file_location = $file->file_location; exec("pgrep ffmpeg", $pids); if (empty($pids)) { if (file_exists($file_location)) { $target_dir = SITEDATAPATH . "videos/" . $file->guid . "/"; ini_set('max_execution_time', 3000); $ffmpeg = \FFMpeg\FFMpeg::create(array('ffmpeg.binaries' => Setting::get("ffmpeg_ffmprobe_executable_path") . "/ffmpeg", 'ffprobe.binaries' => Setting::get("ffmpeg_ffmprobe_executable_path") . "/ffprobe", 'timeout' => 7200, 'ffmpeg.threads' => 6)); $oldmask = umask(0); $video->proccessed = "processing"; $video->save(); $video_file = $ffmpeg->open($file_location); $video_file->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds(10))->save($target_dir . 'frame.jpg'); $video_file->filters()->resize(new \FFMpeg\Coordinate\Dimension(320, 240))->synchronize(); $video_file->save(new \FFMpeg\Format\Video\X264('libfdk_aac', 'libx264'), $target_dir . 'video.mp4')->save(new \FFMpeg\Format\Video\WebM(), $target_dir . 'video.webm')->save(new \FFMpeg\Format\Video\Ogg(), $target_dir . 'video.ogv'); $video = getEntity($video_guid); $video->processed = "true"; $video->save(); umask($oldmask); $user_guid = $video->owner_guid; $message = "Your video has been processed."; $link = $video->getURL(); notifyUser("video_processed", $video->guid, NULL, $user_guid); continue; } else { $video->processed = "true"; $video->save(); } } } else { $video->processed = "true"; $video->save(); } } } } }
public function __construct($data) { $guid = $data['guid']; if (LikesPlugin::loggedInUserHasLiked($guid)) { die; } $entity = getEntity($guid); $owner_guid = $entity->owner_guid; $owner = getEntity($owner_guid); $like = new Like(); $like->container_guid = $guid; $like->owner_guid = getLoggedInUserGuid(); $like->save(); new Activity(getLoggedInUserGuid(), "activity:like", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $owner->getURL(), $owner->full_name, $entity->getURL(), translate($entity->type))); notifyUser("like", $guid, getLoggedInUserGuid(), $owner_guid); die; }
function __construct() { gateKeeper(); $to = getInput("to"); $from = getLoggedInUserGuid(); $subject = getInput("subject"); $message_body = getInput("message"); if (!$message_body) { new SystemMessage("Message body cannot be left blank."); forward(); } // Make sure recipient is a user $to_user = getEntity($to); classGateKeeper($to_user, "User"); // Make sure logged in user and to user are friends if (!FriendsPlugin::friends(getLoggedInUserGuid(), $to)) { forward(); } // Create a new message $message = new Message(); $message->to = $to; $message->from = $from; $message->subject = $subject; $message->save(); $message_element = new Messageelement(); $message_element->to = $to; $message_element->from = $from; $message_element->subject = $subject; $message_element->message = $message_body; $message_element->container_guid = $message->guid; $message_element->save(); $link = getSiteURL() . "messages"; $notify = $to_user->notify_when_message; if (!$notify) { $notify = "both"; } if ($notify == "both" || $notify == "site") { notifyUser("message", $to, $from, $to); } if ($notify == "both" || ($notify = "email")) { sendEmail(array("to" => array("name" => $to_user->full_name, "email" => $to_user->email), "from" => array("name" => getSiteName(), "email" => getSiteEmail()), "subject" => "You have a new message from " . getLoggedInUser()->full_name, "body" => "You have received a new message from " . getLoggedInUser()->full_name . "<br/><a href='{$link}'>Click here to view it.</a>", "html" => true)); } new SystemMessage("Your message has been sent."); forward(); }
function __construct() { gateKeeper(); $page = getInput("p"); $name = getInput("name"); $reason = getInput("reason"); $r = new Reportedcontent(); $r->page = $page; $r->name = $name; $r->reason = $reason; $r->owner_guid = getLoggedInUserGuid(); $r->save(); $admin_guids = getAdminGuidarray(); foreach ($admin_guids as $admin_guid) { notifyUser("reportedcontent", $r->guid, getLoggedInUserGuid(), $admin_guid); } forward("reportThis/reportSent"); }
public function __construct() { if (!pageArray(2)) { return false; } gateKeeper(); $user1 = getLoggedInUser(); $guid = pageArray(2); $user2 = getEntity($guid); if (!FriendsPlugin::friends($user1->guid, $user2->guid)) { // First check if the other user has already initiated a friend request $request = getEntity(array("type" => "Friend", "metadata_name_value_pairs" => array(array("name" => "guid_one", "value" => $guid), array("name" => "guid_two", "value" => $user1->guid), array("name" => "status", "value" => "new")))); if ($request) { FriendsPlugin::addFriend($user1->guid, $guid); forward(); } // Make sure there isn't already a friend request in the system $test = getEntities(array("type" => "Friend", "metadata_name_value_pairs" => array(array("name" => "guid_one", "value" => $user1->guid), array("name" => "guid_two", "value" => $guid)))); if (!$test) { $friend_request = new Friend(); $friend_request->guid_one = $user1->guid; $friend_request->guid_two = $guid; $friend_request->status = "requested"; $friend_request->requested_by = getLoggedInUserGuid(); $friend_request->save(); $friend_request = new Friend(); $friend_request->guid_one = $guid; $friend_request->guid_two = $user1->guid; $friend_request->status = "requested"; $friend_request->requested_by = getLoggedInUserGuid(); $friend_request->save(); new SystemMessage("Your friend request has been sent."); notifyUser("friend", $user2->guid, $user1->guid, $user2->guid); } forward(); } forward(); }
} // if } // NOTIFY SELLER ON DIRECT SELLS $sql = "SELECT FK_auction_offer_user_id,\r\n PK_auction_offer_id,\r\n auction_offer_title,\r\n FK_auction_offer_last_bid_user_id\r\n FROM " . AUCTION_OFFER_TABLE . "\r\n WHERE auction_offer_state=2 AND\r\n auction_offer_notified_seller=''"; if (!($result = $db->sql_query($sql))) { } $total_notifications = 0; while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $total_notifications++; } // while for ($i = 0; $i < $total_notifications; $i++) { // Write pms and emails notifyUser($rowset[$i]['FK_auction_offer_user_id'], 'SOLD', $rowset[$i]['PK_auction_offer_id'], $rowset[$i]['auction_offer_title']); // mark offer buyer-notified $sql = "UPDATE " . AUCTION_OFFER_TABLE . "\r\n SET auction_offer_notified_seller=1\r\n WHERE PK_auction_offer_id=" . $rowset[$i]['PK_auction_offer_id']; if (!($result = $db->sql_query($sql))) { } // if } // BEGIN charge percentage if ($auction_config_data['auction_offer_cost_final_percent'] > 0) { $sql = "SELECT PK_auction_offer_id,\r\n auction_offer_last_bid_price,\r\n FK_auction_offer_user_id\r\n FROM " . AUCTION_OFFER_TABLE . "\r\n WHERE auction_offer_time_stop<" . time() . " AND\r\n auction_offer_percentage_charged=0"; if (!($result4 = $db->sql_query($sql))) { } // if $total_offers = 0; while ($row4 = $db->sql_fetchrow($result4)) { $total_offer_rowset[] = $row4;
<?php //Email notification script //Search the users in the db for anyone with at leat one game that is not picked //Count games in week //Count games user has picked //compare //If picked < games || score IS NULL) = send email // Load Databases and Common functions require "mysql.php"; include 'common.php'; include "functions.php"; //Site Functions //include('include/test_include.php'); //try to guess the current week, function in get_winners guessCurrentWeek(); $num_games = getNumberOfGames($this_season_year, $this_season_type, $this_week); $sql = "SELECT COUNT(pick_id) as num_picks, user_id FROM picks WHERE season_year='{$this_season_year}' AND season_type='{$this_season_type}' AND week='{$this_week}' GROUP BY user_id"; $result = mysqli_query($db, $sql) or die(mysqli_error($db)); while ($user = mysqli_fetch_array($result)) { if ($user['num_picks'] < $num_games) { echo 'User ' . getUserNameFromId($db, $user['user_id']) . ' has only picked ' . $user['num_picks'] . ' of ' . $num_games . ' send her an email at ' . getUserEmailFromId($db, $user['user_id']); notifyUser(getUserEmailFromId($db, $user['user_id']), getUserNameFromId($db, $user['user_id']), $num_games, $user['num_picks']); } }
function notifyUsers($userids, $prizeid, $winEmail, $winNot) { foreach ($userids as $userid) { notifyUser($userid, $prizeid, $winEmail, $winNot); //echo $message; //sendContactEmail() // would go here if we were doing it that way } }
function reply($params) { $guid = $params['message_guid']; $reply = $params['reply']; $message = getEntity($guid); $to = $params['to']; $from = $params['from']; $to = $from == $message->from ? $message->to : $message->from; $to_user = getEntity($to); $from_user = getEntity($from); $message_element = new Messageelement(); $message_element->message = $reply; $message_element->to = $to; $message_element->from = $from; $message_element->container_guid = $guid; $message_element->save(); $link = getSiteURL() . "messages"; notifyUser("message", $to, getLoggedInUserGuid(), $to); sendEmail(array("to" => array("name" => $to_user->full_name, "email" => $to_user->email), "from" => array("name" => getSiteName(), "email" => getSiteEmail()), "subject" => "You have a new message from " . getLoggedInUser()->full_name, "body" => "You have received a new message from " . getLoggedInUser()->full_name . "<br/><a href='{$link}'>Click here to view it.</a>", "html" => true)); return "success"; }