'',), $atts, 'aha_key' ) ); $postCall = 0; if (isset($_POST) && !empty($_POST)) { $nonce = sanitize_key($_POST['_ajax_nonce']); if ( ! wp_verify_nonce( $nonce, 'ajax-nonce' ) ){ die ( 'Access denied..'); }else{ $postCall = 1; } } $id = isset($_POST['id']) ? sanitize_text_field($_POST['id']) : $id; global $wpdb; $prefix = $wpdb->prefix ; $_SESSION['guest_data'] = array(); $ahas = ''; $ip_address = array(); require dirname (dirname( __FILE__ ) ) . '/functions/aha_curl_function.php'; $Curl = new Aha_curl_function; $books_data= $Curl->aha_active_key($id) ; $settings = $Curl->aha_settings($id) ; $user_ip = $Curl->aha_getUserIP(); // print_r($settings); if(isset($_POST['email'])){ $email = sanitize_email($_POST['email'] ); } if(isset($email) AND $email != NULL) { $aha_url ='https://www.ahathat.com/plugin-setup/login'; $datap = wp_unslash($_POST); $responseData = $Curl->aha_login($books_data->api_key , json_encode($datap),esc_url_raw($aha_url)); $user_data = json_decode($responseData); if($user_data[0] != 'error') { if(session_id() == '' || !isset($_SESSION)) { session_start(); } $_SESSION['user_data'] = array(); $_SESSION['user_data'] = $user_data[0] ; } } if(isset($_POST['logout'])){ unset($_SESSION['user_data']);} $session_name = (isset($_POST['session_name']) ? sanitize_text_field($_POST['session_name']) : (isset($_SESSION['user_data']->name ) ? sanitize_text_field($_SESSION['user_data']->name) :'')); $categories = json_decode($settings->categories); //$book_id = $books_data->book_id ; if (empty($categories)) { echo 'Please Select AHAbook Content'; wp_die(); } $end_book = $settings->end_of_aha; $book_id = $categories[0]; $action = (isset($_POST['action']) ? sanitize_text_field($_POST['action']) : NULL ); if(isset($_POST['tweets'])) { $aha_post_tweets = sanitize_text_field($_POST['tweets']); $ahas = "AND `order_no` = '".$aha_post_tweets."'" ; $ip_address = $wpdb->get_results("SELECT * FROM `".$prefix."aha_order` WHERE `ip_address` = '".$user_ip."' AND `w_id` = '".$id."' LIMIT 1") ; if(empty($ip_address)) { $wpdb->insert($prefix.'aha_order', array( 'ip_address' => $user_ip, 'order_no' => $aha_post_tweets, 'w_id' => $id, 'share_limit' => 1 )); }else{ $table = $prefix.'aha_order'; $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET order_no = '%d' WHERE ip_address = '%s' AND w_id = '%d'", $aha_post_tweets, $user_ip,$id ) // $wpdb->prepare ); // $wpdb->query } }else{ $ahas ='ORDER BY RAND()'; if($action == NULL && $settings->shows == 1 ) { $ahas = "AND `order_no` = 1" ; $ip_address = $wpdb->get_results("SELECT * FROM `".$prefix."aha_order` WHERE `ip_address` = '".$user_ip."' AND `w_id` = '".$id."' LIMIT 1"); if(!empty($ip_address)) { $ahas = "AND `order_no` = ".$ip_address[0]->order_no ; $order_no = $ip_address[0]->order_no + 1; $table = $prefix.'aha_order'; $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET order_no = '%d' WHERE ip_address = '%s' AND w_id = '%d'", $order_no, $user_ip,$id ) // $wpdb->prepare ); } }else if($action == NULL && $settings->shows == 2){ $ahas ='ORDER BY `order_no` DESC'; $ip_address = $wpdb->get_results("SELECT * FROM `".$prefix."aha_order` WHERE `ip_address` = '".$user_ip."' AND `w_id` = '".$id."' LIMIT 1"); if(!empty($ip_address)) { $ahas = "AND `order_no` = ".$ip_address[0]->order_no ; $order_no = $ip_address[0]->order_no - 1; $table = $prefix.'aha_order'; $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET order_no = '%d' WHERE ip_address = '%s' AND w_id = '%d'", $order_no, $user_ip,$id ) // $wpdb->prepare ); // $wpdb->query } } } // print_r($ahas); die(); if($book_id != '' OR $end_book == '1' OR $end_book == '2'){ if($end_book == '0') { $book_id = $categories[0]; $all_book_share = $Curl->aha_all_book_share($books_data->api_key , $book_id ,$ahas) ; // print_r($books_data->api_key);die(); if (!empty($all_book_share)) { $aha_data = json_decode($all_book_share); $book_aha = $aha_data->aha; $bookData = $aha_data->bookData; $author_detail = $aha_data->author; $total_order = $aha_data->aha_total[0]->total; if(empty($ip_address) && $settings->shows == 2) { $ahas = "AND `order_no` = ".$ip_address[0]->order_no ; $table = $prefix.'aha_order'; $wpdb->insert($prefix.'aha_order', array( 'ip_address' => $user_ip, 'order_no' => $total_order, 'w_id' => $id, 'share_limit' => 1 )); }else if (empty($ip_address) && $settings->shows == 1) { $table = $prefix.'aha_order'; $wpdb->insert($prefix.'aha_order', array( 'ip_address' => $user_ip, 'order_no' => 1, 'w_id' => $id, 'share_limit' => 1 )); } $aname = ''; foreach($author_detail as $data) { if ($aname == '') { $aname .= $data->name; }else{ $aname .= ', '.$data->name; } } if(!empty($book_aha)) { $aha_tweet = $book_aha[0]->aha; $book_id= $bookData[0]->id; } } }else{ if(!empty($categories)) { $rand_keys = array_rand($categories, 1); $librarie_aha = $Curl->aha_librarie_aha($books_data->api_key,$categories[$rand_keys],$end_book) ; if (!empty($librarie_aha)) { $aha_data = json_decode($librarie_aha); $book_aha = $aha_data->aha; $bookData = $aha_data->bookData; $author_detail = $aha_data->author; $total_order = $aha_data->aha_total[0]->total; $aname = ''; foreach($author_detail as $data) { if ($aname == '') { $aname .= $data->name; }else{ $aname .= ', '.$data->name; } } if(!empty($book_aha)) { $aha_tweet = $book_aha[0]->aha; $book_id= $bookData[0]->id; } } } } if(!empty($book_aha)) { $tweetText = htmlspecialchars_decode( $aha_tweet ); $tweetText1 = $tweetText; $tt = str_replace("#","#",$tweetText); $tt = str_replace("@","@",$tt); $tt = str_replace("@","@",$tt); $tt = str_replace('"','"',$tt); $tt = str_replace("'","´",$tt); $tweetText2 = urlencode($tweetText); if(substr($tweetText2,0,1)=="#") { $tweetText2 = substr($tweetText2, 1); } $ct = mb_strlen($tweetText); } $resultz = $wpdb->get_results( 'SELECT * FROM '.$prefix.'aha_api WHERE id='.$id); if(!empty($resultz)) { $key = ($resultz[0]->api_key != '' ? $resultz[0]->api_key : '' ); } $ahapageSettings = $wpdb->get_results( "SELECT * FROM ".$prefix."aha_settings WHERE id_wid = '".$id."' AND active_s = '1' " ); if ($postCall == 0) { if(!empty($ahapageSettings)){ $ahapageSettings = $ahapageSettings[0]; $b_color = !empty($ahapageSettings) && $ahapageSettings->b_color != '' ? $ahapageSettings->b_color : 'F5F5F5'; $t_color = !empty($ahapageSettings) && $ahapageSettings->t_color != '' ? $ahapageSettings->t_color : '666666'; $text_color = !empty($ahapageSettings) && $ahapageSettings->text_color != '' ? $ahapageSettings->text_color : '141412'; $s_color = !empty($ahapageSettings) && $ahapageSettings->s_color != '' ? $ahapageSettings->s_color : '004DCC'; $button_color = !empty($ahapageSettings) && $ahapageSettings->button_color != '' ? $ahapageSettings->button_color : '96C841'; $width = !empty($ahapageSettings) && $ahapageSettings->width != '' && $ahapageSettings->width >450 ? $ahapageSettings->width.'px' : 'auto'; $height = !empty($ahapageSettings) && $ahapageSettings->height != '' && $ahapageSettings->height > 250 ? $ahapageSettings->height.'px' : 'auto'; $position = !empty($ahapageSettings) && $ahapageSettings->position != '' ? $ahapageSettings->position : '4'; $font = !empty($ahapageSettings) && $ahapageSettings->font != '' ? $ahapageSettings->font : '18'; $title_font = !empty($ettingsData) && $ettingsData->title_font != '' ? $ettingsData->title_font : '22'; if ($position == 0) { $text_align = 'center'; }else if ($position == 1) { $text_align = 'left'; }else if ($position == 2) { $text_align = 'right'; }else if ($position == 3) { $text_align = 'justify'; }else if ($position == 4) { $text_align = 'unset'; } ?>
AHA order_no ; ?>
share_limit) AND $ip_address[0]->share_limit != ''){ $ips = $ip_address[0]->share_limit+1; }else{ $ips = $settings->maximum_share; }?>
show_powered == 0){ ?> Powered by AHAthat®
×

AHAthat Login

Please Login/Signup to Continue Sharing AHAmessages.

LOGIN / SIGNUP
>
×

LOGIN

Invalid Email or password
×

SIGNUP