Source codes, small scripts...

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #61
    slight spelling errors in the strings names:
    Code:
    function GetCountry($IpAddr){
    change to:
    Code:
    function GetCountry($$IpAdds){
    It is a long way to go about getting countrys lol
    but if anyones intrested in doing it this way heres some country codes:
    Code:
    AD   Andorra
    AE   United Arab Emirates
    AF   Afghanistan
    AG   Antigua and Barbuda
    AI   Anguilla
    AL   Albania
    AM   Armenia
    AN   Netherlands Antilles
    AO   Angola
    AQ   Antarctica
    AR   Argentina
    AS   American Samoa
    AT   Austria
    AU   Australia
    AW   Aruba
    AZ   Azerbaijan
    BA   Bosnia and Herzegovina
    BB   Barbados
    BD   Bangladesh
    BE   Belgium
    BF   Burkina Faso
    BG   Bulgaria
    BH   Bahrain
    BI   Burundi
    BJ   Benin
    BM   Bermuda
    BN   Brunei Darussalam
    BO   Bolivia
    BR   Brazil
    BS   Bahamas
    BT   Bhutan
    BV   Bouvet Island
    BW   Botswana
    BY   Belarus
    BZ   Belize
    CA   Canada
    CC   Cocos (Keeling) Islands
    CF   Central African Republic
    CG   Congo
    CH   Switzerland
    CI   Cote D'Ivoire (Ivory Coast)
    CK   Cook Islands
    CL   Chile
    CM   Cameroon
    CN   China
    CO   Colombia
    CR   Costa Rica
    CS   Czechoslovakia (former)
    CU   Cuba
    CV   Cape Verde
    CX   Christmas Island
    CY   Cyprus
    CZ   Czech Republic
    DE   Germany
    DJ   Djibouti
    DK   Denmark
    DM   Dominica
    DO   Dominican Republic
    DZ   Algeria
    EC   Ecuador
    EE   Estonia
    EG   Egypt
    EH   Western Sahara
    ER   Eritrea
    ES   Spain
    ET   Ethiopia
    FI   Finland
    FJ   Fiji
    FK   Falkland Islands (Malvinas)
    FM   Micronesia
    FO   Faroe Islands
    FR   France
    FX   France, Metropolitan
    GA   Gabon
    GB   Great Britain (UK)
    GD   Grenada
    GE   Georgia
    GF   French Guiana
    GH   Ghana
    GI   Gibraltar
    GL   Greenland
    GM   Gambia
    GN   Guinea
    GP   Guadeloupe
    GQ   Equatorial Guinea
    GR   Greece
    GS   S. Georgia and S. Sandwich Isls.
    GT   Guatemala
    GU   Guam
    GW   Guinea-Bissau
    GY   Guyana
    HK   Hong Kong
    HM   Heard and McDonald Islands
    HN   Honduras
    HR   Croatia (Hrvatska)
    HT   Haiti
    HU   Hungary
    ID   Indonesia
    IE   Ireland
    IL   Israel
    IN   India
    IO   British Indian Ocean Territory
    IQ   Iraq
    IR   Iran
    IS   Iceland
    IT   Italy
    JM   Jamaica
    JO   Jordan
    JP   Japan
    KE   Kenya
    KG   Kyrgyzstan
    KH   Cambodia
    KI   Kiribati
    KM   Comoros
    KN   Saint Kitts and Nevis
    KP   Korea (North)
    KR   Korea (South)
    KW   Kuwait
    KY   Cayman Islands
    KZ   Kazakhstan
    LA   Laos
    LB   Lebanon
    LC   Saint Lucia
    LI   Liechtenstein
    LK   Sri Lanka
    LR   Liberia
    LS   Lesotho
    LT   Lithuania
    LU   Luxembourg
    LV   Latvia
    LY   Libya
    MA   Morocco
    MC   Monaco
    MD   Moldova
    MG   Madagascar
    MH   Marshall Islands
    MK   Macedonia
    ML   Mali
    MM   Myanmar
    MN   Mongolia
    MO   Macau
    MP   Northern Mariana Islands
    MQ   Martinique
    MR   Mauritania
    MS   Montserrat
    MT   Malta
    MU   Mauritius
    MV   Maldives
    MW   Malawi
    MX   Mexico
    MY   Malaysia
    MZ   Mozambique
    NA   Namibia
    NC   New Caledonia
    NE   Niger
    NF   Norfolk Island
    NG   Nigeria
    NI   Nicaragua
    NL   Netherlands
    NO   Norway
    NP   Nepal
    NR   Nauru
    NT   Neutral Zone
    NU   Niue
    NZ   New Zealand (Aotearoa)
    OM   Oman
    PA   Panama
    PE   Peru
    PF   French Polynesia
    PG   Papua New Guinea
    PH   Philippines
    PK   Pakistan
    PL   Poland
    PM   St. Pierre and Miquelon
    PN   Pitcairn
    PR   Puerto Rico
    PT   Portugal
    PW   Palau
    PY   Paraguay
    QA   Qatar
    RE   Reunion
    RO   Romania
    RU   Russian Federation
    RW   Rwanda
    SA   Saudi Arabia
    Sb   Solomon Islands
    SC   Seychelles
    SD   Sudan
    SE   Sweden
    SG   Singapore
    SH   St. Helena
    SI   Slovenia
    SJ   Svalbard and Jan Mayen Islands
    SK   Slovak Republic
    SL   Sierra Leone
    SM   San Marino
    SN   Senegal
    SO   Somalia
    SR   Suriname
    ST   Sao Tome and Principe
    SU   USSR (former)
    SV   El Salvador
    SY   Syria
    SZ   Swaziland
    TC   Turks and Caicos Islands
    TD   Chad
    TF   French Southern Territories
    TG   Togo
    TH   Thailand
    TJ   Tajikistan
    TK   Tokelau
    TM   Turkmenistan
    TN   Tunisia
    TO   Tonga
    TP   East Timor
    TR   Turkey
    TT   Trinidad and Tobago
    TV   Tuvalu
    TW   Taiwan
    TZ   Tanzania
    UA   Ukraine
    UG   Uganda
    UK   United Kingdom
    UM   US Minor Outlying Islands
    US   United States
    UY   Uruguay
    UZ   Uzbekistan
    VA   Vatican City State (Holy See)
    VC   Saint Vincent and the Grenadines
    VE   Venezuela
    VG   Virgin Islands (British)
    VI   Virgin Islands (U.S.)
    VN   Viet Nam
    VU   Vanuatu
    WF   Wallis and Futuna Islands
    WS   Samoa
    YE   Yemen
    YT   Mayotte
    YU   Yugoslavia
    ZA   South Africa
    ZM   Zambia
    ZR   Zaire
    ZW   Zimbabwe

    Comment


      #62
      Change database collation.

      PHP Code:
      <?
      #########################################################################
      #########################################################################
      ##                                                                     ##
      ## Script coded by Eric Reiche                                         ##
      ##                                                                     ##
      ## Version: 0.2 / 2006-08-16 17:35 GMT + 100                           ##
      ## Version 0.2 contains bugfixes                                       ##
      ##                                                                     ##
      ## Inspired by serversupportforum.de user monotek                      ##
      ## ( [url="http://www.serversupportforum.de/forum/sql/"]http://www.serversupportforum.de/forum/sql/[/url]        \              ##
      ## 9279-kollation-von-tabellen-aendern.html#post67293 )                ##
      ## [Check link  for bashscript]                                        ##
      ##                                                                     ##
      ## Web: [url="http://www.ericreiche.net"]http://www.ericreiche.net[/url]  ||  Mail: [email]webmaster@ericreiche.net[/email]  ##
      ##                                                                     ##
      ## You can spread this script, until you don't touch this copymark     ##
      ##                                                                     ##
      #########################################################################
      #########################################################################


      //Config:
        $mysqlserver = 'localhost';    //Host
        $mysqluser = 'root';           //User [It's recomment to use root]
        $mysqlpw = 'passwort';                 //Password
        $mysqldb = 'datenbank';       //Database
        $stepping = 100;               //Queries per Page
        $tabletoskip = 'really_big_table'; //If you have a really big table, you can enter it here,
                                       //it will be skipped, to prevent a script abort
                                     
        $collation = 'latin1_german2_ci';
        $character_set = 'latin1';
      //End Config

      #######################################################################
      # Do not change anything from here, until you know what you're doing  #
      #######################################################################
        
      if(isset($_GET['start']) && is_numeric($_GET['start'])){
        $start = $_GET['start'];
        if($start > 0){
          $start = $start * $stepping;
        }
      }else{
        $start = 0;
      }
      //mysql connect
      @mysql_connect($mysqlserver, $mysqluser, $mysqlpw) OR die("No Conncection to Server. Report: :".mysql_error());
      mysql_select_db($mysqldb) OR die("couldn't select database, Report: ".mysql_error());
      unset($mysqlserver);
      unset($mysqluser);
      unset($mysqlpw);

      $i = 0;
      print('<pre>');
      if($start == 0){
        $sql = 'ALTER DATABASE '.$mysqldb.' DEFAULT CHARACTER SET '.$character_set.' COLLATE '.$collation.";\r\n";
        mysql_query($sql);
        print($sql);
      }

      $sql = 'Show tables;';
      $result1 = mysql_query($sql);
      while($tables = mysql_fetch_assoc($result1)){
          if($start == 0){
          $sql = 'ALTER TABLE '.$tables['Tables_in_'.$mysqldb].' DEFAULT CHARACTER SET '.$character_set.' COLLATE '.$collation.";\r\n";
          mysql_query($sql);
          print(''.$sql);
        }
        
        $sql = 'Show columns FROM '.$tables['Tables_in_'.$mysqldb];
        $result2 = mysql_query($sql);
        
        while($columns = mysql_fetch_assoc($result2)){
          
          if(substr_count($columns['Type'], 'varchar') || substr_count($columns['Type'], 'text')){
            $i++;
            if($i >= $start && $i < ($start + $stepping)){
              $sql = 'ALTER TABLE '.$tables['Tables_in_'.$mysqldb].' CHANGE '.$columns['Field'].' '.$columns['Field'].' '.$columns['Type'].' CHARACTER SET '.$character_set.' COLLATE '.$collation.';';
              if($tabletoskip != $tables['Tables_in_'.$mysqldb]){
                mysql_query($sql);
                print(''.$i.'. '.$sql."\r\n");
              }else{
                print(''.$i.'. SKIPPED: '.$sql."\r\n");
              }
            }
          }
        }

      }
      print('</pre>');


        print('<a href="'.$_SERVER['PHP_SELF'].'?start='.($_GET['start'] + 1).'">Weiter...</a>');

      ?>
      Advertise your mobile site for FREE with AdTwirl

      Comment


        #63
        create image via php, with referer, browser and ip info ;)
        PHP Code:
        <?php
        header
        ("Content-type: image/png");

        $im ImageCreateFromgif("default.gif");
        ImageString ($im21036i,2);
        imagepng($im);

        $ref $_SERVER['HTTP_REFERER'];
        $ip $_SERVER['REMOTE_ADDR'];
        $vrijeme date("H:i:s d/m/Y");
        $browser $_SERVER['HTTP_USER_AGENT'];
        $file "info.txt";
        $fp fopen($file"a");


        $sve "IP:$ip \r\n Bro: $browser \r\n Link: $ref \r\n Time: $vrijeme \r\n \r\n\r\n";
        fwrite($fp,$sve);
        fclose($fp);
        ?>

        Comment


          #64
          Fake referer
          PHP Code:
          <?php
          $host 
          'www.mydomainname.com ';
          $service_uri '/index.php';
          $vars ='additional_option1=yes&additional_option2=un';
          $header "Host: $host\r\n";
          $header .= "Referer: http://www.xxxxx.com\r\n";
          $header .= "accept-language: en\r\n";
          $header .= "User-Agent: vvvvv\r\n";
          $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
          $header .= "Content-Length: ".strlen($vars)."\r\n";
          $header .= "Connection: close\r\n\r\n";
          $fp fsockopen("".$host,80$errno$errstr);
          if (!
          $fp) {
          $errstr ($errno);
          $fp;
          }
           else {
           
          fputs($fp"POST $service_uri HTTP/1.1\r\n");
          fputs($fp$header.$vars);
          fwrite($fp$out);
          while (!
          feof($fp)) {
          fgets($fp12;
          }
          fclose($fp);
          }
           
          ?>

          Comment


            #65
            Get useragent eg googlebot, or NokiaN95 istead of mozilla or opera mini, this function i have developed with alesh's help

            PHP Code:
            function get_mob_browser($_mob_browser)
            {

            if(
            preg_match('/(google|bot)/i',strtolower($_mob_browser)))
            {
            $position strpos(strtolower($_mob_browser),"bot");
            $_mob_browser substr($_mob_browser$position-30$position+2);
            $_browser explode (" "$_mob_browser);
             
            $_browser array_reverse($_browser); 
            }
            else if (isset(
            $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])) 
            {
            $_mob_browser $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
            $_position=strpos(strtolower($_mob_browser),"nokia");
            if(
            $_position)$_mob_browser substr($_mob_browser$_position,25);
            $_browser explode ("/"$_mob_browser);
            }
            else 
            {
            $_position=strpos(strtolower($_mob_browser),"nokia");
            if(
            $_position)$_mob_browser substr($_mob_browser$_position,25);
            $_browser explode ("/"$_mob_browser);
            }

            return 
            $_browser[0];
             } 
            Usage:
            Code:
            echo get_mob_browser($_SERVER['HTTP_USER_AGENT']);
            Advertise your mobile site for FREE with AdTwirl

            Comment


              #66
              nice function gum
              does HTTP_X_OPERAMINI_PHONE_UA
              work better than
              HTTP_X_OPERAMINI_PHONE ?
              also it still wont work against n95 hidden behind opera 8.65
              maybee an added option of
              $n95 = explode ("/", $_mob_browser);
              $opera = explode ("Opera", $_mob_browser);
              if(($n95[1]=="4.0 (compatible; MSIE 6.0; Symbian OS; Series 60)")&&($opera[1]==" 8.65 [en]"){
              $_browser[0] = "Nokia N95 (opera 8.65)";
              }
              or is there other s60v3 phones that show the same on opera?

              Comment


                #67
                ban ip range or ip

                PHP Code:
                $getip $_SERVER["REMOTE_ADDR"];
                $banned_ip = array();

                $banned_ip[] = '194.9.94.*';
                $banned_ip[] = '77.105.2.*';

                foreach(
                $banned_ip as $banned)
                {
                $blacked=str_replace('*'''$banned);
                $len=strlen($blacked);
                if (
                $getip==$blacked || substr($getip0$len)==$blacked)
                {
                $_banned_ip=true;
                }
                }

                if(
                $_banned_ip==true){ 
                echo 
                'THIS IP IS BANNED!';
                exit; 

                Advertise your mobile site for FREE with AdTwirl

                Comment


                  #68
                  boss is good ban range like this :

                  77.*.*.*

                  if like my post click:

                  http://coding-talk.com/images/totall...ost_thanks.gif

                  Comment


                    #69
                    <div class='quotetop'>QUOTE (sweetangel @ Mar 7 2009, 10:33 AM) <{POST_SNAPBACK}></div>
                    boss is good ban range like this :

                    77.*.*.*[/b]
                    it would be just
                    Code:
                    77.*
                    and you do unerstand that will ban any one who&#39;s IP starts with 77 ?
                    It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt.
                    ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ !
                    ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.
                    キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

                    Comment


                      #70
                      That is the wildcard character which may be substituted for any of a defined subset of all possible characters

                      This will ban 77.*.*.* the 3 subnos and the range is 77.0.0.0- 77.255.255.255 which will ban 256x256x256=16777216 ips. But 77.105.2.* will ban just a subno and the range is 77.105.2.0- 77.105.2.255 which will ban only 256 ips.

                      Moreover it can be done with htaccess using <deny>

                      Comment


                        #71
                        Like

                        deny from <USER IP>

                        Not always need

                        Code:
                        <Files 404.shtml>
                        order allow,deny
                        allow from all
                        </Files>
                        Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                        Visit: WapMasterz Coming Back Soon!
                        _______
                        SCRIPTS FOR SALE BY SUBZERO
                        Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                        FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                        _______
                        Info & Tips
                        php.net
                        w3schools.com

                        Comment


                          #72
                          gzcompress
                          PHP Code:
                          <?php

                          function miscGzHandler($buf) {
                              
                          $zipRatio 5;
                              
                          $zipDebug 1;

                              if(empty(
                          $buf) || !function_exists('gzcompress') || !isset($_SERVER['HTTP_ACCEPT_ENCODING'])) return $buf;
                              
                          $enc_ar explode(','$_SERVER['HTTP_ACCEPT_ENCODING']);
                              
                          $mayZip false$encoding '';
                              foreach(
                          $enc_ar as $enc) {
                                  
                          $enc trim($enc);
                                  if(
                          'gzip' == $enc || 'x-gzip' == $enc) {
                                      
                          $mayZip true;
                                      
                          $encoding $enc;
                                      break;
                                  }
                              }
                              if(!
                          $mayZip) return $buf;

                              
                          $bufZiped gzcompress($buf$zipRatio);
                              if(
                          $zipDebug) {
                                  
                          $bufLen strlen($buf);
                                  
                          $bufZipedLenstrlen($bufZiped);
                                  
                          $buf .= (== $zipDebug) ? "\n\n<!"."--\n" "\n
                          <pre style='width:15%; border:3px ridge; background-color:white; color:gray; font:xx-small Lucida Console, Courier New; padding:3px; margin:10px;'>\n"
                          ;
                                  
                          $buf .= "HTML content    : ".$bufLen." bytes\n";
                                  
                          $buf .= "Compressed      : ".$bufZipedLen." bytes\n";
                                  
                          $buf .= "GZip level      : ".$zipRatio."\n";
                                  
                          $buf .= "Size difference : ".sprintf("%.1f%%"$bufZipedLen*100/$bufLen)."\n";
                                  
                          $buf .= "Size ratio      : ".sprintf("%.1f"$bufLen/$bufZipedLen)." times\n";
                                  
                          $buf .= (== $zipDebug) ? "--".">\n" "</pre>\n";
                                  
                          $bufZiped gzcompress($buf$zipRatio);
                              }
                              
                          $bufZiped pack('cccccccc',0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00)
                                  .
                          substr($bufZiped0, -4)
                                  .
                          pack('V',crc32($buf))
                                  .
                          pack('V',strlen($buf));
                              
                          header('Content-encoding: '.$encoding);
                              
                          header('Content-length: '.strlen($bufZiped));
                              return 
                          $bufZiped;
                          }

                          ob_start('miscGzHandler');


                          ?>

                          Comment


                            #73
                            PHP Code:
                            function delhtml($str
                            {
                            return 
                            mysql_real_escape_string(htmlspecialchars($str));
                            }

                            if(isset(
                            $_GET)){foreach($_GET as $key=>$value){$_GET[$key]=delhtml($value);}}
                            if(isset(
                            $_POST)){foreach($_POST as $key=>$value){$_POST[$key]=delhtml($value);}}
                            if(isset(
                            $_SESSION)){foreach($_SESSION as $key=>$value){$_SESSION[$key]=delhtml($value);}}
                            if(isset(
                            $_COOKIE)){foreach($_COOKIE as $key=>$value){$_COOKIE[$key]=delhtml($value);}} 

                            Comment


                              #74
                              I got a better way for that code

                              use $_REQUEST

                              One line do all lmao

                              PHP Code:
                              if(isset($_REQUEST)){foreach($_REQUEST as $key=>$value){$_REQUEST[$key]=delhtml($value);}} 
                              PHP Code:
                              function delhtml($str) {
                              return 
                              mysql_real_escape_string(htmlspecialchars($str));
                              }

                              if(isset(
                              $_GET)){foreach($_GET as $key=>$value){$_GET[$key]=delhtml($value);}}
                              if(isset(
                              $_POST)){foreach($_POST as $key=>$value){$_POST[$key]=delhtml($value);}}
                              if(isset(
                              $_SESSION)){foreach($_SESSION as $key=>$value){$_SESSION[$key]=delhtml($value);}}
                              if(isset(
                              $_COOKIE)){foreach($_COOKIE as $key=>$value){$_COOKIE[$key]=delhtml($value);}} 
                              Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                              Visit: WapMasterz Coming Back Soon!
                              _______
                              SCRIPTS FOR SALE BY SUBZERO
                              Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                              FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                              _______
                              Info & Tips
                              php.net
                              w3schools.com

                              Comment


                                #75
                                It gets cookies

                                it do all in one

                                Works on my site


                                The $_REQUEST Variable

                                The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.

                                The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
                                Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                                Visit: WapMasterz Coming Back Soon!
                                _______
                                SCRIPTS FOR SALE BY SUBZERO
                                Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                                FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                                _______
                                Info & Tips
                                php.net
                                w3schools.com

                                Comment

                                Working...
                                X