Dodawanie zdjęć do artykułów z poziomu użytkownika (php-fusi


(Unitromaniak) #1

Witam :smiley:

Posiadam stronę internetową w php-fusion. Chciałbym by użytkownicy mogli dodawać zdjęcia do artykułów, oczywiście zdjęcia mają być przechowywane na moim serwerze. Zależy mi by nie trzeba było doklejać kodu do zdjęcia, czyli po prostu wybieram zdjęcie, a po dodaniu artykułu zdjęcie samo się wyśrodkowuje i ustawia się nad treścią. Proszę o pomoc, gdyż męczę się z tym już trzy miesiące i nie mogę dojść jak to zrobić.


(Mathew) #2

Zabezpieczony upload obrazków i to by było chyba na tyle.


(Unitromaniak) #3

Byłbym wdzięczny jak byś mi dokładnie opisał co mam zrobić, gdyż dopiero zacząłem swoją przygodę z tworzeniem stron.

Z góry dzięki za pomoc.


(kostek135) #4

Wyjaśniając co @Mathew miał na myśli : "upload obrazków skrypt php" <- wpisz coś takiego w google.pl


(Unitromaniak) #5

Znalazłem wiele stron odnośnie uploadowania zdjęć, jednak nie rozumiem w jak dodane zdjęcie ma się znależć w określonym artukule. Gdyż znalezione prze ze mnie strony opisują w większości jak wrzucić zdjęcie na serwer. Jeśli ktoś jest w stanie przerobić kod by była możliwość dodawania zdjęć do artykułu, oraz by zdjęcie w dodanym artykule wyświetlało się nad jego treścią (wyśrodkowane) fajnie :smiley:

submit.php

<?php

/*-------------------------------------------------------+

| PHP-Fusion Content Management System

| Copyright (C) 2002 - 2008 Nick Jones

| http://www.php-fusion.co.uk/

+--------------------------------------------------------+

| Filename: submit.php

| Author: Nick Jones (Digitanium)

+--------------------------------------------------------+

| This program is released as free software under the

| Affero GPL license. You can redistribute it and/or

| modify it under the terms of this license which you

| can read by viewing the included agpl.txt or online

| at www.gnu.org/licenses/agpl.html. Removal of this

| copyright header is strictly prohibited without

| written permission from the original author(s).

+--------------------------------------------------------*/

require_once "maincore.php";

require_once THEMES."templates/header.php";

include LOCALE.LOCALESET."submit.php";


if (!iMEMBER) { redirect("index.php"); }


if (!isset($_GET['stype']) || !preg_check("/^[a-z]$/", $_GET['stype'])) { redirect("index.php"); }


$submit_info = array();


if ($_GET['stype'] == "l") {

    if (isset($_POST['submit_link'])) {

        if ($_POST['link_name'] != "" && $_POST['link_url'] != "" && $_POST['link_description'] != "") {

            $submit_info['link_category'] = stripinput($_POST['link_category']);

            $submit_info['link_name'] = stripinput($_POST['link_name']);

            $submit_info['link_url'] = stripinput($_POST['link_url']);

            $submit_info['link_description'] = stripinput($_POST['link_description']);

            $result = dbquery("INSERT INTO ".DB_SUBMISSIONS." (submit_type, submit_user, submit_datestamp, submit_criteria) VALUES ('l', '".$userdata['user_id']."', '".time()."', '".addslashes(serialize($submit_info))."')");

            add_to_title($locale['global_200'].$locale['400']);

            opentable($locale['400']);

            echo "

\n".$locale['410']." \n"; echo "".$locale['411']."\n"; echo "".$locale['412']."\n
\n"; closetable(); } } else { $opts = ""; add_to_title($locale['global_200'].$locale['400']); opentable($locale['400']); $result = dbquery("SELECT * FROM ".DB_WEBLINK_CATS." WHERE ".groupaccess("weblink_cat_access")." ORDER BY weblink_cat_name"); if (dbrows($result)) { while ($data = dbarray($result)) { $opts .= "".$data['weblink_cat_name']."\n"; } echo $locale['420']." \n"; echo "\n"; echo "

| ".$locale['421']." | \n$opts |
| ".$locale['422']." | |
| ".$locale['423']." | |
| ".$locale['424']." | |
| \n"; echo "\n |

\n\n"; } else { echo "
\n".$locale['551']." \n
\n"; } closetable(); } } elseif ($_GET['stype'] == "n") { if (isset($_POST['submit_news'])) { if ($_POST['news_subject'] != "" && $_POST['news_body'] != "") { $submit_info['news_subject'] = stripinput($_POST['news_subject']); $submit_info['news_cat'] = isnum($_POST['news_cat']) ? $_POST['news_cat'] : "0"; $submit_info['news_body'] = descript($_POST['news_body']); $submit_info['news_breaks'] = (isset($_POST['line_breaks']) ? "y" : "n"); $result = dbquery("INSERT INTO ".DB_SUBMISSIONS." (submit_type, submit_user, submit_datestamp, submit_criteria) VALUES('n', '".$userdata['user_id']."', '".time()."', '".addslashes(serialize($submit_info))."')"); add_to_title($locale['global_200'].$locale['450']); opentable($locale['450']); echo "
\n".$locale['460']." \n"; echo "".$locale['461']."\n"; echo "".$locale['412']."\n
\n"; closetable(); } } else { if (isset($_POST['preview_news'])) { $news_subject = stripinput($_POST['news_subject']); $news_cat = isnum($_POST['news_cat']) ? $_POST['news_cat'] : "0"; $news_body = phpentities(descript(stripslash($_POST['news_body']))); $breaks = (isset($_POST['line_breaks']) ? " checked='checked'" : ""); opentable($news_subject); echo (isset($_POST['line_breaks']) ? nl2br($news_body) : $news_body); closetable(); tablebreak(); } if (!isset($_POST['preview_news'])) { $news_subject = ""; $news_cat = "0"; $news_body = ""; $breaks = " checked='checked'"; } $cat_list = ""; $sel = ""; $result2 = dbquery("SELECT * FROM ".DB_NEWS_CATS." ORDER BY news_cat_name"); if (dbrows($result2)) { while ($data2 = dbarray($result2)) { if (isset($_POST['preview_news'])) { $sel = ($news_cat == $data2['news_cat_id'] ? " selected" : ""); } $cat_list .= "".$data2['news_cat_name']."\n"; } } add_to_title($locale['global_200'].$locale['450']); opentable($locale['450']); echo $locale['470']." \n"; echo "\n"; echo "

| ".$locale['471']." | |
| ".$locale['476']." | \n".$locale['477']."\n".$cat_list." |
| ".$locale['472']." | $news_body |
| \n"; echo "".$locale['473']." \n"; echo "\n"; echo "\n |

\n\n"; closetable(); } } elseif ($_GET['stype'] == "a") { if (isset($_POST['submit_article'])) { if ($_POST['article_subject'] != "" && $_POST['article_body'] != "") { $submit_info['article_cat'] = isnum($_POST['article_cat']) ? $_POST['article_cat'] : "0"; $submit_info['article_subject'] = stripinput($_POST['article_subject']); $submit_info['article_snippet'] = descript($_POST['article_snippet']); $submit_info['article_body'] = descript($_POST['article_body']); $submit_info['article_breaks'] = (isset($_POST['line_breaks']) ? "y" : "n"); $result = dbquery("INSERT INTO ".DB_SUBMISSIONS." (submit_type, submit_user, submit_datestamp, submit_criteria) VALUES ('a', '".$userdata['user_id']."', '".time()."', '".addslashes(serialize($submit_info))."')"); add_to_title($locale['global_200'].$locale['500']); opentable($locale['500']); echo "
\n".$locale['510']." \n"; echo "".$locale['511']."\n"; echo "".$locale['412']."\n
\n"; closetable(); } } else { if (isset($_POST['preview_article'])) { $article_cat = isnum($_POST['article_cat']) ? $_POST['article_cat'] : "0"; $article_subject = stripinput($_POST['article_subject']); $article_snippet = phpentities(descript(stripslash($_POST['article_snippet']))); $article_body = phpentities(descript(stripslash($_POST['article_body']))); $breaks = (isset($_POST['line_breaks']) ? " checked='checked'" : ""); opentable($article_subject); echo (isset($_POST['line_breaks']) ? nl2br($article_body) : $article_body); closetable(); tablebreak(); } if (!isset($_POST['preview_article'])) { $article_cat = "0"; $article_subject = ""; $article_snippet = ""; $article_body = ""; $breaks = " checked='checked'"; } $cat_list = ""; $sel = ""; add_to_title($locale['global_200'].$locale['500']); opentable($locale['500']); $result = dbquery("SELECT * FROM ".DB_ARTICLE_CATS." WHERE ".groupaccess("article_cat_access")." ORDER BY article_cat_name"); if (dbrows($result)) { while ($data = dbarray($result)) { if (isset($_POST['preview_article'])) { $sel = $article_cat == $data['article_cat_id'] ? " selected" : ""; } $cat_list .= "".$data['article_cat_name']."\n"; } echo $locale['520']." \n"; echo "\n"; echo "

| ".$locale['521']." | \n$cat_list |
| ".$locale['522']." | |
| ".$locale['523']." | $article_snippet |
| ".$locale['524']." | $article_body |
| \n"; echo "".$locale['525']." \n"; echo "\n"; echo "\n |

\n\n"; } else { echo "
\n".$locale['551']." \n
\n"; } closetable(); } } elseif ($_GET['stype'] == "p") { if (isset($_POST['submit_photo'])) { require_once INCLUDES."photo_functions_include.php"; $error = ""; $submit_info['photo_title'] = stripinput($_POST['photo_title']); $submit_info['photo_description'] = stripinput($_POST['photo_description']); $submit_info['album_id'] = isnum($_POST['album_id']) ? $_POST['album_id'] : "0"; if (is_uploaded_file($_FILES['photo\_pic\_file']['tmp\_name'])) { $photo_types = array(".gif",".jpg",".jpeg",".png"); $photo_pic = $_FILES['photo_pic_file']; $photo_name = strtolower(substr($photo_pic['name'], 0, strrpos($photo_pic['name'], "."))); $photo_ext = strtolower(strrchr($photo_pic['name'],".")); $photo_dest = PHOTOS."submissions/"; if (!preg_match("/^[-0-9A-Z_[]]+$/i", $photo_name)) { $error = 1; } elseif ($photo_pic['size'] > $settings['photo_max_b']){ $error = 2; } elseif (!in_array($photo_ext, $photo_types)) { $error = 3; } else { $photo_file = image_exists($photo_dest, $photo_name.$photo_ext); move_uploaded_file($photo_pic['tmp_name'], $photo_dest.$photo_file); chmod($photo_dest.$photo_file, 0644); $imagefile = @getimagesize($photo_dest.$photo_file); if (!verify_image($photo_dest.$photo_file)) { $error = 3; unlink($photo_dest.$photo_file); } elseif ($imagefile[0] > $settings['photo_max_w'] || $imagefile[1] > $settings['photo_max_h']) { $error = 4; unlink($photo_dest.$photo_file); } else { $submit_info['photo_file'] = $photo_file; } } } add_to_title($locale['global_200'].$locale['570']); opentable($locale['570']); if (!$error) { $result = dbquery("INSERT INTO ".DB_SUBMISSIONS." (submit_type, submit_user, submit_datestamp, submit_criteria) VALUES ('p', '".$userdata['user_id']."', '".time()."', '".addslashes(serialize($submit_info))."')"); echo "
\n".$locale['580']." \n"; echo "".$locale['581']."\n"; echo "".$locale['412']."\n
\n"; } else { echo "
\n".$locale['600']." \n"; if ($error == 1) { echo $locale['601']; } elseif ($error == 2) { echo sprintf($locale['602'], $settings['photo_max_b']); } elseif ($error == 3) { echo $locale['603']; } elseif ($error == 4) { echo sprintf($locale['604'], $settings['photo_max_w'], $settings['photo_max_h']); } echo " \n".$locale['581']."\n
\n"; } closetable(); } else { $opts = ""; add_to_title($locale['global_200'].$locale['570']); opentable($locale['570']); $result = dbquery("SELECT * FROM ".DB_PHOTO_ALBUMS." WHERE ".groupaccess("album_access")." ORDER BY album_title"); if (dbrows($result)) { while ($data = dbarray($result)) $opts .= "".$data['album_title']."\n"; echo $locale['620']." \n"; echo "\n"; echo "

| ".$locale['621']." | |
| ".$locale['622']." | |
| ".$locale['623']." | \n"; echo "".sprintf($locale['624'], parsebytesize($settings['photo_max_b']), $settings['photo_max_w'], $settings['photo_max_h'])." |
| ".$locale['625']." | \n$opts |
| ".$locale['523']." | $article_snippet |
| \n"; echo "\n |

\n\n"; } else { echo "
\n".$locale['551']." \n
\n"; } closetable(); } } else { redirect("index.php"); } echo "\n"; require_once THEMES."templates/footer.php"; ?>[/code] articles.php
[code]<?php /*-------------------------------------------------------+ | PHP-Fusion Content Management System | Copyright (C) 2002 - 2010 Nick Jones | http://www.php-fusion.co.uk/ +--------------------------------------------------------+ | Filename: articles.php | Author: Nick Jones (Digitanium) +--------------------------------------------------------+ | This program is released as free software under the | Affero GPL license. You can redistribute it and/or | modify it under the terms of this license which you | can read by viewing the included agpl.txt or online | at www.gnu.org/licenses/agpl.html. Removal of this | copyright header is strictly prohibited without | written permission from the original author(s). +--------------------------------------------------------*/ require_once "maincore.php"; require_once THEMES."templates/header.php"; include LOCALE.LOCALESET."articles.php"; add_to_title($locale['global_200'].$locale['400']); if (isset($_GET['article_id']) && isnum($_GET['article_id'])) { $result = dbquery( "SELECT ta.article_subject, ta.article_article, ta.article_breaks, ta.article_datestamp, ta.article_reads, ta.article_allow_comments, ta.article_allow_ratings, tac.article_cat_id, tac.article_cat_name, tu.user_id, tu.user_name, tu.user_status FROM ".DB_ARTICLES." ta INNER JOIN ".DB_ARTICLE_CATS." tac ON ta.article_cat=tac.article_cat_id LEFT JOIN ".DB_USERS." tu ON ta.article_name=tu.user_id WHERE ".groupaccess('article_cat_access')." AND article_id='".$_GET['article_id']."' AND article_draft='0'" ); if (dbrows($result)) { require_once INCLUDES."comments_include.php"; require_once INCLUDES."ratings_include.php"; $data = dbarray($result); if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; } if ($_GET['rowstart'] == 0) { $result = dbquery("UPDATE ".DB_ARTICLES." SET article_reads=article_reads+1 WHERE article_id='".$_GET['article_id']."'"); } $article = stripslashes($data['article_article']); if (preg_match('<--PAGEBREAK-->', $article)) { $article = explode("<--PAGEBREAK-->", $article); } else { $article = explode("", $article); } $pagecount = count($article); $article_subject = stripslashes($data['article_subject']); $article_info = array( "article_id" => $_GET['article_id'], "cat_id" => $data['article_cat_id'], "cat_name" => $data['article_cat_name'], "user_id" => $data['user_id'], "user_name" => $data['user_name'], "user_status" => $data['user_status'], "article_date" => $data['article_datestamp'], "article_breaks" => $data['article_breaks'], "article_comments" => dbcount("(comment_id)", DB_COMMENTS, "comment_type='A' AND comment_item_id='".$_GET['article_id']."'"), "article_reads" => $data['article_reads'], "article_allow_comments" => $data['article_allow_comments'] ); add_to_title($locale['global_201'].$article_subject); echo ""; render_article($article_subject, $article[$_GET['rowstart']], $article_info); echo ""; if ($pagecount > 1) { echo "
\n".makepagenav($_GET['rowstart'], 1, $pagecount, 3, FUSION_SELF."?article_id=".$_GET['article_id']."&")."\n
\n"; } if ($data['article_allow_comments']) { showcomments("A", DB_ARTICLES, "article_id", $_GET['article_id'], FUSION_SELF."?article_id=".$_GET['article_id']); } if ($data['article_allow_ratings']) { showratings("A", $_GET['article_id'], FUSION_SELF."?article_id=".$_GET['article_id']); } } else { redirect(FUSION_SELF); } } elseif (!isset($_GET['cat_id']) || !isnum($_GET['cat_id'])) { opentable($locale['400']); echo "\n"; $result = dbquery("SELECT article_cat_id, article_cat_name, article_cat_description FROM ".DB_ARTICLE_CATS." WHERE ".groupaccess('article_cat_access')." ORDER BY article_cat_name"); $rows = dbrows($result); if ($rows) { $counter = 0; $columns = 2; echo "

| ".$data['article_cat_name']." ($num)"; if ($data['article_cat_description'] != "") { echo " \n".$data['article_cat_description'].""; } echo " |

\n"; } else { echo "
\n".$locale['401']." \n
\n"; } closetable(); } else { $res = 0; $result = dbquery("SELECT article_cat_name, article_cat_sorting, article_cat_access FROM ".DB_ARTICLE_CATS." WHERE article_cat_id='".$_GET['cat_id']."'"); if (dbrows($result) != 0) { $cdata = dbarray($result); if (checkgroup($cdata['article_cat_access'])) { $res = 1; add_to_title($locale['global_201'].$cdata['article_cat_name']); opentable($locale['400'].": ".$cdata['article_cat_name']); echo ""; $rows = dbcount("(article_id)", DB_ARTICLES, "article_cat='".$_GET['cat_id']."' AND article_draft='0'"); if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; } if ($rows != 0) { $result = dbquery( "SELECT article_id, article_subject, article_snippet, article_datestamp FROM ".DB_ARTICLES." WHERE article_cat='".$_GET['cat_id']."' AND article_draft='0' ORDER BY ".$cdata['article_cat_sorting']." LIMIT ".$_GET['rowstart'].",".$settings['articles_per_page'] ); $numrows = dbrows($result); $i = 1; while ($data = dbarray($result)) { if ($data['article_datestamp'] + 604800 > time() + ($settings['timeoffset'] * 3600)) { $new = " [".$locale['402']."]"; } else { $new = ""; } echo "".$data['article_subject']."$new \n".stripslashes($data['article_snippet']); echo ($i != $numrows ? " \n" : "\n"); $i++; } echo ""; closetable(); if ($rows > $settings['articles_per_page']) echo "
\n".makepagenav($_GET['rowstart'], $settings['articles_per_page'], $rows, 3, FUSION_SELF."?cat_id=".$_GET['cat_id']."&")."\n
\n"; } else { echo "
".$locale['403']."
\n"; echo ""; closetable(); } } } if ($res == 0) { redirect(FUSION_SELF); } } require_once THEMES."templates/footer.php"; ?>


(Darom82) #6

Ja tez mam problem z artykulami Klik czy moze mi ktos pomoc ?


(Unitromaniak) #7

Witam

Czy nikt nie pomoze? Jestem w stanie nawet zaplacic za wykonanie tego skryptu, jednak dodawanie zdjec musi wygladac identycznie jak wyzej opisalem.