PATH:
home
/
lab2454c
/
invest.westernclear.com
/
wp-content
/
plugins
/
portfolio
<?php /* Plugin Name: investments Description: investments products. Version: 4.27 Author: 3gmediasolution Text Domain: ure Domain Path: /lang/ */ /* Copyright 2021 */ add_action('init', 'what_are_our_investments'); function what_are_our_investments() { $labels = array( 'name' => _x('Investments', 'post type general name'), 'singular_name' => _x('investments', 'post type singular name'), 'add_new' => _x('Add New', 'investments item'), 'add_new_item' => __('Add New investments Item'), 'edit_item' => __('Edit investments Item'), 'new_item' => __('New investments Item'), 'view_item' => __('View investments Item'), 'search_items' => __('Search investments'), 'not_found' => __('Nothing found'), 'not_found_in_trash' => __('Nothing found in Trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, //'menu_icon' => get_stylesheet_directory_uri() . '/article16.png', 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','thumbnail','custom-fields','comments') ); register_post_type( 'investments' , $args ); } add_action( 'init', 'our_investments_create_taxonomies', 0 ); function our_investments_create_taxonomies() { // Project Categories register_taxonomy('investments-cat',array('investments'),array( 'hierarchical' => true, 'label' => 'Categories', 'singular_name' => 'investments_category', 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => 'investments-cat' ) )); register_taxonomy( 'our_investments_tag', 'investments', array( 'hierarchical' => false, 'label' => __( 'Tags', CURRENT_THEME ), 'singular_name' => __( 'Tag', CURRENT_THEME ), 'rewrite' => true, 'query_var' => true ) ); } /*---------------what_are_other_asking post type end---------------*/ add_filter( 'comments_open', 'my_comments_open', 10, 2 ); function my_comments_open( $open, $post_id ) { $post = get_post( $post_id ); if ( 'investments' == $post->post_type ) $open = true; return $open; } add_shortcode('page_redirection', 'page_redirection'); function page_redirection(){ ob_start(); page_redirection_code(); return ob_get_clean(); } function page_redirection_code() { if ( is_user_logged_in() ) { $current_user_id = get_current_user_id(); $user_meta=get_userdata($current_user_id); echo $user_roles = $user_meta->roles; echo $_COOKIE["get_permalink"]; if ($_COOKIE["get_permalink"] != "") { wp_redirect($_COOKIE["get_permalink"]); }else{ $site_url = site_url()."/dashboard"; wp_redirect($site_url); } } } function generateRandomString($length = 10) { return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length); } add_shortcode('cr_portfolio', 'portfolio_cust'); function portfolio_cust(){ ob_start(); portfolio_cust_show(); return ob_get_clean(); } function portfolio_cust_show() { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'investments', 'posts_per_page' => 12, 'paged'=> $paged, 'order' => 'DESC' ); $the_query = new WP_Query( $args ); $query = new WP_Query( $args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); echo "<br>"; echo get_field('title',$post->ID); echo "<br>"; echo get_field('subtitle',$post->ID); echo "<br>"; echo get_field('media_link',$post->ID); echo "<br>"; echo get_field('website_link',$post->ID); echo "<br>"; echo substr(get_field('description',$post->ID),0,83)."..."; echo "<br>"; echo get_field('place_name',$post->ID); echo "<br>"; echo get_field('valuation',$post->ID); echo "<br>"; echo get_field('price_per_share',$post->ID); echo "<br>"; echo get_field('min_investment',$post->ID); echo "<br>"; echo get_field('shares_offered',$post->ID); echo "<br>"; echo get_field('offering_type',$post->ID); echo "<br>"; echo get_field('offering_max',$post->ID); echo "<br>"; echo get_field('offering',$post->ID); echo "<br>"; ?> <a href="<?php the_permalink();?>">Link</a> <?php echo "<br>"; endwhile; //echo $count = $query->post_count; // https://developer.wordpress.org/reference/functions/paginate_links/ $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $query->max_num_pages ) ); endif; wp_reset_postdata(); } add_shortcode('single_portfolio', 'portfolio_single'); function portfolio_single(){ ob_start(); portfolio_single_show(); return ob_get_clean(); } function portfolio_single_show() { $site_url = site_url()."/login"; $get_permalink = get_permalink(); setcookie("get_permalink", $get_permalink, time() + (86400 * 30), "/"); global $post; global $wpdb; $pid = $post->ID; $investors_data = $wpdb->get_row("SELECT COUNT(DISTINCT `cust_id`) AS investors from transaction WHERE `item_number` = '".$pid."'"); $investors_count = $investors_data->investors; $investmentdata = $wpdb->get_row("SELECT SUM(`paid_amount`) AS total_investment FROM transaction WHERE `item_number` = '".$pid."'"); $totalinvestment = $investmentdata->total_investment/100; $totalinvestment_round = round($totalinvestment); $total_investment = number_format($totalinvestment_round,2,".",","); ?> <link rel="stylesheet" href="<?php echo site_url(); ?>/wp-content/plugins/investments/common.css"> <div class="portfolio__detail__top__wrapp"> <div class="portfolio__video__imege"> <div class="display__brand"> <div class="image__box"><img src="<?php echo site_url(); ?>/wp-content/plugins/investments/images/logo.png" alt="" /></div> <div class="brand__detail"> <h3><?php echo get_field('title',$post->ID); ?></h3> <h4><?php echo get_field('subtitle',$post->ID); ?></h4> </div> </div> <div class="image__box"> <iframe width="420" height="315" src="<?php echo get_field('media_link',$post->ID); ?>"></iframe> </div> <div class="portfolio__categories"> <div class="site__location"> <a href="<?php echo get_field('website_link',$post->ID); ?>" target="_blank"><i class="ico__box"><img src="<?php echo site_url(); ?>/wp-content/plugins/investments/images/link.svg" alt="" /></i>Website</a> <p><i class="ico__box"><img src="<?php echo site_url(); ?>/wp-content/plugins/investments/images/location-pin.svg" alt="" /></i><?php echo get_field('place_name',$post->ID); ?></p> </div> <?php $term_list = get_the_terms($post->ID, 'investments-cat'); foreach ( $term_list as $term ) { ?> <div class="category"><?php echo $term->name; ?></div> <?php } ?> </div> <p> <p><?php echo get_field('description',$post->ID); ?></p> </p> </div> <div class="investment__detail"> <div class="raised__amount"> <h2>$<?php echo $total_investment; ?></h2> <div class="raised" data-toggle="tooltip" title="" data-original-title="IntriEnergy is raising up to $1.07M with a minimum goal of $10K">raised</div> <div class="i__container"><i class="ico__box" data-toggle="tooltip" title="" data-original-title="IntriEnergy is raising up to $1.07M with a minimum goal of $10K"> <img src="<?php echo site_url(); ?>/wp-content/plugins/investments/images/info.svg" alt="" /></i> </div> </div> <div class="investment__detail__inner"> <div class="offering__stats"> <h5><?php echo $investors_count; ?></h5> <h6>Investors</h6> </div> <div class="offering__stats"> <h5><?php echo get_field('valuation',$post->ID); ?></h5> <h6>Valuation</h6> </div> </div> <div class="investment__detail__inner"> <div class="offering__stats"> <h5><?php echo get_field('price_per_share',$post->ID); ?></h5> <h6>Price per Share </h6> </div> <div class="offering__stats"> <h5><?php echo get_field('min_investment',$post->ID); ?></h5> <h6> Min. Investment </h6> </div> <div class="offering__stats"> <h5><?php echo get_field('shares_offered',$post->ID); ?></h5> <h6>Shares Offered</h6> </div> </div> <div class="investment__detail__inner"> <div class="offering__stats"> <h5><?php echo get_field('offering_type',$post->ID); ?></h5> <h6>Offering Type</h6> </div> <div class="offering__stats"> <h5><?php echo get_field('offering_max',$post->ID); ?></h5> <h6>Offering Max</h6> </div> </div> <div class="investment__detail__inner"> <div class="offering__stats"> <h5><?php echo get_field('offering',$post->ID); ?></h5> <h6>Offering</h6> </div> </div> <a href="<?php echo site_url(); ?>/payment/?pid=<?php echo $post->ID; ?>">invest now</a> </div> </div> <?php } add_shortcode('payment_form', 'single_payment'); function single_payment(){ ob_start(); payment_form(); return ob_get_clean(); } function payment_form() { global $wpdb; $site_url = site_url()."/login"; if ( ! is_user_logged_in() ) { wp_redirect($site_url); } if(isset($_GET['pid'])) { $pid = $_GET['pid']; } echo $product_name = get_field('title',$pid); echo "<br>"; echo $min_investment = get_field('min_investment',$pid); echo "<br>"; echo $price_per_share = get_field('price_per_share',$post->ID); echo "<br>"; $investment_avg_data = $wpdb->get_row("SELECT AVG(`paid_amount`) AS avg_investment FROM transaction WHERE `item_number` = '".$pid."'"); $avginvestment = $investment_avg_data->avg_investment/100; $avg_investment_round = round($avginvestment); echo $avg_investment = number_format($avg_investment_round,2,".",","); echo "<br>"; $investment_data = $wpdb->get_row("SELECT MAX(`paid_amount`) AS largest_investment FROM transaction WHERE `item_number` = '".$pid."'"); $largestinvestment = $investment_data->largest_investment/100; $largest_investment_round = round($largestinvestment); echo $largest_investment = number_format($largest_investment_round,2,".",","); echo "<br>"; ?> <div class="panel panel-default"> <div class="panel-heading">Order Process</div> <div class="panel-body"> <form action="http://162.215.253.89/ercabarter/dev/payment-process/" method="POST" id="paymentForm"> <div class="row"> <div class="col-md-8" style="border-right:1px solid #ddd;"> <h4 align="center">Customer Details</h4> <div class="form-group"> <label><b>Price<span class="text-danger">*</span></b></label> <input type="text" name="total_amount" id="total_amount" class="form-control" value=""> </div> <div class="form-group"> <label><b>Card Holder Name <span class="text-danger">*</span></b></label> <input type="text" name="customerName" id="customerName" class="form-control" value=""> <span id="errorCustomerName" class="text-danger"></span> </div> <div class="form-group"> <label><b>Email Address <span class="text-danger">*</span></b></label> <input type="text" name="emailAddress" id="emailAddress" class="form-control" value=""> <span id="errorEmailAddress" class="text-danger"></span> </div> <div class="form-group"> <label><b>Address <span class="text-danger">*</span></b></label> <textarea name="customerAddress" id="customerAddress" class="form-control"></textarea> <span id="errorCustomerAddress" class="text-danger"></span> </div> <div class="row"> <div class="col-sm-6"> <div class="form-group"> <label><b>City <span class="text-danger">*</span></b></label> <input type="text" name="customerCity" id="customerCity" class="form-control" value=""> <span id="errorCustomerCity" class="text-danger"></span> </div> </div> <div class="col-sm-6"> <div class="form-group"> <label><b>Zip <span class="text-danger">*</span></b></label> <input type="text" name="customerZipcode" id="customerZipcode" class="form-control" value=""> <span id="errorCustomerZipcode" class="text-danger"></span> </div> </div> </div> <div class="row"> <div class="col-sm-6"> <div class="form-group"> <label><b>State </b></label> <input type="text" name="customerState" id="customerState" class="form-control" value=""> </div> </div> <div class="col-sm-6"> <div class="form-group"> <label><b>Country <span class="text-danger">*</span></b></label> <input type="text" name="customerCountry" id="customerCountry" class="form-control"> <span id="errorCustomerCountry" class="text-danger"></span> </div> </div> </div> <hr> <h4 align="center">Payment Details</h4> <div class="form-group"> <label>Card Number <span class="text-danger">*</span></label> <input type="text" name="cardNumber" id="cardNumber" class="form-control" placeholder="1234 5678 9012 3456" maxlength="20" onkeypress=""> <span id="errorCardNumber" class="text-danger"></span> </div> <div class="form-group"> <div class="row"> <div class="col-md-4"> <label>Expiry Month</label> <input type="text" name="cardExpMonth" id="cardExpMonth" class="form-control" placeholder="MM" maxlength="2" onkeypress="return validateNumber(event);"> <span id="errorCardExpMonth" class="text-danger"></span> </div> <div class="col-md-4"> <label>Expiry Year</label> <input type="text" name="cardExpYear" id="cardExpYear" class="form-control" placeholder="YYYY" maxlength="4" onkeypress="return validateNumber(event);"> <span id="errorCardExpYear" class="text-danger"></span> </div> <div class="col-md-4"> <label>CVC</label> <input type="text" name="cardCVC" id="cardCVC" class="form-control" placeholder="123" maxlength="4" onkeypress="return validateNumber(event);"> <span id="errorCardCvc" class="text-danger"></span> </div> </div> </div> <br> <div align="center"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="item_details" value="<?php echo $product_name; ?>"> <input type="hidden" name="item_number" value="<?php echo $pid; ?>"> <input type="hidden" name="order_number" value="<?php echo generateRandomString(); ?>"> <input type="button" name="payNow" id="payNow" class="btn btn-success btn-sm" onclick="stripePay(event)" value="Pay Now" /> </div> <br> </div> </div> </form> </div> </div> </div> </div> <script type="text/javascript" src="https://js.stripe.com/v2/"></script> <script type="text/javascript" src="http://162.215.253.89/ercabarter/dev/wp-content/plugins/investments/payment1.js"></script> <script type="text/javascript"> Stripe.setPublishableKey('pk_test_51JQdZZEAJtDMbuhoGvZkiYwfBlflB0FLbKke242tY9JwnUM5OeMkYxb7l2gzRgC9py98TvGFUZwtm35OpFNijpb500dUkZ5ACv'); function stripePay(event) { event.preventDefault(); if(validateForm() == true) { jQuery('#payNow').attr('disabled', 'disabled'); jQuery('#payNow').val('Payment Processing....'); Stripe.createToken({ number:jQuery('#cardNumber').val(), cvc:jQuery('#cardCVC').val(), exp_month : jQuery('#cardExpMonth').val(), exp_year : jQuery('#cardExpYear').val() }, stripeResponseHandler); return false; } } function stripeResponseHandler(status, response) { if(response.error) { jQuery('#payNow').attr('disabled', false); jQuery('#message').html(response.error.message).show(); } else { var stripeToken = response['id']; jQuery('#paymentForm').append("<input type='hidden' name='stripeToken' value='" + stripeToken + "' />"); // alert(stripeToken); jQuery('#paymentForm').submit(); } } </script> <?php } add_shortcode('payment_process', 'payment_process'); function payment_process(){ ob_start(); payment_process_code(); return ob_get_clean(); } function payment_process_code() { $paymentMessage = ''; if(!empty($_POST['stripeToken'])){ // get token and user details $stripeToken = $_POST['stripeToken']; $customerName = $_POST['customerName']; $customerEmail = $_POST['emailAddress']; $customerAddress = $_POST['customerAddress']; $customerCity = $_POST['customerCity']; $customerZipcode = $_POST['customerZipcode']; $customerState = $_POST['customerState']; $customerCountry = $_POST['customerCountry']; $cardNumber = $_POST['cardNumber']; $cardCVC = $_POST['cardCVC']; $cardExpMonth = $_POST['cardExpMonth']; $cardExpYear = $_POST['cardExpYear']; //include Stripe PHP library require_once('stripe-php/init.php'); //set stripe secret key and publishable key $stripe = array( "secret_key" => "sk_test_51JQdZZEAJtDMbuhoDE3lmRJ1R69SsFjOhIUYHqH5BZwEB5yZU6Heaxjd8EL0w8i3Fjcfee6ePpswrQf00iMtaVoy00iUHL5S5M", "publishable_key" => "pk_test_51JQdZZEAJtDMbuhoGvZkiYwfBlflB0FLbKke242tY9JwnUM5OeMkYxb7l2gzRgC9py98TvGFUZwtm35OpFNijpb500dUkZ5ACv" ); \Stripe\Stripe::setApiKey($stripe['secret_key']); //add customer to stripe $customer = \Stripe\Customer::create(array( 'name' => $customerName, 'description' => 'test description', 'email' => $customerEmail, 'source' => $stripeToken, "address" => ["city" => $customerCity, "country" => $customerCountry, "line1" => $customerAddress, "line2" => "", "postal_code" => $customerZipcode, "state" => $customerState] )); // item details for which payment made $itemName = $_POST['item_details']; $itemNumber = $_POST['item_number']; // $itemPrice = $_POST['price']; $rawAmount = $_POST['total_amount']; $totalAmount = $rawAmount*100; // $totalAmount = $_POST['total_amount']; $currency = $_POST['currency_code']; $orderNumber = $_POST['order_number']; // details for which payment performed $payDetails = \Stripe\Charge::create(array( 'customer' => $customer->id, 'amount' => $totalAmount, 'currency' => $currency, 'description' => $itemName, 'metadata' => array( 'order_id' => $orderNumber ) )); // get payment details $paymenyResponse = $payDetails->jsonSerialize(); // check whether the payment is successful if($paymenyResponse['amount_refunded'] == 0 && empty($paymenyResponse['failure_code']) && $paymenyResponse['paid'] == 1 && $paymenyResponse['captured'] == 1){ echo "<pre>"; print_r($paymenyResponse); echo "<pre>"; // transaction details $payment_method = $paymenyResponse['payment_method']; $description = $paymenyResponse['description']; $order_id = $paymenyResponse['metadata']['order_id']; $amountPaid = $paymenyResponse['amount']; $balanceTransaction = $paymenyResponse['balance_transaction']; $paidCurrency = $paymenyResponse['currency']; $paymentStatus = $paymenyResponse['status']; $paymentDate = date("Y-m-d H:i:s"); //insert tansaction details into database global $wpdb; $current_user_id = get_current_user_id(); $userdata = array( 'cust_id' => $current_user_id, 'cust_name' =>$customerName, 'cust_email' =>$customerEmail, 'card_number' =>$cardNumber, 'card_cvc' =>$cardCVC, 'card_exp_month' =>$cardExpMonth, 'card_exp_year' => $cardExpYear, 'item_name' => $itemName, 'item_number' => $itemNumber, 'order_id' => $order_id, 'item_price_currency' => $paidCurrency, 'paid_amount' => $amountPaid, 'transaction_id' => $balanceTransaction, 'payment_status' => $paymentStatus, 'created_date'=> $paymentDate ); $successful_data = $wpdb->insert('transaction', $userdata); if ($successful_data) { update_user_meta( $current_user_id, 'cust_name', $customerName ); update_user_meta( $current_user_id, 'customerAddress', $customerCity ); update_user_meta( $current_user_id, 'customerCity', $customerCity ); update_user_meta( $current_user_id, 'customerState', $customerState ); update_user_meta( $current_user_id, 'customerCountry', $customerCountry ); $site_url = site_url()."/dashboard"; wp_redirect($site_url); }else{ $paymentMessage = "failed"; } } else{ $paymentMessage = "failed"; } } else{ $paymentMessage = "failed"; } $_SESSION["message"] = $paymentMessage; }
[+]
js
[-] portfolio.php-19-11-2021
[edit]
[+]
stripe-php
[+]
..
[-] Investments.php--
[edit]
[-] portfolio.php
[edit]
[-] Investments.php-29-10-2021
[edit]
[-] portfolio.php----subho-bk
[edit]
[-] Investments.php--28-last-su
[edit]
[+]
vendor
[-] Investments.php-pay-27
[edit]
[-] Investments.php----an-29
[edit]
[-] Investments.php-28-10-2021
[edit]
[+]
css
[-] portfolio.php-17-11-2021
[edit]
[-] portfolio.php--01
[edit]
[-] payment1.js-01-11-2021
[edit]
[-] Investments.php-01-11-2021
[edit]
[+]
images
[-] portfolio.php-24-11-2021
[edit]
[-] payment1.js
[edit]
[-] portfolio.php-18-11-2021
[edit]