Current location: Hot Scripts Forums » Programming Languages » PHP » Please Help To Finiesh This Code


Please Help To Finiesh This Code

Reply
  #1 (permalink)  
Old 01-20-05, 09:14 PM
Dream On Dream On is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Please Help To Finiesh This Code

Hello every one..

I'am trying to make a file upload when the user going to the upload any file .. itiwll creat a file ID with their ID

here is the code

PHP Code:

error_reporting(E_ALL & ~E_NOTICE);

define('NO_REGISTER_GLOBALS'1);

$globaltemplates = array(
    
'ADV_LINKS_ADD_EDIT',
    
'adv_links_select',
    
'adv_links_deletebit',
    
'adv_links_addlink_custombits',
    
'newpost_errormessage',
    
'newpost_preview'
);

$actiontemplates['none'] = &$actiontemplates['addlink'];

require_once(
'./links_config.php');

if (empty(
$_REQUEST['do']))
{
    
$_REQUEST['do'] = 'addlink';
}

// ###################### Function To Check Errors ###########################
function check_link_errors($dupe 0)
{
    global 
$_POST$DB_site$vba_options;

    
$errors = array();

    if (!
$_POST['catid'])
    {
        eval(
'$errors[] = "' fetch_phrase('adv_links_must_choose_directory'PHRASETYPEID_ERROR) . '";');
    }
    if (
$_POST['url'] == 'http://' OR !$_POST['url'] OR !$_POST['name'] OR !$_POST['description'])
    {
        eval(
'$errors[] = "' fetch_phrase('adv_links_missingfiled'PHRASETYPEID_ERROR) . '";');
    }

    
$urlcheck substr(trim($_POST['url']), 07);
    if (
$urlcheck != 'http://' AND $urlcheck != 'https:/')
    {
        
$_POST['url'] = 'http://' $_POST['url'];
    }

    if (
$vba_options['links_verifynew'])
    {
        
$geturl = @parse_url(trim($_POST['url'])); 
        
$host $geturl['host']; 
        
$path $geturl['path']; 

        if(!@
fsockopen($host80$errno$errstr20))
        {
            eval(
'$errors[] = "' fetch_phrase('adv_links_invalid_url'PHRASETYPEID_ERROR) . '";');
        }
    }

    if (!
$vba_options['links_allowdupes'])
    {
        function 
strip_url($linkurl)
        {
            
$linkurl str_replace(array('http://www.''http://'), ''$linkurl);
    
            if (
substr($linkurlstrlen($linkurl) - 1strlen($linkurl) - 1) == '/')
            {
                
$linkurl substr($linkurl0strlen($linkurl) - 1);
            }
            return 
$linkurl;
        }
    
        
$linkdomain substr(strip_url($_POST['url']), 0strrpos($_POST['url'], '.')); 
    
        
$checkdupe $DB_site->query("SELECT url FROM " TABLE_PREFIX "links WHERE url LIKE '%$linkdomain%' " iif(!$dupe"AND linkid != '$_POST[linkid]'") . " LIMIT 1");
        while (
$dupe $DB_site->fetch_array($checkdupe))
        {
            if (
strip_url($dupe['url']) == strip_url($_POST['url']))
            {
                
$linkurl htmlspecialchars($_POST['url']);
                eval(
'$errors[] = "' fetch_phrase('adv_links_duplicate'PHRASETYPEID_ERROR) . '";');
            }
        }
    }

    
$cfields = array();
    
$customfields $DB_site->query("SELECT * FROM " TABLE_PREFIX "links_customfields");
    while (
$custom $DB_site->fetch_array($customfields))
    {
        
$cfields[$custom[fieldid]] = $custom;
    }

    foreach (
$cfields AS $field => $values)
    {
        
$thisfield 'field' $field;
        if (
$values['required'] AND empty($_POST["$thisfield"]))
        {
            
$profilefield['title'] = $values['title'];
            eval(
'$errors[] = "' fetch_phrase('requiredfieldmissing'PHRASETYPEID_ERROR) . '";');
        }
    }

    return 
$errors;
}
    
// ################# Mass uploading from server #################
    
if (!$page)
    {
        if (
$server['upload'])
        {
            
$processfiles = array();
            
$errors = array();

            if (!(
$permissions['dloadpermissions'] & CANUPLOADFROMSERVER))
            {
                
print_adv_no_permission();
            }

            
$dir $vba_options['dload_userfolder'] . '/' $bbuserinfo['userid'];

            if (
$dh = @opendir($dir))
            {
                while ((
$file readdir($dh)) !== false)
                {
                    if (
$file != '.' AND $file != '..')
                    {
                        
$filecount++;
                        
$fileinfo fetch_image_info($dir '/' $file$file);
                        
$fileinfo['catid'] = $massimageinfo['catid'];
                        
$errors["$fileinfo[saveas]"] = check_upload_errors();
                        @
chmod($dir '/' $file0777);
                        if (empty(
$errors["$imageinfo[saveas]"]))
                        {
                            
$processfiles[] = $imageinfo['truename'];
                        }
                    }
                }
                
closedir($dh);
            }
        }
        else
        {
            
// ###################### Uploading Single File(s) ######################
            
$server['process_number'] = $vba_options['dload_uploadinputs'];
            foreach (
$_FILES AS $file)
            {
                if (
$file['tmp_name'])
                {
                    
$gotfiles true;
                    
$fileinfo fetch_image_info($file['tmp_name'], $file['name'], 0);
                    
$fileinfo['catid'] = $massimageinfo['catid'];

                    
$errors["$imageinfo[saveas]"] = check_upload_errors();

                    if (!empty(
$errors["$imageinfo[saveas]"]))
                    {
                        
$show['errors'] = true;
                    }
                    else
                    {
                        
$filecount++;
                        @
move_uploaded_file($file['tmp_name'], $fileinfo['saveto'] . '/' $fileinfo['saveas']);
                        
$processfiles[] = $fileinfo['saveas'];
                    }
                }
            }

            if (!
$gotfiles)
            {
                eval(
'$errors[\'\'][\'\'] = "' fetch_phrase('attachnofile'PHRASETYPEID_ERROR) . '";');
            }
        }
    }

    
// Print out any initial errors
    
if (!empty($errors))
    {
        foreach (
$errors AS $filename => $error)
        {
            if (!empty(
$error))
            {
                
$show['errors'] = true;
                
$uploaderrors .= '<tr><td class="thead">' $filename '</td></tr>';
                foreach (
$error AS $varname => $text)
                {
                    
$uploaderrors .= '<tr><td class="alt1">' $text '</td></tr>';
                }
            }
        }
    }
 
// ############################## Main Upload Page ############################
if ($_REQUEST['do'] == 'upload')
{
    
globalize($_POST, array('imageinfo'));

    
$catoptions print_cat_select($catid'upload');

    if (!
$catoptions)
    {
        
print_adv_no_permission();
    }

    
$usedspace $DB_site->query_first("SELECT SUM(filesize) AS normal, SUM(originalfilesize) AS original FROM " TABLE_PREFIX ."adv_gallery_images WHERE userid = '$bbuserinfo[userid]'");

    
$usedspace['total'] = $usedspace['normal'] + $usedspace['original'];

    if (
$permissions['gallery_maxdiskspace'] == 0)
    {
        
$spacelimit $vbphrase['unlimited'];
        
$spaceremaining $vbphrase['unlimited'];
        
$bar['spaceremaining'] = 100;
        
$bar['spaceused'] = 1;
    }
    else
    {
        
$spacelimit make_good_size($permissions['gallery_maxdiskspace']);
        
$spaceremaining make_good_size($permissions['gallery_maxdiskspace'] - $usedspace['total']);

        
$bar['spaceused'] = round(($usedspace['total'] / $permissions['gallery_maxdiskspace']) * 100);
        
$bar['spaceremaining'] = 100 $bar['spaceused'];

    }

    if (
$bar['spaceused'] >= 75)
    {
        
$bar['color'] = 'red';
    }
    else if (
$bar['spaceused'] >= 50)
    {
        
$bar['color'] = 'yellow';
    }
    else
    {
        
$bar['color'] = 'green';
    }

    
$spaceused make_good_size($usedspace['total']);

    if ((
$permissions['gallerypermissions'] & CANUPLOADASUSER))
    {
        
$show['userupload'] = true;
    }

    if ((
$permissions['gallerypermissions'] & CANUPLOADFROMSERVER))
    {
        
$userdirectory $vba_options['gallery_userfolder'] . '/' $bbuserinfo['userid'];
        
$show['serverupload'] = true;
    }

    
$customfieldbits construct_custom_fieldbits($_POST);

    for (
$i 0$i $vba_options['gallery_uploadinputs']; $i++)
    {
        
$uploadbits .= '<div><input class="button" type="file" name="userfile' $i '" /></div>';
    }

    
$navbits[''] = $vbphrase['upload_image'];
    
$navbar construct_adv_navbar($navbits);

    eval(
'print_output("' fetch_template('ADV_GALLERY_UPLOAD') . '");');
}

// ############################### do add new ###############################
if ($_POST['do'] == 'doaddlink')
{
    
globalize($_POST, array('catid' => INT));

    
$errors check_link_errors(iif($vba_options['links_allowdupes'], 01));

    
$name htmlspecialchars($_POST['name']);
    
$description htmlspecialchars($_POST['description']);
    
$linkurl htmlspecialchars($_POST['url']);
    
$keywords htmlspecialchars($_POST['keywords']);

    if (
$errors)
    {
        require_once(
'./includes/functions_newpost.php');
        
$linkerrors construct_errors($errors);

        
$unhtml_linkname $name;

        
$_REQUEST['do'] = 'addlink';
    }
    else
    {
        
$valid 0;
        if (!(
$permissions['linkspermissions'] & MODERATELINKS))
        {
            
$valid 1;
        }

        
$cat $DB_site->query_first("SELECT title, options, newlinkemail FROM " TABLE_PREFIX "links_categories WHERE catid = '$catid'");
        
        
$sendmailto explode(' '$cat['newlinkemail']);

        
$DB_site->query("INSERT INTO " TABLE_PREFIX "links (catid, name, url, description, keywords, valid, open, username, userid, dateline) VALUES ('$catid', '" addslashes($name) . "', '" addslashes($linkurl) . "', '" addslashes($description) . "', '" addslashes($keywords) . "', '$valid', '1', '" addslashes($bbuserinfo['username']) . "', '$bbuserinfo[userid]', '" time() . "')");

        
$newlinkid $DB_site->insert_id();

        
construct_customfields_sql($newlinkid);

        if (!
$valid OR $vba_options['links_newlinkemail_all'])
        {
            if (
$vba_options['links_newlinkemail'])
            {
                
$optmailer explode(' '$vba_options['links_newlinkemail']);
                
$sendmailto array_merge($optmailer$sendmailto);
            }
            
            if (!empty(
$sendmailto))
            {
                foreach (
$sendmailto AS $email)
                {
                    eval(
fetch_email_phrases('adv_links_newlink'0));
                    
vbmail(trim($email), $subject$message);
                }
            }
        }

        if (
$valid == 0)
        {
            eval(
print_standard_error('adv_links_submitted'));
        }
        else
        {
            
$DB_site->query("UPDATE " TABLE_PREFIX "links_categories SET linkcount = linkcount+1, lastlinkid = '$newlinkid', lastposter = '$bbuserinfo[username]', lastlinktitle = '" addslashes(htmlspecialchars($name)) . "', lastuserid = '$bbuserinfo[userid]', lastupdated = '" time() . "' WHERE catid = '$catid'");
    
            
$url "showlink.php?$session[sessionurl]do=showdetails&amp;l=$newlinkid";
            eval(
print_standard_redirect('adv_links_addednew'));
        }
    }
}

// ############################## Do Edit Link ################################
if ($_POST['do'] == 'doeditlink')
{
    
globalize($_POST, array('linkid' => INT'name' => STR'catid' => INT'oldcatid' => INT));

    
$link $DB_site->query_first("SELECT linkid, userid FROM " TABLE_PREFIX "links WHERE linkid = '$linkid'");

    if ((
$link['userid'] != $bbuserinfo['userid'] AND !($permissions['linkspermissions'] & CANEDITOTHERSLINKS)) OR !($permissions['linkspermissions'] & CANEDITLINKS))
    {
        
print_adv_no_permission();
    } 

    
$errors check_link_errors(0);

    if (
$errors)
    {
        
$name htmlspecialchars($_POST['name']);
        
$description htmlspecialchars($_POST['description']);
        
$linkurl htmlspecialchars($_POST['url']);
        
$keywords htmlspecialchars($_POST['keywords']);
        require_once(
'./includes/functions_newpost.php');
        
$linkerrors construct_errors($errors);

        
$unhtml_linkname $name;

        
$_REQUEST['do'] = 'editlink';
    }
    else
    {

        
$_POST['notes'] .= ' ' $vbphrase['last_updated'] . ' ' vbdate($vboptions['dateformat'] . ' ' $vboptions['timeformat'], TIMENOW) . ' ' $vbphrase['by'] . ' ' $bbuserinfo['username'];

        
$DB_site->query("UPDATE " TABLE_PREFIX "links SET catid = '$catid', name = '" addslashes(htmlspecialchars($name)) . "', url = '" addslashes(htmlspecialchars(trim($_POST['url']))) . "', description = '" addslashes(htmlspecialchars($_POST['description'])) . "', keywords = '" addslashes(htmlspecialchars($_POST['keywords'])) . "', lastupdated = '" time() . "', notes = '" addslashes($_POST['notes']) . "' WHERE linkid = '$linkid'");

        
construct_customfields_sql($linkidfalse);

        
$catinfo $DB_site->query_first("SELECT lastlinkid FROM " TABLE_PREFIX "links_categories WHERE catid = '$catid'");

        if (
$catinfo['lastlinkid'] == $linkid)
        {
            
$DB_site->query("UPDATE " TABLE_PREFIX "links_categories SET lastlinktitle = '" addslashes(htmlspecialchars($name)) . "', lastupdated = '" time() . "' WHERE catid = '$catid'");
        }

        if (
$oldcatid != $catid)
        {
            
update_count($catid);
            
update_count($oldcatid);
        }

        
$url "showlink.php?$session[sessionurl]do=showdetails&amp;l=$link[linkid]";
        eval(
print_standard_redirect('adv_links_linkedited'));
    }
}

// ############################### add a link ###############################
if ($_REQUEST['do'] == 'addlink')
{
    if (!(
$permissions['linkspermissions'] & CANADDLINKS))
    {
      
print_adv_no_permission();
    }

    
$options print_dir_select($catidtruetrue);
     
    
$navbits[''] = $vbphrase['submit_a_link'];
    
$navbar construct_adv_navbar($navbits);

    
$customfieldbits construct_custom_fieldbits($_POST);

    if (
defined('VBA_PORTAL'))
    {
        eval(
'$html = "' fetch_template('ADV_LINKS_ADD_EDIT') . '";');
        
print_portal_output($home$html);
    }
    else
    {
        eval(
'print_output("' fetch_template('ADV_LINKS_ADD_EDIT') . '");');
    }
}

// ############################## Edit Link ################################
if ($_REQUEST['do'] == 'editlink')
{

    
$link $DB_site->query_first("
            SELECT linkid, name, links.description, links.catid, url, keywords, userid, notes, customfields.*, parentlist
            FROM " 
TABLE_PREFIX "links AS links
            LEFT JOIN " 
TABLE_PREFIX "links_customfields_entries AS customfields ON (links.linkid = customfields.lid)
            LEFT JOIN " 
TABLE_PREFIX "links_categories AS categories ON (links.catid = categories.catid)
            WHERE linkid = '
$linkid'
    "
);

    if (
$bbuserinfo['userid'] == OR (($link['userid'] != $bbuserinfo['userid'] AND !($permissions['linkspermissions'] & CANEDITOTHERSLINKS)) OR !($permissions['linkspermissions'] & CANEDITLINKS)) AND !is_directory_mod($link['parentlist']))
    {
        
print_adv_no_permission();
    }
    
    if (
is_directory_mod($link['parentlist']))
    {
        
$show['linknotes'] = true;
    }
    
    if (!
$errors)
    {
        
$unhtml_linkname unhtmlspecialchars(stripslashes($link['name']));
        
$linkname stripslashes($link['name']);
        
$description unhtmlspecialchars(stripslashes($link['description']));
        
$linkurl unhtmlspecialchars(stripslashes($link['url']));
        
$keywords unhtmlspecialchars(stripslashes($link['keywords']));
    }

    if ((
$link['userid'] == $bbuserinfo['userid'] AND $permissions['linkspermissions'] & CANDELETE) OR ($permissions['linkspermissions'] & CANDELETEOTHERS) OR is_directory_mod($link['parentlist']))
    {
        eval(
'$deleteoption = "' fetch_template('adv_links_deletebit') . '";');
    }

    
$options print_dir_select($link['catid'], truetrue);

    
$customfieldbits construct_custom_fieldbits($link''true);

    
$navbits construct_dir_navbits($link['parentlist']);
    
$navbits["showlink.php?$session[sessionurl]do=showdetails&amp;l=$link[linkid]"] = $linkname;
    
$navbits[''] = $vbphrase['edit_link'];
    
$navbar construct_adv_navbar($navbits);
    
$show['editlink'] = true;

    if (
defined('VBA_PORTAL'))
    {
        eval(
'$html = "' fetch_template('ADV_LINKS_ADD_EDIT') . '";');
        
print_portal_output($home$html);
    }
    else
    {
        eval(
'print_output("' fetch_template('ADV_LINKS_ADD_EDIT') . '");');
    }
}

// ########################### Delete Link ##############################
if ($_POST['do'] == 'dodeletelink')
{
    
globalize($_POST, array('linkid' => INT'deletelink' => INT));

    
$link $DB_site->query_first("SELECT linkid, name, links.catid, userid, parentlist
            FROM " 
TABLE_PREFIX "links AS links
            LEFT JOIN " 
TABLE_PREFIX "links_categories AS categories USING (catid)
            WHERE linkid = '
$linkid'
    "
);

    
check_link_id($link['linkid']);

    if ((
$link['userid'] != $bbuserinfo['userid'] AND !($permissions['linkspermissions'] & CANDELETEOTHERS)) OR !($permissions['linkspermissions'] & CANDELETE) AND !is_directory_mod($link['parentlist']))
    {
        
print_adv_no_permission();
    }
    
    if (!
$deletelink)
    {
        
$type $vbphrase['link'];
        eval(
print_standard_error('adv_links_nodelete'));
    }
    else
    {
        
delete_links($link['linkid']);

        
update_count($link['catid']);

        
$linkname stripslashes($link['name']);
        
$url "browselinks.php?$session[sessionurl]c=$link[catid]";
        eval(
print_standard_redirect('adv_links_deleted'));
    }    
}

?> 
Can some one tell me what is wrong with this .. becz i dont no why it dont show me the upload Thinky.

thankyou
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP code to edit a text file mdhall Script Requests 12 12-23-10 04:03 AM
html tutoral thefrtman HTML/XHTML/XML 5 04-27-09 10:25 AM
Can anyone help me ? (problem using php variables in html db insert code) chronic_ PHP 2 06-13-04 11:19 AM
How to sale php code to customer without giving him code pradeep_soft PHP 4 03-12-04 12:10 PM
protecting code in PHP ckb PHP 12 01-02-04 08:53 AM


All times are GMT -5. The time now is 05:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.