Skip to content

Instantly share code, notes, and snippets.

@jokosusilo
jokosusilo / Image Upload Preview
Created April 14, 2015 06:01
Preview image setelah memilih file gambar
<!DOCTYPE html>
<!-- Based on HTML5 Bones | http://html5bones.com -->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page Title</title>
<meta name="description" content="">
<!-- Mobile-friendly viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Style sheet link -->
<!-- view -->
<input type="file" class="form-control" id="image" name="image" required>
<?php
// Controller
// fungsi insert
public function store(){
$config['upload_path'] = './assets/produk/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '20000';
@jokosusilo
jokosusilo / ScrollDown.js
Created August 11, 2014 04:53
Scroll Down
$(document).ready(function() {
var track_load = 0; //total loaded record group(s)
var loading = false; //to prevents multipal ajax loads
var total_groups = 10; //total record group(s)
$('#results').load("autoload_process.php", {'group_no':track_load}, function() {track_load++;}); //load first group
$(window).scroll(function() { //detect page scroll
if($(window).scrollTop() + $(window).height() == $(document).height()) //user scrolled to bottom of the page?
{
if(track_load <= total_groups && loading==false) //there's more data to load
{
<?php
class WebUser extends CWebUser {
public function checkAccess($operation, $params = array()) {
if (empty($this->id)) {
return false;
}
$role = $this->getState("roles");
if ($role === 'admin') {
return true;
<?php
/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
class UserIdentity extends CUserIdentity
{
private $id;
<?php
// Load eloquent
require 'vendor/autoload.php';
// Setting eloquent
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;