Advertisement
Koty97

Untitled

Mar 7th, 2017
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.00 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Settings
  4. */
  5.  
  6. get_header(); ?>
  7.  
  8. <?php
  9. //error_reporting(0);
  10. $profitmag_settings = profit_get_theme_options();
  11.  
  12. if( is_singular() ) {
  13.  
  14.         $sidebar_layout = $profitmag_settings['profitmag_sidebar_layout_setting'];    
  15.  
  16. }else {
  17.  
  18.        $sidebar_layout = 'right_sidebar';
  19.  
  20. }
  21. if( $sidebar_layout == 'both_sidebar' ) {
  22.  
  23.        echo '<div id="primary-wrap" class="clearfix">';
  24. }
  25. ?>
  26.     <div id="primary" class="content-area">
  27.         <main id="main" class="site-main" role="main">
  28. <?php if(is_user_logged_in()): ?>
  29.         <!--Custom settings start-->
  30.         <!--Create database connection-->
  31. <?php
  32. $servername = "10.28.16.124";
  33. $username = "a147121_ge3nwkb";
  34. $password = "gWqxGxAq";
  35. $dbname = "d147121_ge3nwkb";
  36. $conn = new mysqli($servername, $username, $password, $dbname);
  37. ?>
  38. <!--Get user ID-->
  39. <?php
  40. $current_user = wp_get_current_user();
  41. $user_ID = $current_user->ID;
  42. ?>
  43. <!--Get checked categories and selected background-->
  44. <?php
  45. $sqlgetch = "SELECT push_categories FROM userdata WHERE ID=".$user_ID.";";
  46. $checked = mysqli_fetch_assoc($conn->query($sqlgetch));
  47. $chu = implode(",",$checked);
  48. $chux = explode(",", $chu);
  49. $sqlgetim = "SELECT background_image FROM userdata Where ID=".$user_ID.";";
  50. $selimg = mysqli_fetch_assoc($conn->query($sqlgetim));
  51. $selectedimage = implode (",",$selimg);
  52. ?>
  53. <!--HTML settings form-->
  54. <form name="myform" action="" method="POST">
  55. <div align="center">
  56. <select name="image">
  57. <?php
  58. $imgarray = array("WF", "SF");
  59. foreach ($imgarray as $prvekpole):
  60. if ($prvekpole != $selectedimage):
  61. echo "<option value=\"". $prvekpole . "\">". $prvekpole . "</option>";
  62. else:
  63. echo "<option value=\"". $prvekpole . "\" ". selected .">". $prvekpole . "</option>";
  64. endif;
  65. endforeach;
  66. ?>
  67. </select>
  68. <input type="submit" value="Submit">
  69. <br>
  70. <?php
  71.  $cats = get_categories();
  72.   foreach($cats as $cat):
  73.   foreach ($chux as $check):
  74.   if($check ==  get_cat_ID($cat->cat_name)):
  75.   $status = "checked";
  76.   elseif ($status == "checked"):
  77.   $status = "checked";
  78.   else:
  79.   $status = "";
  80.   endif;
  81.   endforeach;
  82.   echo "<input type=\"checkbox\"".  $status ." name=\"notification[]\" value=\"". get_cat_ID($cat->cat_name) . "\">". $cat->cat_name ."<br>";
  83.   $status = "";
  84.   endforeach;
  85. ?>
  86. </div>
  87. </form>
  88. <!--Options to variables-->
  89. <?php $Image = $_POST['image']; ?>
  90. <?php $notification = $_POST['notification'];
  91. $notify = implode(",",$notification);
  92. if (!isset($Image)):
  93. $Image = $selectedimage;
  94. endif;
  95. if (!isset($notify)):
  96. $notify = $chu;
  97. endif;
  98. ?>
  99.  
  100. <!--Push SQL-->
  101. <?php
  102. $sql = "UPDATE userdata
  103. SET background_image='".$Image."', push_categories ='".$notify."'
  104. WHERE ID=".$user_ID.";";
  105. if ($conn->query($sql) === TRUE) {
  106. }
  107. ?>
  108. <!--Push original-->
  109. <!--Stop database connection-->
  110. <?php
  111. $conn->close();
  112. ?>
  113. <?php else: ?>
  114. <?php endif; ?>
  115.         </main><!-- #main -->
  116.     </div><!-- #primary -->
  117.  
  118. <?php get_sidebar( 'left' ); ?>
  119. <?php
  120. if( $sidebar_layout == 'both_sidebar' ) {
  121.     echo '</div>';
  122. }
  123. ?>
  124. <?php get_sidebar(); ?>
  125. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement