PHP Classes

File: upload/plugins/bulletinboard/api_libs/bb_account_save_avatar.php

Recommend this page to a friend!
  Classes of James Brows   PHP Bulletin Board   upload/plugins/bulletinboard/api_libs/bb_account_save_avatar.php   Download  
File: upload/plugins/bulletinboard/api_libs/bb_account_save_avatar.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Bulletin Board
Manage and post messages in multi-user forums
Author: By
Last change:
Date: 3 years ago
Size: 1,032 bytes
 

Contents

Class file image Download
<?php

function bb_account_save_avatar()
{

    if(
Configs::$_['user_data']['user_id']=='GUEST')
    {
        return
'NG';
    }
   
   
$cookie_username=isset(Configs::$_['user_data']['user_id'])?Configs::$_['user_data']['user_id']:'';

    if(!isset(
$cookie_username[1]))
    {
        return
'NG';
    }

   
$file_path=addslashes(getPost('file_path',''));

   
$file_path=str_replace(SITE_URL,'',$file_path);

   
$resize = new ResizeImage(ROOT_PATH.$file_path);
   
$resize->resizeTo(256, 256, 'exact');
   
$resize->saveImage(ROOT_PATH.$file_path);

   
$new_path='public/uploads/users/'.basename($file_path);

   
copy($file_path,ROOT_PATH.$new_path);

   
$db=new Database();

   
$db->nonquery("update user_mst set avatar='".$new_path."' where user_id='".Configs::$_['user_data']['user_id']."' ");

    if(
file_exists($file_path))
    {
       
unlink($file_path);
    }

   
$savePath=BB_CACHES_PATH.'forums.php';

    if(
file_exists($savePath))
    {
       
unlink($savePath);
    }

    return
SITE_URL.$new_path;
}