Exemplo n.º 1
0
function getHardDelayNodes($dbSocket)
{
    global $configValues;
    $sql = "SELECT " . "mac,  memfree,  cpu,  wan_ip,  wan_gateway,  lan_mac,  firmware,  firmware_revision " . " FROM " . $configValues['CONFIG_DB_TBL_DALONODE'] . " WHERE ( UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(time) ) > " . $configValues['HARD_DELAY_SEC'];
    $res = $dbSocket->query($sql);
    $nodes = array();
    while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
        $message = getHTMLMessage($row);
        $subject = "daloRADIUS Node Monitor: Offline Node";
        sendEmailNotification($subject, $message);
    }
}
Exemplo n.º 2
0
 function register_new_user_local($registration, $from_intertiki)
 {
     global $_SESSION, $tikilib, $logslib, $userlib, $notificationlib, $prefs, $smarty;
     $result = '';
     if (isset($_SESSION['openid_url'])) {
         $openid_url = $_SESSION['openid_url'];
     } else {
         $openid_url = '';
     }
     $newPass = $registration['pass'] ? $registration['pass'] : $registration["genepass"];
     if ($this->merged_prefs['validateUsers'] == 'y' || isset($this->merged_prefs['validateRegistration']) && $this->merged_prefs['validateRegistration'] == 'y') {
         $apass = md5($tikilib->genPass());
         $userlib->send_validation_email($registration['name'], $apass, $registration['email'], '', '', isset($registration['chosenGroup']) ? $registration['chosenGroup'] : '');
         $userlib->add_user($registration['name'], $newPass, $registration["email"], '', false, $apass, $openid_url, $this->merged_prefs['validateRegistration'] == 'y' ? 'a' : 'u');
         $logslib->add_log('register', 'created account ' . $registration['name']);
         $result = tra('You will receive an email with the information needed to log into this site the first time.');
     } else {
         $userlib->add_user($registration['name'], $newPass, $registration['email'], '', false, NULL, $openid_url);
         $logslib->add_log('register', 'created account ' . $registration['name']);
         $result = $smarty->fetch('mail/user_welcome_msg.tpl');
     }
     if (isset($registration['chosenGroup']) && $userlib->get_registrationChoice($registration['chosenGroup']) == 'y') {
         $userlib->set_default_group($registration['name'], $registration['chosenGroup']);
     } elseif (empty($registration['chosenGroup'])) {
         // to have tiki-user_preferences links par default to the registration tracker
         $userlib->set_default_group($registration['name'], 'Registered');
     }
     $userlib->set_email_group($registration['name'], $registration['email']);
     // save default user preferences
     // Custom fields
     $customfields = $this->get_customfields();
     foreach ($customfields as $custpref => $prefvalue) {
         if (isset($registration[$customfields[$custpref]['prefName']])) {
             $tikilib->set_user_preference($registration['name'], $customfields[$custpref]['prefName'], $registration[$customfields[$custpref]['prefName']]);
         }
     }
     $watches = $tikilib->get_event_watches('user_registers', '*');
     if (count($watches)) {
         require_once "lib/notifications/notificationemaillib.php";
         $smarty->assign('mail_user', $registration['name']);
         $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
         sendEmailNotification($watches, null, 'new_user_notification_subject.tpl', null, 'new_user_notification.tpl');
     }
     return $result;
 }
/**
 * handleBadUsers()
 *
 */
function handleBadUsers($dbSocket)
{
    global $configValues;
    // get all online users
    $sql = " SELECT " . " RadAcctId, AcctSessionId, UserName, NASIPAddress, NASPortId, AcctStartTime, AcctSessionTime, AcctInputOctets, AcctOutputOctets, " . " CalledStationId, CallingStationId, FramedIPAddress " . " FROM " . $configValues['CONFIG_DB_TBL_RADACCT'] . " WHERE " . " (AcctStopTime = '0000-00-00 00:00:00' OR AcctStopTime IS NULL) ";
    $res = $dbSocket->query($sql);
    $users = array();
    while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
        $download = (double) $row['AcctOutputOctets'];
        $upload = (double) $row['AcctInputOctets'];
        $traffic = (double) $download + $upload;
        $message = getHTMLMessage($row);
        if ($traffic >= $configValues['SOFTLIMIT']) {
            $subject = "daloRADIUS Traffic Notification: Soft Limit";
            sendEmailNotification($subject, $message);
        } else {
            if ($traffic >= $configValues['HARDLIMIT']) {
                $subject = "daloRADIUS Traffic Notification: Hard Limit";
                sendEmailNotification($subject, $message);
            } else {
                continue;
            }
        }
    }
}
Exemplo n.º 4
0
$temp = exec('/opt/vc/bin/vcgencmd measure_temp');
preg_match("/^temp=([\\d.]+)/", $temp, $matches);
// Temperature is stored in at index 1.
$temp = $matches[1];
$date = new DateTime();
$filePath = realpath(dirname(__FILE__));
$ret = exec($filePath . '/update_plotly.py \'' . $date->format('Y-m-d H:i:s') . '\' ' . $temp);
$line = $date->format(DateTime::ISO8601) . ";" . $temp . "\n";
// Write the temp to a file
$filePath = realpath(dirname(__FILE__));
file_put_contents(dirname(__FILE__) . '/temperature.log', $line, FILE_APPEND);
// Check if we should send a notification
$config = getConfig();
$notificationConfig = $config['notification'];
$maxTemp = $notificationConfig['max_temp'];
if ((int) $temp >= $maxTemp) {
    // Temp is too high! Send notification!
    if ($notificationConfig['enable_email']) {
        $addresses = $notificationConfig['email_addresses'];
        sendEmailNotification($temp, $addresses);
    }
    if ($notificationConfig['enable_pushover']) {
        $userkey = $notificationConfig['pushover_userkey'];
        sendPushoverNotification($temp, $userkey);
    }
    if ($notificationConfig['enable_pushbullet']) {
        $deviceid = $notificationConfig['pushbullet_deviceid'];
        $apikey = $notificationConfig['pushbullet_apikey'];
        sendPushbulletNotification($temp, $deviceid, $apikey);
    }
}
Exemplo n.º 5
0
 /**
  * blog_post Stores a blog post
  *
  * @param int $blogId
  * @param string $data
  * @param string $excerpt
  * @param string $user
  * @param string $title
  * @param string $contributions
  * @param string $priv
  * @param bool $is_wysiwyg
  * @access public
  * @return int postId
  */
 function blog_post($blogId, $data, $excerpt, $user, $title = '', $contributions = '', $priv = 'n', $created = 0, $is_wysiwyg = FALSE)
 {
     // update tiki_blogs and call activity functions
     global $prefs;
     $tikilib = TikiLib::lib('tiki');
     $smarty = TikiLib::lib('smarty');
     $wysiwyg = $is_wysiwyg == TRUE ? 'y' : 'n';
     if (!$created) {
         $created = $tikilib->now;
     }
     $data = TikiFilter::get('purifier')->filter($data);
     $excerpt = TikiFilter::get('purifier')->filter($excerpt);
     $query = "insert into `tiki_blog_posts`(`blogId`,`data`,`excerpt`,`created`,`user`,`title`,`priv`,`wysiwyg`) values(?,?,?,?,?,?,?,?)";
     $result = $this->query($query, array((int) $blogId, $data, $excerpt, (int) $created, $user, $title, $priv, $wysiwyg));
     $query = "select max(`postId`) from `tiki_blog_posts` where `created`=? and `user`=?";
     $id = $this->getOne($query, array((int) $created, $user));
     $query = "update `tiki_blogs` set `lastModif`=?,`posts`=`posts`+1 where `blogId`=?";
     $result = $this->query($query, array((int) $created, (int) $blogId));
     $this->add_blog_activity($blogId);
     if ($prefs['feature_user_watches'] == 'y' or $prefs['feature_group_watches'] == 'y') {
         $nots = $tikilib->get_event_watches('blog_post', $blogId);
         if (!isset($_SERVER["SERVER_NAME"])) {
             $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
         }
         if ($prefs['user_blog_watch_editor'] != "y") {
             for ($i = count($nots) - 1; $i >= 0; --$i) {
                 if ($nots[$i]['user'] == $user) {
                     unset($nots[$i]);
                     break;
                 }
             }
         }
         if ($prefs['feature_daily_report_watches'] == 'y') {
             $query = "select `title` from `tiki_blogs` where `blogId`=?";
             $blogTitle = $this->getOne($query, array((int) $blogId));
             $reportsManager = Reports_Factory::build('Reports_Manager');
             $reportsManager->addToCache($nots, array("event" => 'blog_post', "blogId" => $blogId, "blogTitle" => $blogTitle, "postId" => $id, "user" => $user));
         }
         if (count($nots)) {
             include_once "lib/notifications/notificationemaillib.php";
             $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
             $smarty->assign('mail_title', $this->get_title($blogId));
             $smarty->assign('mail_post_title', $title);
             $smarty->assign('mail_blogid', $blogId);
             $smarty->assign('mail_postid', $id);
             $smarty->assign('mail_user', $user);
             $smarty->assign('mail_data', $data);
             if ($prefs['feature_contribution'] == 'y' && !empty($contributions)) {
                 $contributionlib = TikiLib::lib('contribution');
                 $smarty->assign('mail_contributions', $contributionlib->print_contributions($contributions));
             }
             sendEmailNotification($nots, "watch", "user_watch_blog_post_subject.tpl", $_SERVER["SERVER_NAME"], "user_watch_blog_post.tpl");
         }
     }
     TikiLib::events()->trigger('tiki.blogpost.create', array('type' => 'blog post', 'object' => $id, 'blog' => $blogId, 'user' => $user));
     if ($prefs['feature_actionlog'] == 'y') {
         $logslib = TikiLib::lib('logs');
         $logslib->add_action('Posted', $blogId, 'blog', "blogId={$blogId}&postId={$id}&add=" . strlen($data) . "#postId{$id}", '', '', '', '', $contributions);
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('blog_posts', $id);
     $tikilib->object_post_save(array('type' => 'blog post', 'object' => $id, 'description' => substr($data, 0, 200), 'name' => $title, 'href' => "tiki-view_blog_post.php?postId={$id}"), array('content' => $data));
     return $id;
 }
 /**
  *  A callback that performs email notifications when a new user registers
  *  @access private
  *  @returns true on success, false to halt event proporgation
  */
 function callback_tikimail_user_registers($raisedBy, $data)
 {
     global $notificationlib, $smarty;
     include_once "lib/notifications/notificationlib.php";
     $emails = $notificationlib->get_mail_events('user_registers', '*');
     if (count($emails)) {
         $smarty->assign('mail_user', $data['user']);
         $smarty->assign('mail_date', $this->now);
         $smarty->assign('mail_site', $data['mail_site']);
         sendEmailNotification($emails, "email", "new_user_notification_subject.tpl", null, "new_user_notification.tpl");
     }
     return true;
 }
Exemplo n.º 7
0
 function replace_article($title, $authorName, $topicId, $useImage, $imgname, $imgsize, $imgtype, $imgdata, $heading, $body, $publishDate, $expireDate, $user, $articleId, $image_x, $image_y, $type, $topline, $subtitle, $linkto, $image_caption, $lang, $rating = 0, $isfloat = 'n', $emails = '', $from = '', $list_image_x = '', $list_image_y = '', $ispublished = 'y')
 {
     global $smarty, $tikilib;
     if ($expireDate < $publishDate) {
         $expireDate = $publishDate;
     }
     $hash = md5($title . $heading . $body);
     if (empty($imgdata) || $useImage === 'n') {
         // remove image data if not using it
         $imgdata = '';
     }
     $query = 'select `name` from `tiki_topics` where `topicId` = ?';
     $topicName = $this->getOne($query, array($topicId));
     $size = $body ? mb_strlen($body) : mb_strlen($heading);
     if ($articleId) {
         $oldArticle = $this->get_article($articleId);
         $query = 'update `tiki_articles` set `title` = ?, `authorName` = ?, `topicId` = ?, `topicName` = ?, `size` = ?, `useImage` = ?, `image_name` = ?, ';
         $query .= ' `image_type` = ?, `image_size` = ?, `image_data` = ?, `isfloat` = ?, `image_x` = ?, `image_y` = ?, `list_image_x` = ?, `list_image_y` = ?, `heading` = ?, `body` = ?, ';
         $query .= ' `publishDate` = ?, `expireDate` = ?, `created` = ?, `author` = ?, `type` = ?, `rating` = ?, `topline`=?, `subtitle`=?, `linkto`=?, ';
         $query .= ' `image_caption`=?, `lang`=?, `ispublished`=? where `articleId` = ?';
         $result = $this->query($query, array($title, $authorName, (int) $topicId, $topicName, (int) $size, $useImage, $imgname, $imgtype, (int) $imgsize, $imgdata, $isfloat, (int) $image_x, (int) $image_y, (int) $list_image_x, (int) $list_image_y, $heading, $body, (int) $publishDate, (int) $expireDate, (int) $this->now, $user, $type, (double) $rating, $topline, $subtitle, $linkto, $image_caption, $lang, $ispublished, (int) $articleId));
         // Clear article image cache because image may just have been changed
         $this->delete_image_cache('article', $articleId);
         $event = 'article_edited';
         $nots = $tikilib->get_event_watches('article_edited', '*');
         $nots2 = $tikilib->get_event_watches('topic_article_edited', $topicId);
         $smarty->assign('mail_action', 'Edit');
         $smarty->assign('mail_old_title', $oldArticle['title']);
         $smarty->assign('mail_old_publish_date', $oldArticle['publishDate']);
         $smarty->assign('mail_old_expiration_date', $oldArticle['expireDate']);
         $smarty->assign('mail_old_data', $oldArticle['heading'] . "\n----------------------\n" . $oldArticle['body']);
     } else {
         // Insert the article
         $query = 'insert into `tiki_articles` (`title`, `authorName`, `topicId`, `useImage`, `image_name`, `image_size`, `image_type`, `image_data`, ';
         $query .= ' `publishDate`, `expireDate`, `created`, `heading`, `body`, `hash`, `author`, `nbreads`, `votes`, `points`, `size`, `topicName`, ';
         $query .= ' `image_x`, `image_y`, `list_image_x`, `list_image_y`, `type`, `rating`, `isfloat`,`topline`, `subtitle`, `linkto`,`image_caption`, `lang`, `ispublished`) ';
         $query .= ' values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
         $result = $this->query($query, array($title, $authorName, (int) $topicId, $useImage, $imgname, (int) $imgsize, $imgtype, $imgdata, (int) $publishDate, (int) $expireDate, (int) $this->now, $heading, $body, $hash, $user, 0, 0, 0, (int) $size, $topicName, (int) $image_x, (int) $image_y, (int) $list_image_x, (int) $list_image_y, $type, (double) $rating, $isfloat, $topline, $subtitle, $linkto, $image_caption, $lang, $ispublished));
         $query2 = 'select max(`articleId`) from `tiki_articles` where `created` = ? and `title`=? and `hash`=?';
         $articleId = $this->getOne($query2, array((int) $this->now, $title, $hash));
         global $prefs;
         if ($prefs['feature_score'] == 'y') {
             $this->score_event($user, 'article_new');
         }
         $event = 'article_submitted';
         $nots = $tikilib->get_event_watches('article_submitted', '*');
         $nots2 = $tikilib->get_event_watches('topic_article_created', $topicId);
         $smarty->assign('mail_action', 'New');
     }
     $nots3 = array();
     foreach ($nots as $n) {
         $nots3[] = $n['email'];
     }
     foreach ($nots2 as $n) {
         if (!in_array($n['email'], $nots3)) {
             $nots[] = $n;
         }
     }
     if (is_array($emails) && (empty($from) || $from == $prefs['sender_email'])) {
         foreach ($emails as $n) {
             if (!in_array($n, $nots3)) {
                 $nots[] = array('email' => $n, 'language' => $prefs['site_language']);
             }
         }
     }
     global $prefs;
     if ($prefs['user_article_watch_editor'] != "y") {
         for ($i = count($nots) - 1; $i >= 0; --$i) {
             if ($nots[$i]['user'] == $user) {
                 unset($nots[$i]);
                 break;
             }
         }
     }
     if (!isset($_SERVER['SERVER_NAME'])) {
         $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
     }
     if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
         $reportsManager = Reports_Factory::build('Reports_Manager');
         $reportsManager->addToCache($nots, array('event' => $event, 'articleId' => $articleId, 'articleTitle' => $title, 'authorName' => $authorName, 'user' => $user));
     }
     if (count($nots) || is_array($emails)) {
         include_once 'lib/notifications/notificationemaillib.php';
         $smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
         $smarty->assign('mail_title', $title);
         $smarty->assign('mail_postid', $articleId);
         $smarty->assign('mail_user', $user);
         $smarty->assign('mail_current_publish_date', $publishDate);
         $smarty->assign('mail_current_expiration_date', $expireDate);
         $smarty->assign('mail_current_data', $heading . "\n----------------------\n" . $body);
         $smarty->assign('mail_heading', $heading);
         $smarty->assign('mail_body', $body);
         sendEmailNotification($nots, 'watch', 'user_watch_article_post_subject.tpl', $_SERVER['SERVER_NAME'], 'user_watch_article_post.tpl');
         if (is_array($emails) && !empty($from) && $from != $prefs['sender_email']) {
             $nots = array();
             foreach ($emails as $n) {
                 $nots[] = array('email' => $n, 'language' => $prefs['site_language']);
             }
             sendEmailNotification($nots, 'watch', 'user_watch_article_post_subject.tpl', $_SERVER['SERVER_NAME'], 'user_watch_article_post.tpl', $from);
         }
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('articles', $articleId);
     global $tikilib;
     $tikilib->object_post_save(array('type' => 'article', 'object' => $articleId, 'description' => substr($heading, 0, 200), 'name' => $title, 'href' => "tiki-read_article.php?articleId={$articleId}"), array('content' => $body . "\n" . $heading));
     return $articleId;
 }
Exemplo n.º 8
0
 /**
  * @param $registration
  * @param $from_intertiki
  * @return string
  */
 private function register_new_user_local($registration, $from_intertiki)
 {
     global $_SESSION, $tikilib, $logslib, $userlib, $notificationlib, $prefs, $smarty;
     $result = '';
     if (isset($_SESSION['openid_url'])) {
         $openid_url = $_SESSION['openid_url'];
     } else {
         $openid_url = '';
     }
     $newPass = $registration['pass'] ? $registration['pass'] : $registration["genepass"];
     $pending = false;
     $confirmed = false;
     if ($prefs['userTracker'] === 'y') {
         // this gets called twice if there's a user tracker
         if (!$userlib->get_user_real_case($registration['name'])) {
             $pending = true;
             // first time to just create the basic user record for the tracker to attach to
         } else {
             $confirmed = true;
             // second time to send notifications, join groups etc
         }
     }
     if ($this->merged_prefs['validateUsers'] == 'y' || isset($this->merged_prefs['validateRegistration']) && $this->merged_prefs['validateRegistration'] == 'y') {
         if ($confirmed) {
             $info = $userlib->get_user_info($registration['name']);
             $apass = $info['valid'];
         } else {
             $apass = md5($tikilib->genPass());
         }
         if (!$pending) {
             // don't send validation until user tracker has been validated
             $userlib->send_validation_email($registration['name'], $apass, $registration['email'], '', '', isset($registration['chosenGroup']) ? $registration['chosenGroup'] : 'Registered');
         }
         if (!$confirmed) {
             $userlib->add_user($registration['name'], $newPass, $registration["email"], '', false, $apass, $openid_url, $this->merged_prefs['validateRegistration'] == 'y' ? 'a' : 'u');
         }
         if (!$pending) {
             $logslib->add_log('register', 'created account ' . $registration['name']);
             if ($this->merged_prefs['validateRegistration'] == 'y') {
                 $result = nl2br($smarty->fetch('mail/user_validation_waiting_msg.tpl'));
             } else {
                 $result = $smarty->fetch('mail/user_validation_msg.tpl');
             }
         }
     } else {
         if (!$confirmed) {
             $userlib->add_user($registration['name'], $newPass, $registration['email'], '', false, null, $openid_url);
         }
         if (!$pending) {
             $logslib->add_log('register', 'created account ' . $registration['name']);
             $result = $smarty->fetch('mail/user_welcome_msg.tpl');
         }
     }
     if ($pending) {
         return '';
     }
     if (isset($registration['chosenGroup']) && $userlib->get_registrationChoice($registration['chosenGroup']) == 'y') {
         $userlib->set_default_group($registration['name'], $registration['chosenGroup']);
     } elseif (empty($registration['chosenGroup'])) {
         // to have tiki-user_preferences links par default to the registration tracker
         $userlib->set_default_group($registration['name'], 'Registered');
     }
     $userlib->set_email_group($registration['name'], $registration['email']);
     // save default user preferences
     // Custom fields
     $customfields = $this->get_customfields();
     foreach ($customfields as $custpref => $prefvalue) {
         if (isset($registration[$customfields[$custpref]['prefName']])) {
             $tikilib->set_user_preference($registration['name'], $customfields[$custpref]['prefName'], $registration[$customfields[$custpref]['prefName']]);
         }
     }
     $watches = $tikilib->get_event_watches('user_registers', '*');
     if (count($watches)) {
         require_once "lib/notifications/notificationemaillib.php";
         $smarty->assign('mail_user', $registration['name']);
         $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
         sendEmailNotification($watches, null, 'new_user_notification_subject.tpl', null, 'new_user_notification.tpl');
     }
     return $result;
 }
Exemplo n.º 9
0
 function replace_article($title, $authorName, $topicId, $useImage, $imgname, $imgsize, $imgtype, $imgdata, $heading, $body, $publishDate, $expireDate, $user, $articleId, $image_x, $image_y, $type, $topline, $subtitle, $linkto, $image_caption, $lang, $rating = 0, $isfloat = 'n')
 {
     if ($expireDate < $publishDate) {
         $expireDate = $publishDate;
     }
     $hash = md5($title . $heading . $body);
     $now = date("U");
     if (empty($imgdata)) {
         $imgdata = '';
     }
     // Fixed query. -rlpowell
     $query = "select `name`  from `tiki_topics` where `topicId` = ?";
     $topicName = $this->getOne($query, array($topicId));
     $size = strlen($body);
     // Fixed query. -rlpowell
     if ($articleId) {
         // Update the article
         $query = "update `tiki_articles` set `title` = ?, `authorName` = ?, `topicId` = ?, `topicName` = ?, `size` = ?, `useImage` = ?, `image_name` = ?, ";
         $query .= " `image_type` = ?, `image_size` = ?, `image_data` = ?, `isfloat` = ?, `image_x` = ?, `image_y` = ?, `heading` = ?, `body` = ?, ";
         $query .= " `publishDate` = ?, `expireDate` = ?, `created` = ?, `author` = ?, `type` = ?, `rating` = ?, `topline`=?, `subtitle`=?, `linkto`=?, ";
         $query .= " `image_caption`=?, `lang`=?  where `articleId` = ?";
         $result = $this->query($query, array($title, $authorName, (int) $topicId, $topicName, (int) $size, $useImage, $imgname, $imgtype, (int) $imgsize, $imgdata, $isfloat, (int) $image_x, (int) $image_y, $heading, $body, (int) $publishDate, (int) $expireDate, (int) $now, $user, $type, (double) $rating, $topline, $subtitle, $linkto, $image_caption, $lang, (int) $articleId));
     } else {
         // Fixed query. -rlpowell
         // Insert the article
         $query = "insert into `tiki_articles` (`title`, `authorName`, `topicId`, `useImage`, `image_name`, `image_size`, `image_type`, `image_data`, ";
         $query .= " `publishDate`, `expireDate`, `created`, `heading`, `body`, `hash`, `author`, `nbreads`, `votes`, `points`, `size`, `topicName`, ";
         $query .= " `image_x`, `image_y`, `type`, `rating`, `isfloat`,`topline`, `subtitle`, `linkto`,`image_caption`, `lang`) ";
         $query .= " values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
         $result = $this->query($query, array($title, $authorName, (int) $topicId, $useImage, $imgname, (int) $imgsize, $imgtype, $imgdata, (int) $publishDate, (int) $expireDate, (int) $now, $heading, $body, $hash, $user, 0, 0, 0, (int) $size, $topicName, (int) $image_x, (int) $image_y, $type, (double) $rating, $isfloat, $topline, $subtitle, $linkto, $image_caption, $lang));
         // Fixed query. -rlpowell
         $query2 = "select max(`articleId`) from `tiki_articles` where `created` = ? and `title`=? and `hash`=?";
         $articleId = $this->getOne($query2, array((int) $now, $title, $hash));
         global $feature_score;
         if ($feature_score == 'y') {
             $this->score_event($user, 'article_new');
         }
         global $feature_user_watches, $smarty, $tikilib;
         if ($feature_user_watches == 'y') {
             #workaround to "pass" $topicId to get_event_watches
             $GLOBALS["topicId"] = $topicId;
             $nots = $this->get_event_watches('article_submitted', '*');
             if (!isset($_SERVER["SERVER_NAME"])) {
                 $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
             }
             if (count($nots)) {
                 include_once "lib/notifications/notificationemaillib.php";
                 $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
                 $smarty->assign('mail_title', $title);
                 $smarty->assign('mail_postid', $articleId);
                 $smarty->assign('mail_date', date("U"));
                 $smarty->assign('mail_user', $user);
                 $smarty->assign('mail_data', $heading . "\n----------------------\n" . $body);
                 $foo = parse_url($_SERVER["REQUEST_URI"]);
                 $machine = $tikilib->httpPrefix() . $foo["path"];
                 $smarty->assign('mail_machine', $machine);
                 $parts = explode('/', $foo['path']);
                 if (count($parts) > 1) {
                     unset($parts[count($parts) - 1]);
                 }
                 $smarty->assign('mail_machine_raw', $tikilib->httpPrefix() . implode('/', $parts));
                 sendEmailNotification($nots, "watch", "user_watch_article_post_subject.tpl", $_SERVER["SERVER_NAME"], "user_watch_article_post.tpl");
             }
         }
     }
     return $articleId;
 }
Exemplo n.º 10
0
 function blog_post($blogId, $data, $user, $title = '', $contributions = '', $priv = 'n')
 {
     // update tiki_blogs and call activity functions
     global $smarty, $tikilib, $prefs;
     $data = strip_tags($data, '<a><b><i><h1><h2><h3><h4><h5><h6><ul><li><ol><br><p><table><tr><td><img><pre>');
     $query = "insert into `tiki_blog_posts`(`blogId`,`data`,`created`,`user`,`title`,`priv`) values(?,?,?,?,?,?)";
     $result = $this->query($query, array((int) $blogId, $data, (int) $this->now, $user, $title, $priv));
     $query = "select max(`postId`) from `tiki_blog_posts` where `created`=? and `user`=?";
     $id = $this->getOne($query, array((int) $this->now, $user));
     $query = "update `tiki_blogs` set `lastModif`=?,`posts`=`posts`+1 where `blogId`=?";
     $result = $this->query($query, array((int) $this->now, (int) $blogId));
     $this->add_blog_activity($blogId);
     if ($prefs['feature_user_watches'] == 'y') {
         $nots = $this->get_event_watches('blog_post', $blogId);
         if (!isset($_SERVER["SERVER_NAME"])) {
             $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
         }
         if (count($nots)) {
             include_once "lib/notifications/notificationemaillib.php";
             $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
             $query = "select `title` from `tiki_blogs` where `blogId`=?";
             $blogTitle = $this->getOne($query, array((int) $blogId));
             $smarty->assign('mail_title', $blogTitle);
             $smarty->assign('mail_post_title', $title);
             $smarty->assign('mail_blogid', $blogId);
             $smarty->assign('mail_postid', $id);
             $smarty->assign('mail_date', $this->now);
             $smarty->assign('mail_user', $user);
             $smarty->assign('mail_data', $data);
             if ($prefs['feature_contribution'] == 'y' && !empty($contributions)) {
                 global $contributionlib;
                 include_once 'lib/contribution/contributionlib.php';
                 $smarty->assign('mail_contributions', $contributionlib->print_contributions($contributions));
             }
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = $tikilib->httpPrefix() . $foo["path"];
             $smarty->assign('mail_machine', $machine);
             $parts = explode('/', $foo['path']);
             if (count($parts) > 1) {
                 unset($parts[count($parts) - 1]);
             }
             $smarty->assign('mail_machine_raw', $tikilib->httpPrefix() . implode('/', $parts));
             sendEmailNotification($nots, "watch", "user_watch_blog_post_subject.tpl", $_SERVER["SERVER_NAME"], "user_watch_blog_post.tpl");
         }
     }
     if ($prefs['feature_score'] == 'y') {
         $this->score_event($user, 'blog_post');
     }
     if ($prefs['feature_actionlog'] == 'y') {
         global $logslib;
         include_once 'lib/logs/logslib.php';
         $logslib->add_action('Posted', $blogId, 'blog', "blogId={$blogId}&amp;postId={$id}&amp;add=" . strlen($data) . "#postId{$id}", '', '', '', '', $contributions);
     }
     if ($prefs['feature_search'] == 'y' && $prefs['feature_search_fulltext'] != 'y' && $prefs['search_refresh_index_mode'] == 'normal') {
         require_once 'lib/search/refresh-functions.php';
         refresh_index('blog_posts', $id);
     }
     return $id;
 }
Exemplo n.º 11
0
 public function wiki_rename_page($oldName, $newName, $renameHomes = true, $user = '')
 {
     global $prefs;
     $tikilib = TikiLib::lib('tiki');
     // if page already exists, stop here
     $newName = trim($newName);
     if ($this->get_page_info($newName, false, true)) {
         // if it is a case change of same page: allow it, else stop here
         if (strcasecmp(trim($oldName), $newName) != 0) {
             throw new Exception("Page already exists", 2);
         }
     }
     if ($this->contains_badchars($newName) && $prefs['wiki_badchar_prevent'] == 'y') {
         throw new Exception("Bad characters", 1);
     }
     // The pre- and post-tags are eating away the max usable page name length
     //	Use ~ instead of Tmp. Shorter
     // $tmpName = "TmP".$newName."TmP";
     $tmpName = "~" . $newName . "~";
     // 1st rename the page in tiki_pages, using a tmpname inbetween for
     // rename pages like ThisTestpage to ThisTestPage
     $query = 'update `tiki_pages` set `pageName`=?, `pageSlug`=NULL where `pageName`=?';
     $this->query($query, array($tmpName, $oldName));
     $slug = TikiLib::lib('slugmanager')->generate($prefs['wiki_url_scheme'], $newName, $prefs['url_only_ascii'] === 'y');
     $query = 'update `tiki_pages` set `pageName`=?, `pageSlug`=? where `pageName`=?';
     $this->query($query, array($newName, $slug, $tmpName));
     // correct pageName in tiki_history, using a tmpname inbetween for
     // rename pages like ThisTestpage to ThisTestPage
     $query = 'update `tiki_history` set `pageName`=? where `pageName`=?';
     $this->query($query, array($tmpName, $oldName));
     $query = 'update `tiki_history` set `pageName`=? where `pageName`=?';
     $this->query($query, array($newName, $tmpName));
     // get pages linking to the old page
     $query = 'select `fromPage` from `tiki_links` where `toPage`=?';
     $result = $this->query($query, array($oldName));
     $linksToOld = array();
     while ($res = $result->fetchRow()) {
         $page = $res['fromPage'];
         $is_wiki_page = true;
         if (substr($page, 0, 11) == 'objectlink:') {
             $is_wiki_page = false;
             $objectlinkparts = explode(':', $page);
             $type = $objectlinkparts[1];
             $objectId = $objectlinkparts[2];
         }
         $linksToOld[] = $res['fromPage'];
         if ($is_wiki_page) {
             $info = $this->get_page_info($page);
             //$data=addslashes(str_replace($oldName,$newName,$info['data']));
             $data = $info['data'];
         } elseif ($type == 'forum post' || substr($type, -7) == 'comment') {
             $comment_info = TikiLib::lib('comments')->get_comment($objectId);
             $data = $comment_info['data'];
         }
         $quotedOldName = preg_quote($oldName, '/');
         $semanticlib = TikiLib::lib('semantic');
         foreach ($semanticlib->getAllTokens() as $sem) {
             $data = str_replace("({$sem}({$oldName}", "({$sem}({$newName}", $data);
         }
         if ($prefs['feature_wikiwords'] == 'y') {
             if (strstr($newName, ' ')) {
                 $data = preg_replace("/(?<= |\n|\t|\r|\\,|\\;|^){$quotedOldName}(?= |\n|\t|\r|\\,|\\;|\$)/", '((' . $newName . '))', $data);
             } else {
                 $data = preg_replace("/(?<= |\n|\t|\r|\\,|\\;|^){$quotedOldName}(?= |\n|\t|\r|\\,|\\;|\$)/", $newName, $data);
             }
         }
         $data = preg_replace("/(?<=\\(\\(){$quotedOldName}(?=\\)\\)|\\|)/i", $newName, $data);
         $quotedOldHtmlName = preg_quote(urlencode($oldName), '/');
         $htmlSearch = '/<a class="wiki" href="tiki-index\\.php\\?page=' . $quotedOldHtmlName . '([^"]*)"/i';
         $htmlReplace = '<a class="wiki" href="tiki-index.php?page=' . urlencode($newName) . '\\1"';
         $data = preg_replace($htmlSearch, $htmlReplace, $data);
         $htmlSearch = '/<a class="wiki" href="' . $quotedOldHtmlName . '"/i';
         $htmlReplace = '<a class="wiki" href="' . urlencode($newName) . '"';
         $data = preg_replace($htmlSearch, $htmlReplace, $data);
         $htmlWantedSearch = '/(' . $quotedOldName . ')?<a class="wiki wikinew" href="tiki-editpage\\.php\\?page=' . $quotedOldHtmlName . '"[^<]+<\\/a>/i';
         $data = preg_replace($htmlWantedSearch, '((' . $newName . '))', $data);
         if ($is_wiki_page) {
             $query = "update `tiki_pages` set `data`=?,`page_size`=? where `pageName`=?";
             $this->query($query, array($data, (int) strlen($data), $page));
         } elseif ($type == 'forum post' || substr($type, -7) == 'comment') {
             $query = "update `tiki_comments` set `data`=? where `threadId`=?";
             $this->query($query, array($data, $objectId));
         }
         $this->invalidate_cache($page);
     }
     // correct toPage and fromPage in tiki_links
     // before update, manage to avoid duplicating index(es) when B is renamed to C while page(s) points to both C (not created yet) and B
     $query = 'select `fromPage` from `tiki_links` where `toPage`=?';
     $result = $this->query($query, array($newName));
     $linksToNew = array();
     while ($res = $result->fetchRow()) {
         $linksToNew[] = $res['fromPage'];
     }
     if ($extra = array_intersect($linksToOld, $linksToNew)) {
         $query = 'delete from `tiki_links` where `fromPage` in (' . implode(',', array_fill(0, count($extra), '?')) . ') and `toPage`=?';
         $this->query($query, array_merge($extra, array($oldName)));
     }
     $query = 'update `tiki_links` set `fromPage`=? where `fromPage`=?';
     $this->query($query, array($newName, $oldName));
     $query = 'update `tiki_links` set `toPage`=? where `toPage`=?';
     $this->query($query, array($newName, $oldName));
     // tiki_footnotes change pageName
     $query = 'update `tiki_page_footnotes` set `pageName`=? where `pageName`=?';
     $this->query($query, array($newName, $oldName));
     // in tiki_categorized_objects update objId
     $newcathref = 'tiki-index.php?page=' . urlencode($newName);
     $query = 'update `tiki_objects` set `itemId`=?,`name`=?,`href`=? where `itemId`=? and `type`=?';
     $this->query($query, array($newName, $newName, $newcathref, $oldName, 'wiki page'));
     $this->rename_object('wiki page', $oldName, $newName, $user);
     // update categories if new name has a category default
     $categlib = TikiLib::lib('categ');
     $categories = $categlib->get_object_categories('wiki page', $newName);
     $info = $this->get_page_info($newName);
     $categlib->update_object_categories($categories, $newName, 'wiki page', $info['description'], $newName, $newcathref);
     $query = 'update `tiki_wiki_attachments` set `page`=? where `page`=?';
     $this->query($query, array($newName, $oldName));
     // group home page
     if ($renameHomes) {
         $query = 'update `users_groups` set `groupHome`=? where `groupHome`=?';
         $this->query($query, array($newName, $oldName));
     }
     // copyright
     $query = 'update tiki_copyrights set `page`=? where `page`=?';
     $this->query($query, array($newName, $oldName));
     //breadcrumb
     if (isset($_SESSION['breadCrumb']) && in_array($oldName, $_SESSION['breadCrumb'])) {
         $pos = array_search($oldName, $_SESSION["breadCrumb"]);
         $_SESSION['breadCrumb'][$pos] = $newName;
     }
     global $prefs;
     global $user;
     $tikilib = TikiLib::lib('tiki');
     $smarty = TikiLib::lib('smarty');
     if ($prefs['feature_use_fgal_for_wiki_attachments'] == 'y') {
         $query = 'update `tiki_file_galleries` set `name`=? where `name`=?';
         $this->query($query, array($newName, $oldName));
     }
     // first get all watches for this page ...
     if ($prefs['feature_user_watches'] == 'y') {
         $nots = $tikilib->get_event_watches('wiki_page_changed', $oldName);
     }
     // ... then update the watches table
     // user watches
     $query = "update `tiki_user_watches` set `object`=?, `title`=?, `url`=? where `object`=? and `type` = 'wiki page'";
     $this->query($query, array($newName, $newName, 'tiki-index.php?page=' . $newName, $oldName));
     $query = "update `tiki_group_watches` set `object`=?, `title`=?, `url`=? where `object`=? and `type` = 'wiki page'";
     $this->query($query, array($newName, $newName, 'tiki-index.php?page=' . $newName, $oldName));
     // now send notification email to all on the watchlist:
     if ($prefs['feature_user_watches'] == 'y') {
         if (!isset($_SERVER["SERVER_NAME"])) {
             $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
         }
         if (count($nots)) {
             include_once 'lib/notifications/notificationemaillib.php';
             $smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
             $smarty->assign('mail_oldname', $oldName);
             $smarty->assign('mail_newname', $newName);
             $smarty->assign('mail_user', $user);
             sendEmailNotification($nots, 'watch', 'user_watch_wiki_page_renamed_subject.tpl', $_SERVER['SERVER_NAME'], 'user_watch_wiki_page_renamed.tpl');
         }
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('pages', $oldName, false);
     refresh_index('pages', $newName);
     if ($renameHomes && $prefs['wikiHomePage'] == $oldName) {
         $tikilib->set_preference('wikiHomePage', $newName);
     }
     if ($prefs['feature_trackers'] == 'y') {
         $trklib = TikiLib::lib('trk');
         $trklib->rename_page($oldName, $newName);
     }
     return true;
 }
Exemplo n.º 12
0
 private function process_action_article($configuration, $data, $rssId)
 {
     $tikilib = TikiLib::lib('tiki');
     $artlib = TikiLib::lib('art');
     $publication = $data['publication_date'];
     // First override with custom settings for source categories if any
     if (isset($data['categories'])) {
         $source_categories = json_decode($data['categories'], true);
     }
     if (!empty($source_categories)) {
         $custominfo = $this->get_article_custom_info($rssId);
         $oldcats = array_keys($custominfo);
         if ($newcats = array_diff($source_categories, $oldcats)) {
             // send a notification if there are new categories
             $nots = $tikilib->get_event_watches('article_submitted', '*');
             if (count($nots)) {
                 $title = $this->modules->fetchOne('name', array('rssId' => $rssId));
                 include_once 'lib/notifications/notificationemaillib.php';
                 $smarty = TikiLib::lib('smarty');
                 $smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
                 $smarty->assign('rssId', $rssId);
                 $smarty->assign('title', $title);
                 $smarty->assign('newcats', $newcats);
                 sendEmailNotification($nots, 'watch', 'rss_new_source_category_subject.tpl', $_SERVER['SERVER_NAME'], 'rss_new_source_category.tpl');
             }
         }
         $current_priority = 0;
         foreach ($custominfo as $source_category => $settings) {
             if (in_array($source_category, $source_categories)) {
                 if (isset($settings['priority']) && $settings['priority'] < $current_priority) {
                     continue;
                 }
                 if (!empty($settings['atype'])) {
                     $configuration['atype'] = $settings['atype'];
                 }
                 if (isset($settings['topic']) && $settings['topic'] > '') {
                     // need to match 0
                     $configuration['topic'] = $settings['topic'];
                 }
                 if (isset($settings['rating']) && $settings['rating'] > '') {
                     // need to match 0
                     $configuration['rating'] = $settings['rating'];
                 }
                 $current_priority = isset($settings['priority']) ? $settings['priority'] : 0;
             }
         }
     }
     if ($configuration['future_publish'] > 0) {
         $publication = $tikilib->now + $configuration['future_publish'] * 60;
     }
     $expire = $publication + 3600 * 24 * $configuration['expiry'];
     if (strpos($data['content'], trim($data['description'])) === 0 && strlen($data['description']) < 1024) {
         $data['content'] = substr($data['content'], strlen(trim($data['description'])));
     }
     $data['content'] = trim($data['content']) == '' ? $data['content'] : '~np~' . $data['content'] . '~/np~';
     $hash = md5($data['title'] . $data['description'] . $data['content']);
     if ($configuration['submission'] == true) {
         $subid = $this->table('tiki_submissions')->fetchOne('subId', array('linkto' => $data['url'], 'topicId' => $configuration['topic'], 'hash' => $hash));
         if (!$subid) {
             $subid = 0;
         }
         $subid = $artlib->replace_submission($data['title'], $data['author'], $configuration['topic'], 'n', '', 0, '', '', $data['description'], $data['content'], $publication, $expire, 'admin', $subid, 0, 0, $configuration['atype'], '', '', $data['url'], '', '', $configuration['rating']);
         if (count($configuration['categories'])) {
             $categlib = TikiLib::lib('categ');
             $objectId = $categlib->add_categorized_object('submission', $subid, $data['title'], $data['title'], 'tiki-edit_submission.php?subId=' . $subid);
             foreach ($configuration['categories'] as $categId) {
                 $categlib->categorize($objectId, $categId);
             }
         }
     } else {
         $id = $this->table('tiki_articles')->fetchOne('articleId', array('linkto' => $data['url'], 'topicId' => $configuration['topic'], 'hash' => $hash));
         if (!$id) {
             $id = 0;
         }
         $id = $artlib->replace_article($data['title'], $data['author'], $configuration['topic'], 'n', '', 0, '', '', $data['description'], $data['content'], $publication, $expire, 'admin', $id, 0, 0, $configuration['atype'], '', '', $data['url'], '', '', $configuration['rating']);
         if (count($configuration['categories'])) {
             $categlib = TikiLib::lib('categ');
             $objectId = $categlib->add_categorized_object('article', $id, $data['title'], $data['title'], 'tiki-read_article.php?articleId=' . $id);
             foreach ($configuration['categories'] as $categId) {
                 $categlib->categorize($objectId, $categId);
             }
         }
         TikiLib::lib('relation')->add_relation('tiki.rss.source', 'article', $id, 'rss', $rssId);
         require_once 'lib/search/refresh-functions.php';
         refresh_index('articles', $id);
         $related_items = TikiLib::lib('relation')->get_relations_to('article', $id, 'tiki.article.attach');
         foreach ($related_items as $item) {
             refresh_index($item['type'], $item['itemId']);
         }
     }
 }
Exemplo n.º 13
0
 function notify($imageId, $galleryId, $name, $filename, $description, $galleryName, $user)
 {
     global $prefs;
     if ($prefs['feature_user_watches'] == 'y') {
         include_once 'lib/notifications/notificationemaillib.php';
         global $smarty, $tikilib;
         $nots = $this->get_event_watches('image_gallery_changed', $galleryId);
         $smarty->assign_by_ref('galleryId', $galleryId);
         $smarty->assign_by_ref('galleryName', $galleryName);
         $smarty->assign_by_ref('mail_date', date('U'));
         $smarty->assign_by_ref('author', $user);
         $foo = parse_url($_SERVER["REQUEST_URI"]);
         $machine = $tikilib->httpPrefix() . dirname($foo["path"]);
         $smarty->assign_by_ref('mail_machine', $machine);
         $smarty->assign_by_ref('fname', $name);
         $smarty->assign_by_ref('filename', $filename);
         $smarty->assign_by_ref('description', $description);
         $smarty->assign_by_ref('imageId', $imageId);
         sendEmailNotification($nots, 'watch', 'user_watch_image_gallery_changed_subject.tpl', NULL, 'user_watch_image_gallery_upload.tpl');
     }
 }
Exemplo n.º 14
0
 function blog_post($blogId, $data, $user, $title = '', $trackbacks = '')
 {
     // update tiki_blogs and call activity functions
     global $smarty;
     global $tikilib;
     global $feature_user_watches;
     global $sender_email;
     $tracks = serialize(explode(',', $trackbacks));
     $data = strip_tags($data, '<a><b><i><h1><h2><h3><h4><h5><h6><ul><li><ol><br><p><table><tr><td><img><pre>');
     $now = date("U");
     $query = "insert into `tiki_blog_posts`(`blogId`,`data`,`created`,`user`,`title`,`trackbacks_from`,`trackbacks_to`) values(?,?,?,?,?,?,?)";
     $result = $this->query($query, array((int) $blogId, $data, (int) $now, $user, $title, serialize(array()), serialize(array())));
     $query = "select max(`postId`) from `tiki_blog_posts` where `created`=? and `user`=?";
     $id = $this->getOne($query, array((int) $now, $user));
     // Send trackbacks recovering only successful trackbacks
     $trackbacks = serialize($this->send_trackbacks($id, $trackbacks));
     // Update post with trackbacks successfully sent
     $query = "update `tiki_blog_posts` set `trackbacks_from`=?, `trackbacks_to` = ? where `postId`=?";
     $this->query($query, array(serialize(array()), $trackbacks, (int) $id));
     $query = "update `tiki_blogs` set `lastModif`=?,`posts`=`posts`+1 where `blogId`=?";
     $result = $this->query($query, array((int) $now, (int) $blogId));
     $this->add_blog_activity($blogId);
     if ($feature_user_watches == 'y') {
         $nots = $this->get_event_watches('blog_post', $blogId);
         if (!isset($_SERVER["SERVER_NAME"])) {
             $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
         }
         if (count($nots)) {
             include_once "lib/notifications/notificationemaillib.php";
             $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
             $query = "select `title` from `tiki_blogs` where `blogId`=?";
             $blogTitle = $this->getOne($query, array((int) $blogId));
             $smarty->assign('mail_title', $blogTitle);
             $smarty->assign('mail_post_title', $title);
             $smarty->assign('mail_blogid', $blogId);
             $smarty->assign('mail_postid', $id);
             $smarty->assign('mail_date', date("U"));
             $smarty->assign('mail_user', $user);
             $smarty->assign('mail_data', $data);
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = $tikilib->httpPrefix() . $foo["path"];
             $smarty->assign('mail_machine', $machine);
             $parts = explode('/', $foo['path']);
             if (count($parts) > 1) {
                 unset($parts[count($parts) - 1]);
             }
             $smarty->assign('mail_machine_raw', $tikilib->httpPrefix() . implode('/', $parts));
             sendEmailNotification($nots, "watch", "user_watch_blog_post_subject.tpl", $_SERVER["SERVER_NAME"], "user_watch_blog_post.tpl");
             //@mail($not['email'], tra('Blog post'). ' ' . $blogTitle, $mail_data, "From: $sender_email\r\nContent-type: text/plain;charset=utf-8\r\n");
         }
     }
     global $feature_score;
     if ($feature_score == 'y') {
         $this->score_event($user, 'blog_post');
     }
     return $id;
 }
Exemplo n.º 15
0
 function replace_article($title, $authorName, $topicId, $useImage, $imgname, $imgsize, $imgtype, $imgdata, $heading, $body, $publishDate, $expireDate, $user, $articleId, $image_x, $image_y, $type, $topline, $subtitle, $linkto, $image_caption, $lang, $rating = 0, $isfloat = 'n', $emails = '', $from = '', $list_image_x = '', $list_image_y = '', $ispublished = 'y', $fromurl = false)
 {
     $tikilib = TikiLib::lib('tiki');
     $smarty = TikiLib::lib('smarty');
     if ($expireDate < $publishDate) {
         $expireDate = $publishDate;
     }
     $hash = md5($title . $heading . $body);
     if (empty($imgdata) || $useImage === 'n') {
         // remove image data if not using it
         $imgdata = '';
     }
     $query = 'select `name` from `tiki_topics` where `topicId` = ?';
     $topicName = $this->getOne($query, array($topicId));
     $size = $body ? mb_strlen($body) : mb_strlen($heading);
     $info = array('title' => $title, 'authorName' => $authorName, 'topicId' => (int) $topicId, 'topicName' => $topicName, 'size' => (int) $size, 'useImage' => $useImage, 'image_name' => $imgname, 'image_type' => $imgtype, 'image_size' => (int) $imgsize, 'image_data' => $imgdata, 'isfloat' => $isfloat, 'image_x' => (int) $image_x, 'image_y' => (int) $image_y, 'list_image_x' => (int) $list_image_x, 'list_image_y' => (int) $list_image_y, 'heading' => $heading, 'body' => $body, 'publishDate' => (int) $publishDate, 'expireDate' => (int) $expireDate, 'created' => (int) $this->now, 'author' => $user, 'type' => $type, 'rating' => (double) $rating, 'topline' => $topline, 'subtitle' => $subtitle, 'linkto' => $linkto, 'image_caption' => $image_caption, 'lang' => $lang, 'ispublished' => $ispublished);
     $article_table = $this->table('tiki_articles');
     if ($articleId) {
         $oldArticle = $this->get_article($articleId);
         $article_table->update($info, array('articleId' => (int) $articleId));
         // Clear article image cache because image may just have been changed
         $this->delete_image_cache('article', $articleId);
         $event = 'article_edited';
         $nots = $tikilib->get_event_watches('article_edited', '*');
         $nots2 = $tikilib->get_event_watches('topic_article_edited', $topicId);
         $smarty->assign('mail_action', 'Edit');
         $smarty->assign('mail_old_title', $oldArticle['title']);
         $smarty->assign('mail_old_publish_date', $oldArticle['publishDate']);
         $smarty->assign('mail_old_expiration_date', $oldArticle['expireDate']);
         $smarty->assign('mail_old_data', $oldArticle['heading'] . "\n----------------------\n" . $oldArticle['body']);
     } else {
         $articleId = $article_table->insert($info);
         global $prefs;
         if ($prefs['feature_score'] == 'y') {
             $this->score_event($user, 'article_new');
         }
         $event = 'article_submitted';
         $nots = $tikilib->get_event_watches('article_submitted', '*');
         $nots2 = $tikilib->get_event_watches('topic_article_created', $topicId);
         $smarty->assign('mail_action', 'New');
         // Create tracker item as well if feature is enabled
         if (!$fromurl && $prefs['tracker_article_tracker'] == 'y' && ($trackerId = $prefs['tracker_article_trackerId'])) {
             $trklib = TikiLib::lib('trk');
             $definition = Tracker_Definition::get($trackerId);
             if ($fieldId = $definition->getArticleField()) {
                 $addit = array();
                 $addit[] = array('fieldId' => $fieldId, 'type' => 'articles', 'value' => $articleId);
                 $itemId = $trklib->replace_item($trackerId, 0, array('data' => $addit));
                 TikiLib::lib('relation')->add_relation('tiki.article.attach', 'trackeritem', $itemId, 'article', $articleId);
             }
         }
     }
     $nots3 = array();
     foreach ($nots as $n) {
         $nots3[] = $n['email'];
     }
     foreach ($nots2 as $n) {
         if (!in_array($n['email'], $nots3)) {
             $nots[] = $n;
         }
     }
     if (is_array($emails) && (empty($from) || $from == $prefs['sender_email'])) {
         foreach ($emails as $n) {
             if (!in_array($n, $nots3)) {
                 $nots[] = array('email' => $n, 'language' => $prefs['site_language']);
             }
         }
     }
     global $prefs;
     if ($prefs['user_article_watch_editor'] != "y") {
         for ($i = count($nots) - 1; $i >= 0; --$i) {
             if ($nots[$i]['user'] == $user) {
                 unset($nots[$i]);
                 break;
             }
         }
     }
     if (!isset($_SERVER['SERVER_NAME'])) {
         $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
     }
     if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
         $reportsManager = Reports_Factory::build('Reports_Manager');
         $reportsManager->addToCache($nots, array('event' => $event, 'articleId' => $articleId, 'articleTitle' => $title, 'authorName' => $authorName, 'user' => $user));
     }
     if (count($nots) || is_array($emails)) {
         include_once 'lib/notifications/notificationemaillib.php';
         $smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
         $smarty->assign('mail_title', $title);
         $smarty->assign('mail_postid', $articleId);
         $smarty->assign('mail_user', $user);
         $smarty->assign('mail_current_publish_date', $publishDate);
         $smarty->assign('mail_current_expiration_date', $expireDate);
         $smarty->assign('mail_current_data', $heading . "\n----------------------\n" . $body);
         sendEmailNotification($nots, 'watch', 'user_watch_article_post_subject.tpl', $_SERVER['SERVER_NAME'], 'user_watch_article_post.tpl');
         if (is_array($emails) && !empty($from) && $from != $prefs['sender_email']) {
             $nots = array();
             foreach ($emails as $n) {
                 $nots[] = array('email' => $n, 'language' => $prefs['site_language']);
             }
             sendEmailNotification($nots, 'watch', 'user_watch_article_post_subject.tpl', $_SERVER['SERVER_NAME'], 'user_watch_article_post.tpl', $from);
         }
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('articles', $articleId);
     $tikilib = TikiLib::lib('tiki');
     $tikilib->object_post_save(array('type' => 'article', 'object' => $articleId, 'description' => substr($heading, 0, 200), 'name' => $title, 'href' => "tiki-read_article.php?articleId={$articleId}"), array('content' => $body . "\n" . $heading));
     return $articleId;
 }
Exemplo n.º 16
0
/**
 * @param $type Type of the object commented on, 'wiki' or 'article'
 * @param $id Identifier of the object commented on. For articles, their id and for wiki pages, their name
 * @param $title Comment title
 * @param $content Comment content
 */
function sendCommentNotification($type, $id, $title, $content, $commentId = null)
{
    global $user, $tikilib, $smarty, $prefs;
    if ($type == 'wiki') {
        $events = 'wiki_comment_changes';
    } elseif ($type == 'article') {
        $events = 'article_commented';
    } elseif ($type == 'trackeritem') {
        $events = 'trackeritem_commented';
        // Blog comment mail
    } elseif ($type == 'blog') {
        $events = 'blog_comment_changes';
    } else {
        throw new Exception('Unknown type');
    }
    if ($type == 'trackeritem') {
        // Tracker watches are pretty complicated, to get from trklib
        $trklib = TikiLib::lib('trk');
        $trackerId = $trklib->get_tracker_for_item($id);
        $trackerOptions = $trklib->get_tracker_options($trackerId);
        $watches = $trklib->get_notification_emails($trackerId, $id, $trackerOptions);
    } else {
        // Blog comment mail
        $watches = $tikilib->get_event_watches($events, $id);
    }
    $watches2 = $tikilib->get_event_watches('comment_post', $commentId);
    if (!empty($watches2)) {
        $watches = array_merge($watches, $watches2);
    }
    if (($type != 'wiki' || $prefs['wiki_watch_editor'] != 'y' || $prefs['user_wiki_watch_editor'] != 'y') && $prefs['user_comment_watch_editor'] != "y") {
        for ($i = count($watches) - 1; $i >= 0; --$i) {
            if ($watches[$i]['user'] == $user) {
                unset($watches[$i]);
                break;
            }
        }
    }
    if (count($watches)) {
        if ($type == 'wiki') {
            $smarty->assign('mail_objectname', $id);
        } elseif ($type == 'article') {
            global $artlib;
            include_once 'lib/articles/artlib.php';
            $smarty->assign('mail_objectname', $artlib->get_title($id));
            $smarty->assign('mail_objectid', $id);
        } elseif ($type == 'trackeritem') {
            if ($prefs['feature_daily_report_watches'] == 'y') {
                $reportsManager = Reports_Factory::build('Reports_Manager');
                $reportsManager->addToCache($watches, array('event' => 'tracker_item_comment', 'itemId' => $id, 'trackerId' => $trackerId, 'user' => $user, 'threadId' => $commentId));
            }
            $tracker = $trklib->get_tracker($trackerId);
            $smarty->assign('mail_objectid', $id);
            $smarty->assign('mail_objectname', $tracker['name']);
            $smarty->assign('mail_item_title', $trklib->get_isMain_value($trackerId, $id));
        }
        // Blog comment mail
        $smarty->assign('mail_objectid', $id);
        $smarty->assign('objecttype', $type);
        $smarty->assign('mail_user', $user);
        $smarty->assign('mail_title', $title);
        $smarty->assign('mail_comment', $content);
        sendEmailNotification($watches, null, 'user_watch_comment_subject.tpl', null, 'user_watch_comment.tpl');
    }
}
Exemplo n.º 17
0
 function assign_user_to_group($user, $group)
 {
     global $cachelib;
     require_once 'lib/cache/cachelib.php';
     global $tikilib, $prefs, $access, $tiki_p_admin, $page;
     if ($this->is_user_banned_from_group($user, $group)) {
         $msg = tr('User "%0" is banned from the group "%1".', $user, $group);
         if ($tiki_p_admin === 'y') {
             $access->check_authenticity($msg . ' ' . tra('Do you want to unban them and continue?'));
             $this->unban_user_from_group($user, $group);
         } else {
             $access->display_error($page, $msg);
         }
     }
     $cachelib->invalidate('user_details_' . $user);
     $tikilib->invalidate_usergroups_cache($user);
     $group_ret = false;
     //Get the ID from the table directly.
     $userid = $this->table('users_users')->fetchOne('userId', array('login' => $user));
     // Maybe it's not best place to do it.
     // If it's not there, the first login with CAS doesn't work well. We will get "You don't have the permission ..."
     $_SESSION['u_info']['id'] = $userid;
     if ($userid > 0) {
         $query = "insert ignore into `users_usergroups`(`userId`,`groupName`, `created`) values(?,?,?)";
         $result = $this->query($query, array($userid, $group, $tikilib->now), -1, -1, false);
         $group_ret = true;
         if ($prefs['user_trackersync_groups'] == 'y') {
             $this->categorize_user_tracker_item($user, $group);
         }
     }
     $this->update_anniversary_expiry();
     if ($prefs['feature_community_send_mail_join'] == 'y') {
         $group_base = trim(str_replace(array_map('trim', explode(",", $prefs['feature_community_Strings_to_ignore'])), '', $group));
         if (!empty($prefs['feature_community_String_to_append'])) {
             $grouplead = $group_base . " " . trim($prefs['feature_community_String_to_append']);
             $groupleaders = $this->get_users_created_group($grouplead);
             unset($groupleaders[$user]);
             if (isset($groupleaders[$_SESSION['u_info']['login']])) {
                 unset($groupleaders[$_SESSION['u_info']['login']]);
             }
             if (!empty($groupleaders)) {
                 $par_data['gname'] = $group_base;
                 $par_data['user'] = $user;
                 if (strpos($group, ' (Needs Approval)')) {
                     $mail_temp = 'user_joins_group_notification_to_leads_need_app.tpl';
                 } else {
                     $mail_temp = 'user_joins_group_notification_to_leads.tpl';
                 }
                 require_once "lib/notifications/notificationemaillib.php";
                 sendEmailNotification($groupleaders, 'group_lead_mail', 'user_joins_group_notification_to_leads_subject.tpl', $par_data, $mail_temp);
             }
         }
     }
     if ($group_ret) {
         $watches = $tikilib->get_event_watches('user_joins_group', $group);
         if (count($watches)) {
             require_once "lib/notifications/notificationemaillib.php";
             $smarty = TikiLib::lib('smarty');
             $smarty->assign('mail_user', $user);
             $smarty->assign('mail_group', $group);
             sendEmailNotification($watches, null, 'user_joins_group_notification_subject.tpl', null, 'user_joins_group_notification.tpl');
         }
     }
     return $group_ret;
 }
Exemplo n.º 18
0
/**
 * send message via internal messenger
 * @param string $subject
 * @param string $message
 * @param string $recipient user_id
 * @param bool $email send email or not
 */
function sendInternalMessage($subject, $message, $recipient_id, $email = true)
{
    $thread = Thread::create(['subject' => $subject]);
    // Message
    $message = Message::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'body' => $message]);
    // Sender
    Participant::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'last_read' => new Carbon()]);
    // Add Recipients
    $thread->addParticipant([$recipient_id]);
    if ($email) {
        sendEmailNotification($message);
    }
    return $thread->id;
}
Exemplo n.º 19
0
 /**
  * Adds a new message to a current thread.
  *
  * @param $id
  * @return mixed
  */
 public function update($id)
 {
     try {
         $thread = Thread::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');
         return redirect('messages');
     }
     $thread->activateAllParticipants();
     // Message
     $message = Message::create(['thread_id' => $thread->id, 'user_id' => Auth::id(), 'body' => Input::get('message')]);
     // Add replier as a participant
     $participant = Participant::firstOrCreate(['thread_id' => $thread->id, 'user_id' => Auth::user()->id]);
     $participant->last_read = new Carbon();
     $participant->save();
     // Recipients
     if (Input::has('recipients')) {
         $thread->addParticipants(Input::get('recipients'));
     }
     // email notification via helper method
     sendEmailNotification($message);
     return redirect('messages/' . $id);
 }
Exemplo n.º 20
0
 function assign_user_to_group($user, $group, $bulk = false)
 {
     if (!$this->group_exists($group)) {
         throw new Exception(tr('Cannot add user %0 to nonexistent group %1', $user, $group));
     }
     if (!$this->user_exists($user)) {
         throw new Exception(tr('Cannot add nonexistent user %0 to group %1', $user, $group));
     }
     global $prefs, $tiki_p_admin, $page;
     $cachelib = TikiLib::lib('cache');
     $tikilib = TikiLib::lib('tiki');
     $access = TikiLib::lib('access');
     if ($this->is_user_banned_from_group($user, $group)) {
         $msg = tr('User "%0" is banned from the group "%1".', $user, $group);
         if ($tiki_p_admin === 'y') {
             $access->check_authenticity($msg . ' ' . tra('Do you want to unban them and continue?'));
             $this->unban_user_from_group($user, $group);
         } else {
             $access->display_error($page, $msg);
         }
     }
     $cachelib->invalidate('user_details_' . $user);
     $tikilib->invalidate_usergroups_cache($user);
     $this->invalidate_usergroups_cache($user);
     // this is needed as cache is present in this instance too
     $group_ret = false;
     $userid = $this->get_user_id($user);
     if ($userid > 0) {
         $query = "insert ignore into `users_usergroups`(`userId`,`groupName`, `created`) values(?,?,?)";
         $result = $this->query($query, array($userid, $group, $tikilib->now), -1, -1, false);
         $group_ret = true;
     }
     $this->update_group_expiries();
     if ($prefs['feature_community_send_mail_join'] == 'y') {
         $api = new TikiAddons_Api_Group();
         if ($api->isOrganicGroup($group)) {
             $groupleaders = $api->getOrganicGroupLeaders($group);
             $groupleaders = array_combine($groupleaders, $groupleaders);
             unset($groupleaders[$user]);
             if (isset($groupleaders[$_SESSION['u_info']['login']])) {
                 unset($groupleaders[$_SESSION['u_info']['login']]);
             }
             if (!empty($groupleaders)) {
                 $par_data['gname'] = $group;
                 $par_data['user'] = $user;
                 if (strpos($group, 'pending')) {
                     $mail_temp = 'user_joins_group_notification_to_leads_need_app.tpl';
                 } else {
                     $mail_temp = 'user_joins_group_notification_to_leads.tpl';
                 }
                 require_once "lib/notifications/notificationemaillib.php";
                 sendEmailNotification($groupleaders, 'group_lead_mail', 'user_joins_group_notification_to_leads_subject.tpl', $par_data, $mail_temp);
             }
         }
     }
     if ($group_ret) {
         $watches = $tikilib->get_event_watches('user_joins_group', $group);
         if (count($watches)) {
             require_once "lib/notifications/notificationemaillib.php";
             $smarty = TikiLib::lib('smarty');
             $smarty->assign('mail_user', $user);
             $smarty->assign('mail_group', $group);
             sendEmailNotification($watches, null, 'user_joins_group_notification_subject.tpl', null, 'user_joins_group_notification.tpl');
         }
         $api = new TikiAddons_Api_Group();
         TikiLib::events()->trigger('tiki.user.groupjoin', array('type' => 'user', 'object' => $user, 'group' => $group, 'addongroup' => $api->getOrganicGroupName($group), 'is_organic' => $api->isOrganicGroup($group) ? 1 : 0, 'is_private' => $api->organicGroupIsPrivate($group) ? 1 : 0, 'addongroupid' => $api->getItemIdFromToken($group), 'bulk_import' => $bulk));
     }
     return $group_ret;
 }
Exemplo n.º 21
0
	function assign_user_to_group($user, $group)
	{
		global $cachelib; require_once('lib/cache/cachelib.php');
		global $tikilib, $prefs, $access, $tiki_p_admin, $page;

		if ($this->is_user_banned_from_group($user, $group)) {
			$msg = tr('User "%0" is banned from the group "%1".', $user, $group);
			if ($tiki_p_admin === 'y') {
				$access->check_authenticity($msg . ' ' . tra('Do you want to unban them and continue?'));
				$this->unban_user_from_group($user, $group);
			} else {
				$access->display_error($page, $msg);
			}
		}

		$cachelib->invalidate('user_details_'.$user);
		$tikilib->invalidate_usergroups_cache($user);

		$group_ret = false;
		$userid = $this->get_user_id($user);

		if ( $userid > 0 ) {
			$query = "insert ignore into `users_usergroups`(`userId`,`groupName`, `created`) values(?,?,?)";
			$result = $this->query($query, array($userid, $group, $tikilib->now), -1, -1, false);
			$group_ret = true;
			if ($prefs['user_trackersync_groups'] == 'y') {
				$this->categorize_user_tracker_item($user, $group);
			}
		}
		$this->update_anniversary_expiry();

		if ($group_ret) {
			$watches = $tikilib->get_event_watches('user_joins_group', $group);
			if (count($watches)) {
				require_once ("lib/notifications/notificationemaillib.php");
				$smarty = TikiLib::lib('smarty');
				$smarty->assign('mail_user', $user);
				$smarty->assign('mail_group', $group);
				sendEmailNotification($watches, null, 'user_joins_group_notification_subject.tpl', null, 'user_joins_group_notification.tpl');
			}
		}

		return $group_ret;
	}
Exemplo n.º 22
0
	</body>
	</html>
	';
}
if (!empty($_POST)) {
    displayPageHead();
    $order_Deadline = $_POST['Order_Deadline'];
    $accountEmail = $_POST['AccountEmail'];
    $pickupOption = $_POST['pickupOption'];
    $orderRemitTotal = $_POST['OrderRemitTotal'];
    $orderTotal = $_POST['OrderTotal'];
    $Order_Deadline = $order_Deadline;
    $AccountEmail = $accountEmail;
    $PickupOption = $pickupOption;
    echo "<h2>Order_Deadline:" . $order_Deadline . '</h2>';
    echo "<h2>AccountEmail:" . $accountEmail . '</h2>';
    echo "<h2>PickupOptions:" . $pickupOption . '</h2>';
    $order_details = json_decode($_POST["order_details"], true);
    if (!is_null($order_details)) {
        if (validateOrderDetails($order_details)) {
            $orders_to_post = array('Order_Deadline' => $order_Deadline, 'Account' => $accountEmail, 'Pickup' => $pickupOption, 'Order' => json_encode($order_entries));
            if (postOrderWithCurl($orders_to_post)) {
                $orders = getOrderWithAccountAndDeadline($accountEmail, $order_Deadline);
                $displayStr = displayReportForAccount($orders);
                sendEmailNotification($accountEmail, $order_Deadline, $pickupOption, $displayStr);
                echo $displayStr;
            }
        }
    }
    displayPageEnd();
}
Exemplo n.º 23
0
 /**
  * @param $imageId
  * @param $galleryId
  * @param $name
  * @param $filename
  * @param $description
  * @param $galleryName
  * @param $action
  * @param $user
  */
 function notify($imageId, $galleryId, $name, $filename, $description, $galleryName, $action, $user)
 {
     global $prefs;
     if ($prefs['feature_user_watches'] == 'y') {
         $event = 'image_gallery_changed';
         $nots = $this->get_event_watches($event, $galleryId);
         if ($prefs['feature_daily_report_watches'] == 'y') {
             $reportsManager = Reports_Factory::build('Reports_Manager');
             $reportsManager->addToCache($nots, array("event" => $event, "imageId" => $imageId, "imageName" => $name, "fileName" => $filename, "galleryId" => $galleryId, "galleryName" => $galleryName, "action" => $action, "user" => $user));
         }
         $smarty = TikiLib::lib('smarty');
         include_once 'lib/notifications/notificationemaillib.php';
         $smarty->assign_by_ref('galleryId', $galleryId);
         $smarty->assign_by_ref('galleryName', $galleryName);
         $smarty->assign_by_ref('author', $user);
         $smarty->assign_by_ref('fname', $name);
         $smarty->assign_by_ref('filename', $filename);
         $smarty->assign_by_ref('description', $description);
         $smarty->assign_by_ref('imageId', $imageId);
         sendEmailNotification($nots, 'watch', 'user_watch_image_gallery_changed_subject.tpl', NULL, 'user_watch_image_gallery_upload.tpl');
     }
 }
Exemplo n.º 24
0
        $tikilib->set_user_preference($_REQUEST['name'], 'mytiki_items', $prefs['users_prefs_mytiki_items']);
        $tikilib->set_user_preference($_REQUEST['name'], 'mytiki_workflow', $prefs['users_prefs_mytiki_workflow']);
        $tikilib->set_user_preference($_REQUEST['name'], 'tasks_maxRecords', $prefs['users_prefs_tasks_maxRecords']);
        // Custom fields
        foreach ($customfields as $custpref => $prefvalue) {
            if (isset($_REQUEST[$customfields[$custpref]['prefName']])) {
                $tikilib->set_user_preference($_REQUEST["name"], $customfields[$custpref]['prefName'], $_REQUEST[$customfields[$custpref]['prefName']]);
            }
        }
        $emails = $notificationlib->get_mail_events('user_registers', '*');
        if (count($emails)) {
            include_once "lib/notifications/notificationemaillib.php";
            $smarty->assign('mail_user', $_REQUEST["name"]);
            $smarty->assign('mail_date', $tikilib->now);
            $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
            sendEmailNotification($emails, "email", "new_user_notification_subject.tpl", null, "new_user_notification.tpl");
        }
    }
}
$smarty->assign('email_valid', $email_valid);
ask_ticket('register');
$_VALID = tra("Please enter a valid %s.  No spaces, more than %d characters and contain %s");
$smarty->assign('_PROMPT_UNAME', sprintf($_VALID, tra("username"), $prefs['min_username_length'], "0-9,a-z,A-Z"));
$smarty->assign('_PROMPT_PASS', sprintf($_VALID, tra("password"), $prefs['min_pass_length'], "0-9,a-z,A-Z"));
$smarty->assign('min_username_length', $prefs['min_username_length']);
$smarty->assign('min_pass_length', $prefs['min_pass_length']);
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
// xajax
if ($prefs['feature_ajax'] == 'y') {
    require_once "lib/ajax/ajaxlib.php";
Exemplo n.º 25
0
function downloadFile($randname)
{
    include "config.inc.php";
    $db = new PDO('sqlite:f2.sqlite');
    $stmt = $db->prepare("SELECT owner,filename FROM files WHERE randname = :randname;");
    $stmt->bindValue(':randname', $randname);
    $stmt->execute();
    $result = $stmt->fetch();
    $filename = $result['filename'];
    $owner = $result['owner'];
    $stmt = $db->prepare("SELECT email FROM user WHERE username = :username;");
    $stmt->bindValue(':username', $owner);
    $stmt->execute();
    $result = $stmt->fetch();
    $mailto = $result['email'];
    $path = $conf['datadir'] . "/" . $randname;
    $mm_type = "application/octet-stream";
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Type: " . $mm_type);
    header("Content-Length: " . (string) filesize($path));
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    header("Content-Transfer-Encoding: binary\n");
    readfile($path);
    sendEmailNotification($filename, $mailto);
}
Exemplo n.º 26
0
function wikiplugin_memberlist_remove($groups, $removes, $mail = false, $params = array())
{
    $userlib = TikiLib::lib('user');
    foreach ($removes as $group => $members) {
        if (isset($groups[$group])) {
            if ($groups[$group]['can_remove']) {
                foreach ($members as $name) {
                    $userlib->remove_user_from_group($name, $group);
                    if ($mail == 'true') {
                        $removed_user[$name] = $_SESSION['u_info']['login'];
                        $par_data['gname'] = $group;
                        $par_data['app_data'] = isset($_POST['text_area']) ? $_POST['text_area'] : '';
                    }
                }
                if ($params['addon_groups_approval_buttons'] == 'y') {
                    $subject = "admin_rejection_user_group_notification_subject.tpl";
                    $body = "admin_rejection_user_group_notification.tpl";
                } else {
                    $subject = "admin_remove_user_group_notification_subject.tpl";
                    $body = "admin_remove_user_group_notification.tpl";
                }
                if (!empty($removed_user) && isset($par_data)) {
                    require_once "lib/notifications/notificationemaillib.php";
                    sendEmailNotification($removed_user, 'add_rem_mail', $subject, $par_data, $body);
                }
            }
        }
    }
}