www.mamboteam.com
Jx Development
Home arrow Support Forum
Saturday, 20 March 2010
 
 
Main Menu
Home
FAQs
Portfolio
File Archive
Bug Reports
Support Forum
Development Update
Work in Progress
Web Links
Contact Me
Component Demos
Jobline Demo
Mamblog Demo
Jambook Demo
Login Form





Lost Password?
No account yet? Register
Who's Online
We have 5167 guests online
Newsletter

Subscribe to our newsletter.






Donate
If you use and like my scripts, and would like further developments, please consider donating a few bucks.

External links
www.ledutveckling.com - The Yard - Utvecklaren - Rollspel.nu - Spelwebben - Gardener's Game Garage - My Pet Peeves - PSPnuts

Interesting Sites
Joomla!
Joomlahut
Netshine Joomla Tutorial
JX extensions on JED
Support Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Hack for attaching documents to submission (2 viewing) (2) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: Hack for attaching documents to submission
#4321
jmccann (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Hack for attaching documents to submission 3 Years, 3 Months ago Karma: 0  
Hi,

I know there is a thread regarding manually changing scripts to allow a visitor to upload a file attachment with an application.

I'm not a php programmer and can't get it to work.

Does anyone have a hack for attachments that I could download?

regards,
jim mccann
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4331
Jurie (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years, 3 Months ago Karma: 0  
I think this is better than just pasting the resume because of formatting issues as the application will be sent in text format...
 
Report to moderator   Logged Logged  
 
Cheers,

Jurie
UrProfiles.com- Filipino Workforce Online
  The administrator has disabled public write access.
#4370
jmccann (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years, 3 Months ago Karma: 0  
Anyone care to share the upload amemdments?

regards,

jim mccann
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4400
godwin (Moderator)
Moderator
Posts: 60
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years, 3 Months ago Karma: 2  
-------------- FILE : jobline.php ---------------
Code:

function sendApplication( $id ) { global $database, $mosConfig_absolute_path, $mosConfig_live_site, $option, $cfgjl, $mainframe, $my, $Itemid; $row = new mosJobPosting( $database ); $row->load( $id ); if ( !$row->id ) { mosRedirect( "$mosConfig_live_site/index.php?option=$option&task=error&msg=" . _JL_NOSUCHJOB ); } else { $tmplvars = get_object_vars( $row ); foreach ( $_REQUEST as $k => $v ) { $tmplvars["req_$k"] = $v; } $reply_email = $tmplvars["req_email"]; $tmpl = new mxTemplate( "$mosConfig_absolute_path/components/com_jobline/templates/{$cfgjl['template']}" ); if ( $tmpl->setTemplate( "applicationemail" ) ) { // store the file information to variables for easier access $tmp_name= $_FILES['attach']['tmp_name']; $type = $_FILES['attach']['type']; $name = $_FILES['attach']['name']; $size = $_FILES['attach']['size']; $error = $_FILES['attach']['error']; $message = ''; $mime_boundary = ''; $tmpl->setVars( $tmplvars ); $tmpl->parseTemplate(); $message = $tmpl->getOutput(); // if the upload succeded, the file will exist if ( file_exists($tmp_name) ) { // generate a random string to be used as the boundary marker $mime_boundary = "<<<--==Multipart_Boundary_x".md5(mt_rand())."x"; // check to make sure that it is an uploaded file and not a system file if( is_uploaded_file($tmp_name) ) { $message .= "\n\n Attachment : $name"; // open the file for a binary read $file = fopen( $tmp_name,'rb' ); // read the file content into a variable $data = fread( $file,filesize($tmp_name) ); // close the file fclose( $file ); // now we encode it and split it into acceptable length lines $data = chunk_split( base64_encode($data) ); } // next, we'll build the message body // note that we insert two dashes in front of the // MIME boundary when we use it $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // now we'll insert a boundary to indicate we're starting the attachment // we have to specify the content type, file name, and disposition as // an attachment, then add the file content and set another boundary to // indicate that the end of the file has been reached if( $data ) { $message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" . " name=\"{$name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$name}\"\n" . "Content-Transfer-Encoding: base64 \n\n" . $data . "\n\n"; } $message .= "--{$mime_boundary}--\n"; } $Replyto = $reply_email; //function sendEmail( $email, $subject, $message, $fromname, $fromemail, $replyto, $mime_boundary ) sendEmail( $row->contactemail, _JL_APPLICATION_SUBJECT, $message, $cfgjl['mailfromname'], $Replyto, $Replyto, $mime_boundary); mosRedirect( "$mosConfig_live_site/index.php?option=$option&Itemid=$Itemid&task=thankyou&id=$id" ); } else { showError( _JL_ERRORSETTMPL . ": applicationemail" ); } } }
-------------- FILE : jobline.common.php ---------------
Code:

/** * Send an email * @param string email Email adress * @param string subject Subject of the email * @param string message The message body of the email * @param string fromname Name of the sender of the email * @param string fromemail Email address of the sender * @param string replyto Email address in Reply-To header */ function sendEmail( $email, $subject, $message, $fromname='', $fromemail='', $replyto='', $mime_boundary='') { $headers = ""; if ( trim( $fromemail ) ) { $headers = "From: $fromname <$fromemail>\r\n"; } if ( trim( $replyto ) ) { $headers .= "Reply-To: <$replyto>\r\n"; } $headers .= "X-Priority: 3\r\n"; $headers .= "X-MSMail-Priority: Low\r\n"; $headers .= "X-Mailer: Mambo Open Source 4.5\r\n"; if( $mime_boundary ) { $headers .= "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; } @mail($email, $subject, $message, $headers); }
------------- FILE : templates/default/applicationform.tmpl --------------- lookout for 'enctype="multipart/form-data"' in the form tag & <input type="file" name="attach" class="inputbox2" size="40" value="" /> at he end of the form
Code:

<form action="index2.php" method="POST" name="adminForm" enctype="multipart/form-data"> <input type="hidden" name="id" value="{mxtvalue=id}" /> <input type="hidden" name="option" value="{mxtvalue=option}" /> <input type="hidden" name="Itemid" value="{mxtvalue=Itemid}" /> <input type="hidden" name="task" value="send" /> <table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane"> <tr> <td class="contentheading" width="100%" colspan="2">{mxtlang=_JL_APPLYFORJOB}: {mxtvalue=title}</td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="10"></td> </tr> <tr> <td><b>{mxtlang=_JL_FIRSTNAME}</b></td> <td><input type="text" name="firstname" class="inputbox2" size="40" value="" /></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td><b>{mxtlang=_JL_LASTNAME}</b></td> <td><input type="text" name="lastname" class="inputbox2" size="40" value="" /></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td><b>{mxtlang=_JL_ADDRESS1}</b></td> <td><input type="text" name="address1" class="inputbox2" size="40" value="" /></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td><b>{mxtlang=_JL_ADDRESS2}</b></td> <td><input type="text" name="address2" class="inputbox2" size="40" value="" /></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td><b>{mxtlang=_JL_CITY}</b></td> <td><input type="text" name="city" class="inputbox2" size="40" value="" /></td> </tr> {mxtshowif=config_useusstate} <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td><b>{mxtlang=_JL_STATE}</b></td> <td>{mxtvalue=usstates}</td> </tr> {/mxtshowif} <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td><b>{mxtlang=_JL_ZIPCODE}</b></td> <td><input type="text" name="zipcode" class="inputbox2" size="40" value="" /></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td><b>{mxtlang=_JL_DAYTELEPHONE}</b></td> <td><input type="text" name="daytelephone" class="inputbox2" size="40" value="" /></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td><b>{mxtlang=_JL_EVENINGTELEPHONE}</b></td> <td><input type="text" name="eveningtelephone" class="inputbox2" size="40" value="" /></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td><b>{mxtlang=_JL_APPLICANTEMAIL}</b></td> <td><input type="text" name="email" class="inputbox2" size="40" value="" /></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td valign="top"><b>{mxtlang=_JL_COVER_LETTER}</b></td> <td><textarea class="inputbox2" name="coverletter" id="coverletter" cols="50" rows="10"></textarea></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td valign="top"><b>{mxtlang=_JL_RESUME}</b></td> <td><textarea class="inputbox2" name="resume" id="resume" cols="50" rows="10"></textarea></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="5"></td> </tr> <tr> <td valign="top"><b>{mxtlang=_JL_ATTACH_RESUME}</b></td> <td><input type="file" name="attach" class="inputbox2" size="40" value="" /></td> </tr> <tr> <td class="contentheading" width="100%" colspan="2" height="10"></td> </tr> <tr> <td colspan="2"><input type="submit" name="sendbtn" class="button" value="{mxtlang=_JL_SEND_APPLICATION}" /></td> </tr> </table> </form>
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#4407
Jurie (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years, 3 Months ago Karma: 0  
Are there instructions on how to apply this patch? Are there any plans on applying this to the official release? Sorry for the questions but I think it would be cool if someone could make this noob-proof ..
 
Report to moderator   Logged Logged  
 
Cheers,

Jurie
UrProfiles.com- Filipino Workforce Online
  The administrator has disabled public write access.
#4410
olle (Admin)
Admin
Posts: 1035
graph
User Online Now Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years, 3 Months ago Karma: 17  
Attachment to the application form will be in v1.2, but not in this form, it will use a more stable functionality that hopefully should work for everyone.
 
Report to moderator   Logged Logged  
 
Olle Johansson
  The administrator has disabled public write access.
#4415
Jurie (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years, 3 Months ago Karma: 0  
Thank you .. can't wait
 
Report to moderator   Logged Logged  
 
Cheers,

Jurie
UrProfiles.com- Filipino Workforce Online
  The administrator has disabled public write access.
#4690
mattbeebe (User)
Fresh Boarder
Posts: 5
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years, 1 Month ago Karma: 0  
This is actually working for me pretty good. Upon inspection of the code, I'm not sure if it's particularly the most "secure" approach (no checks for file type, and size, etc), but I serves my needs right now.

One thing that I'm hoping to tweak is the validation before form submittal (right now this code allows an empty form to be submitted). I'm not sure where I need to add the validation code since this is linked through the .tmpl part of jobline.

Any pointers are appreciated. Thanks!

-Matt
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4700
godwin (Moderator)
Moderator
Posts: 60
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years ago Karma: 2  
Its only basic code for attachment. No other validations are added here.

for allowing only certain files to be uploaded you can use the add this code to the existing code
Code:

$allowedfiles = array("application/msword","text/richtext"«»); if ( !in_array( $type, $allowedfiles ) ) { mosRedirect( "$mosConfig_live_site/index.php?option=$option&Itemid=$Itemid&task=error&msg="._AD_INVALIDFILE ); return; }
The code for attachmnet work both with and woithout attachment. AND If you intend to add some javascript validation, you could add it on 'jobline.html.php' in function 'function showApplicationForm' just above the lines
Code:

$tmpl = new mxTemplate( "$mosConfig_absolute_path/components/$option/templates/{$cfgjl['template']}" ); if ( $tmpl->setTemplate( "applicationform" ) )
Thanx<br><br>Post edited by: godwin, at: 2007/02/19 12:47
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#4704
Mackelito (User)
Fresh Boarder
Posts: 14
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years ago Karma: 0  
admin wrote:
QUOTE:
Attachment to the application form will be in v1.2, but not in this form, it will use a more stable functionality that hopefully should work for everyone.


When will that RC be out?
 
Report to moderator   Logged Logged  
 
- Ja jo dom s&auml;ger det! www.wombatmedia.se
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
Advertisement
Polls
Is Joomla 1.0 support needed in future releases of our extensions?
 
Latest News
Most Read
Latest Commented
Bug Reporting (1 comments)
Mamblog - User blog component (61 comments)
The road to Jobline v1.2 (5 comments)
Export vBulletin users to Mambo (6 comments)
Jobline Documentation (4 comments)
Latest Posts

More...
 
Top! Top!