This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isAllowedOrigin($origin) { | |
| // your logic here | |
| //... | |
| return true; | |
| } | |
| if (($_SERVER["HTTP_ORIGIN"]=="http://www.yoursite.com.au") || (isAllowedOrigin($_SERVER["HTTP_ORIGIN"]))) { | |
| header("Access-Control-Allow-Origin: *"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const KEY_QUERY_VALUE = &H0001 | |
| const KEY_SET_VALUE = &H0002 | |
| const KEY_CREATE_SUB_KEY = &H0004 | |
| const DELETE = &H00010000 | |
| const HKEY_CURRENT_USER = &H80000001 | |
| const HKEY_LOCAL_MACHINE = &H80000002 | |
| const REG_SZ = 1 | |
| const REG_EXPAND_SZ = 2 | |
| const REG_BINARY = 3 | |
| const REG_DWORD = 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function directoryToArray($directory, $recursive) { | |
| $array_items = array(); | |
| if ($handle = opendir($directory)) { | |
| while (false !== ($file = readdir($handle))) { | |
| if (($file != "." && $file != "..") && | |
| (is_dir($directory. "/" . $file)) && | |
| ($recursive)) $array_items = array_merge($array_items, | |
| directoryToArray($directory. "/" . $file, $recursive)); | |
| if (is_dir($directory. "/" . $file)) { | |
| $file = $directory . "/" . $file; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Public Sub ChartAll() | |
| On Error GoTo Handler | |
| Worksheets.Add before:=Worksheets(1) | |
| Sheets(1).Name = "Summary" | |
| Sheets(1).Activate | |
| 'Application.ScreenUpdating = False | |
| ' Fix issue with invalid data type to MakeArray | |
| Dim strSheetName As String | |
| ' end fix | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Option Explicit | |
| 'Icmp constants converted from' | |
| 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_pingstatus.asp' | |
| Private Const ICMP_SUCCESS As Long = 0 | |
| Private Const ICMP_STATUS_BUFFER_TO_SMALL = 11001 'Buffer Too Small' | |
| Private Const ICMP_STATUS_DESTINATION_NET_UNREACH = 11002 'Destination Net Unreachable' | |
| Private Const ICMP_STATUS_DESTINATION_HOST_UNREACH = 11003 'Destination Host Unreachable' | |
| Private Const ICMP_STATUS_DESTINATION_PROTOCOL_UNREACH = 11004 'Destination Protocol Unreachable' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function splitn($string, $needle, $offset) { | |
| $newString = $string; | |
| $totalPos = 0; | |
| $length = strlen($needle); | |
| for($i = 0; $i < $offset; $i++) { | |
| $pos = strpos($newString, $needle); | |
| // If you run out of string before you find all your needles | |
| if($pos === false) | |
| return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sortCustom($data,$field,$datatype="text",$direction="desc") { | |
| $cycle = false; | |
| for ($i=0;$i<(count($data)-1);$i++) { | |
| switch($datatype) { | |
| case "date": | |
| $arrDate1 = explode("-", $data[$i][$field]); | |
| $mkDate1 = mktime(1,1,1,$arrDate1[1],$arrDate1[2],$arrDate1[0]); | |
| $arrDate2 = explode("-", $data[$i+1][$field]); | |
| $mkDate2 = mktime(1,1,1,$arrDate2[1],$arrDate2[2],$arrDate2[0]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getCustomTypeData($name) { | |
| global $wpdb; | |
| $returnValues = array(); | |
| $sql = "SELECT id, post_title, post_status, post_author, post_content FROM wp_posts WHERE post_title<>'Auto Draft' AND post_status='publish' AND post_type='$name'"; | |
| $customPosts= $wpdb->get_results($sql); | |
| $count = 0; | |
| foreach ($customPosts as $post) { | |
| $returnValues[$count]["id"] = $post->id; | |
| $returnValues[$count]["title"] = $post->post_title; | |
| $returnValues[$count]["content"] = $post->post_content; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getURLContent($url) { | |
| $ch = curl_init(); | |
| $timeout = 5; | |
| curl_setopt($ch,CURLOPT_URL,$url); | |
| curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); | |
| curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); | |
| $data = curl_exec($ch); | |
| curl_close($ch); | |
| return $data; | |
| } |