Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: Settings
- */
- get_header(); ?>
- <?php
- //error_reporting(0);
- $profitmag_settings = profit_get_theme_options();
- if( is_singular() ) {
- $sidebar_layout = $profitmag_settings['profitmag_sidebar_layout_setting'];
- }else {
- $sidebar_layout = 'right_sidebar';
- }
- if( $sidebar_layout == 'both_sidebar' ) {
- echo '<div id="primary-wrap" class="clearfix">';
- }
- ?>
- <div id="primary" class="content-area">
- <main id="main" class="site-main" role="main">
- <?php if(is_user_logged_in()): ?>
- <!--Custom settings start-->
- <!--Create database connection-->
- <?php
- $servername = "10.28.16.124";
- $username = "a147121_ge3nwkb";
- $password = "gWqxGxAq";
- $dbname = "d147121_ge3nwkb";
- $conn = new mysqli($servername, $username, $password, $dbname);
- ?>
- <!--Get user ID-->
- <?php
- $current_user = wp_get_current_user();
- $user_ID = $current_user->ID;
- ?>
- <!--Get checked categories and selected background-->
- <?php
- $sqlgetch = "SELECT push_categories FROM userdata WHERE ID=".$user_ID.";";
- $checked = mysqli_fetch_assoc($conn->query($sqlgetch));
- $chu = implode(",",$checked);
- $chux = explode(",", $chu);
- $sqlgetim = "SELECT background_image FROM userdata Where ID=".$user_ID.";";
- $selimg = mysqli_fetch_assoc($conn->query($sqlgetim));
- $selectedimage = implode (",",$selimg);
- ?>
- <!--HTML settings form-->
- <form name="myform" action="" method="POST">
- <div align="center">
- <select name="image">
- <?php
- $imgarray = array("WF", "SF");
- foreach ($imgarray as $prvekpole):
- if ($prvekpole != $selectedimage):
- echo "<option value=\"". $prvekpole . "\">". $prvekpole . "</option>";
- else:
- echo "<option value=\"". $prvekpole . "\" ". selected .">". $prvekpole . "</option>";
- endif;
- endforeach;
- ?>
- </select>
- <input type="submit" value="Submit">
- <br>
- <?php
- $cats = get_categories();
- foreach($cats as $cat):
- foreach ($chux as $check):
- if($check == get_cat_ID($cat->cat_name)):
- $status = "checked";
- elseif ($status == "checked"):
- $status = "checked";
- else:
- $status = "";
- endif;
- endforeach;
- echo "<input type=\"checkbox\"". $status ." name=\"notification[]\" value=\"". get_cat_ID($cat->cat_name) . "\">". $cat->cat_name ."<br>";
- $status = "";
- endforeach;
- ?>
- </div>
- </form>
- <!--Options to variables-->
- <?php $Image = $_POST['image']; ?>
- <?php $notification = $_POST['notification'];
- $notify = implode(",",$notification);
- if (!isset($Image)):
- $Image = $selectedimage;
- endif;
- if (!isset($notify)):
- $notify = $chu;
- endif;
- ?>
- <!--Push SQL-->
- <?php
- $sql = "UPDATE userdata
- SET background_image='".$Image."', push_categories ='".$notify."'
- WHERE ID=".$user_ID.";";
- if ($conn->query($sql) === TRUE) {
- }
- ?>
- <!--Push original-->
- <!--Stop database connection-->
- <?php
- $conn->close();
- ?>
- <?php else: ?>
- <?php endif; ?>
- </main><!-- #main -->
- </div><!-- #primary -->
- <?php get_sidebar( 'left' ); ?>
- <?php
- if( $sidebar_layout == 'both_sidebar' ) {
- echo '</div>';
- }
- ?>
- <?php get_sidebar(); ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement