| |
|
Who's Online |
|
We have 26 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.
|
|
Hack for attaching documents to submission (1 viewing) (1) Guest
Favoured: 0
|
|
|
TOPIC: Hack for attaching documents to submission
|
jmccann (User)
Fresh Boarder
Posts: 3
|
|
Hack for attaching documents to submission 2 Years, 7 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
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
Jurie (User)
Fresh Boarder
Posts: 7
|
|
Re:Hack for attaching documents to submission 2 Years, 7 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...
|
|
|
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
jmccann (User)
Fresh Boarder
Posts: 3
|
|
Re:Hack for attaching documents to submission 2 Years, 7 Months ago
|
Karma: 0
|
|
Anyone care to share the upload amemdments?
regards,
jim mccann
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
godwin (Moderator)
Moderator
Posts: 60
|
|
Re:Hack for attaching documents to submission 2 Years, 6 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>
|
|
|
|
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
Jurie (User)
Fresh Boarder
Posts: 7
|
|
Re:Hack for attaching documents to submission 2 Years, 6 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 .. 
|
|
|
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
olle (Admin)
Admin
Posts: 1002
|
|
Re:Hack for attaching documents to submission 2 Years, 6 Months ago
|
Karma: 16
|
|
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.
|
|
|
|
|
|
|
Olle Johansson
|
|
|
The administrator has disabled public write access.
|
|
|
|
|
|
|
|
|
|
|