The Great Cisco 7960 Reboot from the EndPoint Manager hack!

Ok, so a friend of mine with about 2 dozen cisco 7960 hanging off one of the latest versions of FreePBX was never able to actually get a remote (SIP) reboot of the phones, either from the Endpoint Manager or the Bulk Reset module. I was never able to get my Cisco 7960 to remote reboot either from my own up-to-date FreePBX.
Much research and frustration ensued. SIP messages were going out correctly, but never a reboot. There must be some secret sauce somewhere. Finally… the mystical gods of Google Search bestowed upon me the recipe.

http://www.cisco.com/en/US/docs/voice_ip_comm/cuipph/7960g_7940g/sip/8_0/english/administration/guide/sipmn80.html#wp1144188

Which pointed me at the need for the syncinfo.xml file to be available in the TFTP server. 20 seconds after the SIP notify to check-sync, if the SYNC number is different from whats stored in the phone, the phone reboots. HUZZAH!
Now, how to automate this process so I dont have to hand edit the syncinfo.xml file each time I want a reboot?
Quick Robin, to the PHP books!

Poked around in the Endpoint Manager files and came up with this horrid hack, but it works.

In the file /var/www/html/admin/modules/endpointman/includes/devices_manager.inc

near the top of the file, directly before the SWITCH ($sub_type) statement, insert:

file_put_contents(’/tftpboot/syncinfo.xml’,’’);

This 1 line writes the file /tftpboot/syncinfo.xml with the XML needed and the SYNC= number is set equal to the Unix time. Dosent matter really wat its set to as long as its different from the last reboot. Then when the phone is passed the SIP check sync, it reads this file, sees the number different, and 20 seconds later Reboots.
(of course if your tftp directory path is different, update the code to reflect. I know hardcoding the path is a crock, but what did you want at 2AM?)

This same line can also be inserted in an appropriate place in the Bulk Reset module, and it would be needed there too for the cisco phones.

This hack applied to my OSS PBX End Point Manager 2.11.4.11 module worked fine. YMMV
-Centaur