Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- /* Author : Suhendra Y Putra */
- /* Email : suhendra.yohana@gmail.com */
- /* Url : http://suhendrayphanaputra.wordpress.com/ */
- class Ezyupdater {
- protected $CI;
- private $localVersion;
- private $remoteVersion;
- // We'll use a constructor, as you can't directly call a function
- // from a property definition.
- // https://www.codeigniter.com/user_guide/general/creating_libraries.html
- public function __construct()
- {
- // Assign the CodeIgniter super-object
- $this->CI =& get_instance();
- $this->CI->load->helper('url');
- $this->CI->load->helper('file');
- // Server cache
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache");
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- }
- public function __get($property) {
- if (property_exists($this, $property)) {
- return $this->$property;
- }
- }
- public function __set($property, $value) {
- if (property_exists($this, $property)) {
- $this->$property = $value;
- }
- }
- public function doUpdate(){
- shell_exec("git pull origin master");
- }
- public function checkUpdate($name)
- {
- $file = ($name=='local') ? $this->localVersion : $this->remoteVersion.'?r='.rand(1,1000);
- $handle = fopen($file,'r');
- $readLines = file($file);
- $lineCounts = count($readLines);
- if ($handle){
- $currentVersion = $readLines[$lineCounts-1];
- fclose($handle);
- }
- return $currentVersion;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement