Jump to content
WebFlake
  • 0

Checking if user is logged in + part of usergroup


xMidNight-.

Question

Hey is it possible to make his php code work only for logged in users and some groups?

 

hopefully there's some guide or someone to teach me how

 

<?php



	

$finalfilepath = ('/home/no/hey/oierbnghoe.exe');



function random_name($len)

{

	$output = "";

	$random = "fdhdertht";

	for( $i = 0; $i < $len; $i++ )

	{

		@$output .= $random[rand(0,  strlen($random))];

	}

	return $output;

}



//PROVIDE THE DOWNLOAD

header('Content-Description: File Transfer');

header('Content-Type: application/exe');

header('Content-Disposition: inline; filename="' . random_name(rand(1, 4)) . '.exe"');

header('Expires: 0');

header('Cache-Control: must-revalidate');

header('Pragma: public');

header('Content-Length: ' . filesize($finalfilepath));

header('Accept-Ranges: bytes');

fpassthru(fopen($finalfilepath,"rb"));

 

Edited by xMidNight-.
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0
2 hours ago, Davlin said:

This should work.


{{if member.member_id AND member.inGroup('X')}}

Change the X to the correct group number.

Tried like that's

 

<?php

{{if member.member_id AND member.inGroup('4')}}

$finalfilepath = ('/home/hey/noino/3456342.exe');



function random_name($len)

{

	$output = "";

	$random = "sdgrtehrth";

	for( $i = 0; $i < $len; $i++ )

	{

		@$output .= $random[rand(0,  strlen($random))];

	}

	return $output;

}



//PROVIDE THE DOWNLOAD

header('Content-Description: File Transfer');

header('Content-Type: application/exe');

header('Content-Disposition: inline; filename="' . random_name(rand(1, 4)) . '.exe"');

header('Expires: 0');

header('Cache-Control: must-revalidate');

header('Pragma: public');

header('Content-Length: ' . filesize($finalfilepath));

header('Accept-Ranges: bytes');

fpassthru(fopen($finalfilepath,"rb"));


?>

Doesn't seem to work it returns a HTTP ERROR 500

 

but it works fine without the code u gave to me so what could be the issue 

Link to comment
Share on other sites

  • 0
  • Administrator

That snippet of code I gave you was just to show you how to check whether a user is logged and to reference their user group ID. You can't just toss code into other code and hope it works.

You didn't close out the if statement nor are you telling the parser what to do if the expression returns false for either check. I can see that your code is some sort of file name randomizer but the code you're trying to use won't work with that random_name function because it doesn't fit the context.

I expected you'd have some idea of basic PHP but it appears you don't so without more details, I can't really help you.

  • Like 1
Link to comment
Share on other sites

  • 0
The question(s) in this support topic have been answered and the topic author has resolved their issue. This topic is now closed. If you have other questions, please open a new topic.
  • Support Team - September 9th, 2017 - June 8, 2018
  • Junior Moderator - December 14th 2018 - November 16th, 2019
  • Designer - November 16th, 2019 - June 5th, 2020
  • Moderator - June 5th, 2020 - August 28th, 2020
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...