Skip to content

Instantly share code, notes, and snippets.

@dimak57
dimak57 / gist:5597584
Created May 17, 2013 07:52
Batch rename images in folder
<?php
$folder = 'img/';
$images = glob($folder . "*");
$i = 1;
foreach($images as $img) {
// echo $img . '<br>';
rename($img, $folder . $i . '.jpg');
$i++;
<?php die("Access denied!");
/**
* ---------------- DO NOT UPLOAD THIS FILE TO LIVE SERVER ------------------------
* Laravel IDE Helper <http://LaravelBook.com>
* Implements code completion for Laravel 4 in JetBrains PhpStorm and SublimeText 2
* --------------------------------------------------------------------------------
*/
/**
* @method static bool check() Determine if the current user is authenticated.
@dimak57
dimak57 / user.php
Created February 3, 2013 05:48
Simple User Login Class CodeIgniter
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* statuses:
* 0 - banned
* 1 - member
* 2 - moderator
* 3 - admin
*
*
@dimak57
dimak57 / v_home.php
Created November 11, 2012 07:07
mockup twitter bootstrap page for CI
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="<?=base_url('theme/css/bootstrap.min.css')?>" rel="stylesheet" media="screen">
<link href="<?=base_url('theme/css/site.css')?>" rel="stylesheet" media="screen">
</head>
<body>
<div id="wrap">
@dimak57
dimak57 / msearch.php
Created October 30, 2012 10:35
Codeigniter. Return each category for many posts.
public function get_posts($start=0)
{
$num = $this->get_value('numnews');
if($num->numnews == FALSE){
$num->numnews = 10;
}
return $this->db->select('post.*, GROUP_CONCAT(DISTINCT category.cat_name SEPARATOR ", ") AS categories', FALSE)
->join('postcat', 'post.id = postcat.postID', 'left')
->join('category', 'postcat.catID = category.categID', 'left')
@dimak57
dimak57 / pfunc.php
Created May 11, 2012 09:05
translit function (Транслит)
public function translit($string) {
$zamena = array(
"А" => "A", "а" => "a", "," => "",
"Б" => "B", "б" => "b", "(" => "",
"В" => "V", "в" => "v", ")" => "",
"Г" => "G", "г" => "g", "#" => "",
"Д" => "D", "д" => "d", "@" => "",
"Е" => "E", "е" => "e", "%" => "",
"Ё" => "YO", "ё" => "yo", "&" => "",
@dimak57
dimak57 / Ion Auth config for HMVC CodeIgniter
Created January 10, 2012 06:47
Ion Auth config for HMVC CodeIgniter
$this->ci->load->config('users/ion_auth', TRUE);
$this->ci->load->library('email');
$this->ci->load->library('session');
$this->ci->lang->load('users/ion_auth');
$this->ci->load->model('users/ion_auth_model');