예제 #1
0
    $db =& JFactory::getDBO();
    foreach ($sqlcommands as $sql) {
        $db->setQuery($sql);
        $result = $db->query();
        if (!$result) {
            $err = $db->getErrorMsg();
            echo "ERROR: " . $err . "<br />\n";
        }
    }
    $db->setQuery("SELECT `avatar` FROM `jos_comprofiler` WHERE !ISNULL(`avatar`)");
    $items = ($items = $db->loadObjectList()) ? $items : array();
    foreach ($items as $anItem) {
        $bigpath = "images/comprofiler/" . $anItem->avatar;
        $smallpath = "images/comprofiler/tn" . $anItem->avatar;
        if (file_exists($bigpath)) {
            square_crop($bigpath, $smallpath, 70);
        }
    }
}
function square_crop($src_image, $dest_image, $thumb_size = 64, $jpg_quality = 90)
{
    // Get dimensions of existing image
    $image = getimagesize($src_image);
    // Check for valid dimensions
    if ($image[0] <= 0 || $image[1] <= 0) {
        return false;
    }
    // Determine format from MIME-Type
    $image['format'] = strtolower(preg_replace('/^.*?\\//', '', $image['mime']));
    // Import image
    switch ($image['format']) {
예제 #2
0
 	   $db->setQuery( $sql );
 	   $db->query();
 */
 //		Do not overwrite profile data anything except photos. Update photos ONLY if the profile has no photo.
 //      Making your life simple.
 //-- mugshot
 if ($result->avatarapproved != 1) {
     if (isset($user->pictureUrl) && strlen($user->pictureUrl) > 0) {
         $pictureurl = $user->pictureUrl;
         $imgBaseName = md5($user->pictureUrl) . ".jpg";
         $imgFromLinkedIn = "/../images/comprofiler/" . md5($user->pictureUrl) . ".jpg";
         $AvatarForUser = "******" . md5($user->pictureUrl) . ".jpg";
         $avatar = md5($user->pictureUrl) . "_small.jpg";
         snarf_image($pictureurl, dirname(__FILE__) . $imgFromLinkedIn);
         if (file_exists(dirname(__FILE__) . $imgFromLinkedIn)) {
             square_crop(dirname(__FILE__) . $imgFromLinkedIn, dirname(__FILE__) . $AvatarForUser, 70);
         }
     }
     $sql = "UPDATE `#__comprofiler` SET \n\t\t\t\t   `avatar`  = '" . mysql_real_escape_string(stripslashes($imgBaseName)) . "',\n\t\t\t\t   `avatarapproved` = 1\n\t\t\t\t   WHERE `#__comprofiler`.`user_id` =  '" . intval($result->id) . "'\n\t\t\t\t   AND `avatarapproved` <> 1 ";
     $db->setQuery($sql);
     $db->query();
 }
 //
 //		//-- integration
 //		$sql = "UPDATE `#__comprofiler` SET
 //				`cb_linkedinid` = '" .                  mysql_real_escape_string( stripslashes( $email     )) . "',
 //				`cb_linkedindata` = '".                 mysql_real_escape_string( stripslashes( print_r( $user, true  )     )) . "',
 //				WHERE `#__comprofiler`.`user_id` =  '". intval( $result->id ) ."'";
 //
 //		$db->setQuery( $sql );
 //		$db->query();