Blog Comments

  1. sonofsanta's Avatar
    • |
    • permalink
    The reason you're seeing "success" is because that's not dependent on anything i.e. it's not part of any conditional statement. All that shows is that PHP has reached that point in the script, regardless of what's happened before. I guess you're not seeing the errors it's throwing though, in which case there's something useful you can do to make PHP development much easier for everyone

    On your server, browse to the PHP install directory (e.g. C:\Program Files (x86)\PHP\5.4) and rename php.ini to php.ini.old. Then find php.ini-development, make a copy and rename the copy php.ini. That will change a load of settings to those more suitable to a development environment, including, importantly, outputting error messages to the browser instead of only to the error file. If you made any changes to php.ini before (e.g. the mail server, as above) make them again here. Restart w3svc to reload PHP using these new settings.

    I'll put that in the main post above, because damn if it ain't handy.

    Once you've done that, loading the PHP page should show you what's actually going wrong, and on what line of the PHP script. I got two errors out, from line 12 and line 15 (which was repeated due to the loop).

    Line 12 was permissions; I added Full Control permissions for IUSR on the local server (i.e. search the server, not your directory when you go to Add Permissions) to the wwwroot folder containing everyone's work folder.

    The line 15 error was an error in the way fputcsv() was being used - that function actually wants an array as input, and does all the CSV formatting itself, so there's no need to use the loop.

    Amending the script to fix that problem, and shuffling it to use an IF loop to check if the file could be opened/created before declaring success or otherwise, the script ends up as the fairly similar:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <?php
    $list = array (
        "aaa", "bbb", "ccc", "ddd"
    );
    
    if($fp = fopen("file.csv", "a"))
    {
        fputcsv($fp, $list);
        fclose($fp);
        echo("Great Success!");
    } else {
        echo("Could not open/create file!");
    }
    
    ?>
    <body>
    </body>
    </html>
    If you still have problems with permissions, use Process Monitor on the server to capture events as you refresh the page, then filter your results to show only Process Name = php-cgi.exe, and look for any ACCESS DENIED results. Open the Event Properties and look for the Impersonating: at the end of the Event tab. I suspect yours will be NT AUTHORITY\IUSR same as mine, though.

    HTH!
  2. fiza's Avatar
    • |
    • permalink
    @sonofsanta - Hopefully you can help me with a query from the teacher. I know nothing of PHP so would welcome some help.
    Students are using php to write to a csv file in their area. They create the php file and then browse to it in IE. It should look for a csv file, open it and write to it. If it doesn't exist it should get created. Below is the file. it doesn't seem to work, doesn't create the file and if I manually create the file it doesn't amend it either. We get the "success" at the end but it hasn't done anything.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <?php
    $list = array (
    	'aaa', 'bbb', 'ccc', 'dddd'
    );
    
    $fp = fopen("http:\\phpsvr\08\08brooksa\file.csv", "a");
    
    foreach ($list as $fields) {
        fputcsv($fp, $fields);
    }
    
    fclose($fp);
    
    
    echo 'success';
    ?>
    <body>
    </body>
    </html>
    Updated 27th November 2014 at 04:20 PM by fiza
  3. sonofsanta's Avatar
    • |
    • permalink
    For teachers, I map the K drive to the root of the wwwroot folder, so they can access all the student work as well. Similar to how the kids are mapped, I've added the K drive mapping to the usual staff drive mapping GPO and used Item Level Targeting to check membership of the PHP Users group. If it meets the criteria, map the root of wwwroot, where I've manually added NTFS permissions for the relevant department (i.e. curriculum IT).

    Means they can create their own folders & structure to their heart's content, as well as look at any code they need to when assisting kids, and means I can drop example code in there for the stealing.

    I suppose you can easily enough tweak it so it maps to wwwroot/staff/%username% if they want it working exactly the same, depends on how much confidence they have in the kids' ability to understand "your K drive is here, look, I can show you"

    Glad it's working well for you, it ain't half been a lot easier here than faffing around with FTP!
  4. fiza's Avatar
    • |
    • permalink
    @sonofsanta - Been working great since I set it up. Now a couple of teachers want to have access same as the students do. They want to be able to demonstrate how to do things so want it set up exactly as it is for the students. Whats the easiest way to do this? Their usernames don't follow the same format as the students.
  5. fiza's Avatar
    • |
    • permalink
    Got it working!!
    My VM client didn't have SP1 Doh!!!!

    works a treat.
  6. sonofsanta's Avatar
    • |
    • permalink
    Didn't flag up for me so I won't be any help I'd double check permissions (NTFS and sharing) as a first call but other than that, you're going to have to rely on Google I'm afraid.

    Hope it's proving useful otherwise, anyway!
  7. NikChillin's Avatar
    • |
    • permalink
    Quote Originally Posted by fiza
    excellent - this is exactly what we need!!!

    I am working through your guide. I am at the part of mapping the drive and I get an error and am unable to map the drive.
    In Event Viewer I get :

    The client-side extension caught the unhandled exception '0xC0000005' inside: 'threadEntry : client main' See trace file for more details.

    I googled this and found a hot fix KB976399 but it only applies pre win7 SP1.

    Did you come across this?
    Hi Fiza, I didn't do the mapped drive part as the teacher wanted ftp access.
  8. fiza's Avatar
    • |
    • permalink
    excellent - this is exactly what we need!!!

    I am working through your guide. I am at the part of mapping the drive and I get an error and am unable to map the drive.
    In Event Viewer I get :

    The client-side extension caught the unhandled exception '0xC0000005' inside: 'threadEntry : client main' See trace file for more details.

    I googled this and found a hot fix KB976399 but it only applies pre win7 SP1.

    Did you come across this?
  9. SYNACK's Avatar
    • |
    • permalink
    (I am also happy to see that EG does not have Comic Sans MS as an option for posts )
    It used to but I think the UN stepped in with humanitarian concerns
  10. sonofsanta's Avatar
    • |
    • permalink
    Quote Originally Posted by X-13
    I thought they'd be useful for staff... After being asked how to do something that was covered in one of these, not so much.
    I often get people coming to me all excited, saying "I just found out how to do this from blahdey-blah, I think it would make a really good IT tip!", at which point I have to tell them yes it would, and it did, 2 months ago when I sent it out.
  11. X-13's Avatar
    • |
    • permalink
    Hopefully some of you have found them useful this academic year, at least!
    I thought they'd be useful for staff... After being asked how to do something that was covered in one of these, not so much.
  12. NikChillin's Avatar
    • |
    • permalink
    Superb, just what I need!
  13. sonofsanta's Avatar
    • |
    • permalink
    Quote Originally Posted by NikChillin
    Brilliant!!!!!!
    When will the next bit be available please?
    Around the end of April just gone it's here: Installing a PHP/MySQL Development Server for students on Windows Server 2012 - Part2 - Blogs - EduGeek.net
  14. NikChillin's Avatar
    • |
    • permalink
    Brilliant!!!!!!
    When will the next bit be available please?
  15. sonofsanta's Avatar
    • |
    • permalink
    Huh, doesn't do that for me here (not that I'd want it to, with all my tabs it'd take me twenty minutes to get to the window I wanted). What is annoying, though, is that a single press of Alt+Tab switches to the last window, a single press of Win+Tab just shows a fancy 3D effect but doesn't switch to anything.

    IE does count each tab as a separate window for Aero Peek though, which is a bit annoying as well tbh - fills up too fast, I'd rather switch to the window and then to the tab. I will concede that that is entirely personal preference, though
  16. X-13's Avatar
    • |
    • permalink
    Quote Originally Posted by sonofsanta
    Using WinKey + Tab instead of Alt+Tab is the Windows equivalent of sticking a spoiler and alloys on your Corsa, showing off for no functional gain
    I like to see what it is I'm flipping to. Especially when I have multiple tabs open, alt+tab counts internet as 1 thing, win+tab does them seperatly. [I think, for some reason aero won't enable on my normal account and I can't get into personalisation.]
  17. sonofsanta's Avatar
    • |
    • permalink
    Using WinKey + Tab instead of Alt+Tab is the Windows equivalent of sticking a spoiler and alloys on your Corsa, showing off for no functional gain

    Though when the time comes, it is probably the method I will write up as a tip, because people do love the shiny.
  18. X-13's Avatar
    • |
    • permalink
    I forgot all about the shake...

    Also, Aero win+tab >>>> alt+tab
  19. ThomL's Avatar
    • |
    • permalink
    It is worth mentioning that if you are using Roaming profiles this will not work very well, especially if you are redirecting app data, or deleting profiles when users log off of machines.

    Users will suddenly lose anything they have pinned as it doesn't sit within the normal areas of the appdata that get redirected.

    The way that i have overcome this is by using a logon/logoff script to backup the users pinned items and to restore them when they log on.

    Logon Script
    DEL /F /S /Q /A "%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\*"
    copy /y "\\nas01\%username%\TaskbarPinnedItems" "%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
    REG DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Exp lorer\Taskband /F
    REG IMPORT \\nas01\%username%\TaskbarPinnedItems\Taskbar-Pinned-Items-Backup.reg

    log off script
    mkdir "\\nas01\%username%\TaskbarPinnedItems"
    copy /y "%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar" "\\nas01\%username%\TaskbarPinnedItems"
    REG EXPORT HKCU\Software\Microsoft\Windows\CurrentVersion\Exp lorer\Taskband \\nas01\%username%\TaskbarPinnedItems\Taskbar-Pinned-Items-Backup.reg /y


    Any one using this will have to update the script to work in their environment, if someone has a better solution please comment and let me know!
  20. X-13's Avatar
    • |
    • permalink
    Cheers, Mr. Sonofsanta.

    [Pretend I gave you +Rep on an unrelated post for this. I can't give you any ATM.]
Page 1 of 2 12 LastLast