xMidNight-. Posted February 22, 2019 Share Posted February 22, 2019 (edited) 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 February 22, 2019 by xMidNight-. Link to comment Share on other sites More sharing options...
0 xMidNight-. Posted February 22, 2019 Author Share Posted February 22, 2019 thanks i got it by messing around in attachment.php file thx Link to comment Share on other sites More sharing options...
0 Administrator Tony Posted February 22, 2019 Administrator Share Posted February 22, 2019 This should work. {{if member.member_id AND member.inGroup('X')}} Change the X to the correct group number. Link to comment Share on other sites More sharing options...
0 xMidNight-. Posted February 22, 2019 Author Share Posted February 22, 2019 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 More sharing options...
0 Administrator Tony Posted February 22, 2019 Administrator Share Posted February 22, 2019 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. 1 Link to comment Share on other sites More sharing options...
0 xMidNight-. Posted February 22, 2019 Author Share Posted February 22, 2019 thx i will pay someone to do it for me Link to comment Share on other sites More sharing options...
0 Corona Posted February 22, 2019 Share Posted February 22, 2019 As Davlin sayd you must close the if tag like this: {{if \IPS\Member::loggedIn()->member_group_id === 4}} This content only shows to members in the "Administrators" group (ID 4 in our example) {{endif}} Link to comment Share on other sites More sharing options...
0 Jeffrey Posted February 23, 2019 Share Posted February 23, 2019 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 More sharing options...
Question
xMidNight-.
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
Edited by xMidNight-.Link to comment
Share on other sites
7 answers to this question
Recommended Posts