Jump to content

Boxerman

Members
  • Posts

    275
  • Joined

  • Last visited

Everything posted by Boxerman

  1. Fixed the issue: Adding [[ \"$-\" != *i* ]] && echo '\n' before the Powershell command fixed this issue. Thanks for all the help and i hope my fix helps someone one day!
  2. Anyone got advise?
  3. Any advise on what one would do to work around this issue? OR is there another way?
  4. New code: $stream = ssh2_exec($connection, $runCMD); stream_set_blocking($stream, true); echo stream_get_contents($stream); Still just stays at refreshing its so confusing, im sorry all...
  5. How would one work out if stream is the correct one?
  6. But with the new code provided with the feof in, it does exactly the same?
  7. When i revert back to my old code i get an output if the user exists (full stack trace of what i need), if i create a new user, it only shows part of the stack trace (i presume related to the value of 1 needing to be increased?) but if its set above on, it just gets stuck on refreshing and never returns anything, yet the script does exactly what its suppose to (powershell wise). Hopefully this makes sense.
  8. Thanks! however, the page is not outputting (its still refreshing) but when i check AD i see the new user account has been created!? This is confusing me, so much, im sorry!
  9. Thanks for the reply, im looking at your suggestion, but im getting the following: Warning: fread() expects parameter 1 to be resource, null given in /srv/www/htdocs/newuserphp/test.php on line 31 Notice: Undefined variable: buffer in /srv/www/htdocs/newuserphp/test.php on line 31 any advise?
  10. Hi guys, Tricky one to explain here so first sorry if i do not provide everything. The below script is set to create a new user by passing PHP variables into a powershell script. The powershell has been tested manually and works perfectly: //cmd to run $runCMD = "powershell -Command './MasterScript.ps1 -ucr -udn \"$user\" -pas \"$pass\" -loc \"$loc\"'"; // exec a command and return a stream $stream = ssh2_exec($connection, $runCMD); // force PHP to wait for the output stream_set_blocking($stream, true); // read the output into a variable $data = ''; while($buffer = fread($stream, 4096)) { $data .= $buffer; } // close the stream fclose($stream); // print the response echo $data; As you can see the fread leagth is set to 4096, the webpage just sits at refreshing but never compeletes, however the the user gets created, but the page does not return the echo'ed $data (it doesn't display anything it is just sitting at refreshing the page). If i set this to 1, it works as expected, however does not show the full stack trace (completed output which contains the username generated which is what i need to get. I have tried setting this to 2 but it just keeps waiting for the script to finish, but i can confirm i see the users. So this doesnt appear to be a powershell issue, more of a php code issue. Can anyone see a mistake in the above? Let me know if you require any more information.
  11. I'm completely stupid... why didn't i.... thank you +1
  12. Hey guys, Hopefully a quick one for you... I'm trying to check if two arrays match then output text. what i have is: if (in_array($usernamelower, $superusers AND $adminusers, true)) { full code: //Let's see who has what access $adminsql = "SELECT * FROM permissions WHERE level = 'Admin' "; $superusersql = "SELECT * FROM permissions WHERE level = 'Super User' "; $adminresult = mysql_query($adminsql) or die('Query failed: ' . mysql_error()); $superuserresult = mysql_query($superusersql) or die('Query failed: ' . mysql_error()); //Let's build the adminuser array while($adminrow = mysql_fetch_assoc($adminresult)){ $adminusers[] =$adminrow['username']; } //Let's build the superuser array while($superuserrow = mysql_fetch_assoc($superuserresult)){ $superusers[] =$superuserrow['username']; } the if(in array) doesnt work can anyone help with this one.. i've tried AND, ||, &&
  13. Hey guys, I want to be able to add usernames to a text file, each username will be on a new line: username1 username2 for example, the code i'm using currently is: $userloggedin = $_SESSION['username']; $usernamelower = strtolower($userloggedin); $allowed_users = array('username1','username2'); if(!in_array($usernamelower,$allowed_users)) die('Forbidden - Leave now!'); How do i convert the txt file and use it in the $allowed_users array?
  14. Hey guys, super strange request here, google seems to be failing me How would i move the htusers file to mysql? we want to take our linux server away from htusers and storing (and using) a mysql db with all the users creds in. Is this possible? If so, can someone please help me!
  15. Hey guys, I've trying to explode and array but having no luck: The array is grabbed via: $result = $adldap->group()->all($includeDescription = false, $search = "*", $sorted = false); and the output looks a little like: array(1500) { [0]=> string(16) "Exchange Servers" [1]=> string(36) "Exchange Organization Administrators" [2]=> string(33) "Exchange Recipient Administrators" [3]=> string(33) "Exchange View-Only Administrators" [4]=> string(37) "Exchange Public Folder Administrators" [5]=> string(21) "ExchangeLegacyInterop" [6]=> The command i have so far is: foreach ($result as $group) { $items = explode('[', $group); foreach($items as $element) { list($key, $value) = explode('"', $element); if ($key==']') { echo "$value</a>"; } } } I honestly don't know what to use for the explode as i wanted to try starting with ) and ending with " but i can't get my head around the idea.. Any help would be high fived. Thanks!
  16. That makes complete sense, thanks for you time and effort dude. +1 from me.
  17. Thanks for the reply! Just so i can understand what you are providing, does this script have to take static array values or can this be dynamic? As the array is different for every user.
  18. Thanks for the quick response here! I should silly i know but can you double check where i'm going wrong please? $user = $adldap->user()->infoCollection($username, array('*')); $groupArray = $user->memberOf; foreach ($groupArray as $group) { $group; $string = explode(',',$group); $string = explode('=',$group); } I'm honestly struggling to get this working with the above code, i've read the .php.net site a 100 times, my head just cant get a grip of this
  19. Sorry for the lack of information here: array ( 0 => 'CN=testnamehere,OU=Groups,OU=Employees,OU=UserAccounts,DC=contoso,DC=com', 1 => 'CN=heresanother,OU=Distribution Lists,DC=contoso,DC=com', 2 => CN=VPN,OU=_UserGroups,DC=contoso,DC=com', 3 => 'CN=ManicMondayDL,OU=_UserGroups,DC=contoso,DC=com', ) Again, sorry for the lack of information here.
  20. Hey guys, Hopefully just a quick one and easy for you smart guys, but i'm running into an issue. The code im using: <? $user = $adldap->user()->infoCollection($username, array('*')); $groupArray = $user->memberOf; foreach ($groupArray as $group) { echo $group; }?> This displays something like this (as is): CN=testnamehere,OU=Groups,OU=Employees,OU=UserAccounts,DC=contoso,DC=comCN=heresanother,OU=Distribution Lists,DC=contoso,DC=comCN=VPN,OU=_UserGroups,DC=contoso,DC=comCN=ManicMondayDL,OU=_UserGroups,DC=contoso,DC=com As you can see its not formatting how i want, and everytime i time, i get errors. My question is 2 part, how do i have itas new lines AND now do i get it to strip everything apart from the CN part (so only the first part excluding the CN so the wanted outcome is: testnamehere heresanother VPN ManicMonday I hope that makes sense, i've been banging my head on the wall for the past few hours. Please help! Thanks guys!
  21. Yes it is, sorry.
  22. If i wanted to display letters instead of soley numbers i would have to change the list right? if so would it be extract? What would be the syntax for something like that? here is an example: Id Name LoopA Pos.A LoopB Pos.B Drives Temp RevA RevB Model Side 0 cage0 2:0:1 0 3:0:1 0 40 25-33 2.61 2.61 DC2 n/a extract($Id, $Name, $loopA) = $matches;
  23. Thanks! How would i break the command up? So from the output i spilt it into two varibles? $1 and $2 for space? like above? If ssh outputed foobar and phpfreaks how would php work out that $var1 is foobar and $var2 is phpfreaks?
  24. Hi guys, I've got the following command im trying to push out how it would look if i ran it in ssh <?php if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist"); if(!($con = ssh2_connect("hostname", 22))){ echo "fail: unable to establish connection\n"; } else { if(!ssh2_auth_password($con, "username", "password")) { echo "fail: unable to authenticate\n"; } else { echo "okay: logged in...\n <br>"; if (!($stream = ssh2_exec($con, "showspace" ))) { echo "fail: unable to execute command\n"; } else { stream_set_blocking($stream, true); $data = ""; while ($buf = fread($stream,4096)) { echo $data .= $buf; } fclose($stream); } } } ?> This displays as: ---Estimated(MB)---- ---Estimated(MB)---- RawFree UsableFree ---Estimated(MB)---- RawFree UsableFree 135770112 67885056 in putty it displays as: TestRepo cli% showspace ---Estimated(MB)---- RawFree UsableFree 135770112 67885056 How would i get this to display the same as above on the php page? Also, my 2nd question is how would i get this inputted into MYSQL, i know the command to insert, but how would i enable varibles like $rawspace $usablespace or something with will work?
  25. Hi chaps, I'm a rock in a hard place, basically i want to pull back a row called realname from bugs_activity but only the name of the person who removed CONV from the table.. So, the table layout: Field * Type * bug_id mediumint(9) who mediumint(9) bug_when datetime fieldid mediumint(9) added tinytext removed tinytext What i want to get in the WHO REMOVED the work 'CONV' from the BUG_ID. Below you are about to witness the most messed up SQL coding of your life... SELECT pr.description, bi.BugID, p.login_name AS loginname, p.realname AS prealname, du.realname, b.short_desc, bi.Last_Mod, baw.realname, babid.bug_id FROM conversions.Box_Info bi LEFT JOIN conversions.page_refs pr ON (pr.PGID = bi.boxid) LEFT JOIN bugs.profiles p ON (bi.UserID = p.userid) LEFT JOIN bugs.bugs b ON (b.bug_id = bi.BugID) LEFT JOIN bugs.profiles du ON du.userid = b.assigned_to LEFT JOIN bugs.bugs try ON try.assigned_to = du.realname LEFT JOIN bugs_activity babid ON babid.bug_id = b.bug_id LEFT JOIN bugs.profiles baw ON baw.userid = babid.who WHERE bi.box_use in (0,1) AND babid.removed = 'CONV' AND (b.op_sys not like 'CONV' AND b.op_sys not like 'CNVA') OR b.bug_status = 'CLOSED' OR b.bug_status = 'RESOLVED' AND bi.matterid != 90 GROUP BY description What i have managed to get from that is a random name of someone, but not he actual user who is linked with removing 'CONV' from the bugs database. Can anyone point to where i am going wrong! Again sorry for the mess, i hope i provided enough for you gurus. Thanks, B-Man
×
×
  • 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.