Skip to content

Commit

Permalink
Fix for Version 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cskaza committed Oct 6, 2016
1 parent 120ad54 commit b786f46
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 29 deletions.
51 changes: 48 additions & 3 deletions cszcms/models/Csz_admin_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ function __construct() {
$this->load->model('Csz_model');
$this->load->database();
}


/**
* Load Config
*
* Function for load settings from database
*
* @return object or FALSE
*/
public function load_config() {
$this->db->limit(1, 0);
$query = $this->db->get('settings');
Expand All @@ -39,14 +46,26 @@ public function getLatestVersion($xml_url = '') {
if (!$xml_url){
$xml_url = 'https://www.cszcms.com/downloads/lastest_version.xml';
}
$xml = simplexml_load_file($xml_url);
if($this->Csz_model->is_url_exist($xml_url) !== FALSE){
$xml = simplexml_load_file($xml_url);
}else{
$xml = FALSE;
}
if($xml !== FALSE){
return $xml;
}else{
return FALSE;
}
}

/**
* Set session version
*
* Function for set version into session
*
* @param string $xml_url xml url file
* @return string
*/
public function setSessionLastVer($xml_url) {
if(!$this->session->userdata('cszcms_lastver')){
$xml = $this->getLatestVersion($xml_url);
Expand All @@ -64,7 +83,16 @@ public function setSessionLastVer($xml_url) {
}
return $xml_version;
}


/**
* Check version update
*
* Function for check version for update
*
* @param string $cur_txt current version
* @param string $xml_url xml url file
* @return string or false
*/
public function chkVerUpdate($cur_txt, $xml_url = '') {
$cur_r = array();
$cur_xml = explode(' ', $cur_txt);
Expand All @@ -91,6 +119,15 @@ public function chkVerUpdate($cur_txt, $xml_url = '') {
}
}

/**
* Find next version number
*
* Function for check version for update
*
* @param string $cur_txt current version
* @param string $xml_url xml url file
* @return string or false
*/
public function findNextVersion($cur_txt, $xml_url = '') {
/* sub version is limit x.9.9 */
$cur_r = array();
Expand Down Expand Up @@ -145,6 +182,14 @@ public function getCurPages() {
return $pageURL;
}

/**
* Count table
*
* Function for count in the table
*
* @param string $table DB table
* @return int
*/
public function countTable($table) {
return $this->db->count_all($table);
}
Expand Down
83 changes: 57 additions & 26 deletions cszcms/models/Csz_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,24 @@ function __construct() {
parent::__construct();
$this->load->database();
}


/**
* Get Version From url
*
* Function for get current version from xml url
*
* @param string $xml_url xml url file
* @return string or FALSE
*/
public function getVersion($xml_url = '') {
if (!$xml_url) {
$xml_file = BASE_URL . '/version.xml';
$xml_url = BASE_URL . '/version.xml';
}
$xml = simplexml_load_file($xml_file);
if($this->is_url_exist($xml_url) !== FALSE){
$xml = simplexml_load_file($xml_url);
}else{
$xml = FALSE;
}
if ($xml !== FALSE && $xml->version) {
if ($xml->release == 'beta') {
$beta = ' Beta';
Expand Down Expand Up @@ -475,32 +487,34 @@ public function addWidgetToHTML($content, $wid_name) {
$html = '<div class="panel panel-default">
<div class="panel-heading"><b>'.$getWidget->widget_name.'</b></div>
<div class="panel-body">';
$xml = simplexml_load_file($getWidget->xml_url);
if($xml !== FALSE){
if($xml->plugin[0]->null == 0){
$i = 1;
foreach ($xml->plugin[0]->item as $item) {
$html.= '<div class="row">
<div class="col-md-3">
<a href="'.$item->sub_url.'" title="'.$item->title.'">
<img class="img-responsive img-thumbnail" src="'.$item->photo.'" alt="'.$item->title.'">
</a>
</div>
<div class="col-md-9">
<a href="'.$item->sub_url.'" title="'.$item->title.'"><h4>'.$item->title.'</h4></a><br>
<p>'.$item->short_desc.'</p>
</div>
</div><hr>';
if($i == $getWidget->limit_view){
break;
if($this->is_url_exist($getWidget->xml_url) !== FALSE){
$xml = simplexml_load_file($getWidget->xml_url);
if($xml !== FALSE){
if($xml->plugin[0]->null == 0){
$i = 1;
foreach ($xml->plugin[0]->item as $item) {
$html.= '<div class="row">
<div class="col-md-3">
<a href="'.$item->sub_url.'" title="'.$item->title.'">
<img class="img-responsive img-thumbnail" src="'.$item->photo.'" alt="'.$item->title.'">
</a>
</div>
<div class="col-md-9">
<a href="'.$item->sub_url.'" title="'.$item->title.'"><h4>'.$item->title.'</h4></a><br>
<p>'.$item->short_desc.'</p>
</div>
</div><hr>';
if($i == $getWidget->limit_view){
break;
}
$i++;
}
$i++;
}else{
$html.= '<h4 class="error">'.$this->getLabelLang('shop_notfound').'</h4>';
}
}else{
$html.= '<h4 class="error">'.$this->getLabelLang('shop_notfound').'</h4>';
$html.= '</div>
<div class="panel-footer text-right"><a href="'.$xml->plugin[0]->main_url.'" class="btn btn-primary btn-sm">'.$this->getLabelLang('article_readmore_text').'</a></div>';
}
$html.= '</div>
<div class="panel-footer text-right"><a href="'.$xml->plugin[0]->main_url.'" class="btn btn-primary btn-sm">'.$this->getLabelLang('article_readmore_text').'</a></div>';
}
$html.= '</div>';
$content = str_replace('[?]{=widget:' . $getWidget->widget_name . '}[?]', $html, $content);
Expand Down Expand Up @@ -949,4 +963,21 @@ public function sendEmail($to_email, $subject, $message, $from_email, $from_name
return $result;
}

/**
* is_url_exist
*
* Function for check url is exist
*
* @param string $url url file
* @return TRUE or FALSE
*/
public function is_url_exist($url){
$headers = get_headers($url);
if(stripos($headers[0],'200') || stripos($headers[0],'301') || stripos($headers[0],'302')){
return TRUE;
}else{
return FALSE;
}
}

}

0 comments on commit b786f46

Please sign in to comment.