PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/branding.php

http://clients-oriented-ftp.googlecode.com/
PHP | 137 lines | 101 code | 16 blank | 20 comment | 11 complexity | fe789ea19e606d1f526fc1606f3b9581 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * Shows the current company logo and a form to upload
  4. * a new one.
  5. * This image is used on the files list templates later.
  6. *
  7. * @package ProjectSend
  8. * @subpackage Upload
  9. */
  10. $allowed_levels = array(9);
  11. require_once('sys.includes.php');
  12. $page_title = __('Branding','cftp_admin');
  13. include('header.php');
  14. $database->MySQLDB();
  15. $logo_file_info = generate_logo_url();
  16. ?>
  17. <div id="main">
  18. <h2><?php echo $page_title; ?></h2>
  19. <div class="options_box whitebox">
  20. <?php
  21. if ($_POST) {
  22. /** Valid file extensions (images) */
  23. $image_file_types = "/^\.(jpg|jpeg|gif|png){1}$/i";
  24. if (is_uploaded_file($_FILES['select_logo']['tmp_name'])) {
  25. $this_upload = new PSend_Upload_File();
  26. $safe_filename = $this_upload->safe_rename($_FILES['select_logo']['name']);
  27. /**
  28. * Check the file type for allowed extensions.
  29. *
  30. * @todo Use the file upload class file type validation function.
  31. */
  32. if (preg_match($image_file_types, strrchr($safe_filename, '.'))) {
  33. /**
  34. * Move the file to the destination defined on sys.vars.php. If ok, add the
  35. * new file name to the database.
  36. */
  37. if (move_uploaded_file($_FILES['select_logo']['tmp_name'],LOGO_FOLDER.$safe_filename)) {
  38. $q = 'UPDATE tbl_options SET value="'.$safe_filename.'" WHERE name="logo_filename"';
  39. $sql = $database->query($q, $database->connection);
  40. $msg = __('The image was uploaded correctly.','cftp_admin');
  41. echo system_message('ok',$msg);
  42. /** Record the action log */
  43. $new_log_action = new LogActions();
  44. $log_action_args = array(
  45. 'action' => 29,
  46. 'owner_id' => $global_id
  47. );
  48. $new_record_action = $new_log_action->log_action_save($log_action_args);
  49. }
  50. else {
  51. $msg = __('The file could not be moved to the corresponding folder.','cftp_admin');
  52. $msg .= __("This is a most likely a permissions issue. If that's the case, it can be solved by setting -via FTP- the chmod value of the",'cftp_admin');
  53. $msg .= ' '.LOGO_FOLDER.' ';
  54. $msg .= __('directory to 755, or 777 as a last resource.','cftp_admin');
  55. $msg .= __("If this doesn't solve the issue, try giving the same values to the directories above that one until it works.",'cftp_admin');
  56. echo system_message('error',$msg);
  57. }
  58. }
  59. else {
  60. $msg = __('The file you selected is not a valid image one. Please upload a jpg, gif or png formated logo picture.','cftp_admin');
  61. echo system_message('error',$msg);
  62. }
  63. }
  64. else {
  65. $msg = __('There was an error uploading the file. Please try again.','cftp_admin');
  66. echo system_message('error',$msg);
  67. }
  68. }
  69. else {
  70. ?>
  71. <script type="text/javascript">
  72. $(document).ready(function() {
  73. $("form").submit(function() {
  74. clean_form(this);
  75. is_complete(this.select_logo,'<?php _e('Please select an image file to upload','cftp_admin'); ?>');
  76. // show the errors or continue if everything is ok
  77. if (show_form_errors() == false) { return false; }
  78. });
  79. });
  80. </script>
  81. <p><?php _e('Use this page to upload your company logo, or update your current uploaded one. This image will be shown to your clients when they access their file list.','cftp_admin'); ?></p>
  82. <div id="current_logo">
  83. <div id="current_logo_left">
  84. <p><strong><?php _e('Current logo','cftp_admin'); ?></strong></p>
  85. <p class="logo_note"><?php _e("The picture on the right is not an actual representation of what they will see. The size on this preview is fixed, but remember that you can change the display size and picture quality for your client's pages on the",'cftp_admin'); ?> <a href="options.php"><?php _e("options",'cftp_admin'); ?></a> <?php _e("section.",'cftp_admin'); ?></p>
  86. </div>
  87. <div id="current_logo_right">
  88. <div id="current_logo_img">
  89. <?php
  90. if ($logo_file_info['exists'] === true) {
  91. ?>
  92. <img src="<?php echo TIMTHUMB_URL; ?>?src=<?php echo $logo_file_info['url']; ?>&amp;w=220" alt="<?php _e('Logo Placeholder','cftp_admin'); ?>" />
  93. <?php
  94. }
  95. ?>
  96. </div>
  97. </div>
  98. </div>
  99. <div id="form_upload_logo">
  100. <form action="branding.php" name="logoupload" method="post" enctype="multipart/form-data">
  101. <input type="hidden" name="MAX_FILE_SIZE" value="1000000000">
  102. <ul class="form_fields">
  103. <li>
  104. <label><?php _e('Select image to upload','cftp_admin'); ?></label>
  105. <input type="file" name="select_logo" />
  106. </li>
  107. <li class="form_submit_li">
  108. <input type="submit" name="Submit" value="<?php _e('Upload','cftp_admin'); ?>" class="button button_blue button_submit" />
  109. </li>
  110. </ul>
  111. </form>
  112. </div>
  113. <?php } ?>
  114. </div>
  115. <div class="clear"></div>
  116. </div>
  117. <?php include('footer.php'); ?>