Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('page_contents.php');
- require_once('cc_class.php');
- function wbr_create_admin_menu()
- {
- add_menu_page('WB Reviews', 'SMSchema', 'administrator','wbr_main','wbr_add_main_page_contents');
- add_submenu_page('wbr_main','Settings','Settings','administrator','wbr_main','wbr_add_main_page_contents');
- add_submenu_page('wbr_main','Campaigns','Campaigns','administrator','wbr_campaigns','wbr_add_campaigns_page_contents');
- add_submenu_page('wbr_main','Reviews','Reviews','administrator','wbr_reviews','wbr_add_reviews_page_contents');
- add_submenu_page('wbr_main','Messages','Messages','administrator','wbr_messages','wbr_add_messages_page_contents');
- }
- function wbr_admin_notice(){
- global $pagenow;
- if(isset($_SESSION['wbr_admin_notice']) && !empty($_SESSION['wbr_admin_notice']))
- {
- if($pagenow == 'admin.php')
- {
- echo '<div class="updated" style="color:#21759B;">
- <p>'.$_SESSION['wbr_admin_notice'].'</p>
- </div>';
- }
- unset($_SESSION['wbr_admin_notice']);
- }
- }
- function wbr_redirect_page($URL)
- {
- ?>
- <script type="text/javascript">
- window.location = "<?=$URL?>";
- </script>
- <?php
- die();
- }
- function wbr_init_sessions() {
- if (!session_id()) {
- session_start();
- }
- }
- function wbr_drop_table()
- {
- global $wpdb;
- $pre = $wpdb->prefix;
- $table[0] = $pre."wbr_states";
- $table[1] = $pre."wbr_area_codes";
- $table[2] = $pre."wbr_client_info";
- $table[3] = $pre."wbr_phone_numbers";
- $table[4] = $pre."wbr_campaigns";
- $table[5] = $pre."wbr_camp_questions";
- $table[6] = $pre."wbr_reviews_answers";
- $table[7] = $pre."wbr_reviews";
- $table[8] = $pre."wbr_scheduler";
- //$table[9] = $pre."wbr_html_code";
- $table[9] = $pre."wbr_sms_history";
- $table[10] = $pre."wbr_auto_responder";
- $table[11] = $pre."wbr_review_customize";
- for($i=0; $i<count($table); $i++)
- {
- $Table_name = $table[$i];
- $query = $wpdb->query("DROP TABLE IF EXISTS $Table_name");
- }
- update_option('wb_reviews_ver','0.0');
- }
- function wbr_db_table()
- {
- global $wpdb;
- global $jal_db_version;
- $Table_name = $wpdb->prefix . 'wbr_states';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `State` varchar(255) NOT NULL,
- `Code` varchar(255) NOT NULL,
- `Status` varchar(255) NOT NULL,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- if(dbDelta($sql))
- {
- $tabl_insert = $wpdb->prefix.'wbr_states';
- $filename = WBR_PluginURL.'db_files/wbr_states.csv';
- wbr_insert_in_db($filename, $tabl_insert);
- }
- }
- $Table_name = $wpdb->prefix . 'wbr_area_codes';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `StateCode` varchar(255) NOT NULL,
- `AreaCode` varchar(255) NOT NULL,
- `IsActive` tinyint(3) NOT NULL,
- `Status` tinyint(3) NOT NULL,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- if(dbDelta($sql))
- {
- $tabl_insert = $wpdb->prefix.'wbr_area_codes';
- $filename = WBR_PluginURL.'db_files/wbr_area_codes.csv';
- wbr_insert_in_db($filename, $tabl_insert);
- }
- }
- $Table_name = $wpdb->prefix . 'wbr_client_info';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `AccountSid` varchar(255) NOT NULL,
- `AuthTocken` varchar(255) NOT NULL,
- `Licence_Email` varchar(512) NOT NULL,
- `Schema_Description` longtext NOT NULL,
- `Schema_Img` text NOT NULL,
- `TwilioPhoneNumber` varchar(255) NOT NULL,
- `WBSMS_Username` varchar(255) NOT NULL,
- `WBSMS_Password` varchar(255) NOT NULL,
- `WBSMS_Domain` varchar(510) NOT NULL,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql);
- }
- $Table_name = $wpdb->prefix . 'wbr_phone_numbers';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `TwilioPhoneNo` varchar(255) NOT NULL,
- `PhoneSid` varchar(255) NOT NULL,
- `Type` int(11) NOT NULL,
- `Status` int(11) NOT NULL,
- `CreatedUser` int(11) NOT NULL,
- `CreatedDate` datetime,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql);
- }
- $Table_name = $wpdb->prefix . 'wbr_campaigns';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Name` varchar(255) NOT NULL,
- `Keyword` varchar(255) NOT NULL,
- `Phone_Number` varchar(255) NOT NULL,
- `WBSMS_Campaign` varchar(255) NOT NULL,
- `Threshold` varchar(255) NOT NULL,
- `OfferExpiry` int(11) NOT NULL,
- `Start_Campaign` tinyint(4) NOT NULL,
- `Start_Campaign_Days` varchar(255) NOT NULL,
- `Start_Campaign_Time` varchar(255) NOT NULL,
- `Thank_U_Msg` varchar(255) NOT NULL,
- `AR_Company` tinyint(4) NOT NULL,
- `Auto_Responder_Code` longtext NOT NULL,
- `CC_User` varchar(255) NOT NULL,
- `CC_Pass` varchar(255) NOT NULL,
- `CC_API_Key` varchar(512) NOT NULL,
- `CC_List_ID` varchar(255) NOT NULL,
- `CreatedDate` datetime,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql);
- }
- $Table_name = $wpdb->prefix . 'wbr_camp_questions';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Camp_ID` int(11) NOT NULL,
- `Type` tinyint(4) NOT NULL,
- `Question` varchar(255) NOT NULL,
- `PBD` tinyint(4) NOT NULL,
- `CreatedDate` datetime,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql) or die('table error');
- }
- $Table_name = $wpdb->prefix . 'wbr_reviews_answers';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Review_ID` int(11) NOT NULL,
- `Camp_ID` int(11) NOT NULL,
- `Q_ID` int(11) NOT NULL,
- `Type` tinyint(4) NOT NULL,
- `Answer` varchar(512) NOT NULL,
- `Status` tinyint(4) NOT NULL,
- `CreatedDate` datetime,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql) or die('table error');
- }
- $Table_name = $wpdb->prefix . 'wbr_reviews';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Phone_Number` varchar(255) NOT NULL,
- `Name` varchar(255) NOT NULL,
- `Email` varchar(255) NOT NULL,
- `Camp_ID` int(11) NOT NULL,
- `Current_Q_ID` int(11) NOT NULL,
- `Status` tinyint(4) NOT NULL,
- `Publish` tinyint(4) NOT NULL,
- `CreatedDate` datetime,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql) or die('table error');
- }
- $Table_name = $wpdb->prefix . 'wbr_scheduler';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Review_ID` int(11) NOT NULL,
- `Status` tinyint(4) NOT NULL,
- `Start_Date` datetime,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql) or die('table error');
- }
- }
- function wbr_alter_table()
- {
- global $wpdb;
- global $wb_reviews_ver;
- $table_questions = $wpdb->prefix.'wbr_camp_questions';
- $table_campaigns = $wpdb->prefix.'wbr_campaigns';
- $table_reviews = $wpdb->prefix.'wbr_reviews';
- $updated = get_option('wb_reviews_ver');
- if( $updated < '3.4' )
- {
- $Table_name = $wpdb->prefix . 'wbr_html_code';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Amount` int(11) NOT NULL,
- `Order_Type` varchar(255) NOT NULL,
- `Min_Rating` int(11) NOT NULL,
- `Publish_Camp` text NOT NULL,
- `Name_Color` varchar(255) NOT NULL,
- `Email_Color` varchar(255) NOT NULL,
- `Date_Color` varchar(255) NOT NULL,
- `Q_Color` varchar(255) NOT NULL,
- `Ans_Color` varchar(255) NOT NULL,
- `Frame_Width` varchar(255) NOT NULL,
- `Frame_Height` varchar(255) NOT NULL,
- PRIMARY KEY (`id`)
- );";
- //include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- //dbDelta($sql) or die('table error');
- }
- $Table_name = $wpdb->prefix . 'wbr_sms_history';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `To` varchar(255) NOT NULL,
- `From` varchar(255) NOT NULL,
- `Body` longtext NOT NULL,
- `Status` varchar(255) NOT NULL,
- `Direction` varchar(255) NOT NULL,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql);
- }
- $Table_name = $wpdb->prefix . 'wbr_auto_responder';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Camp_ID` int(11) NOT NULL,
- `Days` varchar(255) NOT NULL,
- `Time` varchar(255) NOT NULL,
- `SMS_Text` longtext NOT NULL,
- `Offer_Days` varchar(255) NOT NULL,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql);
- }
- $Table_name = $wpdb->prefix . 'wbr_ar_scheduler';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Phone_Number` varchar(255) NOT NULL,
- `Twilio_Number` varchar(255) NOT NULL,
- `Message` longtext NOT NULL,
- `Date` datetime NOT NULL,
- `Status` tinyint(1) NOT NULL,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql);
- }
- $Table_name = $wpdb->prefix . 'wbr_review_customize';
- if( !$wpdb->get_var( "SHOW TABLES LIKE $Table_name" ) ) {
- $sql = "CREATE TABLE $Table_name
- (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Camp_ID` int(11) NOT NULL,
- `Name_Color` varchar(255) NOT NULL,
- `Name_Size` varchar(255) NOT NULL,
- `Name_Weight` varchar(255) NOT NULL,
- `Name_Style` varchar(255) NOT NULL,
- `Email_Color` varchar(255) NOT NULL,
- `Email_Size` varchar(255) NOT NULL,
- `Email_Weight` varchar(255) NOT NULL,
- `Email_Style` varchar(255) NOT NULL,
- `Date_Color` varchar(255) NOT NULL,
- `Date_Size` varchar(255) NOT NULL,
- `Date_Weight` varchar(255) NOT NULL,
- `Date_Style` varchar(255) NOT NULL,
- `Q_Color` varchar(255) NOT NULL,
- `Q_Size` varchar(255) NOT NULL,
- `Q_Weight` varchar(255) NOT NULL,
- `Q_Style` varchar(255) NOT NULL,
- `Ans_Color` varchar(255) NOT NULL,
- `Ans_Size` varchar(255) NOT NULL,
- `Ans_Weight` varchar(255) NOT NULL,
- `Ans_Style` varchar(255) NOT NULL,
- PRIMARY KEY (`id`)
- );";
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql);
- }
- $alter_table_camp_disp_q = $wpdb->query("ALTER TABLE $table_questions ADD COLUMN `Disp_Question` int(11) NOT NULL DEFAULT '1' AFTER `PBD`");
- $alter_table_camp_schema = $wpdb->query("ALTER TABLE $table_campaigns ADD `Schema_Desc` LONGTEXT NOT NULL AFTER `CC_List_ID`, ADD `Schema_Img` TEXT NOT NULL AFTER `Schema_Desc`");
- $alter_offer_expiry_chkbox = $wpdb->query("ALTER TABLE $table_campaigns ADD `OfferExpiry_Chkbox` tinyint(1) NOT NULL AFTER `OfferExpiry`");
- $alter_reviews_import_date = $wpdb->query("ALTER TABLE $table_reviews ADD `Import_Date` datetime NOT NULL AFTER `CreatedDate`");
- }
- update_option('wb_reviews_ver','3.4');
- }
- function wbr_insert_in_db($Filename, $Table)
- {
- global $wpdb;
- $check = $wpdb->get_results( "SELECT * FROM $Table" );
- if($check[0] == '')
- {
- $handle = fopen($Filename, "r");
- $db_fields = '';
- if($handle)
- {
- include_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- while (($data = fgetcsv($handle, 10000000, ",")) != false)
- {
- if($Table == $wpdb->prefix.'wbr_states')
- {
- $data_array = array('State' => $data[0],'Code' => $data[1],'Status' => $data[2]);
- $query = $wpdb->insert($Table,$data_array);
- }
- if($Table == $wpdb->prefix.'wbr_area_codes')
- {
- $data_array = array('StateCode' => $data[0],'AreaCode' => $data[1],'IsActive' => $data[2],'Status' => $data[3]);
- $query = $wpdb->insert($Table,$data_array);
- }
- }
- }
- }
- }
- function wbr_check_user_curl($email, $password, $url)
- {
- $url = $url."/handle_curl_request.php";
- $data = array('email_address'=>$email,'password'=>$password,'action'=>'client_verification');
- // makin curl request....
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0');
- $request = curl_exec($ch);
- if($request == 'found')
- {
- return true;
- }
- else
- {
- return false;
- }
- curl_close($ch);
- }
- function wbr_DBin($string)
- {
- $a = html_entity_decode($string);
- return trim(htmlspecialchars($a,ENT_QUOTES));
- }
- function wbr_DBout($string)
- {
- $string = stripslashes(trim($string));
- return html_entity_decode($string);
- }
- function wbr_sendSMS($client,$From,$twilio_user_number,$SMS,$ApiVersion,$AccountSid)
- {
- $response = $client->request("/$ApiVersion/Accounts/$AccountSid/SMS/Messages",
- "POST", array(
- "To" => $From,
- "From" => $twilio_user_number,
- "Body" => $SMS
- ));
- if ($response->IsError)
- {
- return $response->IsError;
- }
- else
- {
- wbr_sms_history($From, $twilio_user_number, $SMS, 'sent', 'outbound-api');
- return 'MSG Sent';
- }
- }
- function wbr_sms_history($to, $from, $body, $status, $direction)
- {
- global $wpdb;
- $table_sms_hitory = $wpdb->prefix."wbr_sms_history";
- $data_array = array(
- 'To' => $to,
- 'From' => $from,
- 'Body' => $body,
- 'Status' => $status,
- 'Direction' => $direction
- );
- $wpdb->insert($table_sms_hitory, $data_array);
- }
- function wbr_genRandomString()
- {
- global $wpdb;
- $table_phone_numbers = $wpdb->prefix."wbr_phone_numbers";
- $couponChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- $couponCharLen = (strlen($couponChars)-1);
- $couponLength = 6;
- $couponCode = '';
- $couponCheck = '0';
- while($couponCheck == '0')
- {
- for($i=0; $i<$couponLength; $i++)
- {
- $couponCode .= $couponChars[rand(0,$couponCharLen)];
- }
- $check_coupon = $wpdb->get_var($wpdb->prepare('SELECT COUNT(id) FROM '.$table_phone_numbers.' WHERE Code = "'.$couponCode.'" LIMIT 1'));
- if($check_coupon == 0)
- {
- $couponCheck = '1';
- }
- }
- return $couponCode;
- }
- function wbr_check_number_in_wbsms($email, $password, $phone_number, $url)
- {
- $url = $url."/handle_curl_request.php";
- $data = array('email_address'=>$email,'password'=>$password,'phone_number'=>$phone_number,'action'=>'check_number');
- // makin curl request....
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0');
- $request = curl_exec($ch);
- if($request == 'found')
- {
- return false;
- }
- else
- {
- return true;
- }
- curl_close($ch);
- }
- function wbr_get_campaign_curl($email, $password, $url)
- {
- $url = $url."/handle_curl_request.php";
- $data = array('email_address'=>$email,'password'=>$password,'action'=>'get_campaigns');
- // makin curl request....
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0');
- $request = curl_exec($ch);
- $xml = simplexml_load_string($request);
- return $xml;
- curl_close($ch);
- }
- function wbr_subscribe_in_campaign($wbsms_url,$from,$to,$body,$sms_sid,$message_sid)
- {
- $url = $wbsms_url."/sms_controlling.php";
- $hander_curl_url = $wbsms_url.'/handle_curl_request.php';
- $data_number = array('keyword'=>$body,'action'=>'get_campaign_number');
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$hander_curl_url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_number);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0');
- //============================================== PAYMENT ===================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement