PASTEBIN
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
PASTEBIN
create new paste
trending pastes
sign up
login
my settings
my profile
Public Pastes
Untitled
2 sec ago
Using HTML in Rail...
5 sec ago
Lightbox that work...
11 sec ago
How to create a cu...
17 sec ago
Untitled
PHP | 21 sec ago
Getting the respon...
24 sec ago
Ghost Rider Spirit...
26 sec ago
How do you disable...
30 sec ago
New Paste
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class EXT_Loader extends CI_Loader { private $apppath = NULL; function EXT_Loader() { parent::CI_Loader(); $this->apppath = APPPATH; } function model($model, $name = '', $db_conn = FALSE, $apppath = NULL) { if (is_array($model)) { foreach($model as $alias => $babe) { $alias = is_numeric($alias) ? '' : $alias; $this->model($babe, $alias); } return; } if ($model == '') { return; } // Is the model in a sub-folder? If so, parse out the filename and path. if (strpos($model, '/') === FALSE) { $path = ''; } else { $x = explode('/', $model); $model = end($x); unset($x[count($x)-1]); $path = implode('/', $x).'/'; } if ($name == '') { $name = $model; } if (in_array($name, $this->_ci_models, TRUE)) { return; } $CI =& get_instance(); if (isset($CI->$name)) { show_error('The model name you are loading is the name of a resource that is already being used: '.$name); } $model = strtolower($model); /* added line for dynamic app path */ if($apppath !== NULL){ $this->apppath = $apppath; } // changed var below for dynamic app path if ( ! file_exists($this->apppath.'models/'.$path.$model.EXT)) { show_error('Unable to locate the model you have specified: '.$model); } if ($db_conn !== FALSE AND ! class_exists('CI_DB')) { if ($db_conn === TRUE) $db_conn = ''; $CI->load->database($db_conn, FALSE, TRUE); } if ( ! class_exists('Model')) { load_class('Model', FALSE); } require_once($this->apppath.'models/'.$path.$model.EXT); $model = ucfirst($model); $CI->$name = new $model(); $CI->$name->_assign_libraries(); $this->_ci_models[] = $name; } function library($library = '', $params = NULL, $object_name = NULL, $apppath = NULL) { if ($library == '') { return FALSE; } if ( ! is_null($params) AND ! is_array($params)) { $params = NULL; } if($apppath !== NULL){ $this->apppath = $apppath; } if (is_array($library)) { foreach ($library as $class) { $this->_ci_load_class($class, $params, $object_name); } } else { $this->_ci_load_class($library, $params, $object_name); } $this->_ci_assign_to_models(); } function _ci_load_class($class, $params = NULL, $object_name = NULL) { // Get the class name, and while we're at it trim any slashes. // The directory path can be included as part of the class name, // but we don't want a leading slash $class = str_replace(EXT, '', trim($class, '/')); // Was the path included with the class name? // We look for a slash to determine this $subdir = ''; if (strpos($class, '/') !== FALSE) { // explode the path so we can separate the filename from the path $x = explode('/', $class); // Reset the $class variable now that we know the actual filename $class = end($x); // Kill the filename from the array unset($x[count($x)-1]); // Glue the path back together, sans filename $subdir = implode($x, '/').'/'; } // We'll test for both lowercase and capitalized versions of the file name foreach (array(ucfirst($class), strtolower($class)) as $class) { $subclass = $this->apppath.'libraries/'.$subdir.config_item('subclass_prefix').$class.EXT; // Is this a class extension request? if (file_exists($subclass)) { $baseclass = BASEPATH.'libraries/'.ucfirst($class).EXT; if ( ! file_exists($baseclass)) { log_message('error', "Unable to load the requested class: ".$class); show_error("Unable to load the requested class: ".$class); } // Safety: Was the class already loaded by a previous call? if (in_array($subclass, $this->_ci_loaded_files)) { // Before we deem this to be a duplicate request, let's see // if a custom object name is being supplied. If so, we'll // return a new instance of the object if ( ! is_null($object_name)) { $CI =& get_instance(); if ( ! isset($CI->$object_name)) { return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); } } $is_duplicate = TRUE; log_message('debug', $class." class already loaded. Second attempt ignored."); return; } include_once($baseclass); include_once($subclass); $this->_ci_loaded_files[] = $subclass; return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); } // Lets search for the requested library file and load it. $is_duplicate = FALSE; for ($i = 1; $i < 3; $i++) { $path = ($i % 2) ? $this->apppath : BASEPATH; $filepath = $path.'libraries/'.$subdir.$class.EXT; // Does the file exist? No? Bummer... if ( ! file_exists($filepath)) { continue; } // Safety: Was the class already loaded by a previous call? if (in_array($filepath, $this->_ci_loaded_files)) { // Before we deem this to be a duplicate request, let's see // if a custom object name is being supplied. If so, we'll // return a new instance of the object if ( ! is_null($object_name)) { $CI =& get_instance(); if ( ! isset($CI->$object_name)) { return $this->_ci_init_class($class, '', $params, $object_name); } } $is_duplicate = TRUE; log_message('debug', $class." class already loaded. Second attempt ignored."); return; } include_once($filepath); $this->_ci_loaded_files[] = $filepath; return $this->_ci_init_class($class, '', $params, $object_name); } } // END FOREACH // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified? if ($subdir == '') { $path = strtolower($class).'/'.$class; return $this->_ci_load_class($path, $params); } // If we got this far we were unable to find the requested class. // We do not issue errors if the load call failed due to a duplicate request if ($is_duplicate == FALSE) { log_message('error', "Unable to load the requested class: ".$class); show_error("Unable to load the requested class: ".$class); } } function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL) { // Is there an associated config file for this class? if ($config === NULL) { // We test for both uppercase and lowercase, for servers that // are case-sensitive with regard to file names if (file_exists($this->apppath.'config/'.strtolower($class).EXT)) { include_once($this->apppath.'config/'.strtolower($class).EXT); } elseif (file_exists($this->apppath.'config/'.ucfirst(strtolower($class)).EXT)) { include_once($this->apppath.'config/'.ucfirst(strtolower($class)).EXT); } } if ($prefix == '') { if (class_exists('CI_'.$class)) { $name = 'CI_'.$class; } elseif (class_exists(config_item('subclass_prefix').$class)) { $name = config_item('subclass_prefix').$class; } else { $name = $class; } } else { $name = $prefix.$class; } // Is the class name valid? if ( ! class_exists($name)) { log_message('error', "Non-existent class: ".$name); show_error("Non-existent class: ".$class); } // Set the variable name we will assign the class to // Was a custom class name supplied? If so we'll use it $class = strtolower($class); if (is_null($object_name)) { $classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class]; } else { $classvar = $object_name; } // Save the class name and object name $this->_ci_classes[$class] = $classvar; // Instantiate the class $CI =& get_instance(); if ($config !== NULL) { $CI->$classvar = new $name($config); } else { $CI->$classvar = new $name; } } function _ci_autoloader() { include_once(APPPATH.'config/autoload'.EXT); if ( ! isset($autoload)) { return FALSE; } // Load any custom config file if (count($autoload['config']) > 0) { $CI =& get_instance(); foreach ($autoload['config'] as $key => $val) { $CI->config->load($val); } } // Autoload plugins, helpers and languages foreach (array('helper', 'plugin', 'language') as $type) { if (isset($autoload[$type]) AND count($autoload[$type]) > 0) { $this->$type($autoload[$type]); } } // A little tweak to remain backward compatible // The $autoload['core'] item was deprecated if ( ! isset($autoload['libraries'])) { $autoload['libraries'] = $autoload['core']; } // Load libraries if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0) { // Load the database driver. if (in_array('database', $autoload['libraries'])) { $this->database(); $autoload['libraries'] = array_diff($autoload['libraries'], array('database')); } // Load scaffolding if (in_array('scaffolding', $autoload['libraries'])) { $this->scaffolding(); $autoload['libraries'] = array_diff($autoload['libraries'], array('scaffolding')); } // Load all other libraries foreach ($autoload['libraries'] as $alias => $item) { $alias = is_numeric($alias) ? NULL : $alias; $this->library($item, NULL, $alias); } } // Autoload models if (isset($autoload['model'])) { $this->model($autoload['model']); } } }
Optional Paste Settings
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
HTML 5
Java
JavaScript
Lua
None
Perl
PHP
Python
Rails
-------------
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
ActionScript
ActionScript 3
Ada
ALGOL 68
Apache Log
AppleScript
APT Sources
ASM (NASM)
ASP
autoconf
Autohotkey
AutoIt
Avisynth
Awk
BASCOM AVR
Bash
Basic4GL
BibTeX
Blitz Basic
BNF
BOO
BrainFuck
C
C for Macs
C Intermediate Language
C#
C++
C++ (with QT extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
ChaiScript
Clojure
Clone C
Clone C++
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
DCS
Delphi
Delphi Prism (Oxygene)
Diff
DIV
DOS
DOT
E
ECMAScript
Eiffel
Email
EPC
Erlang
F#
Falcon
FO Language
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
Game Maker
GDB
Genero
Genie
GetText
Go
Groovy
GwBasic
Haskell
HicEst
HQ9 Plus
HTML
HTML 5
Icon
IDL
INI file
Inno Script
INTERCAL
IO
J
Java
Java 5
JavaScript
jQuery
KiXtart
Latex
Liberty BASIC
Linden Scripting
Lisp
LLVM
Loco Basic
Logtalk
LOL Code
Lotus Formulas
Lotus Script
LScript
Lua
M68000 Assembler
MagikSF
Make
MapBasic
MatLab
mIRC
MIX Assembler
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MPASM
MXML
MySQL
newLISP
None
NullSoft Installer
Oberon 2
Objeck Programming Langua
Objective C
OCalm Brief
OCaml
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
Pascal
PAWN
PCRE
Per
Perl
Perl 6
PHP
PHP Brief
Pic 16
Pike
Pixel Bender
PL/SQL
PostgreSQL
POV-Ray
Power Shell
PowerBuilder
ProFTPd
Progress
Prolog
Properties
ProvideX
PureBasic
PyCon
Python
q/kdb+
QBasic
R
Rails
REBOL
REG
Robots
RPM Spec
Ruby
Ruby Gnuplot
SAS
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
SQL
SystemVerilog
T-SQL
TCL
Tera Term
thinBasic
TypoScript
Unicon
UnrealScript
Vala
VB.NET
VeriLog
VHDL
VIM
Visual Pro Log
VisualBasic
VisualFoxPro
WhiteSpace
WHOIS
Winbatch
XBasic
XML
Xorg Config
XPP
YAML
Z80 Assembler
ZXBasic
Paste Expiration:
Never
10 Minutes
1 Hour
1 Day
1 Month
Paste Exposure:
Public
Unlisted
Private (members only)
Paste Name / Title:
Hello
Guest
Sign Up
or
Login
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login