관리-도구
편집 파일: autoupdate.php
<?php class Autoupdate { var $update_url; var $current_version; var $base_dir; var $mysqli; var $dbpref; function __construct($arr) { $this->mysqli=$arr['mysqli']; $this->dbpref=$arr['dbpref']; // $this->update_url="http://coursefunnels.in/membership/api/auto_update"; $this->update_url="http://63.250.45.252/membership/api/auto_update"; $this->current_version=get_option('qfnl_current_version'); $this->base_dir=$arr['base_dir']; } function request($url,$arr=array(),$type="post") { $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); if($type=="post") { curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$arr); } curl_setopt($ch,CURLOPT_HTTPHEADER,array( "Host: coursefunnels.in" )); $res=curl_exec($ch); curl_close($ch); return $res; } function checkForUpdate($download_url=0,$version=0) { if(!filter_var($download_url,FILTER_VALIDATE_URL)) { $arr=array('user_version'=>$this->current_version,'check_qfnl_update'=>1); $res=self::request($this->update_url,$arr); //echo $res; $res=json_decode($res); if(json_last_error()===0) { if($res->update) { return json_encode(array('download_url'=>$res->download_url,'version'=>$res->updated_version,'changes'=>$res->changes)); } else { // if(isset($res->version)) // { // self::installDependecies($res->version); // } return 0; } } else {return 0;} } elseif(filter_var($download_url,FILTER_VALIDATE_URL)) { $zip=self::request($download_url,array(),'get'); $fp=fopen($this->base_dir."/qfunnel_update.zip","w"); fwrite($fp,$zip); fclose($fp); return 1; } return 0; } function doUpdate($version) { $file=$this->base_dir."/"."qfunnel_update.zip"; $zip=new ZipArchive(); $zip->open($file); $zip->extractTo($this->base_dir); $zip->close(); unlink($file); return 1; } function installDependecies($version=0) { //install all updates if not exists //qfnl_has_update_00 to check if update exists or not //all things will be writtent before lbl $mysqli=$this->mysqli; $dbpref=$this->dbpref; $mysqli_version = $mysqli->server_version; $mysqli_version = (int)str_ireplace(".","",$mysqli_version); $loswer_version = (int)"552"; $charset=''; if( $mysqli_version > $loswer_version ) { $charset .= "utf8mb4 COLLATE utf8mb4_unicode_ci"; }else{ $charset .= "utf8 COLLATE utf8_unicode_ci"; } lbl: if($version>0) { //all version changes will be written here //insidie the updates if(!get_option('qfnl_has_update_19')) { $table=$dbpref."quick_funnels"; if(!$mysqli->query("select `token` from `".$table."`")) { $mysqli->query("alter table `".$table."` add `token` varchar(255) not null after `date_created`"); } update_option('qfnl_has_update_19','1'); } if(!get_option('qfnl_has_update_29')) { $table=$dbpref."quick_autoresponders"; $mysqli->query("alter table `".$table."` modify `autoresponder_detail` text not null"); $mysqli->query("alter table `".$table."` modify `exf` text not null"); update_option('qfnl_has_update_29','1'); } if(!get_option('qfnl_has_update_423')) { add_option('app_language','lang_english_en'); add_option('qfnl_has_update_423',1); } if(!get_option('qfnl_has_update_424')) { $table=$dbpref.'quick_pagefunnel'; $mysqli->query("alter table `".$table."` modify `level` int(11)"); $sql26="create table if not exists `".$dbpref."qfnl_plugins`( `id` bigint not null auto_increment, `base_dir` varchar(255) not null, `destin_version` varchar(255) not null, `status` varchar(10) not null, `activated_on` datetime not null, primary key(`id`) ) "; $mysqli->query($sql26); $sql27="create table if not exists `".$dbpref."qfnl_funnel_meta`( `id` bigint not null auto_increment, `funnel_id` varchar(255) not null, `page_level` varchar(255) not null, `page_type` varchar(4) not null, `key` varchar(255) not null, `value` text not null, primary key(`id`) ) "; $mysqli->query($sql27); if(!get_option('qfnl_setup_token')) { add_option('qfnl_setup_token',time()); } add_option('qfnl_has_update_424',1); } if(!get_option('qfnl_has_update_426')) { add_option('cod_otp_email_title', 'OTP for product confirmation'); add_option('cod_otp_email_content', '<p>Hello,</p><p>Please enter the below OTP code to complete Verification.</p><p><strong>{otp}</strong></p><p>This code is valid for the next 10 minutes.</p><p>If you did not raise the request please write to our support team.</p>'); $sql28="create table if not exists `".$dbpref."qfnl_cod`( `id` bigint not null auto_increment, `sell_id` bigint not null, `status` int default 0, `buyer_email` varchar(255) not null, `signed_by` int not null, `last_ip` text not null, `added_on` datetime not null, `updated_on` datetime not null, primary key(`id`) )"; $mysqli->query($sql28); add_option('qfnl_has_update_426', 1); } if(!get_option('qfnl_has_update_427')) { $sql29= "create table if not exists `".$dbpref."media`( `id` bigint not null auto_increment, `title` varchar(255) not null, `file` text not null, `type` varchar(255) not null, `file_type` varchar(255) not null, `size` varchar(255) not null, `description` text not null, `added_on` varchar(255) not null, `updated_on` varchar(255) not null, primary key(`id`) ) "; $create_twentynine= $mysqli->query($sql29); add_option('qfnl_has_update_427', 1); } if(!get_option('qfnl_has_update_440')) { $sql30= $mysqli->query("alter table `".$dbpref."quick_pagefunnel` add `active_type` enum('NA', 'a','b') not null default 'NA' after `type`"); add_option('qfnl_has_update_440', 1); } if(!get_option('qfnl_has_update_441')) { $sql31= $mysqli->query("ALTER TABLE `".$dbpref."option_comment` ADD `type` VARCHAR(20) NOT NULL DEFAULT 'lecture' AFTER `name`"); $sql32= $mysqli->query("ALTER TABLE `".$dbpref."option_notes` ADD `type` VARCHAR(20) NOT NULL DEFAULT 'lecture' AFTER `name`"); add_option('qfnl_has_update_441', 1); } if(!get_option('qfnl_has_update_445')) { $mysqli->query("ALTER TABLE `".$dbpref."quick_pagefunnel` ADD `csslink` TEXT NULL AFTER `pageheader`"); $mysqli->query("ALTER TABLE `".$dbpref."all_products` ADD `mini_description` VARCHAR(255) NULL AFTER `description`"); $mysqli->query("ALTER TABLE `".$dbpref."quick_optins` ADD `send_pab` VARCHAR(255) NOT NULL AFTER `send_zap`;"); $mysqli->query("ALTER TABLE `".$dbpref."quick_member` ADD `member_type` ENUM('f','p') NOT NULL DEFAULT 'f' AFTER `password`;"); $mysqli->query("DROP TABLE `".$dbpref."quick_membership`"); $sql4 = "CREATE TABLE IF NOT EXISTS `".$dbpref."quick_membership` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `membership` bigint(20) NOT NULL, `funnelid` varchar(255) NOT NULL, `product` varchar(255) NOT NULL, `product_type` varchar(50) NOT NULL, PRIMARY KEY (`id`), KEY `membership` (`membership`), CONSTRAINT `".$dbpref."quick_membership_ibfk_1` FOREIGN KEY (`membership`) REFERENCES `".$dbpref."quick_member` (`id`) ON DELETE CASCADE ON UPDATE CASCADE )"; $mysqli->query($sql4); $sql5 = $mysqli->query( "SELECT `membership`,`productid`,`funnelid` FROM `".$dbpref."all_sales`" ); if( $sql5->num_rows > 0 ){ while( $rs = $sql5->fetch_object() ) { $mem_id=$rs->membership; if( !empty($mem_id) ) { $sql6 = $mysqli->query( "SELECT `id` FROM `".$dbpref."quick_member` WHERE `id`=$mem_id" ); if( $sql6->num_rows > 0 ) { $funnelid=$rs->funnelid; $prds=$rs->productid; $mysqli->query("INSERT INTO `".$dbpref."quick_membership` (`membership`, `funnelid`, `product`, `product_type`) values ('$mem_id','$funnelid','$prds','p')"); } } } } add_option('qfnl_has_update_445', 1); } if(!get_option('qfnl_has_update_500')) { $sql35= $mysqli->query("DROP TABLE `".$dbpref."like_dislike`"); $sql36= $mysqli->query("DROP TABLE `".$dbpref."comment_like`"); $mysqli->query("ALTER TABLE `".$dbpref."section` ADD `updates` ENUM('0','1') NOT NULL DEFAULT '0' AFTER `display_order`;"); $mysqli->query("ALTER TABLE `".$dbpref."content_options` ADD `updates` ENUM('0','1') NOT NULL DEFAULT '0' AFTER `display_order`;"); $mysqli->query("ALTER TABLE `".$dbpref."assignment` ADD `updates` ENUM('0','1') NOT NULL DEFAULT '0' AFTER `show_cert`;"); $sql37 = "CREATE TABLE IF NOT EXISTS `".$dbpref."course_setting` ( `id` INT NOT NULL AUTO_INCREMENT, `theme` CHAR(1) NOT NULL , `text` TEXT NULL DEFAULT NULL , `style` TEXT NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET= $charset;"; $mysqli->query($sql37); $sql38 = $mysqli->query( "SELECT `title`,`id`,`updates` FROM `".$dbpref."section`" ); if( $sql38->num_rows > 0 ){ while( $rs = $sql38->fetch_object() ) { $title = $mysqli->real_escape_string(base64_decode($rs->title)); $s_id = $rs->id; $updates = $rs->updates; if( $updates == 0 ) { $mysqli->query("UPDATE `".$dbpref."section` SET `title`='$title',`updates`='1' WHERE `id`=$s_id"); } } } $sql39 = $mysqli->query( "SELECT `title`,`description`,`content`,`id`,`updates` FROM `".$dbpref."content_options`" ); if( $sql39->num_rows > 0 ){ while( $rs1 = $sql39->fetch_object() ) { $title = $mysqli->real_escape_string( base64_decode( $rs1->title ) ); $description = $mysqli->real_escape_string( base64_decode( $rs1->description ) ); $content = $mysqli->real_escape_string( base64_decode( $rs1->content ) ); $o_id = $rs1->id; $updates = $rs1->updates; if( $updates == 0 ) { $mysqli->query("UPDATE `".$dbpref."content_options` SET `title`='$title',`description`='$description',`content`='$content',`updates`='1' WHERE `id`=$o_id"); } } } $sql40 = $mysqli->query( "SELECT `bi_title`,`bi_desc`,`assign_id`,`updates` FROM `".$dbpref."assignment`" ); if( $sql40->num_rows > 0 ){ while( $rs1 = $sql40->fetch_object() ) { $atitle = $mysqli->real_escape_string( base64_decode( $rs1->bi_title ) ); $adescription = $mysqli->real_escape_string( base64_decode( $rs1->bi_desc ) ); $ao_id = $rs1->assign_id; $aupdates = $rs1->updates; if( $aupdates == 0 ) { $mysqli->query("UPDATE `".$dbpref."assignment` SET `bi_title`='$atitle',`bi_desc`='$adescription',`updates`='1' WHERE `assign_id`=$ao_id"); } } } add_option('qfnl_has_update_500', 1); } if(!get_option('qfnl_has_update_555')) { $mysqli->query("ALTER TABLE `".$dbpref."quick_member` ADD `mailed` ENUM('1','0') NOT NULL DEFAULT '1' AFTER `valid`"); if(!get_option('free_singn_email_title')) {add_option('free_singn_email_title', 'Member registration email');} if(!get_option('free_singn_email_content')) {add_option('free_singn_email_content', '<p>Hi,</p><p>I hope you’re having a great week.</p> <p>We have one registration to your {funnel} funnel</p> <p>Name: {name}</p> <p>Email: {email}</p> <p>Thanks</p>');} add_option('cod_store_message', 'You need to verify your email address for purchasing the listed products'); add_option('cod_store_name', 'Cash On Delivery'); add_option('qfnl_has_update_555', 1); } if(!get_option('qfnl_has_update_561')) { $mysqli->query( "CREATE TABLE `".$dbpref."new_sequence` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `description` text NOT NULL, `created_on` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET = $charset" ); $mysqli->query("ALTER TABLE `".$dbpref."quick_sequence` ADD `sequence_id` INT(11) NOT NULL AFTER `sequence`, ADD INDEX (`sequence_id`);"); add_option('qfnl_has_update_561',1); } if(!get_option('qfnl_has_update_563')) { add_option('underconstruction_page_descritption', 'This site is under construction. Please check back soon.'); add_option('default_under_page_logo', get_option('install_url')."/assets/img/under-logo.png"); add_option('underconstruction_page_title', 'Under Construction'); add_option('default_under_page_template', '1'); add_option('qfnl_has_update_563', 1); } //end of the call $strvar=str_replace(".","",(string)$version); $current_version=get_option('qfnl_current_version'); if($version>$current_version) { update_option('qfnl_current_version',$version); } if(!get_option('qfnl_has_update_'.$strvar,'1')) { update_option('qfnl_current_version',$version); update_option('qfnl_has_update_'.$strvar,'1'); } if(function_exists('checkColumn') && !checkColumn('quick_member','image')){ $mysqli->query("ALTER TABLE `course_funnels_quick_member` ADD `image` VARCHAR(255) NOT NULL AFTER `email`"); } } return 1; } } ?>