Exemplo n.º 1
0
/**
 * Add video.
 * @param MySQLi $link Link to database.
 * @param string $code Code.
 * @param int $widht Width.
 * @param int $height Height.
 * @return int
 * added video id.
 */
function db_videos_add($link, $code, $widht, $height)
{
    $result = mysqli_query($link, "call sp_videos_add('{$code}', {$widht}, {$height})");
    if (!$result) {
        throw new DBException(mysqli_error($link));
    }
    $row = mysqli_fetch_assoc($result);
    mysqli_free_result($result);
    db_cleanup_link($link);
    return is_int($row['id']) ? $row['id'] : kotoba_intval($row['id']);
}
Exemplo n.º 2
0
/**
 * Check page number.
 * @param int $page Page number.
 * @param boolean $throw Default value is TRUE. Throw exception or return NULL.
 * @return int Returns safe page number.
 */
function check_page($page, $throw = TRUE)
{
    return kotoba_intval($page, $throw);
}
Exemplo n.º 3
0
 if (!isset($_POST[$param_name]) && $board['with_attachments']) {
     // Flag down 1 -> 0
     $new_board['with_attachments'] = false;
     $changed = true;
     //echo "with_attachments down<br>\n";
 }
 foreach (array('enable_macro', 'enable_youtube', 'enable_captcha', 'enable_translation', 'enable_geoip', 'enable_shi', 'enable_postid') as $attr) {
     if ($_POST["{$attr}_{$board['id']}"] == '2') {
         $new_board[$attr] = null;
         if ($board[$attr] !== null) {
             $changed = true;
             //echo "$attr inherit<br>\n";
         }
     } else {
         $new_board[$attr] = $_POST["{$attr}_{$board['id']}"] ? true : false;
         if ($board[$attr] === null || kotoba_intval($board[$attr]) != $new_board[$attr]) {
             $changed = true;
             //echo "$attr set to " . ($new_board[$attr] ? 'true' : 'false') . "<br>\n";
         }
     }
 }
 // Is same uploads policy was changed?
 if (isset($_POST["same_upload_{$board['id']}"])) {
     $new_board['same_upload'] = boards_check_same_upload($_POST["same_upload_{$board['id']}"]);
     if ($new_board['same_upload'] === FALSE) {
         // Cleanup.
         DataExchange::releaseResources();
         Logging::close_log();
         display_error_page($smarty, kotoba_last_error());
         exit(1);
     }
Exemplo n.º 4
0
     if (count($banners) > 0) {
         $smarty->assign('banner', $banners[rand(0, count($banners) - 1)]);
     }
 }
 $smarty->assign('thread', $thread);
 $smarty->assign('enable_translation', is_translation_enabled($board));
 $smarty->assign('show_control', is_admin() || is_mod());
 $smarty->assign('categories', $categories);
 $board['annotation'] = $board['annotation'] ? html_entity_decode($board['annotation'], ENT_QUOTES, Config::MB_ENCODING) : $board['annotation'];
 $smarty->assign('boards', $boards);
 $smarty->assign('ib_name', Config::IB_NAME);
 $smarty->assign('MAX_FILE_SIZE', Config::MAX_FILE_SIZE);
 $smarty->assign('board', $board);
 $smarty->assign('name', $_SESSION['name']);
 if (isset($_REQUEST['quote'])) {
     $smarty->assign('quote', kotoba_intval($_REQUEST['quote']));
 }
 if (isset($_SESSION['oekaki'])) {
     $smarty->assign('oekaki', $_SESSION['oekaki']);
 }
 $smarty->assign('enable_macro', is_macrochan_enabled($board));
 $smarty->assign('macrochan_tags', $macrochan_tags);
 $smarty->assign('enable_youtube', is_youtube_enabled($board));
 $smarty->assign('enable_captcha', is_captcha_enabled($board));
 $smarty->assign('captcha', Config::CAPTCHA);
 $smarty->assign('password', $password);
 $smarty->assign('goto', $_SESSION['goto']);
 $smarty->assign('upload_types', $upload_types);
 $smarty->assign('enable_shi', is_shi_enabled($board));
 $smarty->assign('is_moderatable', $is_moderatable);
 $smarty->assign('threads', array($thread));
Exemplo n.º 5
0
 }
 call_user_func(Logging::$f['LOG_VIEW_USE']);
 $categories = categories_get_all();
 $boards = boards_get_all();
 // Make category-boards tree for navigation panel.
 foreach ($categories as &$c) {
     $c['boards'] = array();
     foreach ($boards as $b) {
         if ($b['category'] == $c['id'] && !in_array($b['name'], Config::$INVISIBLE_BOARDS)) {
             array_push($c['boards'], $b);
         }
     }
 }
 if (isset($_REQUEST['log_view'])) {
     $kargv = $_REQUEST['log_view'];
     $records_count = kotoba_intval($kargv['records_count']);
     $records_count = $records_count > 0 ? $records_count : 10;
     $smarty->assign('records_count_prev', $records_count);
     date_default_timezone_set(Config::DEFAULT_TIMEZONE);
     $logf = fopen(Config::ABS_PATH . '/log/actions-' . date(Config::LOG_DATETIME_FORMAT) . '.log', 'r');
     $i = 0;
     while ($line = fgets($logf)) {
         $log[$i] = preg_split('/\\|/', $line, -1, PREG_SPLIT_NO_EMPTY);
         $log[$i][4] = htmlentities($log[$i][4], ENT_QUOTES, Config::MB_ENCODING);
         $i++;
     }
     if (($n = count($log)) > $records_count) {
         $log = array_slice($log, $n - $records_count, $records_count);
     }
     $log = array_reverse($log);
     $smarty->assign('log', $log);
Exemplo n.º 6
0
/**
 * Check count of threads per page.
 * @param int $threads_per_page Count of threads per page.
 * @return int|boolean Returns safe count of threads per page or boolean FALSE
 * if any error occurred and set last error to appropriate error object.
 */
function users_check_threads_per_page($threads_per_page)
{
    $threads_per_page = kotoba_intval($threads_per_page);
    $length = strlen($threads_per_page);
    if ($length <= 2 && $length >= 1) {
        $threads_per_page = RawUrlEncode($threads_per_page);
        $length = strlen($threads_per_page);
        if ($length > 2 || ctype_digit($threads_per_page) === false || $length < 1) {
            $_ = new UserThreadsPerPageError(Config::MIN_THREADSPERPAGE, Config::MAX_THREADSPERPAGE);
            kotoba_set_last_error($_);
            return FALSE;
        }
    } else {
        $_ = new UserThreadsPerPageError(Config::MIN_THREADSPERPAGE, Config::MAX_THREADSPERPAGE);
        kotoba_set_last_error($_);
        return FALSE;
    }
    return kotoba_intval($threads_per_page);
}