Co usunąć z kodu żeby buton nie wyświetlał się niezalogowany


(Thor1982) #1

Co muszę usunąć z tego kodu żeby link "Edytuj" ( ['MPL207'] ) nie wyświetlał się niezalogowanym?? Ale żeby pozostał widoczny dla zalogowanych

<?php

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

| PHP-Fusion Content Management System

| Copyright © 2002 - 2008 Nick Jones

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

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

| Filename: marketplace.php

| CVS Version: 1.00

| Author: Peter Bruggink

| Email: p.bruggink@zonnet.nl

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

| v7 By Diemux

| www.phpfusion-mods.net

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

| 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).

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

// If register_globals is turned off, extract super globals (php 4.2.0+)

if (ini_get('register_globals') != 1) {

	if ((isset($_POST) == true) && (is_array($_POST) == true)) extract($_POST, EXTR_OVERWRITE);

	if ((isset($_GET) == true) && (is_array($_GET) == true)) extract($_GET, EXTR_OVERWRITE);

}


require_once "../../maincore.php";

require_once THEMES."templates/header.php";

include_once INCLUDES."bbcode_include.php";

include INFUSIONS."marketplace_panel/infusion_db.php";


if (file_exists(INFUSIONS."marketplace_panel/locale/".$settings['locale'].".php")) {

	include INFUSIONS."marketplace_panel/locale/".$settings['locale'].".php";

} else {

	include INFUSIONS."marketplace_panel/locale/English.php";

}

error_reporting(E_ALL ^ E_NOTICE);

function mailok($email) {

	if ($email == "" || !preg_match("/^[-0-9A-Z_\.]{1,50}@([-0-9A-Z_\.]+\.){1,50}([0-9A-Z]){2,4}$/i", $email)) {

		return false;

	}

	return true;

}


if (isset($mplace_id) && !isNum($mplace_id)) redirect(FUSION_SELF);

if (!isset($action)) $action = "";


if ($action == "delete") {

	if (iADMIN) {

		$result = dbquery("DELETE FROM ".DB_MARKETPLACE." WHERE mplace_id='$mplace_id'");

		$result = dbquery("DELETE FROM ".DB_MARKETPLACE_BIDDING." WHERE mplace_id='$mplace_id'");

		redirect(FUSION_SELF);

	}

}


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

	$mplace_article = stripinput($_POST['mplace_article']);

	$mplace_price = stripinput($_POST['mplace_price']);

	$place_message = $_POST['mplace_message'];

	if ($action == "edit") {

		$result = dbquery("UPDATE ".DB_MARKETPLACE." SET mplace_article='$mplace_article', mplace_price='$mplace_price', mplace_message='$mplace_message' WHERE mplace_id='$mplace_id'");

	} else {

		$mplace_owner = $userdata['user_id'];

		$mplace_datestamp = time();

		$result = dbquery("INSERT INTO ".DB_MARKETPLACE." (mplace_owner, mplace_article, mplace_message, mplace_price, mplace_datestamp) VALUES('$mplace_owner', '$mplace_article', '$mplace_message', '$mplace_price', '$mplace_datestamp')");

	}

	redirect(FUSION_SELF);

}


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

	$mplace_id = stripinput($_POST['mplace_id']);

	$bidding_price = stripinput($_POST['bidding_price']);

	$bidding_owner = $userdata['user_id'];

	$bidding_date = time();

	$result = dbquery("SELECT * FROM ".DB_MARKETPLACE_BIDDING." WHERE bidding_owner='".$bidding_owner."' AND mplace_id='".$mplace_id."'");

	$rows = dbrows($result);

	if ($rows == 0) {

		$result = dbquery("INSERT INTO ".DB_MARKETPLACE_BIDDING." (mplace_id, bidding_owner, bidding_price, bidding_date) VALUES('$mplace_id', '$bidding_owner', '$bidding_price', '$bidding_date')");

	} else {

		$result = dbquery("UPDATE ".DB_MARKETPLACE_BIDDING." SET bidding_price='$bidding_price', bidding_date='$bidding_date' WHERE bidding_owner='".$bidding_owner."' AND mplace_id='".$mplace_id."'");

	}

	redirect(FUSION_SELF);

}


if ($action == "close") {

	$result = dbquery("SELECT * FROM ".DB_MARKETPLACE." WHERE mplace_id='$mplace_id'");

	$data = dbarray($result);

	if ($userdata['user_id'] == $data['mplace_owner']) {

		$mailfrom = $userdata['user_email'];

		$u_result = dbarray(dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='".$mplace_sold."'"));

		if (mailok($u_result['user_email'])) {

        	$mailto = $u_result['user_email'];

			$mailtype = "plain";

			$mailsubject = "[".$data['mplace_article']."]";

			$mailmessage = $locale['MPL700'].$data['mplace_article'].$locale['MPL701'].$bidding_price.$locale['MPL203']."\n";

			$mailmessage .= $locale['MPL702']."\n\n";

    		require_once INCLUDES."sendmail_include.php";

    		sendemail($u_result['user_name'],$mailto,$userdata['user_name'],$mailfrom,$mailsubject,$mailmessage,$mailtype);		

			$result = dbquery("UPDATE ".DB_MARKETPLACE." SET mplace_sold='$mplace_sold' WHERE mplace_id='$mplace_id'");

		}

	}	

	redirect(FUSION_SELF);

}


//new	

	if ($action == "decline") {

	$result = dbquery("SELECT * FROM ".DB_MARKETPLACE." WHERE mplace_id='$mplace_id'");

	$data = dbarray($result);

	if ($userdata['user_id'] == $data['mplace_owner']) {

		$mailfrom = $userdata['user_email'];

		$u_result = dbarray(dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='".$mplace_sold."'"));

		if (mailok($u_result['user_email'])) {

        	$mailto = $u_result['user_email'];

			$mailtype = "plain";

			$mailsubject = "[".$data['mplace_article']."]";

			$mailmessage = $locale['MPL700'].$data['mplace_article'].$locale['MPL704'].$bidding_price.$locale['MPL203']."\n";

			$mailmessage .= $locale['MPL702']."\n\n";

    		require_once INCLUDES."sendmail_include.php";

    		sendemail($u_result['user_name'],$mailto,$userdata['user_name'],$mailfrom,$mailsubject,$mailmessage,$mailtype);		

			$result = dbquery("DELETE FROM ".DB_MARKETPLACE_BIDDING." WHERE mplace_id='$mplace_id'");

		}

	}	

	redirect(FUSION_SELF);

}	



if ($action == "edit") {

	$result = dbquery("SELECT * FROM ".DB_MARKETPLACE." WHERE mplace_id='$mplace_id'");

	$data = dbarray($result);

	if (dbrows($result) && (iADMIN || $userdata['user_id'] == $data['mplace_owner'])) {

		$mplace_article = $data['mplace_article'];

		$mplace_price = $data['mplace_price'];

		$mplace_message = $data['mplace_message'];

		$formaction = FUSION_SELF."?action=edit&mplace_id=$mplace_id";

	} else {

		$action = "";

		$formaction = FUSION_SELF;

	}

} else {

	$mplace_article = "";

	$mplace_price = "";

	$mplace_message = $locale['MPL303'];

	$formaction = FUSION_SELF;

}


if ($action == "new" || $action == "edit") {

	opentable($locale['MPL300']);

	echo "

\n"; closetable(); //tablebreak(); } if ($action == "make") { $result = dbarray(dbquery("SELECT * FROM ".DB_MARKETPLACE." WHERE mplace_id='$mplace_id'")); $mplace_article = $result['mplace_article']; $formaction = FUSION_SELF; opentable($locale['MPL600']." [".$mplace_article."]"); echo "\n"; closetable(); //tablebreak(); } opentable($locale['MPL200']); $result = dbquery("SELECT * FROM ".DB_MARKETPLACE.""); $rows = dbrows($result); if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; if ($rows != 0) { echo "[Dodaj ogłoszenie]\n";

tablebreak();

$i = 1;

$result = dbquery("SELECT * FROM ".DB_MARKETPLACE." ORDER BY mplace_datestamp DESC LIMIT $rowstart,10");

$numrows = dbrows($result);

while ($data = dbarray($result)) {

$u_result = dbarray(dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='".$data['mplace_owner']."'"));

echo "

".nl2br(parseubb(parsesmileys($data['mplace_message'])))."
\n";

$b_result = dbquery("SELECT * FROM ".DB_MARKETPLACE_BIDDING." WHERE mplace_id='".$data['mplace_id']."'");

$b_rows = dbrows($b_result);

if ($b_rows != 0) {

		echo "<table cellpadding="0" cellspacing="0" width="100%"><tr>




".$locale['MPL503']."
".$locale['MPL505']."



".$locale['MPL500']."\n";

}

echo "

\n";

if ($i != $numrows) echo "
\n";

$i++;

}

} else {

echo "
\n".$locale['MPL209']."

\n[".$locale['MPL201']." ]

\n\n";

}

closetable();

if ($rows != 0) echo "

\n".makePageNav($rowstart,10,$rows,3,FUSION_SELF."?")."\n
\n";

require_once THEMES."templates/footer.php";

?[/code]




(Ooi) #2
if (iADMIN) {

         echo "".$locale['MPL207']." | ";[/code]

Zamiast iADMIN trzeba wpisać iUSER


(Thor1982) #3

Przepraszam, trochę źle się wyraziłem.

Adminowi ma się wyświetlać button "edytuj" i "usuń" i to się wyświetla poprawnie.

Osobie zalogowanej która napisała ogłoszenie ma się wyświetlać tylko "edytuj" i to też się poprawnie wyświetla.

Niestety niezalogowanym wyświetla się też "edytuj" i chciał bym żeby to znikło.

Jedyne dwa miejsca gdzie jest odwołanie do localu 207 jest to dla admina i to

if ($userdata['user_id'] == $u_result['user_id']) {

            echo "".$locale['MPL207']." | ";[/code]

Wydaje mi się że jest poprawnie zapisane ale jednak coś jest nie tak bo wyświetla się wszystkim.


(Ooi) #4

spróbuj

if ($userdata['user_id'] === $u_result['user_id']) {

(Thor1982) #5

Nic się nie zmieniło.


(Ooi) #6
if ($userdata['user_id'] == $u_result['user_id'] && !(iGUEST) {

(Thor1982) #7
Parse error: syntax error, unexpected '{' in /virtual/w/i/wiener-info.ugu.pl/infusions/marketplace_panel/marketplace.php on line 264

(Ooi) #8

zjadłem ) na końcu, przed {


(Thor1982) #9

Teraz działa :slight_smile: Dzięki wielkie :slight_smile:

To jak już jesteśmy przy tym temacie to może ktoś mi powie co zrobić żebym na górze mógł wstawić jakiś tekst (pomiędzy buttonem "Dadaj ogłoszenie" a"Ogłoszenia")

Ps da się tu gdzieś dać "pomógł" czy coś takiego??


(Ooi) #10

Możesz dopisać bezpośrednio w skrypcie albo dodać do langa np.

'ID_TXT_1' = "tekst, który chcesz dodać"; (nie wiem jak dokładnie w fusionie są definiowane zmienne językowe, ale na wzór tam zdefiniowanych dodajesz swój) i dodać w skrypcie odwołanie do niego, tj. $locale['ID_TXT_1'] pomiędzy odwołaniami do wymienionych przez ciebie buttonów.


(Thor1982) #11

Jeszcze raz dzięki wielkie :slight_smile: