www.mamboteam.com
Jx Development
Home arrow Support Forum
Saturday, 13 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 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.

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 (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Hack for attaching documents to submission
#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 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.
#4710
mbowerbank (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 ago Karma: 0  
I copied all of the parts to the specific files, and got this when i click on apply:

Warning: constant() [function.constant]: Couldn't find constant _JL_ATTACH_RESUME in /home/mbower/public_html/jobsnew/components/com_jobline/mxtemplate.php(124) : regexp code on line 1

anyone got any ideas?

many thanks

j
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4711
mbowerbank (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 ago Karma: 0  
mbowerbank wrote:
QUOTE:
I copied all of the parts to the specific files, and got this when i click on apply:

Warning: constant() [function.constant]: Couldn't find constant _JL_ATTACH_RESUME in /home/mbower/public_html/jobsnew/components/com_jobline/mxtemplate.php(124) : regexp code on line 1

anyone got any ideas?

many thanks

j


Sorry im a complete idiot, and figured that i hadnt added this text in the com_jobline/languages/english.php

DEFINE('_JL_ATTACH_RESUME', 'Attach Resume';

anyone whos as stupid as me just copy and paste this into the english.php file
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4712
olle (Admin)
Admin
Posts: 1031
graph
User Online Now Click here to see the profile of this user
Re:Hack for attaching documents to submission 3 Years ago Karma: 17  
Good tip, this also works if a similar error occurs when using any other language file than English, since some strings might be missing in those.

It really should be a more clear error message, but since I'm planning on switching template system in the future I don't want to work so much on the current one.
 
Report to moderator   Logged Logged  
 
Olle Johansson
  The administrator has disabled public write access.
#4759
baldurmcqueen (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 2 Years, 11 Months ago Karma: 0  
Hello

I had this thing working today, briefly, but stupidly forgot to take a spare copy of everything before I started making other changes.

Now, everything is back to the way it was before - that is, the attachment comes integrated into the e-mail; not as a picture/file, but as garbled text.

Anyone familiar with that problem?

Here is the code in jobline.php

Code:

function sendApplication( $id ) { global $database, $mosConfig_absolute_path, $mosConfig_live_site, $option, $cfgjl, $mainframe, $my, $Itemid; $row = new mosJobPosting( $database ); $row-&gt;load( $id ); if ( !$row-&gt;id ) { mosRedirect( &quot;$mosConfig_live_site/index.php?option=$option&amp;task=error&amp;msg=&quot; . _JL_NOSUCHJOB ); } else { $tmplvars = get_object_vars( $row ); foreach ( $_REQUEST as $k =&gt; $v ) { $tmplvars[&quot;req_$k&quot;] = $v; } $reply_email = $tmplvars[&quot;req_email&quot;]; $tmpl = new mxTemplate( &quot;$mosConfig_absolute_path/components/com_jobline/templates/{$cfgjl['template']}&quot; ); if ( $tmpl-&gt;setTemplate( &quot;applicationemail&quot; ) ) { // 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-&gt;setVars( $tmplvars ); $tmpl-&gt;parseTemplate(); $message = $tmpl-&gt;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 = &quot;&lt;&lt;&lt;--==Multipart_Boundary_x&quot;.md5(mt_rand()).&quot;x&quot;; // check to make sure that it is an uploaded file and not a system file if( is_uploaded_file($tmp_name) ) { $message .= &quot;\n\n Attachment : $name&quot;; // 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 = &quot;This is a multi-part message in MIME format.\n\n&quot; . &quot;--{$mime_boundary}\n&quot; . &quot;Content-Type: text/plain; charset=\&quot;iso-8859-1\&quot;\n&quot; . &quot;Content-Transfer-Encoding: 7bit\n\n&quot; . $message . &quot;\n\n&quot;; // 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 .= &quot;--{$mime_boundary}\n&quot; . &quot;Content-Type: {$type};\n&quot; . &quot; name=\&quot;{$name}\&quot;\n&quot; . &quot;Content-Disposition: attachment;\n&quot; . &quot; filename=\&quot;{$name}\&quot;\n&quot; . &quot;Content-Transfer-Encoding: base64 \n\n&quot; . $data . &quot;\n\n&quot;; } $message .= &quot;--{$mime_boundary}--\n&quot;; } $Replyto = $reply_email; //function sendEmail( $email, $subject, $message, $fromname, $fromemail, $replyto, $mime_boundary ) sendEmail( $row-&gt;contactemail, _JL_APPLICATION_SUBJECT, $message, $cfgjl['mailfromname'], $Replyto, $Replyto, $mime_boundary); mosRedirect( &quot;$mosConfig_live_site/index.php?option=$option&amp;Itemid=$Itemid&amp;task=thankyou&amp;id=$id&quot; ); } else { showError( _JL_ERRORSETTMPL . &quot;: applicationemail&quot; ); } } }
And here is the code in jobline.common.php
Code:

function sendEmail( $email, $subject, $message, $fromname='', $fromemail='', $replyto='', $mime_boundary='' ) { $headers = &quot;&quot;; if ( trim( $fromemail ) ) { $headers = &quot;From: $fromname &lt;$fromemail&gt;\r\n&quot;; } if ( trim( $replyto ) ) { $headers .= &quot;Reply-To: &lt;$replyto&gt;\r\n&quot;; } $headers .= &quot;X-Priority: 3\r\n&quot;; $headers .= &quot;X-MSMail-Priority: Low\r\n&quot;; $headers .= &quot;X-Mailer: Joomla Open Source 1.12\r\n&quot;; if( $mime_boundary ) { $headers .= &quot;MIME-Version: 1.0\r\n&quot; . &quot;Content-Type: multipart/mixed;\r\n&quot; . &quot; boundary=\&quot;{$mime_boundary}\&quot;&quot;; } @mail($email, $subject, $message, $headers); }
In the template, I have:
Code:

&lt;form action=&quot;index2.php&quot; method=&quot;POST&quot; name=&quot;adminForm&quot; enctype=&quot;multipart/form-data&quot;&gt; and where the input box is... &lt;input type=&quot;file&quot; name=&quot;attach&quot; class=&quot;inputbox2&quot; size=&quot;60&quot; value=&quot;&quot;&gt;
Any help would be greatly appreciated Thank you for an excellent component. Below is the attachment code as seen in a typical application - not attached, but integrated into the e-mail:
Code:

Attachment : ONLINE.BMP --&lt;&lt;&lt;--==Multipart_Boundary_x77e5853ac728d175fe4cb854e452db9fx Content-Type: image/bmp; name=&quot;ONLINE.BMP&quot; Content-Disposition: attachment; filename=&quot;ONLINE.BMP&quot; Content-Transfer-Encoding: base64 Qk12AgAAAAAAAHYAAAAoAAAAIAAAACAAAAABAAQAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA ////AGZmZmZu7u7u7uZmZmZmZmZmZmZu5mqqqqpu7uZmZmZmZmZu5mqmZmZmqqZu5mZmZmZm5mqm ZgAAAAZqpm5mZmZmbmamZgD//39wBmpm5mZmZm5qZgD///f/fuAGpm5mZmbmpmD////3937u4Gpm 5mZm5qYHf///9/d+7u4GpuZmbmpgd3f///f3fu7u4GpmZm5qYKd3f//3937u53BqZmZmagqnd3f/ 9/d+7nf/BqZmZqYKqnd3f/f3fud/9wamZmpgqqqnd3f3935393dwpmZqYKqqqnd3AAB+/3e3cKZm amCqqqp3cGZmD3d3u3CmZmpgqqqqp3BmZgd+53dwpmZqYLuqqqpwZmZgfud2YGZmamC7u7qqoGZm YAYAYGBmZmpgu7u7u7sGZma7Zm7mZmZmpgu7u7u3cAAGu2puZmZmZqYLu7u7d3d3BmaqZmZmZmZm YLu7t3d3cGZ3ZmZmZmZmZmC7u7d3d3BmdmbuZmZmZmZmC7t3d3cGZmZm7mZmZmZmZmC3d3dwZmaq ZmZmZmZmZmZmAHd3BmZmqmd2ZmZmZmZmZmYAcGZmZmZmdmZmZmZmaZZpZpZplpaWaWmZZmZmZpZp aWaWaWaWlmlpZmZmZmaWaWlmmZlmlpZpaZZmZmZmlmlpZpZpZmaWaWlmZmZmZmmWaZlmaWaWmZZp mWZm --&lt;&lt;&lt;--==Multipart_Boundary_x77e5853ac728d175fe4cb854e452db9fx--
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4760
olle (Admin)
Admin
Posts: 1031
graph
User Online Now Click here to see the profile of this user
Re:Hack for attaching documents to submission 2 Years, 11 Months ago Karma: 17  
The most common cause of this problem is malformed headers, the mail isn't properly formatted.

I can't tell you exactly what's wrong, but a quick look reveals that you are using different ways to mark new lines. You should try to replace all &quot;\n&quot; into &quot;\r\n&quot; unless they are already preceded by &quot;\r&quot;.

A better way would be to use an API for formatting mails with attachments to make sure they are properly formatted. The Joomla API includes such a function, so it would probably be easier to just look it up in the Joomla developer documentation.
 
Report to moderator   Logged Logged  
 
Olle Johansson
  The administrator has disabled public write access.
#4761
baldurmcqueen (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:Hack for attaching documents to submission 2 Years, 11 Months ago Karma: 0  
Not only a fast reply, but the perfect one

You hit the nail on the head(er), everything working fine now.
I will look into the API as well, did not know about that possibility.

Thank you very much for the assistance Ollie.

Best wishes,
Baldur

Just for those who will follow, here is the code as it works for me.

1. The function sendApplication( $id ) in jobline.php:

Code:

function sendApplication( $id ) { global $database, $mosConfig_absolute_path, $mosConfig_live_site, $option, $cfgjl, $mainframe, $my, $Itemid; $row = new mosJobPosting( $database ); $row-&gt;load( $id ); if ( !$row-&gt;id ) { mosRedirect( &quot;$mosConfig_live_site/index.php?option=$option&amp;task=error&amp;msg=&quot; . _JL_NOSUCHJOB ); } else { $tmplvars = get_object_vars( $row ); foreach ( $_REQUEST as $k =&gt; $v ) { $tmplvars[&quot;req_$k&quot;] = $v; } $reply_email = $tmplvars[&quot;req_email&quot;]; $tmpl = new mxTemplate( &quot;$mosConfig_absolute_path/components/com_jobline/templates/{$cfgjl['template']}&quot; ); if ( $tmpl-&gt;setTemplate( &quot;applicationemail&quot; ) ) { // 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-&gt;setVars( $tmplvars ); $tmpl-&gt;parseTemplate(); $message = $tmpl-&gt;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 = &quot;&lt;&lt;&lt;--==Multipart_Boundary_x&quot;.md5(mt_rand()).&quot;x&quot;; // check to make sure that it is an uploaded file and not a system file if( is_uploaded_file($tmp_name) ) { $message .= &quot;\r\n\r\n Attachment : $name&quot;; // 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 = &quot;This is a multi-part message in MIME format.\n\n&quot; . &quot;--{$mime_boundary}\n&quot; . &quot;Content-Type: text/plain; charset=\&quot;iso-8859-1\&quot;\n&quot; . &quot;Content-Transfer-Encoding: 7bit\n\n&quot; . $message . &quot;\n\n&quot;; // 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 .= &quot;--{$mime_boundary}\r\n&quot; . &quot;Content-Type: {$type};\r\n&quot; . &quot; name=\&quot;{$name}\&quot;\r\n&quot; . &quot;Content-Disposition: attachment;\r\n&quot; . &quot; filename=\&quot;{$name}\&quot;\r\n&quot; . &quot;Content-Transfer-Encoding: base64 \r\n\r\n&quot; . $data . &quot;\r\n\r\n&quot;; } $message .= &quot;--{$mime_boundary}--\r\n&quot;; } $Replyto = $reply_email; //function sendEmail( $email, $subject, $message, $fromname, $fromemail, $replyto, $mime_boundary ) sendEmail( $row-&gt;contactemail, _JL_APPLICATION_SUBJECT, $message, $cfgjl['mailfromname'], $Replyto, $Replyto, $mime_boundary); mosRedirect( &quot;$mosConfig_live_site/index.php?option=$option&amp;Itemid=$Itemid&amp;task=thankyou&amp;id=$id&quot; ); } else { showError( _JL_ERRORSETTMPL . &quot;: applicationemail&quot; ); } } }
2. The function sendEmail in jobline.common.php:
Code:

function sendEmail( $email, $subject, $message, $fromname='', $fromemail='', $replyto='', $mime_boundary='' ) { $headers = &quot;&quot;; if ( trim( $fromemail ) ) { $headers = &quot;From: $fromname &lt;$fromemail&gt;\r\n&quot;; } if ( trim( $replyto ) ) { $headers .= &quot;Reply-To: &lt;$replyto&gt;\r\n&quot;; } $headers .= &quot;X-Priority: 3\r\n&quot;; $headers .= &quot;X-MSMail-Priority: Low\r\n&quot;; $headers .= &quot;X-Mailer: Joomla Open Source 1.12\r\n&quot;; if( $mime_boundary ) { $headers .= &quot;MIME-Version: 1.0\r\n&quot; . &quot;Content-Type: multipart/mixed;\r\n&quot; . &quot; boundary=\&quot;{$mime_boundary}\&quot;&quot;; } @mail($email, $subject, $message, $headers); }
The applicationform.tmpl needs to have some simple changes as well, which can be seen in previous posts.
 
Report to moderator   Logged Logged  
  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!