Initial Commit
This commit is contained in:
28
web/revslider/application/models/curl_model.php
Normal file
28
web/revslider/application/models/curl_model.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Curl_model extends CI_Model {
|
||||
|
||||
/**
|
||||
* Check if Curl available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
||||
public function test() {
|
||||
$test = function_exists('curl_version');
|
||||
return $test;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do request
|
||||
*
|
||||
* @param string url
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public function request($url) {
|
||||
$result = wp_remote_post($url);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
54
web/revslider/application/models/image_model.php
Normal file
54
web/revslider/application/models/image_model.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Nwdthemes Standalone Slider Revolution
|
||||
*
|
||||
* @package StandaloneRevslider
|
||||
* @author Nwdthemes <mail@nwdthemes.com>
|
||||
* @link http://nwdthemes.com/
|
||||
* @copyright Copyright (c) 2015. Nwdthemes
|
||||
* @license http://themeforest.net/licenses/terms/regular
|
||||
*/
|
||||
|
||||
class Image_model extends CI_Model {
|
||||
|
||||
/*
|
||||
* Table name
|
||||
*
|
||||
*/
|
||||
public $table = 'images';
|
||||
|
||||
/**
|
||||
* Get image url
|
||||
*
|
||||
* @param int Id
|
||||
* @return string Image url
|
||||
*/
|
||||
public function getUrl($id) {
|
||||
$image = $this->db->where('id', $id)->get($this->table)->row();
|
||||
return $image ? $image->url : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image ud by url
|
||||
*
|
||||
* @param string Url
|
||||
* @return int Id
|
||||
*/
|
||||
public function getId($url) {
|
||||
$image = $this->db->where('url', $url)->get($this->table)->row();
|
||||
return $image ? $image->id : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new image
|
||||
*
|
||||
* @param string Image
|
||||
* @return int Id
|
||||
*/
|
||||
public function insert($image) {
|
||||
$this->db->set('url', $image)->insert($this->table);
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
|
||||
}
|
||||
10
web/revslider/application/models/index.html
Normal file
10
web/revslider/application/models/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
76
web/revslider/application/models/option_model.php
Normal file
76
web/revslider/application/models/option_model.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Nwdthemes Standalone Slider Revolution
|
||||
*
|
||||
* @package StandaloneRevslider
|
||||
* @author Nwdthemes <mail@nwdthemes.com>
|
||||
* @link http://nwdthemes.com/
|
||||
* @copyright Copyright (c) 2015. Nwdthemes
|
||||
* @license http://themeforest.net/licenses/terms/regular
|
||||
*/
|
||||
|
||||
class Option_model extends CI_Model {
|
||||
|
||||
private $_options = array();
|
||||
|
||||
/*
|
||||
* Table name
|
||||
*
|
||||
*/
|
||||
public $table = 'options';
|
||||
|
||||
/**
|
||||
* Get option by handle
|
||||
*
|
||||
* @param string Handle
|
||||
* @return string Option
|
||||
*/
|
||||
public function get_option($handle) {
|
||||
if (isset($this->_options[$handle])) {
|
||||
$value = $this->_options[$handle];
|
||||
} else {
|
||||
$option = $this->db->where('handle', $handle)->get($this->table)->row();
|
||||
if ($option) {
|
||||
$value = $option->option;
|
||||
$this->_options[$handle] = $value;
|
||||
} else {
|
||||
$value = false;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update option
|
||||
*
|
||||
* @param string Handle
|
||||
* @param string Value
|
||||
*/
|
||||
|
||||
public function update_option($handle, $value) {
|
||||
$value = is_string($value) ? $value : serialize($value);
|
||||
$this->_options[$handle] = $value;
|
||||
$option = $this->db->where('handle', $handle)->get($this->table)->row();
|
||||
$this->db->set('option', $value);
|
||||
if ($option) {
|
||||
$this->db->where('handle', $handle)->update($this->table);
|
||||
} else {
|
||||
$this->db->set('handle', $handle)->insert($this->table);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete option
|
||||
*
|
||||
* @param string Handle
|
||||
*/
|
||||
|
||||
public function delete_option($handle) {
|
||||
if (isset($this->_options[$handle])) {
|
||||
unset($this->_options[$handle]);
|
||||
}
|
||||
$this->db->where('handle', $handle)->delete($this->table);
|
||||
}
|
||||
|
||||
}
|
||||
81
web/revslider/application/models/transient_model.php
Normal file
81
web/revslider/application/models/transient_model.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Nwdthemes Standalone Slider Revolution
|
||||
*
|
||||
* @package StandaloneRevslider
|
||||
* @author Nwdthemes <mail@nwdthemes.com>
|
||||
* @link http://nwdthemes.com/
|
||||
* @copyright Copyright (c) 2015. Nwdthemes
|
||||
* @license http://themeforest.net/licenses/terms/regular
|
||||
*/
|
||||
|
||||
class Transient_model extends CI_Model {
|
||||
|
||||
|
||||
/*
|
||||
* Table name
|
||||
*
|
||||
*/
|
||||
public $table = 'transients';
|
||||
|
||||
/**
|
||||
* Get transient value
|
||||
*
|
||||
* @param string Handle
|
||||
* @return string
|
||||
*/
|
||||
public function get_value($handle) {
|
||||
$value = false;
|
||||
$transient = $this->db->where('handle', $handle)->get($this->table)->row();
|
||||
if ($transient)
|
||||
{
|
||||
if (is_null($transient->expires) || strtotime($transient->expires) > time())
|
||||
{
|
||||
$value = json_decode($transient->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->delete($handle);
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set transient
|
||||
*
|
||||
* @param string Handle
|
||||
* @param string Value
|
||||
* @param int Expires
|
||||
*/
|
||||
public function set($handle, $value, $expires = NULL) {
|
||||
$value = json_encode($value);
|
||||
$transient = $this->db->where('handle', $handle)->get($this->table)->row();
|
||||
$this->db
|
||||
->set('value', $value)
|
||||
->set('expires', $expires);
|
||||
if ($transient)
|
||||
{
|
||||
$this->db
|
||||
->where('handle', $handle)
|
||||
->update($this->table);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db
|
||||
->set('handle', $handle)
|
||||
->insert($this->table);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete transient
|
||||
*
|
||||
* @param string Handle
|
||||
*/
|
||||
public function delete($handle) {
|
||||
$this->db->where('handle', $handle)->delete($this->table);
|
||||
}
|
||||
|
||||
}
|
||||
195
web/revslider/application/models/user_model.php
Normal file
195
web/revslider/application/models/user_model.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
require_once(RS_PLUGIN_PATH . 'includes/globals.class.php');
|
||||
|
||||
/**
|
||||
* Nwdthemes Standalone Slider Revolution
|
||||
*
|
||||
* @package StandaloneRevslider
|
||||
* @author NWDthemes <nwdthemes@gmail.com>
|
||||
* @link http://nwdthemes.com/
|
||||
* @copyright Copyright (c) 2016. NWDthemes
|
||||
* @license http://themeforest.net/licenses/terms/regular
|
||||
*/
|
||||
class User_model extends CI_Model {
|
||||
|
||||
/*
|
||||
* Table name
|
||||
*
|
||||
*/
|
||||
public $table = 'user';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->load->library('SaltCellar');
|
||||
$this->load->library('PasswordStorage');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is admin user exists
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists() {
|
||||
return $this->db->count_all($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user
|
||||
*
|
||||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
public function get($id) {
|
||||
return $this->db->where('id', $id)->get($this->table)->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Login user
|
||||
*
|
||||
* @param string $identity
|
||||
* @param string $password
|
||||
* @return mixed
|
||||
*/
|
||||
public function login($identity, $password) {
|
||||
|
||||
$loginUser = false;
|
||||
if ( empty($identity) || empty($password) ) {
|
||||
return $loginUser;
|
||||
}
|
||||
|
||||
$query = $this->db
|
||||
->where('username', $identity)
|
||||
->or_where('email', $identity)
|
||||
->get( $this->table );
|
||||
|
||||
if ($query->num_rows() > 0) {
|
||||
|
||||
$user = $query->row_array();
|
||||
|
||||
//TODO: remove this condition
|
||||
// password backwards compatiblity
|
||||
if ($password == $this->_decrypt($user['password'], $user)) {
|
||||
$salt = SaltCellar::getSalt(44, 50);
|
||||
$this->db
|
||||
->set('salt', $salt)
|
||||
->set('password', PasswordStorage::create_hash($salt . $password))
|
||||
->where('id', $user['id'])
|
||||
->update($this->table);
|
||||
$user = $this->db
|
||||
->where('id', $user['id'])
|
||||
->get($this->table)
|
||||
->row_array();
|
||||
}
|
||||
|
||||
if (PasswordStorage::verify_password($user['salt'] . $password, $user['password'])) {
|
||||
$loginUser = $user;
|
||||
}
|
||||
}
|
||||
|
||||
return $loginUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check email
|
||||
*
|
||||
* @param string $email
|
||||
* @return mixed
|
||||
*/
|
||||
public function check_email($email) {
|
||||
$check = false;
|
||||
$query = $this->db->where('email', $email)->get( $this->table );
|
||||
if ($query->num_rows() > 0) {
|
||||
$check = $query->row_array();
|
||||
}
|
||||
return $check;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function update($data) {
|
||||
$error = '';
|
||||
if ( ! $data['user_id'] ) {
|
||||
$error = __('No user id provided');
|
||||
} elseif ( ! $data['username'] || ! $data['email']) {
|
||||
$error = __('Username and Email address are required');
|
||||
} elseif ( strlen($data['username']) < 4) {
|
||||
$error = __("Username should be at least 4 characters long");
|
||||
} elseif ( $data['password'] && $data['password'] != $data['confirm_password']) {
|
||||
$error = __("New password don't match confirmed password");
|
||||
} elseif ( $data['password'] && strlen($data['password']) < 4) {
|
||||
$error = __("Password should be at least 4 characters long");
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
|
||||
$user = $this->get($data['user_id']);
|
||||
|
||||
$user['username'] = $data['username'];
|
||||
$user['email'] = $data['email'];
|
||||
|
||||
if ($data['password']) {
|
||||
$salt = SaltCellar::getSalt(44, 50);
|
||||
$user['salt'] = $salt;
|
||||
$user['password'] = PasswordStorage::create_hash($salt . $data['password']);
|
||||
}
|
||||
|
||||
$this->db
|
||||
->set($user)
|
||||
->where('id', $user['id'])
|
||||
->update( $this->table );
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'success' => empty($error),
|
||||
'message' => empty($error) ? __('Account have been updated') : $error
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts the password.
|
||||
*
|
||||
* @deprecated
|
||||
* @param string $password
|
||||
* @param array $user
|
||||
* @return string
|
||||
*/
|
||||
private function _decrypt($password, $user) {
|
||||
$ci = &get_instance();
|
||||
$ci->load->library('encryption');
|
||||
$hash = $this->sha1($user['username'] . $user['salt']);
|
||||
$key = $this->sha1($ci->config->item('encryption_key') . $hash);
|
||||
return $ci->encryption->decrypt($password, array('key' => substr($key, 0, 56)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an SHA1 Hash
|
||||
*
|
||||
* @deprecated
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
private function sha1($str) {
|
||||
if ( ! function_exists('sha1')) {
|
||||
if ( ! function_exists('mhash')) {
|
||||
require_once(BASEPATH.'libraries/Sha1.php');
|
||||
$SH = new CI_SHA;
|
||||
return $SH->generate($str);
|
||||
} else {
|
||||
return bin2hex(mhash(MHASH_SHA1, $str));
|
||||
}
|
||||
} else {
|
||||
return sha1($str);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
164
web/revslider/application/models/wpdb_model.php
Normal file
164
web/revslider/application/models/wpdb_model.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Nwdthemes Standalone Slider Revolution
|
||||
*
|
||||
* @package StandaloneRevslider
|
||||
* @author Nwdthemes <mail@nwdthemes.com>
|
||||
* @link http://nwdthemes.com/
|
||||
* @copyright Copyright (c) 2015. Nwdthemes
|
||||
* @license http://themeforest.net/licenses/terms/regular
|
||||
*/
|
||||
|
||||
class WPDB_model extends CI_Model {
|
||||
|
||||
public $prefix = '';
|
||||
|
||||
public function __construct() {
|
||||
include(APPPATH.'config/database'.EXT);
|
||||
$this->prefix = $db[$active_group]['dbprefix'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query results
|
||||
*
|
||||
* @param string Query
|
||||
* @param string Result format
|
||||
* @return array
|
||||
*/
|
||||
public function get_results($query, $mode = ARRAY_A) {
|
||||
$res = $this->db->query($query);
|
||||
if ( ! is_object($res)) {
|
||||
return false;
|
||||
}
|
||||
return $mode == ARRAY_A ? $res->result_array() : $res->result();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query row
|
||||
*
|
||||
* @param string Query
|
||||
* @param string Result format
|
||||
* @return array
|
||||
*/
|
||||
public function get_row($query, $mode = false) {
|
||||
$res = $this->db->query($query);
|
||||
return $mode == ARRAY_A ? $res->row_array() : $res->row();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert row
|
||||
*
|
||||
* @param string Table name
|
||||
* @param array Data
|
||||
* @return int
|
||||
*/
|
||||
|
||||
public function insert($table, $data = array()) {
|
||||
$this->db->insert($table, $data);
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update row
|
||||
*
|
||||
* @param string Table name
|
||||
* @param array Data
|
||||
* @param array Where
|
||||
*/
|
||||
|
||||
public function update($table, $data = array(), $where) {
|
||||
return $this->db
|
||||
->set($data)
|
||||
->where($where)
|
||||
->update($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete row
|
||||
*
|
||||
* @param string Table name
|
||||
* @param array Data
|
||||
* @param array Where
|
||||
*/
|
||||
|
||||
public function delete($table, $where) {
|
||||
return $this->db
|
||||
->where($where)
|
||||
->delete($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare query
|
||||
*
|
||||
* @param string Query
|
||||
* @param mixed Args
|
||||
* @return array
|
||||
*/
|
||||
public function prepare($query, $args) {
|
||||
$args = func_get_args();
|
||||
array_shift( $args );
|
||||
// If args were passed as an array (as in vsprintf), move them up
|
||||
if ( isset( $args[0] ) && is_array($args[0]) )
|
||||
$args = $args[0];
|
||||
$query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it
|
||||
$query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting
|
||||
$query = preg_replace( '|(?<!%)%f|' , '%F', $query ); // Force floats to be locale unaware
|
||||
$query = preg_replace( '|(?<!%)%s|', "%s", $query ); // quote the strings, avoiding escaped strings like %%s
|
||||
array_walk( $args, array( $this, 'escape_by_ref' ) );
|
||||
|
||||
return @vsprintf( $query, $args );
|
||||
}
|
||||
|
||||
public function escape_by_ref(&$arg) {
|
||||
if( (string)(int)$arg != $arg) $arg = $this->db->escape($arg);
|
||||
}
|
||||
|
||||
public function tables() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable debug mode
|
||||
*
|
||||
* @param boolean $isDebug
|
||||
* @return boolean
|
||||
*/
|
||||
|
||||
public function suppress_errors($isDebug = null) {
|
||||
$savedState = $this->db->db_debug;
|
||||
if (is_null($isDebug)) {
|
||||
$this->db->db_debug = ! $this->db->db_debug;
|
||||
} else {
|
||||
$this->db->db_debug = $isDebug;
|
||||
}
|
||||
return $savedState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run SQL query
|
||||
*
|
||||
* @param string $query
|
||||
*/
|
||||
|
||||
public function query($query) {
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get var from query
|
||||
*
|
||||
* @param string $query
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function get_var($query) {
|
||||
$res = $this->db->query($query);
|
||||
if (is_object($res)) {
|
||||
$row = $res->row_array();
|
||||
$value = reset($row);
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user