PageRenderTime 32ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/bbcsadmin/modules/tools/generalsettings_a.php

https://gitlab.com/zohaibsaleem/shipcliq
PHP | 170 lines | 116 code | 36 blank | 18 comment | 27 complexity | 210d15da9a22696724044086faddae0b MD5 | raw file
  1. <?php
  2. include_once(TPATH_LIBRARIES."/general/Imagecrop.class.php");
  3. $thumb = new thumbnail();
  4. $action = $_REQUEST['action'];
  5. $Data = $_POST["Data"];
  6. //echo "<pre>"; print_r($_POST); /*print_r($_FILES);*/ exit;
  7. $validext = array ('image/png',"image/jpeg","image/gif","image/jpg","image/bmp");
  8. if($action == "edit")
  9. {
  10. if($_POST) {
  11. $Data = $_POST['Data'];
  12. ################# For Logo Start #########################
  13. $logo_file_object = $_FILES['Data']['tmp_name']['SITE_LOGO'];
  14. $logo_file_name = $_FILES['Data']['name']['SITE_LOGO'];
  15. $logo_file_type = $_FILES['Data']['type']['SITE_LOGO'];
  16. //echo "<pre>"; print_r($logo_file_type); exit;
  17. $PATH = $tconfig["tsite_upload_site_logo_path"];
  18. $size1 = $tconfig["tsite_upload_images_site_logo_size1"];
  19. //$validext = array ('image/png',"image/jpeg","image/gif","image/jpg","image/bmp");
  20. if($logo_file_name != "" && in_array($logo_file_type, $validext))
  21. {
  22. $vFile = $generalobj->general_upload_image($logo_file_object,$logo_file_name,$PATH,$size1,"","","","","","y","");
  23. $logoupdatepara = array("vValue"=>"$vFile");
  24. $where2 = "vName = 'SITE_LOGO'";
  25. $result2 = $obj->MySQLQueryPerform('configurations',$logoupdatepara,'update',$where2);
  26. }
  27. ################# For Logo End #########################
  28. ################# For Footer Logo Start #########################
  29. $footer_logo_file_object = $_FILES['Data']['tmp_name']['FOOTER_LOGO'];
  30. $footer_logo_file_name = $_FILES['Data']['name']['FOOTER_LOGO'];
  31. $footer_logo_file_type = $_FILES['Data']['type']['FOOTER_LOGO'];
  32. $PATH = $tconfig["tsite_upload_footer_logo_path"];
  33. $size2 = $tconfig["tsite_upload_images_footer_logo_size2"];
  34. if($footer_logo_file_name != "" && in_array($footer_logo_file_type, $validext))
  35. {
  36. $vFile2 = $generalobj->general_upload_image($footer_logo_file_object,$footer_logo_file_name,$PATH,$size2,"","","","","","","");
  37. $logoupdatepara = array("vValue"=>"$vFile2");
  38. $where2 = "vName = 'FOOTER_LOGO'";
  39. $result2 = $obj->MySQLQueryPerform('configurations',$logoupdatepara,'update',$where2);
  40. }
  41. ################# For Logo End #########################
  42. ################# For Ride Background Start #########################
  43. /* ------ code for unlink image Start -------*/
  44. $where2 = "vName = 'RIDE_BACKGROUND'";
  45. $sql="SELECT * FROM configurations WHERE ".$where2;
  46. $db_res=$obj->MySQLSelect($sql);
  47. $PATH = $tconfig["tsite_upload_footer_logo_path"];
  48. $unlink_img=$PATH."1_".$db_res[0]['vValue'];
  49. if($background_logo_file_name !='')
  50. {
  51. unlink($unlink_img);
  52. }
  53. /* ------ code for unlink image END -------*/
  54. $background_logo_file_object = $_FILES['Data']['tmp_name']['RIDE_BACKGROUND'];
  55. $background_logo_file_name = $_FILES['Data']['name']['RIDE_BACKGROUND'];
  56. $background_logo_file_type = $_FILES['Data']['type']['RIDE_BACKGROUND'];
  57. $size2 = $tconfig["tsite_upload_images_site_logo_size_bg"];
  58. if($background_logo_file_name != "" && in_array($background_logo_file_type, $validext))
  59. {
  60. $vFile2 = $generalobj->general_upload_image($background_logo_file_object,$background_logo_file_name,$PATH,$size2,"","","","","","","");
  61. //echo $vFile2; exit;
  62. $logoupdatepara = array("vValue"=>"$vFile2");
  63. $result2 = $obj->MySQLQueryPerform('configurations',$logoupdatepara,'update',$where2);
  64. }
  65. ################# For Ride Background End #########################
  66. ################# For Email Logo Start #########################
  67. $Email_logo_file_object = $_FILES['Data']['tmp_name']['EMAIL_LOGO'];
  68. $Email_logo_file_name = $_FILES['Data']['name']['EMAIL_LOGO'];
  69. $Email_logo_file_type = $_FILES['Data']['type']['EMAIL_LOGO'];
  70. $PATH = $tconfig["tsite_upload_email_logo_path"];
  71. $size3 = $tconfig["tsite_upload_images_email_logo_size1"];
  72. if($Email_logo_file_name != "" && in_array($Email_logo_file_type, $validext))
  73. {
  74. $vFile4 = $generalobj->general_upload_image($Email_logo_file_object,$Email_logo_file_name,$PATH,$size3,"","","","","","","");
  75. $logoupdatepara = array("vValue"=>"$vFile4");
  76. $where2 = "vName = 'EMAIL_LOGO'";
  77. $result2 = $obj->MySQLQueryPerform('configurations',$logoupdatepara,'update',$where2);
  78. }
  79. ################# For Email Logo End #########################
  80. ################# For Favicon Start #########################
  81. $favicon_file_object = $_FILES['Data']['tmp_name']['FAVICON_ICON'];
  82. $favicon_file_name = $_FILES['Data']['name']['FAVICON_ICON'];
  83. $favicon_file_type = $_FILES['Data']['type']['FAVICON_ICON'];
  84. $PATH1 = $tconfig["tsite_upload_site_favicon_path"];
  85. $size4 = $tconfig["tsite_upload_images_site_favicon_size4"];
  86. if($favicon_file_name != "")
  87. {
  88. $vFile1 = $generalobj->imageupload($PATH1,$favicon_file_object,$favicon_file_name,$prefix='', $vaildExt="ico");
  89. if($vFile1[2] != "")
  90. {
  91. $msg = "You have selected wrong file format for Image. Valid format is ico";
  92. header("Location: ".$tconfig["tpanel_url"]."/index.php?file=to-generalsettings&mode=edit&var_msg=".$msg."&eType=".$_POST['eType']);
  93. exit;
  94. }
  95. $faviconupdatepara = array("vValue"=>"$vFile1[0]");
  96. $where1 = "vName = 'FAVICON_ICON'";
  97. $result1 = $obj->MySQLQueryPerform('configurations',$faviconupdatepara,'update',$where1);
  98. }
  99. ################# For Favicon End #########################
  100. foreach($Data as $key=>$val) {
  101. $Value = array(
  102. 'vValue'=>$val
  103. );
  104. $where = ' vName = "'.$key.'"';
  105. $result = $obj->MySQLQueryPerform('configurations',$Value,'update',$where);
  106. }
  107. if($result){
  108. $var_msg='Setting Updated Successfully.';
  109. }else{
  110. $var_msg='Error-in updating setting.Please try again.';
  111. }
  112. header("Location: ".$tconfig["tpanel_url"]."/index.php?file=to-generalsettings&mode=edit&var_msg=".$var_msg."&eType=".$_POST['eType']);
  113. exit;
  114. }
  115. }
  116. ################## Delete Logo & Favicon Start ######################
  117. if($action == "confirm_delete")
  118. {
  119. $imagemode = $_POST['imagemode'];
  120. $sql = "select vValue from configurations where vName = '$imagemode' ";
  121. $db_gallery = $obj->MySQLSelect($sql);
  122. if($imagemode == "FAVICON_ICON")
  123. {
  124. $imgfolder = $tconfig["tsite_upload_site_favicon_path"];
  125. }
  126. unlink($imgfolder.$db_gallery[0]['vValue']);
  127. $sql="UPDATE configurations SET vValue = '' where vName = '$imagemode'";
  128. $db_delete=$obj->sql_query($sql);
  129. if($db_delete)$var_msg = "Deleted Successfully.";else $var_msg="Error-in Delete.";
  130. header("Location: ".$tconfig["tpanel_url"]."/index.php?file=to-generalsettings&mode=edit&var_msg=".$var_msg."&eType=".$_POST['eType']);
  131. exit;
  132. }
  133. ################## Delete Logo & Fvaicon End ########################
  134. ?>