예제 #1
0
 /**
  * Add the image for gravatar
  *
  * @param string $file
  * @param string $path
  * @return array [name (the name of the file), image (the path of the image), message (the returned message)]
  *
  */
 public function addImage($file, $path = ABSPATH)
 {
     $out = array();
     $out['name'] = strtolower(basename($file['name']));
     $out['gravatar'] = _ABH_GRAVATAR_DIR_ . strtolower(basename($file['name']));
     $out['message'] = '';
     $file_error = $file['error'];
     $img = new Model_ABH_Image();
     /* get the file extension */
     $file_name = explode('.', $file['name']);
     $file_type = strtolower($file_name[count($file_name) - 1]);
     /* if the file has a name */
     if (!empty($file['name'])) {
         /* Check the extension */
         $file_type = strtolower($file_type);
         $files = array('jpeg', 'jpg', 'gif', 'png');
         $key = in_array($file_type, $files);
         if (!$key) {
             ABH_Classes_Error::setError(__("File type error: Only JPEG, JPG, GIF or PNG files are allowed.", _ABH_PLUGIN_NAME_));
             return;
         }
         /* Check for error messages */
         $error_count = count($file_error);
         if (!empty($file_error) && $error_count > 0) {
             for ($i = 0; $i <= $error_count; ++$i) {
                 ABH_Classes_Error::setError($file['error'][$i]);
                 return;
             }
         } elseif (!$img->checkFunctions()) {
             ABH_Classes_Error::setError(__("GD error: The GD library must be installed on your server.", _ABH_PLUGIN_NAME_));
             return;
         } else {
             /* Delete the previous file if exists */
             if (is_file($out['gravatar'])) {
                 if (!unlink($out['gravatar'])) {
                     ABH_Classes_Error::setError(__("Delete error: Could not delete the old gravatar.", _ABH_PLUGIN_NAME_));
                     return;
                 }
             }
             /* Upload the file */
             if (!move_uploaded_file($file['tmp_name'], $out['gravatar'])) {
                 ABH_Classes_Error::setError(__("Upload error: Could not upload the gravatar.", _ABH_PLUGIN_NAME_), 'fatal');
                 return;
             }
             /* Change the permision */
             if (!chmod($out['gravatar'], 0755)) {
                 ABH_Classes_Error::setError(__("Permission error: Could not change the gravatar permissions.", _ABH_PLUGIN_NAME_));
                 return;
             }
             /* Transform the image into icon */
             $img->openImage($out['gravatar']);
             $img->resizeImage(80, 80);
             $img->saveImage();
             copy($img->image, $out['gravatar']);
             $out['message'] .= __("The gravatar has been updated.", _ABH_PLUGIN_NAME_);
             return $out;
         }
     }
 }
예제 #2
0
 /**
  * Check for SEO blog bad settings
  */
 public static function checkErrorSettings($count_only = false)
 {
     if (function_exists('is_network_admin') && is_network_admin()) {
         return;
     }
     if (false) {
         if ($count_only) {
             self::$errors_count++;
         } else {
             ABH_Classes_Error::setError(__('Notice', _ABH_PLUGIN_NAME_) . " <br /> ", 'settings');
         }
     }
 }