Beispiel #1
0
<?php

session_start();
require_once "../config.php";
require_once "../function.php";
$first_row = fetch_first_row("SELECT COUNT(*) FROM exchange_article WHERE parent_id IS NULL");
$number_of_row = $first_row["COUNT(*)"];
$page = 1;
if (isset($_GET["page"])) {
    $page = (int) $_GET["page"];
}
$total_page_count = $number_of_row % 10 != 0 ? $number_of_row / 10 + 1 : $number_of_row / 10;
if ($page < 1 || $page > $total_page_count) {
    $page = 1;
}
$result = fetch_all_row("SELECT * FROM exchange_article " . "WHERE parent_id IS NULL ORDER BY id DESC LIMIT ?, 10", "i", ($page - 1) * 10);
//////////////////// HTML START ////////////////////
require_once "../header.php";
?>
<main id="exchange-list">
  <div>
    <?php 
foreach ($result as $row) {
    ?>
      <article>
        <section class="status">
          <span class="views">
            <big><?php 
    echo $row['board_hit'];
    ?>
</big>
Beispiel #2
0
<?php

session_start();
require_once "config.php";
require_once "function.php";
$language = fetch_all_row("SELECT * FROM ui_language");
require_once "header.php";
?>
<main class="narrow">
  <h2>Change Language</h2>
  <ul class="lang-list">
  <?php 
foreach ($language as $row) {
    echo "<li onclick=\"document.cookie='lang=" . $row["lang_code"] . "; path=/'; location.href='" . $_SERVER["HTTP_REFERER"] . "'\">" . $row["english"] . "</a></li>";
}
?>
  </ul>
</main>

<?php 
require_once "footer.php";
        <?php 
echo sprintf(T_('<select name="start_language">%s</select>에서 <select name="end_language">%s</select>으로'), $option, $option);
?>
      </p>
      <p class="form-line">
        <label for="category"><?php 
echo T_("카테고리");
?>
:</label>
        <select name="category">
          <option value=""><?php 
echo T_("카테고리 선택");
?>
</option>
          <?php 
$all_categories = fetch_all_row("SELECT * FROM category");
foreach ($all_categories as $category) {
    ?>
            <option value="<?php 
    echo $category['category_code'];
    ?>
">
              <?php 
    echo T_($category['category_code']);
    ?>
            </option>
          <?php 
}
?>
        </select>
      </p>
    echo "<script>history.back();</script>";
    exit;
}
$q = htmlspecialchars($_GET['q']);
$like = '%' . $q . '%';
$first_row = fetch_first_row("SELECT COUNT(*) FROM exchange_article " . "WHERE parent_id IS NULL AND board_title LIKE ?", 's', $like);
$number_of_row = $first_row["COUNT(*)"];
$page = 1;
if (isset($_GET["page"])) {
    $page = (int) $_GET["page"];
}
$total_page_count = $number_of_row % 10 != 0 ? $number_of_row / 10 + 1 : $number_of_row / 10;
if ($page < 1 || $page > $total_page_count) {
    $page = 1;
}
$result = fetch_all_row("SELECT * FROM exchange_article WHERE parent_id IS NULL AND board_title LIKE ? " . "ORDER BY id DESC LIMIT ?, 10", "si", $like, ($page - 1) * 10);
//////////////////// HTML START ////////////////////
require_once "../header.php";
?>
<main id="exchange-list">
  <div>
    <h2><?php 
echo sprintf(T_("검색 결과 %d개 표시 중"), $number_of_row);
?>
</h2>
      <?php 
foreach ($result as $row) {
    ?>
        <article>
          <section class="status">
            <span class="views">
<?php

require_once "config.php";
require_once "function.php";
$all_row = fetch_all_row("SELECT * FROM exchange_article");
$users = fetch_all_row("SELECT * FROM users");
foreach ($users as $user) {
    execute_query("UPDATE users SET user_reputation = 0 WHERE ID = ?", 'i', $user['ID']);
    //echo "Done clear user ID " . $user['ID'] . "<br />";
}
foreach ($all_row as $row) {
    execute_query("UPDATE users SET user_reputation = user_reputation + ? WHERE ID = ?", 'ii', $row['vote_up'] + $row['vote_down'], $row['author']);
    //echo "Done calculating article ID " . $row['ID'] . "<br />";
}
Beispiel #6
0
function recursive_comment($parent_article, $parent_id, $level)
{
    $result = fetch_all_row("SELECT * FROM exchange_comment " . "WHERE parent_article = ? " . "AND (IF (ISNULL(?), parent_id IS NULL, parent_id = ?))", "iii", $parent_article, $parent_id, $parent_id);
    if ($parent_id === NULL && isset($_SESSION['ID'])) {
        ?>
        <form method="post" action="/board/write_comment.php">
            <input type="text" name="text" placeholder="<?php 
        echo T_("댓글을 입력하세요...");
        ?>
" />
            <input type="hidden" name="mode" value="exchange" />
            <input type="hidden" name="parent_id" value="NULL" />
            <input type="hidden" name="parent_article" value="<?php 
        echo $parent_article;
        ?>
" />
        </form>
    <?php 
    } else {
        if ($parent_id === NULL) {
            ?>
        <form>
            <input type="text" name="text" placeholder="<?php 
            echo T_("권한이 없습니다.");
            ?>
 "disabled />
            <input type="hidden" name="mode" value="exchange" />
            <input type="hidden" name="parent_id" value="NULL" />
            <input type="hidden" name="parent_article" value="<?php 
            echo $parent_article;
            ?>
" />
        </form>
    <?php 
        }
    }
    if (count($result) > 0) {
        foreach ($result as $row) {
            echo '<li style="padding-left: ' . ($level * 1.5 - 1) . 'rem;">';
            if ($row['visible'] == 1) {
                $user = fetch_first_row('SELECT * FROM users WHERE ID = ?', 'i', $row['author']);
                echo $row["content"];
                echo " - <small>";
                echo sprintf("<a href='/profile.php?id=%s'>%s</a>가 %s에", $user['ID'], $user['user_nickname'], time2str($row['date']));
                echo "</small>";
                if (isset($_SESSION['ID']) && !empty($_SESSION['ID']) && $row['author'] == $_SESSION['ID']) {
                    ?>
                    <a href="/board/exchange_remove_comment.php?mode=exchange&comment=<?php 
                    echo $row['ID'];
                    ?>
">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" class="icon icon-small">
                            <path d="M0,1h3v-1h5v1h3v1h-12z" />
                            <path d="M1,3h9v9h-1v-8h-1v7h-1v-7h-1v7h-1v-7h-1v7h-1v-7h-1v7h7v1h-8z" />
                        </svg>
                    </a>
                <?php 
                }
                ?>
                <?php 
                if (isset($_SESSION['ID']) && !empty($_SESSION['ID'])) {
                    ?>
                    <label for="toggle-visible-comment-<?php 
                    echo $row['ID'];
                    ?>
">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12"
                             class="icon icon-small">
                            <path d="M1,4v7h7m-7,0L11,1z" stroke-width="2" stroke="#000" fill="none" />
                        </svg>
                    </label>
                    <input type="checkbox" style="display: none;"
                           id="toggle-visible-comment-<?php 
                    echo $row['ID'];
                    ?>
" />
                        <form method="post" action="/board/write_comment.php">
                        <input type="text" name="text" placeholder="<?php 
                    echo T_("댓글을 입력하세요...");
                    ?>
" />
                        <input type="hidden" name="mode" value="exchange" />
                        <input type="hidden" name="parent_id" value="<?php 
                    echo $row['ID'];
                    ?>
" />
                        <input type="hidden" name="parent_article" value="<?php 
                    echo $parent_article;
                    ?>
" />
                    </form>
                <?php 
                }
                ?>
            <?php 
            } else {
                echo T_("<i>[삭제된 댓글입니다]</i>");
            }
            recursive_comment($parent_article, $row['ID'], $level + 1);
        }
    }
}
Beispiel #7
0
        } else {
            $different_password = true;
        }
    }
    if (isset($_POST['user_nickname']) && !empty($_POST['user_nickname'])) {
        execute_query('UPDATE users SET user_nickname = ? WHERE ID = ?', 'si', htmlspecialchars($_POST['user_nickname']), $_SESSION['ID']);
        $modified = true;
    }
    $my_data = fetch_first_row("SELECT * FROM users WHERE ID = ?", 'i', $_SESSION['ID']);
    $_SESSION['user_id'] = $my_data['user_id'];
    $_SESSION['user_nickname'] = $my_data['user_nickname'];
    $_SESSION['user_email'] = $my_data['user_email'];
}
$profile_data = fetch_first_row("SELECT * FROM users WHERE ID = ?", 'i', $id);
$recent_question = fetch_all_row("SELECT * FROM exchange_article WHERE author = ? AND parent_id IS NULL ORDER BY date DESC LIMIT 10", 'i', $id);
$recent_answer = fetch_all_row("SELECT * FROM exchange_article WHERE author = ? AND parent_id IS NOT NULL ORDER BY date DESC LIMIT 10", 'i', $id);
function find_root_article($article_id)
{
    $result = fetch_first_row("SELECT * FROM exchange_article WHERE ID = ?", 'i', $article_id);
    if ($result['parent_id'] == NULL) {
        return $result;
    } else {
        return find_root_article($result['parent_id']);
    }
}
//////////////////// HTML START ////////////////////
require_once 'header.php';
?>

<main>
  <header>