display_error_page($smarty, kotoba_last_error()); exit(1); } } else { copy_uploded_file($uploaded_file_path, $abs_img_path); copy_uploded_file(Config::ABS_PATH . "/shi/{$_SESSION['oekaki']['thumbnail']}", $abs_thumb_path); $thumb_dimensions = array('x' => Config::THUMBNAIL_WIDTH, 'y' => Config::THUMBNAIL_HEIGHT); } $spoiler = isset($_REQUEST['spoiler']) && $_REQUEST['spoiler'] == '1' ? true : false; $attachment_id = images_add($file_hash, $file_names[0], $img_dimensions['x'], $img_dimensions['y'], $uploaded_file_size, $file_names[1], $thumb_dimensions['x'], $thumb_dimensions['y'], $spoiler); } } elseif ($attachment_type == Config::ATTACHMENT_TYPE_LINK) { $macrochan_image = macrochan_images_get_random($macrochan_tag['name']); $macrochan_image['name'] = "http://12ch.ru/macro/index.php/image/" . "{$macrochan_image['name']}"; $macrochan_image['thumbnail'] = "http://12ch.ru/macro/index.php/" . "thumb/" . "{$macrochan_image['thumbnail']}"; $attachment_id = links_add($macrochan_image['name'], $macrochan_image['width'], $macrochan_image['height'], $macrochan_image['size'], $macrochan_image['thumbnail'], $macrochan_image['thumbnail_w'], $macrochan_image['thumbnail_h']); } elseif ($attachment_type == Config::ATTACHMENT_TYPE_VIDEO) { $attachment_id = videos_add($youtube_video_code, 220, 182); } else { throw new ParanoicException("Attachment type {$attachment_type} not " . "supported."); } } // Create empty thread and create post. $thread = threads_add($board['id'], null, null, 0, null); $post = posts_add($board['id'], $thread['id'], $_SESSION['user'], $password, $name, $tripcode, ip2long($_SERVER['REMOTE_ADDR']), $subject, date(Config::DATETIME_FORMAT), $text, null); // Закрепляем сообщение как оригинальное сообщение созданной пустой нити. threads_edit_original_post($thread['id'], $post['number']); // Save attachment. if ($attachment_type !== null) { switch ($attachment_type) { case Config::ATTACHMENT_TYPE_FILE:
function links_update($page) { // if (PKWK_READONLY) return; // Do nothing if (auth::check_role('readonly')) { return; } // Do nothing if (ini_get('safe_mode') == '0') { set_time_limit(0); } $time = is_page($page, TRUE) ? get_filetime($page) : 0; $rel_old = array(); $rel_file = CACHE_DIR . encode($page) . '.rel'; $rel_file_exist = file_exists($rel_file); if ($rel_file_exist === TRUE) { $lines = file($rel_file); unlink($rel_file); if (isset($lines[0])) { $rel_old = explode("\t", rtrim($lines[0])); } } $rel_new = array(); // 参照先 $rel_auto = array(); // オートリンクしている参照先 $links = links_get_objects($page, TRUE); foreach ($links as $_obj) { if (!isset($_obj->type) || $_obj->type != 'pagename' || $_obj->name == $page || $_obj->name == '') { continue; } if (is_a($_obj, 'Link_autolink')) { // 行儀が悪い $rel_auto[] = $_obj->name; } else { if (is_a($_obj, 'Link_autoalias')) { $_aliases = get_autoaliases($_obj->name); foreach ($_aliases as $_alias) { if (is_pagename($_alias)) { $rel_auto[] = $_alias; } } } else { $rel_new[] = $_obj->name; } } } $rel_new = array_unique($rel_new); // autolinkしか向いていないページ $rel_auto = array_diff(array_unique($rel_auto), $rel_new); // 全ての参照先ページ $rel_new = array_merge($rel_new, $rel_auto); // .rel:$pageが参照しているページの一覧 if ($time) { // ページが存在している if (!empty($rel_new)) { $fp = fopen($rel_file, 'w') or die_message('cannot write ' . htmlspecialchars($rel_file)); fputs($fp, join("\t", $rel_new)); fclose($fp); } } // .ref:$_pageを参照しているページの一覧 links_add($page, array_diff($rel_new, $rel_old), $rel_auto); links_delete($page, array_diff($rel_old, $rel_new)); global $WikiName, $autolink, $nowikiname, $search_non_list; // $pageが新規作成されたページで、AutoLinkの対象となり得る場合 if ($time && !$rel_file_exist && $autolink && (preg_match("/^{$WikiName}\$/", $page) ? $nowikiname : strlen($page) >= $autolink)) { // $pageを参照していそうなページを一斉更新する(おい) $search_non_list = 1; $pages = do_search($page, 'AND', TRUE, TRUE); foreach ($pages as $_page) { if ($_page != $page) { links_update($_page); } } } $ref_file = CACHE_DIR . encode($page) . '.ref'; // $pageが削除されたときに、 if (!$time && file_exists($ref_file)) { foreach (file($ref_file) as $line) { list($ref_page, $ref_auto) = explode("\t", rtrim($line)); // $pageをAutoLinkでしか参照していないページを一斉更新する(おいおい) if ($ref_auto) { links_delete($ref_page, array($page)); } } } }
$name = trim($_POST['name']); if (mb_strlen($name) > 64) { $error_msg_array[] = sprintf(gettext("Link name too long. Maximum is %s characters"), 64); $valid = false; } } else { $error_msg_array[] = gettext("You must specify a name!"); $valid = false; } if (isset($_POST['description']) && strlen(trim($_POST['description'])) > 0) { $description = trim($_POST['description']); } else { $description = ""; } if ($valid) { if (links_add($uri, $name, $description, $fid, $_SESSION['UID'])) { header_redirect("links.php?webtag={$webtag}&fid={$fid}&link_added={$name}"); exit; } else { $error_msg_array[] = gettext("Failed to add link"); $valid = false; } } } else { if (isset($_POST['add']) && $mode == LINKS_ADD_FOLDER) { $valid = true; if (isset($_POST['fid']) && is_numeric($_POST['fid'])) { $fid = $_POST['fid']; } else { $fid = 1; }
$name = trim($_POST['name']); if (mb_strlen($name) > 64) { $error_msg_array[] = sprintf(gettext("Link name too long. Maximum is %s characters"), 64); $valid = false; } } else { $error_msg_array[] = gettext("You must specify a name!"); $valid = false; } if (isset($_POST['description']) && strlen(trim($_POST['description'])) > 0) { $description = trim($_POST['description']); } else { $description = ""; } if ($valid) { if (links_add($uri, $name, $description, $fid, $uid)) { header_redirect("links.php?webtag={$webtag}&fid={$fid}&link_added={$name}"); exit; } else { $error_msg_array[] = gettext("Failed to add link"); $valid = false; } } } else { if (isset($_POST['add']) && $mode == LINKS_ADD_FOLDER) { $valid = true; if (isset($_POST['fid']) && is_numeric($_POST['fid'])) { $fid = $_POST['fid']; } else { $fid = 1; }