while ($row3 = mysql_fetch_array($result3)) { $event_fav = $row3['COUNT']; } while ($row4 = mysql_fetch_array($result4)) { $event_user_id[] = $row4['USER_ID']; $user_last_name[] = $row4['USER_LAST_NAME']; $user_first_name[] = $row4['USER_FIRST_NAME']; } while ($row5 = mysql_fetch_array($result5)) { $organizer_user_id = $row5['USER_ID']; $organizer_last_name = $row5['USER_LAST_NAME']; $organizer_first_name = $row5['USER_FIRST_NAME']; } //イベント詳細情報を文字ごとに改行 $host_comment = mb_wordwrap($host_comment, 25, "<br>\n", true); $event_detail = mb_wordwrap($event_detail, 25, "<br>\n", true); //$event_detail = nl2br($event_detail); //データベース切断 mysql_close($link); ?> <!-- マルチバイト対応のwordwrap --> <?php function mb_wordwrap($string, $width = 75, $break = "\n", $cut = false) { if (!$cut) { $regexp = '#^(?:[\\x00-\\x7F]|[\\xC0-\\xFF][\\x80-\\xBF]+){' . $width . ',}\\b#U'; } else { $regexp = '#^(?:[\\x00-\\x7F]|[\\xC0-\\xFF][\\x80-\\xBF]+){' . $width . '}#'; } $string_length = mb_strlen($string, 'UTF-8');
if ($thistorrent['is_private']) { $statusflags .= "· Private "; } if ($thistorrent['complete'] == 1) { $statusstyle = "complete"; } else { $statusstyle = "incomplete"; } if ($thistorrent['is_active'] == 1) { $statusstyle .= "active"; } else { $statusstyle .= "inactive"; } echo "<div class='container' style='width:550px'>\n"; echo "<table border=0 cellspacing=0 cellpadding=5 class='maintable' width='100%'>\n"; echo "<tr class='row2'><td class='datacol' align=right><b>Name</b></td><td><span class='torrenttitle {$statusstyle}'>" . mb_wordwrap($thistorrent['name'], 60, "<br/>\n", TRUE) . "</span></td></tr>\n"; echo "<tr class='row1'><td class='datacol' align=right><b>Status</b></td><td><img src='images/" . $statusstyle . ".gif' width=10 height=9 alt='Status' /> " . $thistorrent['status_string'] . "</td></tr>\n"; echo "<tr class='row2'><td class='datacol' align=right><b>Priority</b></td><td>"; echo "<form action='control.php' method='post'>"; echo "<input type='hidden' name='hash' value='" . $thistorrent['hash'] . "' />"; echo "<select name='set_tpriority'>\n"; echo "<option value='0' " . ($thistorrent['priority'] == 0 ? "selected" : "") . ">Off </option>\n"; echo "<option value='1' " . ($thistorrent['priority'] == 1 ? "selected" : "") . ">Low </option>\n"; echo "<option value='2' " . ($thistorrent['priority'] == 2 ? "selected" : "") . ">Normal </option>\n"; echo "<option value='3' " . ($thistorrent['priority'] == 3 ? "selected" : "") . ">High </option>\n"; echo "</select>\n"; echo "<input type='submit' value='Set' />\n"; echo "</form>\n"; echo "<tr class='row1'><td class='datacol' align=right><b>Status Flags</b></td><td>" . $statusflags . "</td></tr>\n"; echo "<tr class='row2'><td class='datacol' align=right><b>Message</b></td><td>" . $thistorrent['message'] . "</td>"; echo "<tr class='row1'><td class='datacol' align=right><b>Completed Bytes</b></td><td>" . format_bytes($thistorrent['completed_bytes']) . "</td></tr>\n";
if (substr($date, 5, 1) == 0) { $date_month = substr($date, 6, 1); } else { $date_month = substr($date, 5, 2); } //イベント開始日の表示(先頭の0は表示されない) if (substr($date, 8, 1) == 0) { $date_day = substr($date, 9, 1); } else { $date_day = substr($date, 8, 2); } $temp = $temp . "<tr>"; $temp = $temp . "<td class=e_num_main>" . $display_num++ . "</td>"; $temp = $temp . "<td class=e_title_main><a href=../event/event_detail.php?event_id={$send}>" . $row['EVENT_TITLE'] . "</a></td>"; $temp = $temp . "<td class=e_date_main>" . substr($date, 0, 4) . "年" . $date_month . "月" . $date_day . "日" . "</td>"; $temp = $temp . "<td class=e_detail_main>" . mb_wordwrap($row['EVENT_DETAIL'], 30, "<br>\n", true) . "</td>"; $temp = $temp . "</tr>"; } $msg = "<p><h3>検索結果: 該当するイベントが" . $rows . "件表示されました。</h3></p><br>"; } else { $msg = "<p><h3>検索結果: 該当するイベントは存在しません。</h3></p>"; } //mysql_close() - MySQLサーバへの接続をクローズにする $close_flag = mysql_close($link); if (!$close_flag) { die('切断に失敗しました。' . mysql_error()); } //print('<p>切断に成功しました。</p>'); ?>
} echo '<div id="messages">'; gb_showpages($_GET['page']); // положение первой записи страницы $begin = ($_GET['page'] - 1) * RECSPERPAGE; $result = mysql_query('SELECT * FROM mandarinko_poll_comments WHERE `moder` = 1 and `hc_id` = ' . $_GET['poll'] . ' ORDER BY time DESC LIMIT ' . $begin . ', ' . RECSPERPAGE); // цикл по всем выбранным записям while ($row = mysql_fetch_array($result)) { $out = '<div class=element><div class=title><b>' . stripslashes($row['nick']) . '</b> '; if ($row['email']) { $out .= '( '; $out .= ' <a href=mailto:' . stripslashes($row['email']) . '>email</a>'; $out .= ' )'; } $row['time'] = date('d.m.Y H:i', $row['time']); $out .= ' пишет ' . $row['time'] . ':</div><div class=msg>' . htmlspecialchars(mb_wordwrap(html_entity_decode(stripslashes($row['msg']), ENT_QUOTES), 120, "\n")) . '</div></div>'; echo $out; } // уничтожаем результат mysql_free_result($result); gb_showpages($_GET['page']); echo '</div>'; //форма добавления сообщения ?> <div id="add_msg"> <h2>Добавить новое сообщение</h2> <table cellspacing="2" cellpadding="2" border="0"> <form action="?poll=<?php echo $_GET['poll']; ?> &result=1&add=1" method=post>
/** * wrapper for mail() * * @param string $to * @param string $subject * @param string $body * @param array $headers (optional) * @param string $fingerprint (optional) encrypt mail with the public key with this fingerprint * @return bool */ function send_mail($to, $subject, $body, array $headers=array(), $fingerprint="") { $subject = mb_encode_mimeheader( limitstr(MAIL_SUBJECT_PREFIX.$subject, 125) ); $headers[] = "Content-Type: text/plain; charset=UTF-8"; $headers[] = "Content-Transfer-Encoding: 8bit"; if (MAIL_FROM) $headers[] = "From: ".MAIL_FROM; $body = mb_wordwrap($body); if (GNUPG_SIGN_KEY) { $gnupg = new_gnupg(); if ( $gnupg->addsignkey(GNUPG_SIGN_KEY) ) { if ($fingerprint) { if ( gnupg_keyinfo_matches_email($gnupg->keyinfo($fingerprint), $to) and $gnupg->addencryptkey($fingerprint) ) { $body = $gnupg->encryptsign($body); } else { $body .= "\n\n".mb_wordwrap(_("This email should be encrypted, but no available key matching your fingerprint and email address was found! Please check your settings:")." ".BASE_URL."settings_encryption.php"); $body = $gnupg->sign($body); } } else { $body = $gnupg->sign($body); } } else { trigger_error("Gnupg sign key cound not be added", E_USER_WARNING); } } return mail($to, $subject, $body, join("\r\n", $headers)); }
} } } } } } } } } } } } } } //自己紹介文を文字ごとに改行 $profile = mb_wordwrap($profile, 26, "<br>\n", true); mysql_close($link); ?> <!-- このページの利用者が立ち上げているイベント情報の取得 --> <?php $event_title = array(); $event_start = array(); $event_id = array(); $link = mysql_connect('localhost', 'root', 'root'); if (!$link) { die('接続失敗です。' . mysql_error()); } $db_selected = mysql_select_db('greenbakari', $link); if (!$db_selected) { die('データベース選択失敗です。' . mysql_error());
function render($width, $options) { // Allow room for the border. // TODO: Consider left-right padding and margin $bw = $this->getStyle('border-width', 0); if ($bw) { $width -= 4; } $output = parent::render($width, $options); if ($output instanceof PreFormattedText) { // TODO: Consider CSS rules return new PreFormattedText("\n" . $output); } $output = trim($output); if (!strlen($output)) { return ""; } // Wordwrap the content to the width switch ($this->ws) { case 'nowrap': case 'pre': break; case 'pre-line': case 'pre-wrap': case 'normal': default: $output = mb_wordwrap($output, $width, "\n", true); } // Apply stylesheet styles // TODO: Padding // TODO: Justification // Border if ($bw) { $output = self::borderize($output, $width); } // Margin $mb = $this->getStyle('margin-bottom', 0); $output .= str_repeat("\n", (int) $mb); return "\n" . $output; }
$status_flags .= '· Hash Checked '; } if ($this_torrent['is_hash_checking']) { $status_flags .= '· Hash Checking '; } if ($this_torrent['is_multi_file']) { $status_flags .= '· Multi-file '; } if ($this_torrent['is_open']) { $status_flags .= '· Open '; } if ($this_torrent['is_private']) { $status_flags .= '· Private '; } $status_style = ($this_torrent['complete'] ? 'complete' : 'incomplete') . ($this_torrent['is_active'] ? 'active' : 'inactive'); $name = mb_wordwrap($this_torrent['name'], 60, "<br />\n", true); $selected = array(); foreach (range(0, 3) as $i) { $selected[$i] = $this_torrent['priority'] == $i ? ' selected="selected"' : ''; } $formatted = array(); foreach (array('completed_bytes', 'size_bytes', 'down_rate', 'down_total', 'up_rate', 'up_total') as $i) { $formatted[$i] = format_bytes($this_torrent[$i]); } $percent_bar = percentbar($this_torrent['percent_complete']); $ratio = number_format($this_torrent['ratio'] / 1000, 2); echo <<<HTML <div class="container"> <table border=0 cellspacing=0 cellpadding=5 class="maintable" width="100%"> <tr class="row"> <td class="datacol" align=right><b>Name</b></td>
//mysql_num_rows() - クエリの実行結果から行の数を取得する $rows = mysql_num_rows($result); if ($rows) { //mysql_fetch_array() - クエリの実行結果を連想配列として取得する while ($row = mysql_fetch_array($result)) { $send = $row['USER_ID']; $name = $row['USER_LAST_NAME'] . $row['USER_FIRST_NAME']; $temp = $temp . "<tr>"; $temp = $temp . "<td class=u_num_main>" . $display_num++ . "</td>"; //ログイン中のユーザが表示される場合はmypage.phpへのリンクを生成 if ($send == $user_id) { $temp = $temp . "<td class=u_name_main><a href=../mypage/mypage.php>" . $name . "</a></td>"; } else { $temp = $temp . "<td class=u_name_main><a href=../mypage/personalpage.php?user_id={$send}>" . $name . "</a></td>"; } $temp = $temp . "<td class=u_prof_main>" . mb_wordwrap($row['PROFILE'], 45, "<br>\n", true) . "</td>"; $temp = $temp . "</tr>"; } $msg = "<p><h3>検索結果: 該当する利用者が" . $rows . "名表示されました。</h3></p><br>"; } else { $msg = "<p><h3>検索結果: 該当する利用者は存在しません。</h3></p>"; } //mysql_close() - MySQLサーバへの接続をクローズにする $close_flag = mysql_close($link); if (!$close_flag) { die('切断に失敗しました。' . mysql_error()); } //print('<p>切断に成功しました。</p>'); ?> <!-- マルチバイト対応のwordwrap -->
$result = mysql_query('SELECT * FROM mandarinko_gbook WHERE `moder` = 1 ORDER BY time DESC LIMIT ' . $begin . ', ' . RECSPERPAGE); // цикл по всем выбранным записям while ($row = mysql_fetch_array($result)) { if ($row['id'] == 1) { $out = '<div class=element><div class=msg><b>' . htmlspecialchars(mb_wordwrap(html_entity_decode(stripslashes($row['msg']), ENT_QUOTES), 120, "\n")) . '</b></div></div>'; } else { $out = '<div class=element><div class=title><b>' . stripslashes($row['nick']) . '</b> '; if ($row['email']) { $out .= '( '; $out .= ' <a href=mailto:' . stripslashes($row['email']) . '>email</a>'; $out .= ' )'; } $row['time'] = date('d.m.Y H:i', $row['time']); $out .= ' пишет ' . $row['time'] . ':</div><div class=msg>' . htmlspecialchars(mb_wordwrap(html_entity_decode(stripslashes($row['msg']), ENT_QUOTES), 120, "\n")) . '</div>'; if ($row['answer']) { $out .= '<div class=answer>Ответ: ' . htmlspecialchars(mb_wordwrap(html_entity_decode(stripslashes($row['answer']), ENT_QUOTES), 200, "\n")) . '</div></div>'; } } echo $out; } // уничтожаем результат mysql_free_result($result); gb_showpages($_GET['page']); echo '</div>'; //форма добавления сообщения ?> <div id="add_msg"> <h2>Добавить новое сообщение</h2> <table cellspacing="2" cellpadding="2" border="0"> <form action=?add=1 method=post> <tr>
function showSurveyMetaData($message = '') { echo ' <ol class="breadcrumb"> <li><a href="?page=surveys">Surveys</a></li> <li><a href="?page=survey">' . $this->survey->getName($_SESSION['language']) . '</a></li> <li class="active">' . 'Meta data' . '</li> </ol>'; echo mb_wordwrap('this is a very long <b>string</b> ah yes wee ais a very long string yes is a very long string yes yesyes', 25, '--<br/>-----'); echo '<div class="well" style="background: white;">'; echo $message; global $survey; $sections = $survey->getSections(); $level = 0; $lastq = ''; $condition = ''; $output = ''; $state = 0; foreach ($sections as $section) { $filename = prependPath($section->getRulesLocation()); //echo $filename; $tokens = token_get_all(file_get_contents($filename)); foreach ($tokens as $key => $token) { echo "<b>{$key}</b>:" . print_r($token); echo '<br/>'; if (is_array($token)) { echo '---' . token_name($token[0]) . '---<br/>'; if ($token[0] == T_IF) { echo 'THIS IS AN IFFFFFF!'; $condition = 'IF '; $state = 1; } elseif ($token[0] == T_ELSE) { $output .= '<br/>ELSE '; } if ($token[1] == 'ask') { //question to ask!! $output .= '<hr>ASK!!(' . $level . '):' . $lastq . '<hr>'; //$output .= substr($lastq, 1) . '<br/>'; $question = $survey->getQuestionOrGroup(substr($lastq, 1)); if ($question != null) { // $output .= $question; // $output .= '<br/>NOT NULL<br/>'; // $output .= json_encode($question); // $output .= '-----<br/>----' . get_class($question) . '-----<br/>----'; // $output .= 'end expr'; if ($question instanceof Question) { $output .= tagwrap($question->getQuestionText(), 25, '<br/>'); $output .= '<hr>'; } } } if ($token[1] == 'value') { } else { if ($token[1] == '->') { } else { //question if ($state == 1) { $condition .= ' ' . $token[1]; } $lastq = $token[1]; } } } else { //level? if ($token == '{') { $state = 0; $output .= '<b>' . $condition . '</b>'; //'IF???'; $output .= '<br/>'; $condition = ''; $level++; } elseif ($token == '}') { $output .= '<b>END</b>'; //'IF???'; $output .= '<br/>'; $condition = ''; $state = 0; $level--; } } } } echo '<hr>OUTPUT<hr>'; echo $output; echo '<hr><hr>'; echo tagwrap('this is a very long string yes is a very long string yes is a very long string yes yesyes', 25, '--<br/>-----'); }
/** * save vote for this issue * * @param string $token * @param array $vote */ public function vote($token, array $vote) { // example for one single proposal: // array( 123 => array('acceptance' => 0) ) // example for two proposals: // array( 123 => array('acceptance' => 1, 'score' => 2), 456 => array('acceptance' => -1, 'score' => 0) ) // convert strings to integers foreach ( $vote as &$value ) { $value = array_map('intval', $value); } unset($value); DB::transaction_start(); $sql = "INSERT INTO vote_vote (token, vote) VALUES (".DB::esc($token).", ".DB::esc(serialize($vote)).") RETURNING votetime"; if ( $result = DB::query($sql) ) { list($votetime) = pg_fetch_row($result); if (!Login::$member->mail) { notice(_("Your vote has been saved, but the email receipt could not be sent, because you have no confirmed email address!")); } else { // Since the subject can not be encrypted, we don't show which issue. $subject = _("Vote receipt"); $body = _("Group").": ".$this->area()->ngroup()->name."\n\n"; $body .= sprintf(_("Vote receipt for your vote on issue %d:"), $this->id)."\n\n"; foreach ( $vote as $proposal_id => $vote_proposal ) { $proposal = new Proposal($proposal_id); $body .= mb_wordwrap(_("Proposal")." ".$proposal_id.": ".$proposal->title)."\n" .BASE_URL."proposal.php?id=".$proposal->id."\n" ._("Acceptance").": ".acceptance($vote_proposal['acceptance']); if (isset($vote_proposal['score'])) $body .= ", "._("Score").": ".score($vote_proposal['score']); $body .= "\n\n"; } $body .= _("Your username").": ".Login::$member->username."\n" ._("Your user ID").": ".Login::$member->id."\n" ._("Your vote token").": ".$token."\n" ._("Voting time").": ".date(VOTETIME_FORMAT, strtotime($votetime))."\n\n" ._("You can change your vote by voting again on:")."\n" .BASE_URL."vote.php?issue=".$this->id."\n"; if ( send_mail(Login::$member->mail, $subject, $body, array(), Login::$member->fingerprint) ) { success(_("Your vote has been saved and an email receipt has been sent to you.")); } else { warning(_("Your vote has been saved, but the email receipt could not be sent!")); } } DB::transaction_commit(); } else { warning(_("Your vote could not be saved!")); DB::transaction_rollback(); } }
function contentbuilder_wordwrap($str, $width = 75, $break = "\n", $cut = false, $charset = null) { return mb_wordwrap($str, $width, $break, $cut, $charset); }
function tagwrap($html, $width = 75, $break = "nr") { $html = '<div>' . $html . '</div>'; //using dom object $dom = new domDocument(); //load the html into the object $dom->loadXML($html); // preserve white space $dom->preserveWhiteSpace = true; //getting all tags $content = $dom->getElementsByTagname("*"); $html = ""; foreach ($content as $item) { //wrapping contents of tags, function described above is used, //but you can use your own function or simple wordwrap() php function $item->nodeValue = mb_wordwrap($item->nodeValue, $width, $break); $html .= $dom->saveXML($item); } //return the results return $html; //html_entity_decode($html); }