function xmultiquote_get_xmessage_string($message_parser) { global $config; $ids = xmultiquote_get_ids(); $xmessages = array(); foreach ($ids as $id) { $post_data = xmultiquote_get_post($id); if ($config['allow_bbcode']) { $message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($post_data['post_text'])) . "[/quote]\n"; } else { $offset = 0; $quote_string = "> "; $message = censor_text(trim($post_data['post_text'])); // see if we are nesting. It's easily tricked but should work for one level of nesting if (strpos($message, ">") !== false) { $offset = 10; } $message = utf8_wordwrap($message, 75 + $offset, "\n"); $message = $quote_string . $message; $message = str_replace("\n", "\n" . $quote_string, $message); $message = $post_data['quote_username'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n"; } $message_parser->message = $message; $message_parser->decode_message($post_data['bbcode_uid']); $message = $message_parser->message; $xmessages[] = $message; } return implode("\n\n", $xmessages); }
function main($id, $mode) { global $config, $template, $phpbb_admin_path, $phpEx; $collect_url = "http://www.phpbb.com/stats/receive_stats.php"; $this->tpl_name = 'acp_send_statistics'; $this->page_title = 'ACP_SEND_STATISTICS'; // generate a unique id if necessary if (!isset($config['questionnaire_unique_id'])) { $install_id = unique_id(); set_config('questionnaire_unique_id', $install_id); } else { $install_id = $config['questionnaire_unique_id']; } $collector = new phpbb_questionnaire_data_collector($install_id); // Add data provider $collector->add_data_provider(new phpbb_questionnaire_php_data_provider()); $collector->add_data_provider(new phpbb_questionnaire_system_data_provider()); $collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config)); $template->assign_vars(array('U_COLLECT_STATS' => $collect_url, 'RAW_DATA' => $collector->get_data_for_form(), 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.{$phpEx}"))); $raw = $collector->get_data_raw(); foreach ($raw as $provider => $data) { if ($provider == 'install_id') { $data = array($provider => $data); } $template->assign_block_vars('providers', array('NAME' => htmlspecialchars($provider))); foreach ($data as $key => $value) { if (is_array($value)) { $value = utf8_wordwrap(serialize($value), 75, "\n", true); } $template->assign_block_vars('providers.values', array('KEY' => utf8_htmlspecialchars($key), 'VALUE' => utf8_htmlspecialchars($value))); } } }
public function test_utf8_wordwrap_utf8_cut() { $text = "0123456 0123 012345 01234"; $greek = $this->turn_into_greek($text); $expected = $this->turn_into_greek(wordwrap($text, 5, "\n", true)); $phpbb_utf8_wordwrap = utf8_wordwrap($greek, 5, "\n", true); $this->assertEquals($expected, $phpbb_utf8_wordwrap, 'Checking UTF-8 cutting long words'); }
} // Decode text for message display $post_data['bbcode_uid'] = $mode == 'quote' && !$preview && !$refresh && !sizeof($error) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid; $message_parser->decode_message($post_data['bbcode_uid']); if ($mode == 'quote' && !$submit && !$preview && !$refresh) { if ($config['allow_bbcode']) { $message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n"; } else { $offset = 0; $quote_string = "> "; $message = censor_text(trim($message_parser->message)); // see if we are nesting. It's easily tricked but should work for one level of nesting if (strpos($message, ">") !== false) { $offset = 10; } $message = utf8_wordwrap($message, 75 + $offset, "\n"); $message = $quote_string . $message; $message = str_replace("\n", "\n" . $quote_string, $message); $message_parser->message = $post_data['quote_username'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n"; } } if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh) { $post_data['post_subject'] = (strpos($post_data['post_subject'], 'Re: ') !== 0 ? 'Re: ' : '') . censor_text($post_data['post_subject']); } $attachment_data = $message_parser->attachment_data; $filename_data = $message_parser->filename_data; $post_data['post_text'] = $message_parser->message; if (sizeof($post_data['poll_options']) || !empty($post_data['poll_title'])) { $message_parser->message = $post_data['poll_title']; $message_parser->bbcode_uid = $post_data['bbcode_uid']; $message_parser->decode_message();
/** * Process queue * Using lock file */ function process() { global $db, $config, $phpEx, $phpbb_root_path, $user; set_config('last_queue_run', time(), true); // Delete stale lock file if (file_exists($this->cache_file . '.lock') && !file_exists($this->cache_file)) { @unlink($this->cache_file . '.lock'); return; } if (!file_exists($this->cache_file) || file_exists($this->cache_file . '.lock') && filemtime($this->cache_file) > time() - $config['queue_interval']) { return; } $fp = @fopen($this->cache_file . '.lock', 'wb'); fclose($fp); @chmod($this->cache_file . '.lock', 0777); include $this->cache_file; foreach ($this->queue_data as $object => $data_ary) { @set_time_limit(0); if (!isset($data_ary['package_size'])) { $data_ary['package_size'] = 0; } $package_size = $data_ary['package_size']; $num_items = !$package_size || sizeof($data_ary['data']) < $package_size ? sizeof($data_ary['data']) : $package_size; // If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs... if (sizeof($data_ary['data']) > $package_size * 2.5) { $num_items = sizeof($data_ary['data']); } switch ($object) { case 'email': // Delete the email queued objects if mailing is disabled if (!$config['email_enable']) { unset($this->queue_data['email']); continue 2; } break; case 'jabber': if (!$config['jab_enable']) { unset($this->queue_data['jabber']); continue 2; } include_once $phpbb_root_path . 'includes/functions_jabber.' . $phpEx; $this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], $config['jab_password'], $config['jab_use_ssl']); if (!$this->jabber->connect()) { messenger::error('JABBER', $user->lang['ERR_JAB_CONNECT']); continue 2; } if (!$this->jabber->login()) { messenger::error('JABBER', $user->lang['ERR_JAB_AUTH']); continue 2; } break; default: return; } for ($i = 0; $i < $num_items; $i++) { // Make variables available... extract(array_shift($this->queue_data[$object]['data'])); switch ($object) { case 'email': $err_msg = ''; $to = !$to ? 'undisclosed-recipients:;' : $to; if ($config['smtp_delivery']) { $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers); } else { ob_start(); $result = $config['email_function_name']($to, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers); $err_msg = ob_get_clean(); } if (!$result) { @unlink($this->cache_file . '.lock'); messenger::error('EMAIL', $err_msg); continue 2; } break; case 'jabber': foreach ($addresses as $address) { if ($this->jabber->send_message($address, $msg, $subject) === false) { messenger::error('JABBER', $this->jabber->get_log()); continue 3; } } break; } } // No more data for this object? Unset it if (!sizeof($this->queue_data[$object]['data'])) { unset($this->queue_data[$object]); } // Post-object processing switch ($object) { case 'jabber': // Hang about a couple of secs to ensure the messages are // handled, then disconnect $this->jabber->disconnect(); break; } } if (!sizeof($this->queue_data)) { @unlink($this->cache_file); } else { if ($fp = @fopen($this->cache_file, 'wb')) { @flock($fp, LOCK_EX); fwrite($fp, "<?php\n\$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>"); @flock($fp, LOCK_UN); fclose($fp); phpbb_chmod($this->cache_file, CHMOD_WRITE); } } @unlink($this->cache_file . '.lock'); }
/** * Set page description for current execution. * * @param array $tag_params * @param array $children */ private function setDescription($tag_params, $children) { global $language; // set from language constant if (isset($tag_params['constant'])) { $language_handler = MainLanguageHandler::getInstance(); $constant = fix_chars($tag_params['constant']); $this->page_description = $language_handler->getText($constant); // set from article } else { if (isset($tag_params['article']) && class_exists('articles')) { $manager = ArticleManager::getInstance(); $text_id = fix_chars($tag_params['article']); // get article from database $item = $manager->getSingleItem(array('content'), array('text_id' => $text_id)); if (is_object($item)) { $content = strip_tags(Markdown($item->content[$language])); $data = explode("\n", utf8_wordwrap($content, 150, "\n", true)); if (count($data) > 0) { $this->page_description = $data[0]; } } } } }
/** * Process queue * Using lock file */ function process() { global $db, $config, $phpEx, $phpbb_root_path, $user; $lock = new \phpbb\lock\flock($this->cache_file); $lock->acquire(); // avoid races, check file existence once $have_cache_file = file_exists($this->cache_file); if (!$have_cache_file || $config['last_queue_run'] > time() - $config['queue_interval']) { if (!$have_cache_file) { set_config('last_queue_run', time(), true); } $lock->release(); return; } set_config('last_queue_run', time(), true); include $this->cache_file; foreach ($this->queue_data as $object => $data_ary) { @set_time_limit(0); if (!isset($data_ary['package_size'])) { $data_ary['package_size'] = 0; } $package_size = $data_ary['package_size']; $num_items = !$package_size || sizeof($data_ary['data']) < $package_size ? sizeof($data_ary['data']) : $package_size; /* * This code is commented out because it causes problems on some web hosts. * The core problem is rather restrictive email sending limits. * This code is nly useful if you have no such restrictions from the * web host and the package size setting is wrong. // If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs... if (sizeof($data_ary['data']) > $package_size * 2.5) { $num_items = sizeof($data_ary['data']); } */ switch ($object) { case 'email': // Delete the email queued objects if mailing is disabled if (!$config['email_enable']) { unset($this->queue_data['email']); continue 2; } break; case 'jabber': if (!$config['jab_enable']) { unset($this->queue_data['jabber']); continue 2; } include_once $phpbb_root_path . 'includes/functions_jabber.' . $phpEx; $this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl']); if (!$this->jabber->connect()) { $messenger = new messenger(); $messenger->error('JABBER', $user->lang['ERR_JAB_CONNECT']); continue 2; } if (!$this->jabber->login()) { $messenger = new messenger(); $messenger->error('JABBER', $user->lang['ERR_JAB_AUTH']); continue 2; } break; default: $lock->release(); return; } for ($i = 0; $i < $num_items; $i++) { // Make variables available... extract(array_shift($this->queue_data[$object]['data'])); switch ($object) { case 'email': $err_msg = ''; $to = !$to ? 'undisclosed-recipients:;' : $to; if ($config['smtp_delivery']) { $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers); } else { $result = phpbb_mail($to, $subject, $msg, $headers, $this->eol, $err_msg); } if (!$result) { $messenger = new messenger(); $messenger->error('EMAIL', $err_msg); continue 2; } break; case 'jabber': foreach ($addresses as $address) { if ($this->jabber->send_message($address, $msg, $subject) === false) { $messenger = new messenger(); $messenger->error('JABBER', $this->jabber->get_log()); continue 3; } } break; } } // No more data for this object? Unset it if (!sizeof($this->queue_data[$object]['data'])) { unset($this->queue_data[$object]); } // Post-object processing switch ($object) { case 'jabber': // Hang about a couple of secs to ensure the messages are // handled, then disconnect $this->jabber->disconnect(); break; } } if (!sizeof($this->queue_data)) { @unlink($this->cache_file); } else { if ($fp = @fopen($this->cache_file, 'wb')) { fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>"); fclose($fp); phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); } } $lock->release(); }
$heim = ""; $exp_heim = explode(" ", $row['heim']); foreach ($exp_heim as $subs_heim => $sub_heim) { if ($sub_heim != "Freihausen") { $heim = $heim . utf8_wordwrap($sub_heim, 9, "<br />", true) . " "; } else { $heim = $heim . utf8_wordwrap($sub_heim, 10, "<br />", true) . " "; } } $gast = ""; $exp_gast = explode(" ", $row['gast']); foreach ($exp_gast as $subs_gast => $sub_gast) { if ($sub_gast != "Freihausen") { $gast = $gast . utf8_wordwrap($sub_gast, 9, "<br />", true) . " "; } else { $gast = $gast . utf8_wordwrap($sub_gast, 10, "<br />", true) . " "; } } echo "<div style=\"float:left; clear: both; margin-bottom: 10px; border-bottom: 1px dashed #000000\">\n"; echo "<span style=\"float: left; text-align: center; width: 77px; overflow: hidden;\">" . $heim . "</span>\n"; echo "<span style=\"width: 15px; float: left; text-align: center; overflow: hidden;\">-</span>\n"; echo "<span style=\"float: left; text-align: center; width: 77px; overflow: hidden;\">" . $gast . "</span>\n"; if ($row['tore_heim'] >= 0 and $row['tore_gast'] >= 0) { echo "<span style=\"float: left; text-align: center; width: 100%; overflow: hidden;\">" . $row['tore_heim'] . ":" . $row['tore_gast'] . "</span>\n"; } else { echo "<span style=\"float: left; text-align: center; width: 100%; overflow: hidden;\">" . "-:-" . "</span>\n"; } echo "<span style=\"float: left; text-align: center; width: 100%; overflow: hidden;\">"; echo $row['spieltag'] . ". Spieltag "; if ($row['runde'] == 1) { echo "Hinrunde";
function next_game($liga_id, $team, $runde, $spieltag) { $Teams = "SELECT *\r\n\t FROM `tabelle_{$liga_id}`\r\n\t "; mysql_query('SET character_set_client = utf8'); mysql_query('SET character_set_results = utf8'); mysql_query('SET character_set_connection = utf8'); $result_Teams = mysql_query($Teams) or die(mysql_error()); $num_teams = mysql_num_rows($result_Teams); $datetime = getdate(); $sql_next = "SELECT *\r\nFROM `ergebnisse_{$liga_id}`\r\nWHERE `runde` = '{$runde}'\r\nAND `spieltag` = '{$spieltag}'\r\nAND (`heim` = '{$team}' OR `gast` = '{$team}')\r\nLIMIT 0 , 30"; mysql_query('SET character_set_client = utf8'); mysql_query('SET character_set_results = utf8'); mysql_query('SET character_set_connection = utf8'); $result = mysql_query($sql_next) or die(mysql_error()); if (mysql_num_rows($result)) { if ($row = mysql_fetch_assoc($result)) { $spiel_id = $row['id']; $title = $team; if ($team == 'SV Freihausen') { $title = '1. Mannschaft'; } if ($team == 'SV Freihausen II') { $title = '2. Mannschaft'; } echo "<span style=\"float: left; clear: both; width: 100%; text-align: center;\">{$title}:</span>\n"; setlocale(LC_TIME, 'de_DE'); $dtime = strftime("%e. %B %Y"); echo "<span style=\"float: left; clear: both; text-align: center; width: 100%;\">" . strftime("%a, %d. %b %Y<br />%H:%M Uhr", strtotime($row['datum'])) . "</span>\n"; echo "<div style=\"clear: both; width: 100%;\">\n"; echo "<div style=\"width: 49%; float: left; overflow: hidden\">\n"; mysql_query('SET character_set_client = utf8'); mysql_query('SET character_set_results = utf8'); mysql_query('SET character_set_connection = utf8'); $result_Teams = mysql_query($Teams) or die(mysql_error()); if (mysql_num_rows($result_Teams)) { while ($row_Teams = mysql_fetch_assoc($result_Teams)) { if ($row_Teams['name'] == $row['heim']) { //echo "<div style=\"width: 100%;\">\n"; echo "<div style=\"width: 50px; margin: auto;\"><img src=\"" . $row_Teams['logo_medium'] . "\" alt=\"\" /></div>\n"; //echo "</div>"; } } } echo "</div>\n"; echo "<div style=\"width: 49%; float: left; overflow: hidden\">\n"; mysql_query('SET character_set_client = utf8'); mysql_query('SET character_set_results = utf8'); mysql_query('SET character_set_connection = utf8'); $result_Teams = mysql_query($Teams) or die(mysql_error()); if (mysql_num_rows($result_Teams)) { while ($row_Teams = mysql_fetch_assoc($result_Teams)) { if ($row_Teams['name'] == $row['gast']) { echo "<div style=\"width: 100%;\">\n"; echo "<div style=\"width:50px; margin: 5px auto;\"><img src=\"" . $row_Teams['logo_medium'] . "\" alt=\"\" /></div>\n"; echo "</div>"; } } } echo "</div>\n"; echo "</div>\n"; $heim = ""; $exp_heim = explode(" ", $row['heim']); foreach ($exp_heim as $subs_heim => $sub_heim) { if ($sub_heim != "Freihausen") { $heim = $heim . utf8_wordwrap($sub_heim, 9, "<br />", true) . " "; } else { $heim = $heim . utf8_wordwrap($sub_heim, 10, "<br />", true) . " "; } } $gast = ""; $exp_gast = explode(" ", $row['gast']); foreach ($exp_gast as $subs_gast => $sub_gast) { if ($sub_gast != "Freihausen") { $gast = $gast . utf8_wordwrap($sub_gast, 9, "<br />", true) . " "; } else { $gast = $gast . utf8_wordwrap($sub_gast, 10, "<br />", true) . " "; } } echo "<div style=\"float:left; clear: both;\">\n"; echo "<span style=\"float: left; text-align: center; width: 77px; overflow: hidden;\">" . $heim . "</span>\n"; echo "<span style=\"width: 15px; float: left; text-align: center; overflow: hidden;\">-</span>\n"; echo "<span style=\"float: left; text-align: center; width: 77px; overflow: hidden;\">" . $gast . "</span>\n"; echo "</div>\n"; if ($row['tore_heim'] >= 0 and $row['tore_gast'] >= 0) { echo "<span style=\"float: left; text-align: center; width: 100%; overflow: hidden;\">" . $row['tore_heim'] . ":" . $row['tore_gast'] . "</span>\n"; } else { echo "<span style=\"float: left; text-align: center; width: 100%; overflow: hidden;\">" . "-:-" . "</span>\n"; } echo "<span style=\"float: left; text-align: center; width: 100%; overflow: hidden;\">"; echo $row['spieltag'] . ". Spieltag "; if ($row['runde'] == 1) { echo "Hinrunde"; } if ($row['runde'] == 2) { echo "Rückrunde"; } echo "</span>"; echo "<p style=\"float: left; text-align: center; width: 100%; overflow: hidden;\"><a href=\"modules/report_popin.php?id={$liga_id}&spiel_id={$spiel_id}&team=" . urlencode($team) . "&runde={$runde}&spieltag={$spieltag}\" onclick=\"return reportPopin(this)\">Spielbericht</a></p>"; $next_spieltag = 1; $next_runde = $row['runde']; $last_spieltag = 1; $last_runde = $row['runde']; if ($num_teams > $row['spieltag'] + 1) { $next_spieltag = $row['spieltag'] + 1; $next_runde = $row['runde']; } else { if ($row['runde'] < 2) { $next_spieltag = 1; $next_runde = 2; } } if ($row['spieltag'] < 2 and $row['runde'] > 1) { $last_spieltag = $num_teams - 1; $last_runde = 1; } else { $last_spieltag = $row['spieltag'] - 1; $last_runde = $row['runde']; } if ($last_spieltag > 0 and $last_runde > 0) { echo "<span onclick=\"game('{$liga_id}', '{$team}', '{$last_runde}', '{$last_spieltag}')\" style=\"cursor: pointer; float: left; color:#336699;\">< voriges</span>"; } if ($next_spieltag < $num_teams and $next_runde < 3) { echo "<span onclick=\"game('{$liga_id}', '{$team}', '{$next_runde}', '{$next_spieltag}')\" style=\"cursor: pointer; float: right; color:#336699;\">nächstes ></span>"; } } } }
private function post() { global $phpbb_root_path, $phpEx, $template, $db, $auth; global $config, $user; if (!function_exists('generate_smilies')) { include $phpbb_root_path . 'includes/functions_posting.' . $phpEx; } if (!function_exists('submit_gb_post')) { include $phpbb_root_path . 'includes/functions_guestbook.' . $phpEx; } if (!class_exists('parse_message')) { include $phpbb_root_path . 'includes/message_parser.' . $phpEx; } $user->add_lang('posting'); // Grab only parameters needed here $post_id = request_var('p', 0); $lastclick = request_var('lastclick', 0); $submit = isset($_POST['post']) ? true : false; $preview = isset($_POST['preview']) ? true : false; $delete = isset($_POST['delete']) ? true : false; $refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['full_editor']) ? true : false; $mode = $delete && !$preview && !$refresh && $submit ? 'delete' : request_var('gbmode', ''); $error = $post_data = array(); $current_time = time(); // Was cancel pressed? If so then redirect to the appropriate page if ($current_time - $lastclick < 2 && $submit) { $redirect = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u={$this->user_id}&gbmode=display&{$post_id}#p{$post_id}"); redirect($redirect); } // We need to know some basic information in all cases before we do anything. switch ($mode) { case 'quote': case 'edit': case 'delete': if (!$post_id) { $user->setup('posting'); trigger_error('NO_POST'); } $sql = 'SELECT g.*, u.* FROM ' . GUESTBOOK_TABLE . ' g, ' . USERS_TABLE . ' u WHERE u.user_id = g.poster_id AND post_id = ' . (int) $post_id; break; case 'smilies': $sql = ''; generate_smilies('window'); break; case 'popup': upload_popup(); break; default: $sql = ''; break; } if ($sql) { $result = $db->sql_query($sql); $post_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$post_data) { $user->setup('posting'); trigger_error('NO_POST'); } } if ($mode == 'popup') { upload_popup($post_data['forum_style']); return; } if ($config['enable_post_confirm'] && !$user->data['is_registered']) { include $phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx; $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_POST); } // Use post_row values in favor of submitted ones... $post_id = !empty($post_data['post_id']) ? (int) $post_data['post_id'] : (int) $post_id; // Check permissions if ($user->data['is_bot']) { redirect(append_sid("{$phpbb_root_path}index.{$phpEx}")); } // Is the user able to read within this forum? if (!$auth->acl_get('u_gb_view')) { if ($user->data['user_id'] != ANONYMOUS) { trigger_error('USER_CANNOT_READ'); } login_box('', $user->lang['LOGIN_EXPLAIN_POST']); } // Permission to do the action asked? $is_authed = false; switch ($mode) { case 'post': if ($auth->acl_get('u_gb_post')) { $is_authed = true; } break; case 'quote': $post_data['post_edit_locked'] = 0; // @TODO: Decide if we want to add a config option/ucp option/checkbox for this feature. if ($post_data['poster_id'] != ANONYMOUS) { $post_data['orginal_author'] = $post_data['poster_id']; } // no break; // no break; case 'reply': if ($auth->acl_get('u_gb_post')) { $is_authed = true; } break; case 'edit': if ($user->data['is_registered'] && $auth->acl_gets('u_gb_edit', 'm_gb_edit')) { $is_authed = true; } break; case 'delete': if ($user->data['is_registered'] && $auth->acl_gets('u_gb_delete', 'm_gb_delete')) { $is_authed = true; } break; } if (!$is_authed) { $check_auth = $mode == 'quote' ? 'reply' : $mode; if ($user->data['is_registered']) { trigger_error('USER_CANNOT_' . strtoupper($check_auth)); } login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); } // Can we edit this post ... if we're a moderator with rights then always yes // else it depends on editing times, lock status and if we're the correct user if ($mode == 'edit' && !$auth->acl_get('m_gb_edit')) { if ($user->data['user_id'] != $post_data['poster_id']) { trigger_error('USER_CANNOT_EDIT'); } if (!($post_data['post_time'] > time() - $config['edit_time'] * 60 || !$config['edit_time'])) { trigger_error('CANNOT_EDIT_TIME'); } if ($post_data['post_edit_locked']) { trigger_error('CANNOT_EDIT_POST_LOCKED'); } } // Handle delete mode... if ($mode == 'delete') { handle_gb_post_delete($post_id, $post_data, $this); return; } // Determine some vars if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS) { $post_data['quote_username'] = !empty($post_data['post_username']) ? $post_data['post_username'] : $user->lang['GUEST']; } else { $post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : ''; } $post_data['post_edit_locked'] = isset($post_data['post_edit_locked']) ? (int) $post_data['post_edit_locked'] : 0; $post_data['post_subject_md5'] = isset($post_data['post_subject']) && $mode == 'edit' ? md5($post_data['post_subject']) : ''; $post_data['post_subject'] = in_array($mode, array('quote', 'edit')) ? $post_data['post_subject'] : (isset($post_data['topic_title']) ? $post_data['topic_title'] : ''); $post_data['topic_time_limit'] = isset($post_data['topic_time_limit']) ? $post_data['topic_time_limit'] ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit'] : 0; $post_data['icon_id'] = !isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply')) ? 0 : (int) $post_data['icon_id']; $message_parser = new parse_message(); if (isset($post_data['post_text'])) { $message_parser->message =& $post_data['post_text']; unset($post_data['post_text']); } // Set some default variables $uninit = array('poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); foreach ($uninit as $var_name => $default_value) { if (!isset($post_data[$var_name])) { $post_data[$var_name] = $default_value; } } unset($uninit); if ($post_data['poster_id'] == ANONYMOUS) { $post_data['username'] = $mode == 'quote' || $mode == 'edit' ? trim($post_data['post_username']) : ''; } else { $post_data['username'] = $mode == 'quote' || $mode == 'edit' ? trim($post_data['username']) : ''; } $post_data['enable_urls'] = $post_data['enable_magic_url']; if ($mode != 'edit') { $post_data['enable_sig'] = $config['allow_sig'] && $user->optionget('attachsig') ? true : false; $post_data['enable_smilies'] = $config['allow_smilies'] && $user->optionget('smilies') ? true : false; $post_data['enable_bbcode'] = $config['allow_bbcode'] && $user->optionget('bbcode') ? true : false; $post_data['enable_urls'] = true; } $post_data['enable_icons'] = true; $post_data['enable_magic_url'] = $post_data['drafts'] = false; $check_value = ($post_data['enable_bbcode'] + 1 << 8) + ($post_data['enable_smilies'] + 1 << 4) + ($post_data['enable_urls'] + 1 << 2) + ($post_data['enable_sig'] + 1 << 1); // Do we want to edit our post ? if ($mode == 'edit' && $post_data['bbcode_uid']) { $message_parser->bbcode_uid = $post_data['bbcode_uid']; } // HTML, BBCode, Smilies, Images and Flash status $bbcode_status = $config['allow_bbcode'] && $auth->acl_get('u_gb_bbcode') ? true : false; $smilies_status = $config['allow_smilies'] && $auth->acl_get('u_gb_smilies') ? true : false; $img_status = $bbcode_status && $auth->acl_get('u_gb_img') ? true : false; $url_status = $config['allow_post_links'] ? true : false; $flash_status = $bbcode_status && $auth->acl_get('u_gb_flash') && $config['allow_post_flash'] ? true : false; $quote_status = true; if ($submit || $preview || $refresh) { $post_data['post_subject'] = utf8_normalize_nfc(request_var('subject', '', true)); $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); $post_data['topic_time_limit'] = request_var('topic_time_limit', $mode != 'post' ? (int) $post_data['topic_time_limit'] : 0); if ($post_data['enable_icons'] && $auth->acl_get('u_gb_icons')) { $post_data['icon_id'] = request_var('icon', (int) $post_data['icon_id']); } $post_data['enable_bbcode'] = !$bbcode_status || isset($_POST['disable_bbcode']) ? false : true; $post_data['enable_smilies'] = !$smilies_status || isset($_POST['disable_smilies']) ? false : true; $post_data['enable_urls'] = isset($_POST['disable_magic_url']) ? 0 : 1; $post_data['enable_sig'] = !$config['allow_sig'] || !$auth->acl_get('u_gb_sig') ? false : (isset($_POST['attach_sig']) && $user->data['is_registered'] ? true : false); if ($config['allow_topic_notify'] && $user->data['is_registered']) { $notify = isset($_POST['notify']) ? true : false; } else { $notify = false; } if ($submit) { $status_switch = ($post_data['enable_bbcode'] + 1 << 8) + ($post_data['enable_smilies'] + 1 << 4) + ($post_data['enable_urls'] + 1 << 2) + ($post_data['enable_sig'] + 1 << 1); $status_switch = $status_switch != $check_value; } else { $status_switch = 1; } // Grab md5 'checksum' of new message $message_md5 = md5($message_parser->message); // Check checksum ... don't re-parse message if the same $update_message = $mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN ? true : false; // Also check if subject got updated... $update_subject = $mode != 'edit' || $post_data['post_subject_md5'] && $post_data['post_subject_md5'] != md5($post_data['post_subject']); // Parse message if ($update_message) { if (sizeof($message_parser->warn_msg)) { $error[] = implode('<br />', $message_parser->warn_msg); $message_parser->warn_msg = array(); } $message_parser->parse($post_data['enable_bbcode'], $config['allow_post_links'] ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); // On a refresh we do not care about message parsing errors if (sizeof($message_parser->warn_msg) && $refresh) { $message_parser->warn_msg = array(); } } else { $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; } if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('u_gb_ignoreflood')) { // Flood check $last_post_time = 0; if ($user->data['is_registered']) { $last_post_time = $user->data['user_lastpost_time']; } else { $sql = 'SELECT post_time AS last_post_time FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\tWHERE poster_ip = '" . $user->ip . "'\n\t\t\t\t\t\t\tAND post_time > " . ($current_time - $config['flood_interval']); $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) { $last_post_time = $row['last_post_time']; } $db->sql_freeresult($result); } if ($last_post_time && $current_time - $last_post_time < intval($config['flood_interval'])) { $error[] = $user->lang['FLOOD_ERROR']; } } // Validate username if ($post_data['username'] && !$user->data['is_registered'] || $mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username']) { if (!function_exists('validate_user')) { include $phpbb_root_path . 'includes/functions_user.' . $phpEx; } if (($result = validate_username($post_data['username'], !empty($post_data['post_username']) ? $post_data['post_username'] : '')) !== false) { $user->add_lang('ucp'); $error[] = $user->lang[$result . '_USERNAME']; } } if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) { $captcha_data = array('message' => utf8_normalize_nfc(request_var('message', '', true)), 'subject' => utf8_normalize_nfc(request_var('subject', '', true)), 'username' => utf8_normalize_nfc(request_var('username', '', true))); $vc_response = $captcha->validate($captcha_data); if ($vc_response) { $error[] = $vc_response; } } // check form if (($submit || $preview) && !check_form_key('posting')) { $error[] = $user->lang['FORM_INVALID']; } // Parse subject if (sizeof($message_parser->warn_msg)) { $error[] = implode('<br />', $message_parser->warn_msg); } // DNSBL check if ($config['check_dnsbl'] && !$refresh) { if (($dnsbl = $user->check_dnsbl('post')) !== false) { $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); } } // Store message, sync counters if (!sizeof($error) && $submit) { if ($submit) { $data = array('user_id' => (int) ($mode == 'quote' && isset($post_data['orginal_author']) ? $post_data['orginal_author'] : $this->user_id), 'topic_title' => empty($post_data['topic_title']) ? $post_data['post_subject'] : $post_data['topic_title'], 'post_id' => (int) $post_id, 'icon_id' => (int) $post_data['icon_id'], 'poster_id' => (int) $user->data['user_id'], 'enable_sig' => (bool) $post_data['enable_sig'], 'enable_bbcode' => (bool) $post_data['enable_bbcode'], 'enable_smilies' => (bool) $post_data['enable_smilies'], 'enable_urls' => (bool) $post_data['enable_urls'], 'message_md5' => (string) $message_md5, 'post_time' => isset($post_data['post_time']) ? (int) $post_data['post_time'] : $current_time, 'post_checksum' => isset($post_data['post_checksum']) ? (string) $post_data['post_checksum'] : '', 'post_edit_reason' => $post_data['post_edit_reason'], 'post_edit_user' => $mode == 'edit' ? $user->data['user_id'] : (isset($post_data['post_edit_user']) ? (int) $post_data['post_edit_user'] : 0), 'poster_ip' => isset($post_data['poster_ip']) ? $post_data['poster_ip'] : $user->ip, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'message' => $message_parser->message, 'guestbook' => $this); // The last parameter tells submit_post if search indexer has to be run submit_gb_post($mode, $post_data['post_subject'], $post_data['username'], $data, $update_message, $update_message || $update_subject ? true : false); $post_id = $data['post_id']; $uid = $mode == 'quote' && isset($post_data['orginal_author']) ? $post_data['orginal_author'] : $this->user_id; $redirect_url = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&gbmode=display&u={$uid}&p={$post_id}#p{$post_id}"); if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) { $captcha->reset(); } meta_refresh(3, $redirect_url); $message = $mode == 'edit' ? 'POST_EDITED' : 'POST_STORED'; $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $redirect_url . '">', '</a>'); trigger_error($message); } } } // Preview if (!sizeof($error) && $preview) { $post_data['post_time'] = $mode == 'edit' ? $post_data['post_time'] : $current_time; $preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false); $preview_signature = $mode == 'edit' ? $post_data['user_sig'] : $user->data['user_sig']; $preview_signature_uid = $mode == 'edit' ? $post_data['user_sig_bbcode_uid'] : $user->data['user_sig_bbcode_uid']; $preview_signature_bitfield = $mode == 'edit' ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield']; // Signature if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('u_gb_sig')) { $parse_sig = new parse_message($preview_signature); $parse_sig->bbcode_uid = $preview_signature_uid; $parse_sig->bbcode_bitfield = $preview_signature_bitfield; // Not sure about parameters for bbcode/smilies/urls... in signatures $parse_sig->format_display($config['allow_sig_bbcode'], true, $config['allow_sig_smilies']); $preview_signature = $parse_sig->message; unset($parse_sig); } else { $preview_signature = ''; } $preview_subject = censor_text($post_data['post_subject']); if (!sizeof($error)) { $template->assign_vars(array('PREVIEW_SUBJECT' => $preview_subject, 'PREVIEW_MESSAGE' => $preview_message, 'PREVIEW_SIGNATURE' => $preview_signature, 'S_DISPLAY_PREVIEW' => true)); } } // Decode text for message display $post_data['bbcode_uid'] = $mode == 'quote' && !$preview && !$refresh && !sizeof($error) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid; $message_parser->decode_message($post_data['bbcode_uid']); if ($mode == 'quote' && !$submit && !$preview && !$refresh) { if ($config['allow_bbcode']) { $message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n"; } else { $offset = 0; $quote_string = "> "; $message = censor_text(trim($message_parser->message)); // see if we are nesting. It's easily tricked but should work for one level of nesting if (strpos($message, ">") !== false) { $offset = 10; } $message = utf8_wordwrap($message, 75 + $offset, "\n"); $message = $quote_string . $message; $message = str_replace("\n", "\n" . $quote_string, $message); $message_parser->message = $post_data['quote_username'] . " " . $user->lang['WROTE'] . " :\n" . $message . "\n"; } } if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh) { $post_data['post_subject'] = (strpos($post_data['post_subject'], 'Re: ') !== 0 ? 'Re: ' : '') . censor_text($post_data['post_subject']); } $post_data['post_text'] = $message_parser->message; // MAIN POSTING PAGE BEGINS HERE // Generate smiley listing generate_smilies('inline', 0); // Do show topic type selection only in first post. $topic_type_toggle = false; $s_topic_icons = false; if ($post_data['enable_icons'] && $auth->acl_get('u_gb_icons')) { $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); } $bbcode_checked = isset($post_data['enable_bbcode']) ? !$post_data['enable_bbcode'] : ($config['allow_bbcode'] ? !$user->optionget('bbcode') : 1); $smilies_checked = isset($post_data['enable_smilies']) ? !$post_data['enable_smilies'] : ($config['allow_smilies'] ? !$user->optionget('smilies') : 1); $urls_checked = isset($post_data['enable_urls']) ? !$post_data['enable_urls'] : 0; $sig_checked = $post_data['enable_sig']; // If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting $notify_set = $mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set'] ? $user->data['user_notify'] : $post_data['notify_set']; $notify_checked = isset($notify) ? $notify : ($mode == 'post' ? $user->data['user_notify'] : $notify_set); // Page title & action URL, include session_id for security purpose $s_action = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u={$this->user_id}&gbmode={$mode}", true, $user->session_id); $s_action .= $post_id ? "&p={$post_id}" : ''; switch ($mode) { case 'post': $page_title = $user->lang['POST_GUESTBOOK']; break; case 'quote': case 'reply': $page_title = $user->lang['POST_GUESTBOOK']; break; case 'delete': case 'edit': $page_title = $user->lang['EDIT_POST']; break; } // Posting uses is_solved for legacy reasons. Plugins have to use is_solved to force themselves to be displayed. if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) { $template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template())); } $s_hidden_fields = '<input type="hidden" name="lastclick" value="' . $current_time . '" />'; if ($mode == 'edit') { $s_hidden_fields .= build_hidden_fields(array('edit_post_message_checksum' => $post_data['post_checksum'], 'edit_post_subject_checksum' => $post_data['post_subject_md5'])); } // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview if (isset($captcha) && $captcha->is_solved() !== false) { $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); } add_form_key('posting'); // Start assigning vars for main posting page ... $template->assign_vars(array('L_POST_A' => $page_title, 'L_ICON' => $user->lang['POST_ICON'], 'L_MESSAGE_BODY_EXPLAIN' => intval($config['max_post_chars']) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '', 'TOPIC_TITLE' => censor_text($post_data['topic_title']), 'USERNAME' => !$preview && $mode != 'quote' || $preview ? $post_data['username'] : '', 'SUBJECT' => $post_data['post_subject'], 'MESSAGE' => $post_data['post_text'], 'BBCODE_STATUS' => $bbcode_status ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $bbcode_status && $url_status ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']), 'POST_DATE' => $post_data['post_time'] ? $user->format_date($post_data['post_time']) : '', 'ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], 'EDIT_REASON' => $post_data['post_edit_reason'], 'S_PRIVMSGS' => false, 'S_CLOSE_PROGRESS_WINDOW' => isset($_POST['add_file']) ? true : false, 'S_EDIT_POST' => $mode == 'edit' ? true : false, 'S_EDIT_REASON' => false, 'S_DISPLAY_USERNAME' => !$user->data['is_registered'] || $mode == 'edit' && $post_data['poster_id'] == ANONYMOUS ? true : false, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_BBCODE_CHECKED' => $bbcode_checked ? ' checked="checked"' : '', 'S_SMILIES_ALLOWED' => $smilies_status, 'S_SMILIES_CHECKED' => $smilies_checked ? ' checked="checked"' : '', 'S_SIG_ALLOWED' => $auth->acl_get('u_gb_sig') && $config['allow_sig'] && $user->data['is_registered'] ? true : false, 'S_SIGNATURE_CHECKED' => $sig_checked ? ' checked="checked"' : '', 'S_NOTIFY_ALLOWED' => !$user->data['is_registered'] || $mode == 'edit' && $user->data['user_id'] != $post_data['poster_id'] || !$config['allow_topic_notify'] || !$config['email_enable'] ? false : true, 'S_NOTIFY_CHECKED' => $notify_checked ? ' checked="checked"' : '', 'S_LINKS_ALLOWED' => $url_status, 'S_MAGIC_URL_CHECKED' => $urls_checked ? ' checked="checked"' : '', 'S_TYPE_TOGGLE' => '', 'S_SAVE_ALLOWED' => false, 'S_HAS_DRAFTS' => false, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status, 'SIGNATURE' => '', 'S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields)); // Build custom bbcodes array display_custom_bbcodes(); $template->set_filenames(array('body' => 'posting_body.html')); make_jumpbox(append_sid("{$phpbb_root_path}viewforum.{$phpEx}")); }
/** * Send out emails */ function msg_email($is_html = false) { global $config; if (empty($config['email_enable'])) { return false; } // Addresses to send to? if (empty($this->addresses) || empty($this->addresses['to']) && empty($this->addresses['cc']) && empty($this->addresses['bcc'])) { // Send was successful. ;) return true; } $contact_name = htmlspecialchars_decode($config['board_contact_name']); $board_contact = ($contact_name !== '' ? '"' . mail_encode($contact_name) . '" ' : '') . '<' . $config['board_contact'] . '>'; if (empty($this->replyto)) { $this->replyto = $board_contact; } if (empty($this->from)) { $this->from = $board_contact; } $encode_eol = $config['smtp_delivery'] ? "\r\n" : $this->eol; // Build to, cc and bcc strings $to = $cc = $bcc = ''; foreach ($this->addresses as $type => $address_ary) { if ($type == 'im') { continue; } foreach ($address_ary as $which_ary) { ${$type} .= (${$type} != '' ? ', ' : '') . ($which_ary['name'] != '' ? mail_encode($which_ary['name'], $encode_eol) . ' <' . $which_ary['email'] . '>' : $which_ary['email']); } } // Build header $headers = $this->build_header($to, $cc, $bcc, $is_html); // Send message ... $mail_to = $to == '' ? 'undisclosed-recipients:;' : $to; $err_msg = ''; if ($config['smtp_delivery']) { $result = smtpmail($this->addresses, mail_encode($this->subject), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $err_msg, $headers); } else { $result = phpbb_mail($mail_to, $this->subject, $this->msg, $headers, $this->eol, $err_msg); } if (!$result) { $this->error('EMAIL', $err_msg); return false; } return true; }
/** * Wrap text - WT_Report_HTML * * @param string $str Text to wrap * @param int $width Width in points the text has to fit into * * @return string */ function textWrap($str, $width) { // Calculate the line width $lw = (int) ($width / ($this->getCurrentStyleHeight() / 2)); // Wordwrap each line //@@ indi source texts, note text, indi sub-titles, footer texts $lines = explode("\n", $str); // Line Feed counter $lfct = count($lines); $wraptext = ''; foreach ($lines as $line) { $wtext = utf8_wordwrap($line, $lw, "\n", true); $wraptext .= $wtext; // Add a new line as long as it’s not the last line if ($lfct > 1) { $wraptext .= "\n"; } $lfct--; } return $wraptext; }
/** * Smarty wordwrap modifier plugin * * Type: modifier<br /> * Name: wordwrap_new<br /> * Purpose: wrap a string of text at a given length, hopefully in a way that doesn't break things! Call this before nl2br. * @author ordog (lol) * @param string $string The source string * @param integer $length The length to wrap to, defaults to 80 * @param string $break The string to break up lines by, defaults to " " * @param boolean $cut If $cut is true, the string is always wrapped at the specified width * @return string The wordwrapped string */ function smarty_modifier_wordwrap_new($string, $length = 80, $break = " ", $cut = false) { // We'll use this to do the cutting for us. $string = preg_replace("/(\\B{" . $length . "})(\\B+)/Su", "\\1" . $break . "\\2", $string); return utf8_wordwrap($string, $length, $break, $cut); }
/** * Send email for transaction using specified template. * * @param object $transaction * @param string $template * @return boolean */ private function sendTransactionMail($transaction, $template) { global $language; $result = false; // require contact form if (!class_exists('contact_form')) { return $result; } $email_address = null; $contact_form = contact_form::getInstance(); // template replacement data $fields = array('transaction_id' => $transaction->id, 'transaction_uid' => $transaction->uid, 'status' => $transaction->status, 'handling' => $transaction->handling, 'shipping' => $transaction->shipping, 'total' => $transaction->total, 'weight' => $transaction->weight, 'payment_method' => $transaction->payment_method, 'delivery_method' => $transaction->delivery_method, 'remark' => $transaction->remark, 'token' => $transaction->token, 'timestamp' => $transaction->timestamp); $timestamp = strtotime($transaction->timestamp); $fields['date'] = date($this->getLanguageConstant('format_date_short'), $timestamp); $fields['time'] = date($this->getLanguageConstant('format_time_short'), $timestamp); // get currency $currency_manager = ShopCurrenciesManager::getInstance(); $currency = $currency_manager->getSingleItem($currency_manager->getFieldNames(), array('id' => $transaction->currency)); if (is_object($currency)) { $fields['currency'] = $currency->currency; } // add buyer information $buyer_manager = ShopBuyersManager::getInstance(); $buyer = $buyer_manager->getSingleItem($buyer_manager->getFieldNames(), array('id' => $transaction->buyer)); if (is_object($buyer)) { $fields['buyer_first_name'] = $buyer->first_name; $fields['buyer_last_name'] = $buyer->last_name; $fields['buyer_email'] = $buyer->email; $fields['buyer_uid'] = $buyer->uid; $email_address = $buyer->email; } // add system user information $user_manager = UserManager::getInstance(); $user = $user_manager->getSingleItem($user_manager->getFieldNames(), array('id' => $transaction->system_user)); if (is_object($user)) { $fields['user_name'] = $user->username; $fields['user_fullname'] = $user->fullname; $fields['user_email'] = $user->email; if (is_null($email_address) || empty($email_address)) { $email_address = $user->email; } else { if ($email_address != $user->email) { $email_address = $email_address . ',' . $user->email; } } } // add buyer address $address_manager = ShopDeliveryAddressManager::getInstance(); $address = $address_manager->getSingleItem($address_manager->getFieldNames(), array('id' => $transaction->address)); if (is_object($address)) { $fields['address_name'] = $address->name; $fields['address_street'] = $address->street; $fields['address_street2'] = $address->street2; $fields['address_phone'] = $address->phone; $fields['address_city'] = $address->city; $fields['address_zip'] = $address->zip; $fields['address_state'] = $address->state; $fields['address_country'] = $address->country; } // create item table switch ($transaction->type) { case TransactionType::SHOPPING_CART: $item_manager = ShopTransactionItemsManager::getInstance(); $items = $item_manager->getItems($item_manager->getFieldNames(), array('transaction' => $transaction->id)); if (count($items) > 0) { // create items table $text_table = str_pad($this->getLanguageConstant('column_name'), 40); $text_table .= str_pad($this->getLanguageConstant('column_price'), 8); $text_table .= str_pad($this->getLanguageConstant('column_amount'), 6); $text_table .= str_pad($this->getLanguageConstant('column_item_total'), 8); $text_table .= "\n" . str_repeat('-', 40 + 8 + 6 + 8) . "\n"; $html_table = '<table border="0" cellspacing="5" cellpadding="0">'; $html_table .= '<thead><tr>'; $html_table .= '<td>' . $this->getLanguageConstant('column_name') . '</td>'; $html_table .= '<td>' . $this->getLanguageConstant('column_price') . '</td>'; $html_table .= '<td>' . $this->getLanguageConstant('column_amount') . '</td>'; $html_table .= '<td>' . $this->getLanguageConstant('column_item_total') . '</td>'; $html_table .= '</td></thead><tbody>'; foreach ($items as $item) { // append item name with description if (empty($data['description'])) { $line = $item->name[$language] . ' (' . $item->description . ')'; } else { $line = $item->name[$language]; } $line = utf8_wordwrap($line, 40, "\n", true); $line = mb_split("\n", $line); // append other columns $line[0] = $line[0] . str_pad($item->price, 8, ' ', STR_PAD_LEFT); $line[0] = $line[0] . str_pad($item->amount, 6, ' ', STR_PAD_LEFT); $line[0] = $line[0] . str_pad($item->total, 8, ' ', STR_PAD_LEFT); // add this item to text table $text_table .= implode("\n", $line) . "\n\n"; // form html row $row = '<tr><td>' . $item->name[$language]; if (!empty($item->description)) { $row .= ' <small>' . $item->description . '</small>'; } $row .= '</td><td>' . $item->price . '</td>'; $row .= '<td>' . $item->amount . '</td>'; $row .= '<td>' . $item->total . '</td></tr>'; // update subtotal $subtotal += $item->total; } // close text table $text_table .= str_repeat('-', 40 + 8 + 6 + 8) . "\n"; $html_table .= '</tbody>'; // create totals $text_table .= str_pad($this->getLanguageConstant('column_subtotal'), 15); $text_table .= str_pad($subtotal, 10, ' ', STR_PAD_LEFT) . "\n"; $text_table .= str_pad($this->getLanguageConstant('column_shipping'), 15); $text_table .= str_pad($transaction->shipping, 10, ' ', STR_PAD_LEFT) . "\n"; $text_table .= str_pad($this->getLanguageConstant('column_handling'), 15); $text_table .= str_pad($transaction->handling, 10, ' ', STR_PAD_LEFT) . "\n"; $text_table .= str_repeat('-', 25); $text_table .= str_pad($this->getLanguageConstant('column_total'), 15); $text_table .= str_pad($transaction->total, 10, ' ', STR_PAD_LEFT) . "\n"; $html_table .= '<tfoot>'; $html_table .= '<tr><td colspan="2"></td><td>' . $this->getLanguageConstant('column_subtotal') . '</td>'; $html_table .= '<td>' . $subtotal . '</td></tr>'; $html_table .= '<tr><td colspan="2"></td><td>' . $this->getLanguageConstant('column_shipping') . '</td>'; $html_table .= '<td>' . $transaction->shipping . '</td></tr>'; $html_table .= '<tr><td colspan="2"></td><td>' . $this->getLanguageConstant('column_handling') . '</td>'; $html_table .= '<td>' . $transaction->handling . '</td></tr>'; $html_table .= '<tr><td colspan="2"></td><td><b>' . $this->getLanguageConstant('column_total') . '</b></td>'; $html_table .= '<td><b>' . $transaction->total . '</b></td></tr>'; $html_table .= '</tfoot>'; // close table $html_table .= '</table>'; // add field $fields['item_table'] = $text_table; } break; case TransactionType::SUBSCRIPTION: $plan_manager = ShopTransactionPlansManager::getInstance(); $plan = $plan_manager->getSingleItem($plan_manager->getFieldNames(), array('transaction' => $transaction->id)); // get payment method $plan_data = null; if (isset($this->payment_methods[$transaction->payment_method])) { $payment_method = $this->payment_methods[$transaction->payment_method]; $plans = $payment_method->get_recurring_plans(); if (isset($plans[$plan->plan_name])) { $plan_data = $plans[$plan->plan_name]; } } // populate fields with plan params if (is_object($plan) && !is_null($plan_data)) { $fields['plan_text_id'] = $plan->plan_name; $fields['plan_name'] = $plan_data['name'][$language]; } break; } // we require email address for sending if (is_null($email_address) || empty($email_address)) { return $result; } // get mailer $mailer = $contact_form->getMailer(); $sender = $contact_form->getSender(); $template = $contact_form->getTemplate($template); // start creating message $mailer->start_message(); $mailer->set_subject($template['subject']); $mailer->set_sender($sender['address'], $sender['name']); $mailer->add_recipient($email_address); $mailer->set_body($template['plain_body'], $template['html_body']); $mailer->set_variables($fields); // send email $mailer->send(); return $result; }
function main($id, $mode) { global $config, $request, $template, $user, $phpbb_dispatcher, $phpbb_admin_path, $phpbb_root_path, $phpEx; if (!class_exists('phpbb_questionnaire_data_collector')) { include $phpbb_root_path . 'includes/questionnaire/questionnaire.' . $phpEx; } $collect_url = "https://www.phpbb.com/stats/receive_stats.php"; $this->tpl_name = 'acp_help_phpbb'; $this->page_title = 'ACP_HELP_PHPBB'; $submit = $request->is_set_post('submit') ? true : false; $form_key = 'acp_help_phpbb'; add_form_key($form_key); $error = array(); if ($submit && !check_form_key($form_key)) { $error[] = $user->lang['FORM_INVALID']; } // Do not write values if there is an error if (sizeof($error)) { $submit = false; } // generate a unique id if necessary if (!isset($config['questionnaire_unique_id'])) { $install_id = unique_id(); $config->set('questionnaire_unique_id', $install_id); } else { $install_id = $config['questionnaire_unique_id']; } $collector = new phpbb_questionnaire_data_collector($install_id); // Add data provider $collector->add_data_provider(new phpbb_questionnaire_php_data_provider()); $collector->add_data_provider(new phpbb_questionnaire_system_data_provider()); $collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config)); /** * Event to modify ACP help phpBB page and/or listen to submit * * @event core.acp_help_phpbb_submit_before * @var boolean submit Do we display the form or process the submission * @since 3.2.0-RC2 */ $vars = array('submit'); extract($phpbb_dispatcher->trigger_event('core.acp_help_phpbb_submit_before', compact($vars))); if ($submit) { $config->set('help_send_statistics', $request->variable('help_send_statistics', false)); $response = $request->variable('send_statistics_response', ''); $config->set('help_send_statistics_time', time()); if (!empty($response)) { if (strpos($response, 'Thank you') !== false || strpos($response, 'Flood protection') !== false) { trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); } else { trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action)); } } trigger_error($user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); } $template->assign_vars(array('U_COLLECT_STATS' => $collect_url, 'S_COLLECT_STATS' => !empty($config['help_send_statistics']) ? true : false, 'RAW_DATA' => $collector->get_data_for_form(), 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.{$phpEx}"), 'U_ACTION' => $this->u_action, 'COLLECT_STATS_TIME' => intval($config['help_send_statistics_time']) + 86400)); $raw = $collector->get_data_raw(); foreach ($raw as $provider => $data) { if ($provider == 'install_id') { $data = array($provider => $data); } $template->assign_block_vars('providers', array('NAME' => htmlspecialchars($provider))); foreach ($data as $key => $value) { if (is_array($value)) { $value = utf8_wordwrap(serialize($value), 75, "\n", true); } $template->assign_block_vars('providers.values', array('KEY' => utf8_htmlspecialchars($key), 'VALUE' => utf8_htmlspecialchars($value))); } } }
function fill_smarty($smarty, $type = 'full') { static $link_index = 0; global $current_user, $globals, $the_template, $db, $ranklist; if (!$ranklist) { $users = $db->get_results("SELECT user_karma, COUNT(*) FROM " . table_users . " WHERE user_level NOT IN ('Spammer') AND user_karma>0 GROUP BY user_karma ORDER BY user_karma DESC", ARRAY_N); $ranklist = array(); $rank = 1; if ($users) { foreach ($users as $dbuser) { $ranklist[$dbuser[0]] = $rank; $rank += $dbuser[1]; } } } // DB 08/04/08 if (!is_numeric($this->id)) { return false; } ///// $smarty->assign('link_id', $this->id); if (!$this->read) { return $smarty; } $url = str_replace('&', '&', htmlspecialchars($this->url)); $url_short = txt_shorter($url); if ($this->url == "http://" || $this->url == '') { $url_short = "http://"; } else { $parsed = parse_url($this->url); if (isset($parsed['scheme'])) { $url_short = $parsed['scheme'] . "://" . $parsed['host']; } } echo $parsed['scheme']; $title_short = htmlspecialchars(utf8_wordwrap($this->title, 30, " ", 1)); $smarty->assign('viewtype', $type); $smarty->assign('URL_tagcloud', getmyurl("tagcloud")); $smarty->assign('URL_global_statistics', getmyurl("global_statistics")); $smarty->assign('No_URL_Name', No_URL_Name); if (track_outgoing == true && $url_short != "http://") { if (track_outgoing_method == "id") { $smarty->assign('url', getmyurl("out", $this->id)); } if (track_outgoing_method == "title") { $smarty->assign('url', getmyurl("outtitle", urlencode($this->title_url))); } if (track_outgoing_method == "url") { $smarty->assign('url', getmyurl("outurl", $url)); } } else { $smarty->assign('url', $url); } // DB 11/12/08 if ($url_short == "http://" || $url_short == "://") { $smarty->assign('enc_url', urlencode(my_base_url . $this->get_internal_url())); } else { $smarty->assign('enc_url', urlencode($url)); } ///// $smarty->assign('url_short', $url_short); $smarty->assign('title_short', $title_short); //$smarty->assign('title_url', urlencode($this->title_url)); $smarty->assign('enc_title_short', urlencode($title_short)); $smarty->assign('story_url', $this->get_internal_url()); $smarty->assign('story_edit_url', getmyurl("editlink", $this->id)); $smarty->assign('story_admin_url', getmyurl("admin_modify", $this->id)); $smarty->assign('story_comment_count', $this->comments()); $smarty->assign('story_status', $this->status); //$smarty->assign('story_karma', $this->karma); if ($type == "summary") { if ($this->link_summary == "") { $smarty->assign('story_content', $this->truncate_content()); } else { $smarty->assign('story_content', $this->link_summary); } } /* $sql = "SELECT link_id FROM " . table_links . " WHERE link_category='$id'"; $links = $db->get_results($sql); foreach($links as $link) { $db->query('UPDATE '.table_comments." SET comment_status='discard' WHERE comment_link_id={$link->link_id}"); $vars = array('link_id' => $link->link_id); check_actions('story_discard', $vars); $db->query('UPDATE '.table_links." SET link_status='discard' WHERE link_id={$link->link_id}"); } */ if ($type == "full") { $smarty->assign('story_content', $this->content); $smarty->assign('story_id', $this->id); } if ($this->get_author_info == true) { $smarty->assign('link_submitter', $this->username()); $smarty->assign('submitter_profile_url', getmyurl('user', $this->username)); $smarty->assign('submitter_rank', $ranklist[$this->userkarma]); } $smarty->assign('link_submit_time', $this->date); $smarty->assign('link_submit_timeago', txt_time_diff($this->date)); $smarty->assign('link_submit_date', date('F, d Y g:i A', $this->date)); $smarty->assign('link_published_time', $this->published_date); $smarty->assign('link_published_timeago', txt_time_diff($this->published_date)); $smarty->assign('link_category', $this->category_name()); if (Multiple_Categories) { $cats = array(); foreach ($this->additional_cats as $cat) { $url = $this->category_safe_name($cat); if ($this->status == "published") { $url = getmyurl("maincategory", $url); } if ($this->status == "queued") { $url = getmyurl("queuedcategory", $url); } if ($this->status == "discard") { $url = getmyurl("discardedcategory", $url); } $cats[$url] = $this->category_name($cat); } $smarty->assign('link_additional_cats', $cats); } //assign category id to smarty, so we can use it in the templates. Needed for category colors! $smarty->assign('category_id', $this->category); global $URLMethod; $catvar = $this->category_safe_name(); $smarty->assign('Voting_Method', Voting_Method); $this->votecount = $this->countvotes(); if (Voting_Method == 2) { if (!$this->rating) { $this->rating = $this->rating($this->id) / 2; } $smarty->assign('link_rating', $this->rating); $smarty->assign('link_rating_width', $this->rating * 25); $current_user_id = $current_user->user_id; $jsLink = "vote({$current_user_id}, {$this->id}, {$link_index}, '" . md5($current_user_id . $this->randkey) . "', "; for ($stars = 1; $stars <= 5; $stars++) { $smarty->assign("link_shakebox_javascript_vote_{$stars}star", $jsLink . $stars * 2 . ')'); } $smarty->assign('vote_count', $this->votecount); if ($this->votes($current_user_id) > 0) { $smarty->assign('star_class', "-noh"); } else { $smarty->assign('star_class', ""); } } $smarty->assign('get_group_membered', $this->get_group_membered()); if ($this->status == "published") { $smarty->assign('category_url', getmyurl("maincategory", $catvar)); } if ($this->status == "queued") { $smarty->assign('category_url', getmyurl("queuedcategory", $catvar)); } if ($this->status == "discard") { $smarty->assign('category_url', getmyurl("discardedcategory", $catvar)); } $smarty->assign('trackback_url', get_trackback($this->id)); $smarty->assign('user_logged_in', $current_user->user_login); $smarty->assign('randmd5', md5($current_user->user_id . $this->randkey)); $smarty->assign('user_id', $this->author); $smarty->assign('current_user_id', $current_user_id); if (Enable_Extra_Fields) { $main_smarty = $smarty; include mnminclude . 'extra_fields_smarty.php'; $smarty = $main_smarty; $smarty->assign('link_field1', $this->link_field1); $smarty->assign('link_field2', $this->link_field2); $smarty->assign('link_field3', $this->link_field3); $smarty->assign('link_field4', $this->link_field4); $smarty->assign('link_field5', $this->link_field5); $smarty->assign('link_field6', $this->link_field6); $smarty->assign('link_field7', $this->link_field7); $smarty->assign('link_field8', $this->link_field8); $smarty->assign('link_field9', $this->link_field9); $smarty->assign('link_field10', $this->link_field10); $smarty->assign('link_field11', $this->link_field11); $smarty->assign('link_field12', $this->link_field12); $smarty->assign('link_field13', $this->link_field13); $smarty->assign('link_field14', $this->link_field14); $smarty->assign('link_field15', $this->link_field15); } $smarty->assign('link_group_id', $this->link_group_id); $smarty->assign('Enable_Recommend', Enable_Recommend); $smarty->assign('instpath', my_base_url . my_pligg_base . "/"); $smarty->assign('UseAvatars', do_we_use_avatars()); $smarty->assign('Avatar_ImgSrc', get_avatar('large', "", "", "", $this->userid)); $smarty->assign('Avatar_ImgSrcs', get_avatar('small', "", "", "", $this->userid)); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); $canIhaveAccess = $canIhaveAccess + checklevel('admin'); if ($canIhaveAccess == 1) { $smarty->assign('isadmin', 'yes'); } if ($this->check_friends == true) { // For Friends // include_once mnminclude . 'friend.php'; $friend = new Friend(); // make sure we're logged in and we didnt submit the link. if ($current_user->user_id > 0 && $current_user->user_login != $this->username()) { $friend_md5 = friend_MD5($current_user->user_login, $this->username()); $smarty->assign('FriendMD5', $friend_md5); $isfriend = $friend->get_friend_status($this->author); if (!$isfriend) { $friend_text = 'add to'; $friend_url = 'addfriend'; } else { $friend_text = 'remove from'; $friend_url = 'removefriend'; } $smarty->assign('Friend_Text', $friend_text); $smarty->assign('user_add_remove', getmyurl('user_add_remove', $this->username(), $friend_url)); } $smarty->assign('Allow_Friends', Allow_Friends); // --- // } if ($current_user->user_id != '') { $vars = array('author_id' => $this->author, 'link_id' => $this->id); check_actions('friends_activity_function', $vars); if ($vars['value'] == true) { $smarty->assign('friendvoted', 1); } } /* //for friends voting activity include_once(mnminclude.'friend.php'); $friend = new Friend; $sql = 'SELECT ' . table_votes . '.*, ' . table_users . '.user_id FROM ' . table_votes . ' INNER JOIN ' . table_users . ' ON ' . table_votes . '.vote_user_id = ' . table_users . '.user_id WHERE (((' . table_votes . '.vote_value)>0) AND ((' . table_votes . '.vote_link_id)='.$this->id.') AND (' . table_votes . '.vote_type= "links"));'; $voters = $db->get_results($sql); $voters = object_2_array($voters); foreach($voters as $key => $val) { $voteduserid = $val['user_id']; if($voteduserid == $friend->get_friend_status($this->author)) { $friendvoted = 1; } $smarty->assign('friendvoted', $friendvoted); }*/ if ($this->check_saved == true) { global $cached_saved_links; if (isset($cached_saved_links[$this->id])) { $smarty->assign('link_mine', $cached_saved_links[$this->id]); } else { $smarty->assign('link_mine', $db->get_row("SELECT * FROM " . table_saved_links . " WHERE saved_user_id={$current_user->user_id} AND saved_link_id={$this->id} LIMIT 1;")); } } $smarty->assign('user_url_saved', getmyurl('user2', $current_user->user_login, 'saved')); $smarty->assign('user_add_links_private', getmyurl('user_add_links_private', $this->id)); $smarty->assign('user_add_links_public', getmyurl('user_add_links_public', $this->id)); $smarty->assign('group_story_links_publish', getmyurl('group_story_links_publish', $this->id)); $smarty->assign('group_story_links_queued', getmyurl('group_story_links_queued', $this->id)); $smarty->assign('group_story_links_discard', getmyurl('group_story_links_discard', $this->id)); $smarty->assign('user_url_add_links', getmyurl('user_add_links', $this->id)); $smarty->assign('user_url_remove_links', getmyurl('user_remove_links', $this->id)); $smarty->assign('enable_tags', Enable_Tags); $smarty->assign('link_shakebox_index', $link_index); $smarty->assign('link_shakebox_votes', $this->votes); $smarty->assign('link_shakebox_showbury', $this->reports); $this->get_current_user_votes($current_user->user_id); $smarty->assign('link_shakebox_currentuser_votes', $this->current_user_votes); $smarty->assign('link_shakebox_currentuser_reports', $this->current_user_reports); if ($this->reports == -1) { // reporting was added to the svn and some people started using it // so in upgrade if someone already has the reports field, we set it to // -1. Then when we read() we check if -1. if it still is, update the count // from the votes table and store it into the link_reports field so we // don't have to look at the votes table again. $this->reports = $this->count_all_votes("<0"); $this->store_basic(); $smarty->assign('link_shakebox_reports', $this->reports); } $jslink = "vote({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',10)"; $jsreportlink = "vote({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',-10)"; $smarty->assign('link_shakebox_javascript_vote', $jslink); $jsunvote = "unvote({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',10)"; $smarty->assign('link_shakebox_javascript_unvote', $jsunvote); $smarty->assign('link_shakebox_javascript_report', $jsreportlink); if (!defined('alltagtext')) { // for pages like index, this ->display was being called for each story // which was sometimes 15+ times per page. this way it's just called once $smarty->display('blank.tpl'); //this is just to load the lang file so we can pull from it in php define('alltagtext', $smarty->get_config_vars('PLIGG_Visual_Tags_All_Tags')); } $alltagtext = alltagtext; if (Enable_Tags) { $smarty->assign('tags', $this->tags); if (!empty($this->tags)) { $tags_words = str_replace(", ", ",", $this->tags); $tags_count = substr_count($tags_words, ','); if ($tags_count > 1) { $tags_words = $tags_words; } $tag_array = explode(",", $tags_words); $c = count($tag_array); $tag_array[$c] = $this->tags; $c++; for ($i = 0; $i <= $c; $i++) { if (isset($tag_array[$i])) { if ($URLMethod == 1) { $tags_url_array[$i] = my_pligg_base . "/search.php?search=" . urlencode(trim($tag_array[$i])) . "&tag=true"; } elseif ($URLMethod == 2) { $tags_url_array[$i] = my_pligg_base . "/tag/" . urlencode(trim($tag_array[$i])); } } } $tag_array[$c - 1] = $alltagtext; $smarty->assign('tag_array', $tag_array); $smarty->assign('tags_url_array', $tags_url_array); $tags_url = urlencode($this->tags); $smarty->assign('tags_count', $tags_count); $smarty->assign('tags_words', $tags_words); $smarty->assign('tags_url', $tags_url); } } $smarty->assign('enable_group', enable_group); $smarty->assign('pagename', pagename); $smarty->assign('my_base_url', my_base_url); $smarty->assign('my_pligg_base', my_pligg_base); $smarty->assign('Default_Gravatar_Large', Default_Gravatar_Large); $link_index++; $vars['smarty'] = $smarty; check_actions('lib_link_summary_fill_smarty', $vars); return $smarty; }
function fill_smarty($smarty, $type = 'full') { static $link_index = 0; global $current_user, $globals, $the_template; $smarty->assign('link_id', $this->id); $smarty->display('blank.tpl'); //this is just to load the lang file so we can pull from it in php if (!$this->read) { return; } $url = str_replace('&', '&', htmlspecialchars($this->url)); $url_short = txt_shorter($url); if ($this->url == "http://") { $url_short = "http://"; } else { $parsed = parse_url($this->url); $url_short = $parsed['scheme'] . "://" . $parsed['host']; } $title_short = htmlspecialchars(utf8_wordwrap($this->title, 30, " ", 1)); $smarty->assign('viewtype', $type); $smarty->assign('URL_tagcloud', getmyurl("tagcloud")); $smarty->assign('No_URL_Name', No_URL_Name); if (track_outgoing == true) { if (track_outgoing_method == "id") { $smarty->assign('url', getmyurl("out", $this->id)); } if (track_outgoing_method == "title") { $smarty->assign('url', getmyurl("outtitle", $this->title_url)); } if (track_outgoing_method == "url") { $smarty->assign('url', getmyurl("outurl", $url)); } } else { $smarty->assign('url', $url); } $smarty->assign('enc_url', urlencode($url)); $smarty->assign('url_short', $url_short); $smarty->assign('title_short', $title_short); $smarty->assign('title_url', urlencode($this->title_url)); $smarty->assign('enc_title_short', urlencode($title_short)); if ($this->title_url == "") { $smarty->assign('story_url', getmyurl("story", $this->id)); // internal link to the comments page } else { $smarty->assign('story_url', getmyurl("storyURL", $this->category_safe_name(), urlencode($this->title_url), $this->id)); // internal link to the comments page } $smarty->assign('story_edit_url', getmyurl("editlink", $this->id)); $smarty->assign('story_admin_url', getmyurl("admin_modify", $this->id)); $smarty->assign('story_comment_count', $this->comments()); $smarty->assign('story_status', $this->status); if ($type == "summary") { if ($this->link_summary == "") { $smarty->assign('story_content', $this->truncate_content()); } else { $smarty->assign('story_content', $this->link_summary); } } if ($type == "full") { $smarty->assign('story_content', $this->content); } $smarty->assign('link_submitter', $this->username()); $smarty->assign('submitter_profile_url', getmyurl('user', $this->username())); $smarty->assign('link_submit_time', $this->date); $smarty->assign('link_submit_timeago', txt_time_diff($this->date)); $smarty->assign('link_published_time', $this->published_date); $smarty->assign('link_published_timeago', txt_time_diff($this->published_date)); $smarty->assign('link_category', $this->category_name()); //assign category id to smarty, so we can use it in the templates. Needed for category colors! $smarty->assign('category_id', $this->category); global $URLMethod; $catvar = $this->category_safe_name(); $smarty->assign('Voting_Method', Voting_Method); if (Voting_Method == 2) { $this->rating = $this->rating($this->id) / 2; $smarty->assign('link_rating', $this->rating); $smarty->assign('link_rating_width', $this->rating * 25); $js5link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 10)"; $smarty->assign('link_shakebox_javascript_vote_5star', $js5link); $js4link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 8)"; $smarty->assign('link_shakebox_javascript_vote_4star', $js4link); $js3link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 6)"; $smarty->assign('link_shakebox_javascript_vote_3star', $js3link); $js2link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 4)"; $smarty->assign('link_shakebox_javascript_vote_2star', $js2link); $js1link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 2)"; $smarty->assign('link_shakebox_javascript_vote_1star', $js1link); $this->votecount = $this->countvotes(); $smarty->assign('vote_count', $this->votecount); if ($this->votes($current_user->user_id) > 0) { $smarty->assign('star_class', "-noh"); } else { $smarty->assign('star_class', ""); } } if ($this->status == "published") { $smarty->assign('category_url', getmyurl("maincategory", $catvar)); } if ($this->status == "queued") { $smarty->assign('category_url', getmyurl("queuedcategory", $catvar)); } if ($this->status == "discard") { $smarty->assign('category_url', getmyurl("discardedcategory", $catvar)); } $smarty->assign('trackback_url', get_trackback($this->id)); $smarty->assign('user_logged_in', $current_user->user_login); $smarty->assign('randmd5', md5($current_user->user_id . $this->randkey)); $smarty->assign('user_id', $this->author); $smarty->assign('current_user_id', $current_user->user_id); if (Enable_Extra_Fields) { $main_smarty = $smarty; include mnminclude . 'extra_fields_smarty.php'; $smarty = $main_smarty; $smarty->assign('link_field1', $this->link_field1); $smarty->assign('link_field2', $this->link_field2); $smarty->assign('link_field3', $this->link_field3); $smarty->assign('link_field4', $this->link_field4); $smarty->assign('link_field5', $this->link_field5); $smarty->assign('link_field6', $this->link_field6); $smarty->assign('link_field7', $this->link_field7); $smarty->assign('link_field8', $this->link_field8); $smarty->assign('link_field9', $this->link_field9); $smarty->assign('link_field10', $this->link_field10); $smarty->assign('link_field11', $this->link_field11); $smarty->assign('link_field12', $this->link_field12); $smarty->assign('link_field13', $this->link_field13); $smarty->assign('link_field14', $this->link_field14); $smarty->assign('link_field15', $this->link_field15); } $smarty->assign('Enable_Recommend', Enable_Recommend); $smarty->assign('Recommend_Type', Recommend_Type); $smarty->assign('instpath', my_base_url . my_pligg_base . "/"); $smarty->assign('UseAvatars', do_we_use_avatars()); $smarty->assign('Avatar_ImgSrc', get_avatar('large', "", $this->username(), $this->author_email)); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); $canIhaveAccess = $canIhaveAccess + checklevel('admin'); if ($canIhaveAccess == 1) { $smarty->assign('isadmin', 'yes'); } // For Friends // include_once mnminclude . 'friend.php'; $friend = new Friend(); // make sure we're logged in and we didnt submit the link. if ($current_user->user_id > 0 && $current_user->user_login != $this->username()) { $friend_md5 = friend_MD5($current_user->user_login, $this->username()); $smarty->assign('FriendMD5', $friend_md5); $isfriend = $friend->get_friend_status($this->author); if (!$isfriend) { $friend_text = 'add to'; $friend_url = 'addfriend'; } else { $friend_text = 'remove from'; $friend_url = 'removefriend'; } $smarty->assign('Friend_Text', $friend_text); $smarty->assign('user_add_remove', getmyurl('user_add_remove', $this->username(), $friend_url)); } $smarty->assign('Allow_Friends', Allow_Friends); $smarty->assign('Enable_AddTo', Enable_AddTo); // --- // $smarty->assign('enable_tags', Enable_Tags); $smarty->assign('link_shakebox_index', $link_index); $smarty->assign('link_shakebox_votes', $this->votes); $smarty->assign('link_shakebox_currentuser_votes', $this->votes($current_user->user_id)); $smarty->assign('link_shakebox_currentuser_reports', $this->reports($current_user->user_id)); $jslink = "menealo({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',10)"; $smarty->assign('link_shakebox_javascript_vote', $jslink); $jslink_negative = "menealo({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',-10)"; $smarty->assign('link_shakebox_javascript_vote_negative', $jslink_negative); $alltagtext = $smarty->get_config_vars('PLIGG_Visual_Tags_All_Tags'); if (Enable_Tags) { $smarty->assign('tags', $this->tags); if (!empty($this->tags)) { $tags_words = str_replace(",", ", ", $this->tags); $tags_count = substr_count($tags_words, ','); if ($tags_count > 1) { $tags_words = $tags_words; } $tag_array = explode(",", $tags_words); $c = count($tag_array); $tag_array[$c] = $this->tags; $c++; for ($i = 0; $i <= $c; $i++) { if ($URLMethod == 1) { $tags_url_array[$i] = my_pligg_base . "/search.php?search=" . urlencode(trim($tag_array[$i])) . "&tag=true"; } elseif ($URLMethod == 2) { $tags_url_array[$i] = my_pligg_base . "/tag/" . urlencode(trim($tag_array[$i])); } } $tag_array[$c - 1] = $alltagtext; $smarty->assign('tag_array', $tag_array); $smarty->assign('tags_url_array', $tags_url_array); $tags_url = urlencode($this->tags); $smarty->assign('tags_count', $tags_count); $smarty->assign('tags_words', $tags_words); $smarty->assign('tags_url', $tags_url); } } $smarty->assign('pagename', pagename); $smarty->assign('my_base_url', my_base_url); $smarty->assign('my_pligg_base', my_pligg_base); $smarty->assign('Default_Gravatar_Large', Default_Gravatar_Large); $smarty->assign('enable_categorycolors', enable_categorycolors); //read enable or disable category colors in config.php $link_index++; check_actions('lib_link_summary_fill_smarty'); return $smarty; }