Jump to content

Recommended Posts

I'm posting php to a file, and for some reason right before [Delete Bulletin] it seems to think that I ended the echo I was doing.. when I didn't... whats wrong? I tried multiple different arrangements and uses of the quotes... =/

 

$content = '<? if ($_SESSION["lvl"] == "1")'. " { echo '<a".' href="?login=deletebulletin&bulletin=$date">'."[Delete Bulletin]</a>'; } ?>";

Link to comment
https://forums.phpfreaks.com/topic/85313-stops-echo-when-it-shouldnt/
Share on other sites

yes but take a look carefully

 

$content =

  is a variable  so i supposed you are inside php block and your php tags in that code will be treated as string please let me know if i was wrong

 

is this i typo error or this is really valid?

Yes, it's going to be in a file.

 

The thing is, it always seems to get cut off, and it displays

[Delete Bulletin]"; } ?>________________

It did that with the code that you provided.. Is there any reason you can think of that it's doing this?

use html entities.. your string is treated as html tags because of unwanted use of <

$content = '<?php if ($_SESSION["lvl"] == "1") { echo "<a href=\"?login=deletebulletin&bulletin=$date\">[Delete Bulletin]</a>"; } ?>';
echo htmlentities($content);

use html entities.. your string is treated as html tags because of unwanted use of <

$content = '<?php if ($_SESSION["lvl"] == "1") { echo "<a href=\"?login=deletebulletin&bulletin=$date\">[Delete Bulletin]</a>"; } ?>';
echo htmlentities($content);

 

No you see I want it to display the link but somehow it gets broken and just displays what I wrote before as text.

What it did was display the actual php as text.

 

I want it to actually act as php, so if ($_SESSION['lvl'] == '1') it will display that link. it was working before, and i didn't change anything.

well its being encrypted but i don't see how that would mess it up.

Oh sorry, I didn't have session_start();

I made the encryption a little less, and it still does it, so Ill try to show more code for you guys..

 

It was working, but when I put it so it will post to the file, it does what my problem at first was. This is the code for when it posts ($content is the content submitted from the form).

$newcontent = str_replace('<?', '', str_replace('?>', '', $content));
$delete = ($_SESSION["lvl"] == "1")?"<a href=\"?login=deletebulletin&bulletin=$date\">[Delete Bulletin]</a>":'';
$filename = 'bulletin.txt';
putenv("TZ=America/Denver");
$date = date("D dS M, Y h:i:s a");
$final_en = base64_encode('<b><i>'.$date.'</i></b><br />'.$newcontent.' '
	.'<i>-'.$_SESSION['user'].'</i><br />'
	."<?php echo $delete; ?>");
$somecontent = ' | '.$final_en;
chmod ($filename, 0777);
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
	 echo "Cannot open file.";
		 exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
	echo "Cannot write to file.";
		exit;
}

fclose($handle);
echo '<h1>Bulletin Posted </h1><center><a href="index.php">Your bulletin has been posted.</a></center><br /><br />'
.'<META HTTP-EQUIV=Refresh CONTENT="1; URL=index.php">';
include ('links.php');
} else {
echo "The file is not writable";
}

 

And then this is when I display the file...

$file = 'bulletin.txt';
echo '<b>Welcome, you are currently logged in as: </b>'.$_SESSION['user'].'.<br />'
.'<b>User level: </b>'.$_SESSION['lvl'].'.<br /><br />';
if (filesize($file) !== 0) {
echo '<h1>Bulletins</h1>';
$filename = 'bulletin.txt';
$handle = fopen($filename, 'r');
$read = fread($handle, filesize($filename));
$array = explode(' | ', $read);
$i = 0;
while ($array[$i] !== NULL) {
	echo base64_decode($array[$i]);
	$i++;
}
if ($_SESSION['lvl'] == '1') {
	echo '________________<br />'
		.'<a href="?login=deletebulletins">Delete All Bulletins</a><br /><br />';
}
}

 

I think that I could probably just put that part into when I display the files, but it was working before, and it seemed easier. Should I do that, or is there a way to make it actually work..?

 

It's a method of posting a bulletin, the bulletins go encrypted into a file and then are read on the site unencrypted. The bulletins can be posted and deleted by the Administrators.

 

It was working before, and I have no idea why its not anymore.

Well, if I write that exact string to a file. eg;

 

<?php

  $date = date("D dS M, Y h:i:s a");
  $content = '<?php if ($_SESSION["lvl"] == "1") {echo "<a href=\"?login=deletebulletin&bulletin=' . $date . '\">[Delete Bulletin]</a>"; ?>';
  file_put_contents('file.php',$content);

?>

 

It writes perfectly fine.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.