working on it ...

Filters

Explore Public Snippets

Sort by

Found 60k snippets

    public by azazqadir modified Tuesday at 10:46:45 AM  58  0  3  1

    CDN integration in Yii2 App

    How to integrate CloudwaysCDN with Yii2 applications: https://www.cloudways.com/blog/cdn-in-yii2/
    // ...
    
    'components' => [
    
       // ...
    
    'cdn' => [
                'class' => '\yii2cdn\Cdn',
                'baseUrl' => defined ('YII2CDN_OFFLINE')
                    ? 'http://localhost/yii2/cdn'
                    : '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn',
                'basePath' => dirname(__DIR__, 2) . '/cdn',
                'components' => [
                    'font-awesome' => [
                        'css' => [
                            [
                                // local version
                                'font-awesome.min.css',
                                // cdn version
                                '@cdn' => '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn/font-awesome/css/font-awesome.min.css',
                            ]
                        ]
                    ]
                ],
            ],
     // ...
    
    ],
    
    // ...

    public by AbhishekGhosh modified Oct 11, 2017  53  1  1  0

    ob flush example

    ob flush example: ob_flush.php
    <?php
    
    /*
    	== ob_end_flush() ==
    	Flush (send) the output buffer and turn off output buffering
    
    	== ob_end_clean() ==
    	Clean (erase) the output buffer and turn off output buffering
    
    	== ob_get_contents() ==
    	Return the contents of the output buffer
    */
    
    
    # The following two functions result in the same output.
    
    function output_some_html_with_var() {
    	ob_start();
    	?>
    	<p>This is a paragraph echoed from a variable.</p>
    	<?php
    	$para = ob_get_contents();
    	ob_end_clean();
    	echo $para;
    }
    
    function output_some_html_with_end_flush() {
    	ob_start();
    	?>
    	<p>This is a paragraph sent with ob_end_flush.</p>
    	<?php
    	ob_end_flush();
    }
    
    output_some_html_with_var();
    
    output_some_html_with_end_flush();
    
    /*
    	If you want to return the contents of ob_start()
    	you should store ob_get_contents() into a variable,
    	then call ob_end_clean(), and then return the variable.
    */
    
    function return_some_html_with_var() {
    	ob_start();
    	?>
    	<p>This is a paragraph being stored into a variable and returned.</p>
    	<?php
    	$para = ob_get_contents();
    	ob_end_clean();
    	return $para;
    }
    
    echo return_some_html_with_var();
    
    echo '<a style="text-decoration:none;" href="http://php.net/manual/en/function.ob-start.php">See the ob_start documentiation for more info</a>';
    
    

    public by AbhishekGhosh modified Jun 8, 2017  32  0  1  0

    GEO IP TEST PHP Script

    GEO IP TEST PHP Script: geoip.php
    <html>
    <body>
    <?php
    
    $geoip_country_code = getenv(GEOIP_COUNTRY_CODE);
    $geoip_country_name = getenv(GEOIP_COUNTRY_NAME);
    $geoip_region = getenv(GEOIP_REGION);
    $geoip_city = getenv(GEOIP_CITY);
    $geoip_postal_code = getenv(GEOIP_POSTAL_CODE);
    $geoip_latitude = getenv(GEOIP_LATITUDE);
    $geoip_longitude = getenv(GEOIP_LONGITUDE);
    
    
    echo 'Country code: '.$geoip_country_code.'<br>';
    echo 'Country name: '.$geoip_country_name.'<br>';
    echo 'Region: '.$geoip_region.'<br>';
    echo 'City: '.$geoip_city.'<br>';
    echo 'Postal code: '.$geoip_postal_code.'<br>';
    echo 'Latitude: '.$geoip_latitude.'<br>';
    echo 'Longitude: '.$geoip_longitude.'<br>';
    
    ?>
    </body>
    </html>
    
    

    public by AbhishekGhosh modified May 26, 2017  37  0  1  0

    nginx php 7.1 default

    nginx php 7.1 default: default
    server {
        listen 80;
        listen [::]:80;
    
        server_name localhost;
    
        access_log /var/log/access.log;
        error_log /var/log/error.log;
    
        root /usr/share/nginx/html;
        index index.php;
    
        location / {
            try_files $uri $uri/ /index.php?$args;
        }
    
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/run/php/php7.1-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
        }
    }
    
    

    public by vnhgroup4m modified May 22, 2017  232  0  4  0

    update wp

    update wp
    php
    $wpdb->update('usertb', array('xu'=>$xuThang,'RemainMoney'=>$tienThang ,'RemainTime'=>$newTime) ,array('FirstName'=>$username)); // cộng tiền gỡ 
    

    public by JavierSalazar modified Mar 30, 2017  1162  7  5  0

    Clonar registros en mysql

    Si necesitas una función para clonar registros, aquí tienes unas. La idea es sencilla: usar SQL para clonar un registro. En esencia es algo así: INSERT INTO tabla (SELECT * FROM tabla WHERE id=..) El problema es que la SQL anterior no funciona si tienes un campo clave (99% de las tablas, o un campo único). Así que toca refinar mas la funció
    php
    <?php
    function mysql_clonar_registro ( $tabla, $clave ) {
    
       // limpieza parámetros
       $tabla= mysql_real_escape_string($tabla);
       $clave= mysql_real_escape_string($clave);
    
       // obtener lista de campos, no únicos
       $rsCampos = mysql_query("SHOW COLUMNS FROM $tabla");
       $campos= array();
       $campoClave ="";
       while ( $campo = mysql_fetch_array($rsCampos) ){
    
           if ( $campo["Key"] == "PRI" ){
               $campoClave = $campo[0];
           }
           $campos[] =  $campo["Key"] == "PRI" || $campo["Key"] == "UNI" ? "NULL":    $campo[0];
       }
       mysql_free_result ( $rsCampos );
    
       // clonar el registro mediante una SQL
       if ( $campoClave && count($campos)>0 ) {
           $SQL = sprintf( "INSERT INTO $tabla ( SELECT %s FROM $tabla WHERE %s='%s' )",
               implode(",",$campos),
               $campoClave,
               $clave );
           mysql_query ($SQL);
           return mysql_affected_rows();
       }
       return false;
    }   
    ?>            

    public by JavierSalazar modified Feb 23, 2017  5702  1  4  0

    Llenar un SELECT OPTION con PHP con info de la BD

    Llenar un SELECT OPTION con PHP con info de la BD
    php
    // $ctlTipoProveedor es una clase que obtiene sus datos desde la bd
    <?php 
        foreach ($ctlTipoProveedor->listarTodos($link) as $k) {
          if ($k->getId() == $proveedor->getTipoProveedor()){
            echo "<option value=".$k->getId()."' selected>Proveedor ".$k->getNombre()."</option>";
          }
          else
          {
            echo "<option value=".$k->getId()."'>Proveedor ".$k->getNombre()."</option>";
          }
        }
    ?>                        

    public by bhavinshah modified Jan 28, 2017  2271  1  4  0

    pre

    PHP
    echo '<pre>';print_r();die("deaD");

    public by kbudylov modified Jan 26, 2017  1747  14  5  0

    Yii2 $form->field

    <?= $form->field($model,'field',[
      //'template' => '{input}',
      //'options' => [
        //'class' => ''
      //]
    ])->textField([
      //'class' => ''
    ]) ?>

    public by Watson modified Jan 20, 2017  2242  1  4  1

    simple Generator duplicate classes CSS

    		<?php
    		if(isset($_POST['submit'])){
    			$count = $_POST['count'];
    			$shag = $_POST['shag'];
    			$prefix = $_POST['prefix'];
    			$postfix = $_POST['postfix'];
    			$attribut = $_POST['attribut'];
    			$znachenie = $_POST['znachenie'];
    		}
    		function rasschet($count, $shag, $prefix, $postfix, $attribut, $znachenie){
    			$html = '';
    			for($i = 0; $i<=$count; $i++){
    				if ($shag != ''){
    					if($i%$shag == 0){
    						$html .= ".".$prefix.$i.$postfix." { ".$attribut.": ".$i.$znachenie.";}<br/>";
    					}
    				}
    			}
    			echo $html;
    		}
    
    		?>
    		<!DOCTYPE html>
    		<html lang="ru">
    		<head>
    			<meta charset="UTF-8">
    			<title>simple Generator duplicate classes CSS</title>
    		</head>
    		<body>
    			<div class="container">
    				<div class="row">
    					<div class="page-header">
    						<h2>Generator duplicate CSS .class {attr: value;}</h2>
    					</div>
    				</div>
    				<div class="row">
    				<div class="panel-group"><div id="examp" class="panel panel-success"><div class="panel-heading"><a data-toggle="collapse" href="#collapse0" class="btn btn-primary"> <i class="indicator glyphicon glyphicon-collapse-down"></i> Example</a></div><div id="collapse0" class="panel-collapse collapse "><div class="panel-body">
    					<div class="col-sm-6">
    											<div class="panel panel-primary">
    							<div class="panel-heading"><h4>example input:</h4></div>
    							<div class="panel-body">
    							max volume : 25<br/>
    							step: 5<br/>
    							prefix : max_w<br/>
    							postfix : p<br/>
    							attribute class : max-width<br/>
    							units : %
    					</div>
    				</div>
    					</div>
    					<div class="col-sm-6">
    						<div class="panel panel-primary">
    							<div class="panel-heading"><h4>example out:</h4></div>
    							<div class="panel-body">
    							<code>.max_w0p { max-width: 0%;}<br/>
    							.max_w5p { max-width: 5%;}<br/>
    							.max_w10p { max-width: 10%;}<br/>
    							.max_w15p { max-width: 15%;}<br/>
    							.max_w20p { max-width: 20%;}<br/>
    							.max_w25p { max-width: 25%;}</code>
    						</div>
    						</div>
    					</div>
    					</div></div></div></div>
    				</div>
    				<div class="row">
    					<div class="col-md-6">
    						<div class="thumbnail">
    							<form action="service_css.php" method="post">
    								<div class="form-group"><input type="text" name="count" value="" placeholder="max volume attribute of class" class="form-control"></div>
    								<div class="form-group"><input type="text" name="shag" value="" placeholder="step volume" class="form-control"></div>
    								<div class="form-group"><input type="text" name="prefix" value="" placeholder="prefix of name css class" class="form-control"></div>
    								<div class="form-group"><input type="text" name="postfix" value="" placeholder="postfix of name css class" class="form-control"></div>
    								<div class="form-group"><input type="text" name="attribut" value="" placeholder="attribute class" class="form-control"></div>
    								<div class="form-group"><input type="text" name="znachenie" value="" placeholder="units: em, rem, px, pt or %" class="form-control"></div>
    								<div class="form-group"><input type="submit" name="submit" value="Submit" class="btn btn-success btn-block"></div>
    							</form>
    						</div>
    					</div>
    					<div class="col-md-6">
    						<div class="thumbnail">
    							<?php 
    //echo $html;
    							rasschet($count, $shag, $prefix, $postfix, $attribut, $znachenie);
    							?>
    						</div>
    					</div>
    				</div>
    			</div>
    
    
    			<!-- Latest compiled and minified CSS & JS -->
    			<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    			<script src="//code.jquery.com/jquery.js"></script>
    			<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>	
    			<script>
    function toggleChevron(e) {
        $(e.target)
            .prev('.panel-heading')
            .find("i.indicator")
            .toggleClass('glyphicon-collapse-down glyphicon-collapse-up');
    }
    $('#examp').on('hidden.bs.collapse', toggleChevron);
    $('#examp').on('shown.bs.collapse', toggleChevron);
    			</script>
    		</body>
    		</html>            
    • Public Snippets
    • Channels Snippets