Пример #1
0
     // Cleanup
     DataExchange::releaseResources();
     display_error_page($smarty, new NonUnicodeError());
     exit(1);
 }
 posts_prepare_text($text, $board);
 if (posts_check_text_size($text) === FALSE) {
     // Cleanup
     DataExchange::releaseResources();
     display_error_page($smarty, kotoba_last_error());
     exit(1);
 }
 // Attachment.
 if ($attachment_type !== NULL) {
     if ($attachment_type == Config::ATTACHMENT_TYPE_FILE || $attachment_type == Config::ATTACHMENT_TYPE_IMAGE) {
         $file_hash = calculate_file_hash($uploaded_file_path);
         $file_exists = false;
         $same_attachments = null;
         switch ($board['same_upload']) {
             case 'once':
                 $same_attachments = attachments_get_same($board['id'], $_SESSION['user'], $file_hash);
                 if (count($same_attachments) > 0) {
                     $file_exists = true;
                 }
                 break;
             case 'no':
                 $same_attachments = attachments_get_same($board['id'], $_SESSION['user'], $file_hash);
                 if (count($same_attachments) > 0) {
                     $smarty->assign('show_control', is_admin() || is_mod());
                     $smarty->assign('boards', boards_get_visible($_SESSION['user']));
                     $smarty->assign('board', $board);
                     $delete_count++;
                 } elseif (!isset($_POST['submit'])) {
                     // For show list of dangling attachments.
                     $a['flag'] = true;
                     $a['link'] = Config::DIR_PATH . "/{$b['name']}/other/{$a['name']}";
                     $a['thumbnail'] = Config::DIR_PATH . "/img/{$a['thumbnail']}";
                 }
             }
         }
     }
     break;
 case Config::ATTACHMENT_TYPE_IMAGE:
     foreach ($boards as $b) {
         $full_path = Config::ABS_PATH . "/{$b['name']}/img/{$a['name']}";
         if (file_exists($full_path)) {
             if ($a['hash'] === null || $a['hash'] == calculate_file_hash($full_path)) {
                 if (isset($_POST['submit']) && (isset($_POST["delete_image_{$a['id']}"]) || isset($_POST['delete_all']))) {
                     // Actually delete.
                     // TODO Uncomment
                     //unlink($full_path);
                     //images_delete($a['id']);
                     $delete_count++;
                 } elseif (!isset($_POST['submit'])) {
                     // For show list of dangling attachments.
                     $a['flag'] = true;
                     $a['link'] = Config::DIR_PATH . "/{$b['name']}/img/{$a['name']}";
                     $a['thumbnail'] = Config::DIR_PATH . "/{$b['name']}/thumb/{$a['thumbnail']}";
                 }
             }
         }
     }