diff --git a/AVsitter2/Utilities/Noob-detector.lsl b/AVsitter2/Utilities/Noob-detector.lsl new file mode 100644 index 0000000..5a82615 --- /dev/null +++ b/AVsitter2/Utilities/Noob-detector.lsl @@ -0,0 +1,293 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright (c) the AVsitter Contributors (http://avsitter.github.io) + * AVsitterā„¢ is a trademark. For trademark use policy see: + * https://avsitter.github.io/TRADEMARK.mediawiki + * + * Please consider supporting continued development of AVsitter and + * receive automatic updates and other benefits! All details and user + * instructions can be found at http://avsitter.github.io + */ + +/* + * Things not implemented: + * ~ perms of the object + * ~ creator of the object + * ~ which platform/world (OpenSim/SL) +*/ + +integer sendToSupport=FALSE; +integer sendItems = TRUE; +string support_avi = ""; + +string disclaimer = "This script will inspect your object and create a link you can share with others.\n\nClick OK to proceed."; +string start_message = "Preparing info, please wait..."; +string end_message = "Inspection complete! Script removed."; + +string product = "Noob Detector"; +string version = "1.3"; + +list allowed_products = ["AVpos","[AV]menu","[AV]object"]; + +string out; +string next_out; + +list notecards_to_read; +key notecard_query; +integer notecard_index; +integer notecard_line; + +list item_types = ["TEXTURE","SOUND","LANDMARK","CLOTHING","OBJECT","NOTECARD","SCRIPT","BODYPART","ANIMATION","GESTURE","ALL TYPES"]; +list item_ints = [0,1,3,5,6,7,10,13,20,21]; + +integer menu_channel; + +string url = "https://avsitter.com/settings.php"; +string cache; +string webkey; +integer webcount; + +add_out(string say, integer force){ + cache+=say; + if(!force){ + cache+="\n"; + } + if(llStringLength(llEscapeURL(cache))>1024 || force){ + webcount++; + llHTTPRequest(url, [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded",HTTP_VERIFY_CERT,FALSE], "w="+webkey+"&c="+(string)webcount+"&t="+llEscapeURL(cache)); + cache=""; + } +} + +remove_script(){ + llOwnerSay("Diagnostic script removed."); + llRemoveInventory(llGetScriptName()); +} + +default { + state_entry(){ + integer i; + for(i=0;i1){ + i=1; + } + + while (i<=llGetObjectPrimCount(llGetKey())){ + list data = llGetLinkPrimitiveParams(i,[PRIM_NAME,PRIM_DESC]); + add_out((string)i+", "+llDumpList2String(data,", "),FALSE); + i++; + + if(llGetObjectPrimCount(llGetKey())==1){ + jump end; + } + } + @end; + + // Inventory + + string line; + + integer j; + for (j=0;j10000){ + $out.= $row['text']; + + if(1==2){ // switch on to 'keep' any record that ever was accessed + $sql = "UPDATE $avpos_table SET + keep = '1' + WHERE webkey = '$given_webkey'"; + $result = mysqli_query($link,$sql) or email_death("ERR05: " . mysqli_error($link)); + } + + // delete all entries older than 10 minutes that are not flagged keep + $sql = "DELETE FROM $avpos_table WHERE timestamp < DATE_SUB(NOW(), INTERVAL 10 MINUTE) AND keep = '0'"; + $result = mysqli_query($link,$sql) or email_death("ERR06: " . mysqli_error($link)); + + } + else{ + $out.="Data was incomplete, please try again.\n\nThis feature is new and experimental - you're welcome to report any issues."; + } + } + echo $out; +} + +function parse_llHTTPRequest_headers(){ + $position_array = explode(', ',substr($_SERVER['HTTP_X_SECONDLIFE_LOCAL_POSITION'],1,-1)); + $rotation_array = explode(', ',substr($_SERVER['HTTP_X_SECONDLIFE_LOCAL_ROTATION'],1,-1)); + $velocity_array = explode(', ',substr($_SERVER['HTTP_X_SECONDLIFE_LOCAL_VELOCITY'],1,-1)); + list($global_x,$global_y) = explode(',',trim(substr($_SERVER['HTTP_X_SECONDLIFE_REGION'],$position_of_left_bracket + 1,-1))); + $region_array = array($region_name,(integer)$global_x,(integer)$global_y); + $headers = array('Accept'=>$_SERVER['HTTP_ACCEPT'], + 'User-Agent'=>$_SERVER['HTTP_USER_AGENT'], + 'X-SecondLife-Shard'=>$_SERVER['HTTP_X_SECONDLIFE_SHARD'], + 'X-SecondLife-Object-Name'=>$_SERVER['HTTP_X_SECONDLIFE_OBJECT_NAME'], + 'X-SecondLife-Object-Key'=>$_SERVER['HTTP_X_SECONDLIFE_OBJECT_KEY'], + 'X-SecondLife-Region'=>$_SERVER['HTTP_X_SECONDLIFE_REGION'], + 'X-SecondLife-Region-Array'=> $region_array, + 'X-SecondLife-Local-Position'=>array( 'x'=>(float)$position_array[0],'y'=>(float)$position_array[1],'z'=>(float)$position_array[2]), + 'X-SecondLife-Local-Rotation'=>array( 'x'=>(float)$rotation_array[0],'y'=>(float)$rotation_array[1],'z'=>(float)$rotation_array[2],'w'=>(float)$rotation_array[3]), + 'X-SecondLife-Local-Velocity'=>array( 'x'=>(float)$velocity_array[0],'y'=>(float)$velocity_array[1],'z'=>(float)$velocity_array[2]), + 'X-SecondLife-Owner-Name'=>$_SERVER['HTTP_X_SECONDLIFE_OWNER_NAME'], + 'X-SecondLife-Owner-Key'=>$_SERVER['HTTP_X_SECONDLIFE_OWNER_KEY'] + ); + if(!strstr($headers['X-SecondLife-Owner-Name'],' ') && $_POST['X-SecondLife-Owner-Name']){ + $headers['X-SecondLife-Owner-Name'] == $_POST['X-SecondLife-Owner-Name']; + } + if(is_array($headers)){ + return $headers; + } + else{ + return FALSE; + } +} + +function isValidGuid($guid){ + return !empty($guid) && preg_match('/^\{?[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}\}?$/', $guid); +} + +function email_death($error){ + $body.="\n"; + $body.="\n\$_SERVER\n"; + foreach($_SERVER as $key_name => $key_value) { + $body.= $key_name . " = " . $key_value . "\n"; + } + $body.="\n\$_GET\n"; + foreach($_GET as $key_name => $key_value) { + $body.= $key_name . " = " . $key_value . "\n"; + } + $body.="\n\$_POST\n"; + foreach($_POST as $key_name => $key_value) { + $body.= $key_name . " = " . $key_value . "\n"; + } + $to = $GLOBALS['email_to']; + $subject = "avsitter: $error"; + $email_headers = "From: ". $GLOBALS['email_from'] ."\r\n" . "X-Mailer: php"; + mail($to, $subject, $body, $email_headers); + die($error); +} + +function startsWith($haystack, $needle) { + // search backwards starting from haystack length characters from the end + return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; +} + +function endsWith($haystack, $needle) { + // search forward starting from end minus needle length characters + return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); +} + +function isAllowedIP($ip){ + if($GLOBALS['check_ip']==false){ + return true; + } + $llsubnets = array( + "8.2.32.0/22", + "8.4.128.0/22", + "8.10.144.0/21", + "63.210.156.0/22", + "64.154.220.0/22", + "216.82.0.0/18" + ); + foreach($llsubnets as $range){ + if(ip_in_range($ip,$range)) return true; + } + return false; +} + +// check if an ip_address in a particular range +function ip_in_range( $ip, $range ) { + // $range is in IP/CIDR format eg 127.0.0.1/24 + list( $range, $netmask ) = explode( '/', $range, 2 ); + $range_decimal = ip2long( $range ); + $ip_decimal = ip2long( $ip ); + $wildcard_decimal = pow( 2, ( 32 - $netmask ) ) - 1; + $netmask_decimal = ~ $wildcard_decimal; + return ( ( $ip_decimal & $netmask_decimal ) == ( $range_decimal & $netmask_decimal ) ); +} + +?> \ No newline at end of file