Exemplo n.º 1
0
 /**
  * Process the uploaded image in the settings form.
  * @return void
  */
 private function uploadLogo()
 {
     check_admin_referer('upload-login-image');
     if (isset($_POST['action']) && 'upload' == $_POST['action']) {
         // Process uploaded file
         require_once AK_VENDOR . '/upload/class.upload.php';
         $handle = new akUpload($_FILES['login_image'], $this->PID);
         if ($handle->uploaded) {
             $handle->image_resize = true;
             $handle->image_ratio_y = true;
             $handle->image_x = 326;
             $handle->file_overwrite = true;
             $handle->file_auto_rename = false;
             $handle->file_new_name_body = 'login';
             $handle->image_convert = 'png';
             $uploads = wp_upload_dir();
             $folder = trailingslashit($uploads['basedir']) . 'alkivia';
             $handle->Process($folder);
             if ($handle->processed) {
                 ak_admin_notify(__('File uploaded.', $this->PID));
             } else {
                 ak_admin_error(__('Error', $this->PID) . ': ' . $handle->error);
             }
         } else {
             ak_admin_error(__('No file received.', $this->PID));
         }
     } else {
         // Missing action
         ak_admin_error(__('Bad form received.', $this->PID));
     }
 }
Exemplo n.º 2
0
 /**
  * Saves gallery settings from admin page.
  * @return void
  */
 private function saveAdminSettings()
 {
     check_admin_referer('alkivia-gallery-settings');
     if (isset($_POST['action']) && 'update' == $_POST['action']) {
         $post = stripslashes_deep($_POST['settings']);
         $post = array_merge($this->defaultOptions(), $post);
         $post['megapixels'] = str_replace(',', '.', $post['megapixels']);
         $post['minpixels'] = str_replace(',', '.', $post['minpixels']);
         $settings = array('descending' => intval($post['descending']), 'local_avatar' => intval($post['local_avatar']), 'check_gravatar' => intval($post['check_gravatar']), 'max_number' => intval($post['max_number']), 'concurrent_up' => intval($post['concurrent_up']), 'max_size' => intval($post['max_size']), 'megapixels' => floatval($post['megapixels']), 'minpixels' => floatval($post['minpixels']), 'large' => intval($post['large']), 'large_w' => intval($post['large_w']), 'large_h' => intval($post['large_h']), 'thumb' => intval($post['thumb']), 'thumb_w' => intval($post['thumb_w']), 'thumb_h' => intval($post['thumb_h']), 'thumb_crop' => intval($post['thumb_crop']), 'avatar_size' => intval($post['avatar_size']), 'watermark' => intval($post['watermark']), 'needs_load' => intval($post['needs_load']), 'author_thumbnail' => $post['author_thumbnail'], 'gallery_template' => $post['gallery_template']);
         $settings['anonymous_url'] = empty($post['anonymous_url']) ? ak_get_object($this->PID)->getURL() . 'images/anonymous.png' : $post['anonymous_url'];
         $this->setNewOptions($settings);
         // Upload the Watermark file
         require_once AK_VENDOR . '/upload/class.upload.php';
         $handle = new akUpload($_FILES['wmark_file'], $this->PID);
         if ($handle->uploaded) {
             $handle->image_resize = true;
             $handle->image_ratio_y = true;
             $img_w = 2 == $this->getOption('large') ? $this->getOption('large_w') : get_option('large_size_w');
             $handle->image_x = intval((int) $img_w / 3);
             // Watermark is 1/3 large image width.
             $handle->file_overwrite = true;
             $handle->file_auto_rename = false;
             $handle->file_new_name_body = 'watermark';
             $handle->image_convert = 'png';
             $uploads = wp_upload_dir();
             $handle->Process($uploads['basedir'] . '/alkivia');
             if (!$handle->processed) {
                 ak_admin_error(__('Error', $this->PID) . ': ' . $handle->error);
             }
         }
         ak_admin_notify();
     } else {
         // Missing action
         wp_die('Bad form received.', $this->PID);
     }
 }