Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mms message from cell to Server

Status
Not open for further replies.

mailerman

Technical User
Jan 2, 2007
29
SE
Hello

Im using the script bellow to try to upload MMS messages to my webserver. the folder "data" is CHmoded 777 and im using a swedish SMS/MMS service to send the content of the MMS to my server

now for my problem, when i send a MMS to the payment number of my MMS service, it's recived by the service and forwarded to my server, my server send my response back to my cell "thank yo ufor your mms" BUT no picture is uploaded onto my server in the Folder "data" and i cant figure out why not, do anyone se anyting in my code that would indicate why my picture is not uploaded to the server? my cell sends jpg files as specefied in the code.

in my logs for my server i se the request by my mms service but i dont se any picture upload or decline request. also the MMS is added into my database and get a specific id number.

Code:
<?
// Define database connection
$MYSQL_HOST = 'my host';
$MYSQL_USER = 'database username';
$MYSQL_PASSWORD = 'database pass';
$MYSQL_DATABASE = 'database name';

// turn of PHP error reporting
error_reporting(0);

// connect to the database
mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
mysql_select_db($MYSQL_DATABASE);

// pick out the senders number.
$nr = $_REQUEST['nr'];

// pick up the mms message
$sms = urldecode($_REQUEST['sms']);

// "url to the picture if any was sent with"
$mms = urldecode($_REQUEST['mms']);

// pick out the price of the mms
// (statistic)
$tariff = $_REQUEST['tariff'];

// add to the database
mysql_query('INSERT INTO mms (sender,message,tariff,tstamp) VALUES ("'
    . addslashes($nr) . '","'
    . addslashes($sms) . '","'
    . addslashes($tariff) . '",now())');

// download and save picture
if ($mms != 'data/') {

// pick the ID of the latest database entry
    $id = mysql_insert_id();

// read and save the file in the folder 'data'
    $file = fopen('data/' . $id . '.jpeg', 'w');
    fwrite($file,file_get_contents($mms));
    fclose($file);
    
}

// Answer returned to sender after succsesfull recivement
echo 'thanks for your mms :)';
?>
 
files are uploaded and are accessible in the $_FILES superglobal. i don't see any references to this in your code. how does the file get to your server if it is not uploaded via a POST form?
 
Some of the code shown above is wrong, i posted the code of a php file i was testing around with. bellow is the part of the code that is wrong and what it should be, just wanted to clear up the misstake,

**********************************************
// download and save picture

if ($mms != 'data/') {

CURRENTLY IS

// download and save picture

if ($mms != '') {


**********************************************
 
Hey there jpadie, i solved the download error, the code shown bellow now saves my pictures in /data/ with a named made by the database entry number, BUt now i have another problem, the script shown bellow saves the picture in /data/, 1 picture is 8Kb and shows my MMS picture, while the other 2 is 8byte and broken,

a friend said that it is cause by the "foreach" and that i need to filter a value, but i dunno how i do that and what i should filter, do you have any idea?

Code:
<?php

require_once('Mail/mimeDecode.php');

// Define database connection
$MYSQL_HOST = 'AAA';
$MYSQL_USER = 'AAA';
$MYSQL_PASSWORD = 'AAA';
$MYSQL_DATABASE = 'AAA';

// turn of PHP error reporting
error_reporting(0);

// connect to the database
mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
mysql_select_db($MYSQL_DATABASE);

if($_SERVER['REQUEST_METHOD'] == 'POST') {
    $mms = new MMSDecoder();
    foreach ($mms->parts as $part) {
        // values
        $message = mysql_real_escape_string($mms->subject);
        $phonenr = mysql_real_escape_string($mms->number);
        $tariff  = isset($_POST['tariff']) ? (int)$_POST['tariff'] : 0;

        // sql
        $sql = "INSERT INTO mms(sender,message,tariff,tstamp)
                VALUES ('%s','%s',%d,NOW())";
        $sql = sprintf($sql,$phonenr,$message,$tariff);
   
        // execute
        $res = mysql_query($sql) or die(mysql_error());
   
        // save image in /data/
        $filename = 'data/'.mysql_insert_id().'.jpeg';
        file_put_contents($filename,$part['body']);
    }
}

////////////////////////////////////////////////////////////////

class MMSDecoder {
	var $subject;
	var $number;
	var $parts;

	function MMSDecoder() {
		

// Text that your service matched
		$this->subject = $_SERVER['HTTP_MOSMS_SUBJECT'];
		

// Users phone number
		$this->number = $_SERVER['HTTP_MOSMS_NUMBER'];		

		

// MMS message from the cell, coded in MIME
		$mimedata = file_get_contents('php://input');
		$headers  = "Content-Type: {$_SERVER['CONTENT_TYPE']}\n";
		$headers .= "Content-Length: {$_SERVER['CONTENT_LENGTH']}\n";

		

// Decode mms message
		$params = array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true);
		$decoder = new Mail_mimeDecode($headers . "\n" . $mimedata);
		$decoded = $decoder->decode($params);
		
		$this->parts = array();
		
		foreach ($decoded->parts as $part) {
			$temp = array();
			

// MIME example: text/plain, image/jpeg, application/smil
			$temp['type'] = $part->ctype_primary . '/' . $part->ctype_secondary;
			

// content-id, That is used in some content to define picutre, audio etc.
			if (isset($part->headers['content-id'])) {
				$temp['cid'] = trim($part->headers['content-id'], '<>');
			}
			if (isset($part->d_parameters['filename'])) {
				$temp['filename'] = $part->d_parameters['filename'];
			}
			$temp['body'] = $part->body;

			$this->parts[] = $temp;
		}
	}
}

?>
 
I have no idea what you are talking about.

what other 2? in what way are they 'broken'? can you provide examples?

in any event this does not look right
Code:
   $message = mysql_real_escape_string($mms->subject);
        $phonenr = mysql_real_escape_string($mms->number);
        $tariff  = isset($_POST['tariff']) ? (int)$_POST['tariff'] : 0;

why are you not referring to the elements of the array $part here? they would be type, cid, filename and body from an examination of your MMSDecoder class.
 
ok, when i send an MMS to my webserver, the script downloads the picture, the picture from the MMS message and places it into /data/ , but it downloads it 3 times,

Yesterday i sent 2 MMS messages to my webserver, and both where downloaded as you cna se here
but you also se 4 broken picture, those for broken ones ar 8byte picture, and the 2 working are 8Kb, each time i sent and MMS and the script downloaded the picture, it also made those 2 broken picture, and that's what i need to prevent.
 
we need to have a look at some of your variables.

please replace this line
Code:
$mms = new MMSDecoder();

with these lines
Code:
$mms = new MMSDecoder();
echo "<hr/><pre>".print_r($mss, true)."</pre><hr/>";

and post the output between the ruled lines.
 
Ok, i changed the lines for what you said and tryed another MMS, if you check the page the same thing happend, also i got "'<hr/><pre></pre><hr/>'" in response back to me
 
the second line should have been $mms and $mss
 
That didint work either

i changed it to

Code:
$mms = new MMSDecoder();
echo "<hr/><pre>".print_r($mms, true)."</pre><hr/>";

then i got a long long long error wich was greayed out so i coulde not copy it, te image was not saved and so on.
 
i've never heard of a greyed out error on a web browser.

to help we need precise error messages.
 
there, i finally got it out.

all this was actully the error,


URL: 'HTTP Response: 200 (OK)
Response: '<hr/><pre>MMSDecoder Object
(
[subject] => bildmms *
[number] => cell number remoed
[parts] => Array
(
[0] => Array
(
[type] => application/smil
[cid] => AAAA
[filename] => image.smil
[body] => <smil>
<head>
<layout>
<root-layout backgroundColor="#FFFFFF" background-color="#FFFFFF" height="480px" width="640px"/>
<region id="Image" top="0" left="0" height="50%" width="100%" fit="meet"/>
<region id="Text" top="50%" left="0" height="50%" width="100%" fit="meet"/>
</layout>
</head>
<body>
<par dur="4000ms">
<img src="cid:example.jpg" region="Image">
</img>
<text src="cid:example.txt" region="Text">
<param name="foreground-color" value="#000000"/>
</text>
</par>
</body>
</smil>


)

[1] => Array
(
[type] => image/jpeg
[cid] => example.jpg
[filename] => example.jpg
[body] => ÿØÿà?JFIF??H?H??ÿþ?&File written by Adobe Photoshop¨ 5.0ÿÛ?C? 

 $.' ",#(7),01444'9=82<.342ÿÛ?C 

2!!222222222222222222222222222222222222222222222222
CÉôsBÙxÊÉSö4ËQª×ä±m–
#9úÕêçs׶NFË^èqC5´†ËÄd^Hô™²o¼°¯Ë?î㙉 XlTÐê²^„ºÊÈãb?]“B´ÝcdóûìyÂå?ï
WTýt*~”$ÉZ­WY˜
‘ž #Õ¬·ŸÐ¯d7íe•‹óÖeõ(|ØØ:`åègʶýgŽÍÒ¾Ü5Õ†¿-†¿?ÙŸÑUË•šòéäÑ÷6âÖ<ðµ:úᓸÂÓÞè­
pÍWRdrzëp³’ªq7?h-ãÐlfW{‰NˆúÛaîÚªd¹¨íÛÅ^\ênD‡n–Éms&ëÊU=µóÙÎð…δ.Q: 0$ÊÓBúÒå!}PFÀ„¥Š–+—…´§:'ןNöv¾gFY¦ÚŒ‚ê‹B'ªWŽøäôÖ?ìúôÒåeSL^}WLf6Á*XÁ
g²Wœ‹˜êùЉ΄+Ñ“ w\ÀäÜ·ŠgܵѴ,ⶫÆÝ®hsz°ÅÁÌf¶, —žÂÀÕóüÂÐÎ-ç®ä¥óZ¸¶âD6Ë«pvyI/EºkL®„\Ghrñ@P¤?Ë2H\RtŹ¨G’GÁŠ[X^X(iŠ?º¢•n
ÃÝŒÜÏœK@I™i@ üã¬ì0­;e²÷1¯Ä²º4¶|©Í"BÕ $µ*Xè
$¤&M'”2¤Üþ…†Hµx’ËÿÄ?(??????! "1#2AB0ÿÚ??÷—>~›óm'ó_ú˜ùsó,Ýv­¢kÿ?ŸÔÈÊùY§Üÿ?!iÝx¬"¸C[÷`„M{3nõ
ZkÈS5 Ñô®×FW/´‰©¯KìíTI&æ¥&Œ9ÁKØÖV*o\FòDÔÔjjjjq™Ö‡D¨¸ÅSÉ)âQt>]“Š¨¶²¸Ï¨‰K÷k
L;8Y©©¯f¦a+‹éE?¶ÉâÞAR{e¹ZïÊT½°T‘j8G›qƒÊêjj^¦Üqâ/3ÚÚ¯"8íh¬V.í\Tä
:¸ýQ~ÞÒ²œÚì‚ÚÄêNFWyˆî4[ZSdBÆ·Éd™…u_×_š¸ÍMzì»6Õe“ÆÈ°Ûáed
"#Í<?"2ˇÝ¬Î?{)h¦öUpáE›àO?±DTA›Ê¥‚í1?h@¼À
n«_²²­Cg|‘·òÃù…lùF¶÷MeIñŸdDÔ
¯
Eh*¡H@ôç
üdžUeÙèöǪ!t¤©™¢˜V[uDgô£û•¿’ÈP?9Ùç—ÑB!—ñ?œ4»Q?ÐÊ j®®„ŸEâ¿ÊÍ€ÑO)‰Ý1×aÕRÄs°õãC¢h4v…wo¢sBÈÕQC™_©x‹\Ú~•Ú·ÂQoZ&¸[œ?? vmlƒË;«µ¡ |ÀIe\,çì¥ç)Ñ¥´SÙ°ª3Ùì8ôX˜ym~«7þ¢Ëן)²{6<ž2¿å¨7+3j×.ï²Ë”;Ί
ÎÇënIÊ"PìðˆÞWÓ)?ä¤Dl»ô=kÂëû
S1þa±529Úv<n‹]WuZý×ûFr?”9ßuÜw¢%®´$#a9…ó7øQnqõ(à’d§€Ûa€?¾°ªæ²Í‹þT”S?Œ5Q®èÓ÷ âjž
>iÌ6»Póáaè*Q(&· 1D²˜ì¡d*`0ú¡Úãäµ
¬Ø¥ø‡õ”„Ù 9²ú ×?Ü·ºgJkÇ‹DßûrÛÕ;»œ]h<{®Ê«ˆ3rÝFi#r?ˆ(¸™EšÒñQfö@·d4ˆ*GæPS¨ã”+Âü@ÒRdtÕO$ì³, ȸY¶Y›-%gm7XƒÈ¦y'E»4àwMËbxõP1;èI$?U¼ºrõh³—æ-þÓ¼–/š²FÂ?£b?!?Æ­Ê,‡EA.$?E
åkGÌSAùŠ?¥>µ„TORWzÅ@¨;,¤ÁÑu)*êg4ת ²Ìóä7T¨áºÃ4ñ¦P ,píÓ?©²ªT8âî?Pk¤:è»Í*9°¾ œ]y]ÑSe&§ªí]ˆpËb?•ºí…á‚Œè?¨:W€”â/Ë!}|;G@ÓÙ^Q”
•iY˜¤ ÙîÝÈ·ßdXîñòã{!eÛMÑÃ>7yÙd`T©(fõR|áeÔ…K·Dc†v£‹S¦¦PH?ªWÿÄ?&???????!1AQa
q?‘¡±ÁÑáð ÿÚ???!•T¨t D#®&1®©Ülœá0Ziay£q¦T?©GÓ'ø–¶¡# Q:×KÄzf_)PLr#V†ÚùžÚýÁb]åñS_ijÛØ€?àš-<Å®…èu$3‰YšµÜ"®úh¢å/Û7Âëñ*bË ªdæ êÒÆ=
ãéÑY‚æô<ÇIkÒá‰ÞUôKmè2Ì`¥ÁMÌ´—Ô¦Žz?™ýGp;Z1°d÷2GªË/HŠßD™¤V>1
ìF¾S´=Wv\ 4ûÿ?¼ÁH{Ý\~fý?ÔÌ&öçˆå«æ.rñéN˜ôˆ!è3¿¬n"ÍÛ*jwÚ5¼%T¬rßù ¬ž/™‘ѧËÚpBœ?$jgüëoÒ>Ãæý•.<g¾†H0ĉa)á¼CÆÓq ÙeW Fhÿ?‚%øsìÛ)®ˆäÑú?¤ÅIþSaPú ó•üÜtåv«øš¿^%ñ«‡´nßø"$Hà@«Î¡dSÄçg~Tœ€ød–¬Þ~b?¥TRß2íÚµ‰„êoé€{­ s½µý”>)œ„䇑:|[tµ;Ÿi¹5J'ÌàgS}å3J,ù˜'mÙ…FeÝ‹"mó©µ9îÇ€&È(­?þ\FL.
«`À€[Áã Œt’á*TN¬¬)¨öN`ÕÇé€hŒâY ?=ß²ÆïáĽMX( _ ‘S\6D2.Aìƒép5¦h:ÌñÚ†euYeF<A=UïwdÆñ݉ÖèÓù#F—ò?C^
·Ç0ê"^?+ áÌ?Ôh¥KÀw ±ÀmCG¹æ/‹öþ¦QT~G ÃÔ(-9Œ?ƒÔ:žf(§´ Ž¹dô(Ý€ÍÔH8É?œíšL…¹d!¦%ÛÚBÁ¸«¯s6œóúýJ
©?M@ï%Ê•+*%ÀÅ¥”Ó0•­—QW<”%!)U²‹WÁ
?{TsübQgHL…?!-_ñr¨.—•d¦T@bœµO¹]© MB¤ø¹¹å Hš
53V?jL?sË"Žèíù˜
f.ƒr‰cFãÉ)Ì°lСš]†iä†Ç?”:ù;÷KUYb%tñæ訊øP?Î#·d#j·w`7¶ˆïj)o´«¨qJ_¸ÿ? wL¢•¡¦"ˆö'?
á uo¹ÌÕ·ì”—
ˆvœa—Õ—P国Þ9Ñ‹? cü²Â—)q™a„äJG\áúšÇ?¹Ó(wÛá;€º…;4+æ 5:?gdJm u«?¸y•yf@`qÂC,g\/©…N -ë\Àã[i7sÛ‰ùE\sT@¢js²R«¾¥ïŠ?Ø?s·ŽXXaOgÉ*¸Š+‡“Ôak0~â¦(´?æ%P)DÈúég–rŸ ñ/)¹bQy¤4X%s ¬^´§²ëä™—Ã?ÃËÒçˆÖ™'«¨<d¸…?ºÆ—•?q* çí" ó:c¯ÔXºÆ¢?Q?ÉàÕ[Úá.ŒÔµÙð¯‰qV]5I´Q†î8¯>!¤4
^ÎÒÃc’÷
oƒµÞ*†oyÿ?—-?)ã®ÕÑ÷pÓ¿ø‹L¼;Ýà€AøÅm2Q±/˜V?dwÓ%lÅ9bG–cÑhò—Ü»%“Aâj1¨9ƒô
‹—Å“,•?†
hX Ç 4žà†ÌEM´ßæYUøeõ³?ÅâU–>0À,ÓÁ‰fÆn?ÍØÍà ³A 0j8nÑM+%ÈïI¡öK¸‚šÛ*P:³}ˆ8:*üÆ3ý7y4Œ¡Ç„.Ç «ª¦?× ;÷‹¢ÞyvÖÉv˜=·0Y¼Ê
?³qG™W?'ýú‹s5Äu(w³†áÞÞˆ%±˜UþyæF“Ðù!Ëà¼Yq #Ž5('}¡9((üÊp…ñ(à‰Á b¶-1ä´Oܲ±m™£·î:/ŠŠ\+4KÃ%ÔÂþ°°ÉSaýË?‚ŽÈx_x¹pª;
¨®?7|ËÜ¥6{ŸóÀ„”àãÔ;ÑÈìÅž³`Z;Ô m‘<ÄRY·K¿2”×÷;?~ïø%q„`Ø7)ëŽïLnžm&’gÚV¶ðâTàY€BL3,g¥eY8Ïq•¸>¦x¾qÄâzê
±âÊxXi9ƒL^#w|Ê?yÜlÛ¶g´ÎÕ?»üM2݈&T»” Àù;FŒ˜txÕùæY?h5 +~©;L­,’H|/øe(‘Üæûƒé
œ>å!\±µQ?3&öÓd7×êÿÚ? ?????—3Lt%ÁŒ3ÁéÊ U62D£i˜BJgØĪó}r‡ÜœÎ ?mdN»Ú%?-z;^ß¡?ÑkíìW»Ú³ì?^¸/nï§&}?-rê>
ÁG½àÀ9ÒØ Pâ†â¥Ìë„Vz+'ŽÁŒÜ‚?ÿÄ??????????!1AQa¡ÑðÿÚ??·Â=?z<)콓հÛo?yœû?ys­·0 ñ‰à5ìëƒt糧ŒÍù ößËÞNšÊ0€Â°,5"o\|;"e²|žå>Éo»>’æ@z?§”IR ˜6«’rqÙößÿÄ???????????!1AQ ÿÚ??笔¶Æ<¾?å²aÁÒLá'—iÎËvÁÕŒ´±q‡?º–g»´0Ûm··$W-þÊ8®.Û{Ô˜ç4„zpSÃ9-ëb¸ lOc‚o/Õß’þÈýà^6êì°ò]vKe‹쌈ü²jzžðËÌdñ¶eî{e¶2™î0dwݳ$‡k>·¤?] “%“îOŽ^K/ÿÄ?&??????!1AQa?q‘¡±ÁÑðáñÿÚ???¢„.L¦&?\æQˇ<åóÿ??TãV^ ú
¤8/?#à*»ƒ $¤Pûhø‚,™ÑX„¯ÏòŒˆ
™?äÍ,ŠªÈ•¾fVd˜nF.ñ?Š™f#z—?Q!]pYJ5¯Ñ+L\TJ¬¯î
ºíÞ×õ*Pš‡¨*¥?õ̓+hkX‚Ö¬R¿»%íyLUÍÊPô Ó:‘—… É"|}M?™C¢ +)z8¨?ðƒ?pRÚ†ûŒ!
E×15"”Ԩ“GQ½V5?Î?¸&¹hÌPCwUtÂú¸ùÄ¥pä»ìš&5ÓÔçP3øÍ4L
¡zŒA®G(¯j¼Î•%—NRã‰5m8-¿â^¨\«%ß9˜$giyn åçîcË°©W Ѩ,; àÿ?ÈH­SŠZûˆrêî+§ËüÌXïÍr%
¦mL˨Ñ<R×S ƒP½ÚëU~Îp¾?ø)¼á—<eUØHþ#¢vœÐª?ÜÁpn[(ëå³,êQKŒ¾?¬mð– RÆêøø<ÞâÓl•¯ÇjñAÜ*îáU½oùœ3e²—ÑÛ”£eŽNƒb›ýÇ0î¹7‰Sÿ?&S^8Žê`×0dĵ¸cÂ_„È@æ·
ÿ?ƯA”ñ– ¦ôÑõ¿3vbâ†+ïóˆ"
@TüUÖЈf—£!ÿ?‘YO€%àÍîþ%F|¤·AÅõÑæ> >W>;î 7t+ÄýÂ?-И¶a‹·æ¥Ž]§G½Mû™52êRŠ•Ban¥êN3)±|\3‡§'ûù”@ 22ÕõoçÄOÖl½‡Ü4
VÒXú€¥ŽáÚ½ÚóÒÆ¢—Ÿ¤kÌ f?•|…9ºãŽeŠ|?«¢†žV.¬£3Ñ™T½Ê©q˜)½ù€ÞÀØæ£:d¿ ™¦×êVî™á”²Ñ¢8uH·”-úÄ°]9!©`sL>%¸šZ[Ê̽…?ä|…{ˆåÚ²üˆSª¶{.\˜ânÕÑú•áaw ëµjÕ
Ó–åТXGº?¸ à¸\Ö›>ÈÓo].®óŸ ÔCUÀ|Ç©`¼üÁ’Ø»<ãñ6p˶@°?™î¢â%:¯µˆRÁžidqÀ÷«Eõ]˜ûy™meúTÐÿ
?s`Ú6+ž?dÄiëg~-úŒ¥­PÑëÄQ³€(ÌÈ.í?X|õýì¯6?b"]?.ø‰?[??ÙËÎWÔÓ!Æ,=uÓ1ñaM>G [Rb oø?Ýð®Õ&£k—âP…Å? eŠ÷q?·S¶ì÷šù„‰‚Éj3ù©HÓk‘ó”H¢7صÄTÁÊéðkܦFríøñ3+&êŸ+
ú•†áðý–š)`?¿Á¥òó]ÆSlš Êû+î~hsœ'ê½Å^p±±‚?s2f Kìß×óyƒQFSî1 ÃßÄ—ZîQ÷ôB¸²{b?G˜L¬8S®ÉŽdsh]+õšQÈyÄ£³KtÖ4ßâ?G8ø×¹ž{Är-{‚„}Ï?½¹ŽàNIo
‡âã Öör<8c?;îm}K¹~ ³Q»ŽJ©Ex
^)?š $ÞÃõ±½Q(—mùͲ·¨© « ;ó[…lËUCzG§Î8†µ?ú¾<@÷U}…î<??×ò2Р€c’³,'ún‹Þ¢öø¬9i›ÌGVû(7ñ ¼¶¿°)­¿ˆVÈã¨äîu2•«ÏR¨R¶ÜF?E“9Éå?GG3!Fm.·‚1rµL€Kö§©nι:|™–U”Ȉ+?Ëæ‰XË
¥¸ˆ‡˜ÇÍnUz[aÚ“¬éþ£MaÚ_²¦càÙQM
è?©ð•ÝÁd£•ÿ?Èã®Æ=T€Zõ#½o¤ÿ?q!Ð ¶ë;øƒWè
ÚË?RÂô]Ò½ÄFvQs£«FPÍò£oÆÜ]ÿ?çˆVÝŠ»ü^=“–±@&›ãýR´nÿ? »ÿ?ØåÔÊK®ŽÌYêÈJÏ)¯?§ÔÀ©(íLË—Šñ1Zõ!:œA ÿ?n*Rõ瘜ԛ•”T]‹?_ÌËÑ&ƒ.*?PdîâÌ¿DEBrù”Ñœ;-V%DXÖ¨S~cÅð3¬Â#X¿"L€0{1g#Ù ©¹ÐÈûª¯îqÞê=ï›~Ñ÷[tW*¿šƒØ+IÄ«Ã÷´?\ÀuÖʬæ-‹¸Ýyú˜¨Eñ,%É›y˜“qY=¼|Ç¡B
£Î3 €‚ô
gò·aÙæo6—|?q,ëÀ@Sx6ùŠ½Zµ3’TÝËâïódl?K±¿â^²®Ø×¢ÉH÷o@?Ž®¾%ÊKå¾/ó (¥R??8˜8ùaEni¨nÔ¥Š8ýB”ß㑘aáÖ¾?˜,ëµÒ÷¤Pûæ2
·á
̵ù£ðˆªåoQ?ï?ü°bkAB§òTmÏÅ$!+KZ<w‰”^Âì>Cž±äž—F äÙ’'ªTC^7ÈðÁ}?€ Àãæ^¨‹Ž+(ÏhJü|ƒF”øs„P˜¡?“¤âZÕk*ühÕmØ[¨—E’‹v01Á…}…âSBË7¡Ä•Ê2%î$Ô?j
-?Ó-ÖQá’^Ÿ™ôoßû1m„ÄrÀWÛõäTãœC
6 6ÜSRz1tì÷p
C|? ŠÊ9~sü Èc–.±¹€5òÔ§:øÈ»R÷ñÿ?Å7j´²Ù¹C7ÁßL¥í„–´*7i-gnæ ³±äܱqÖ?ÁHdÖÁÛÃö
ç&ÏgYâ°×ôè P3g7_ìL‘å¹qÀƒî£sêi
@bÕ/]€÷ÄrJkm¹p GbÊ'ýómEZl&¸FK—:_™²å´’83CÕG!yz¶¿ˆÀª­îgám÷˜eØ.²ÏŒFnCEº”Gt
óQ樓^é<ÄQÊÄM§?›1üþ ;äçÙ ®gÏÌ«1Y}!Òß©J0M®lV0?cC8oîýEkggãŃitŠµæ`Àðzœö0¹ÖÑ5õ2Jš™?ÁïKâ†Ê쉶
Ÿè¨ ŒDdÖPÁ¦ßÜpdÊUÈû‡>ŠËƃ`1ô\µ&?
Ó1–i*5^«îYƒ Ã7Æ?ôß™“Ò-QﯚÓp *£cÀá<À-µ¦¥ Z©6&(ÀÀ=AÉ–ì°#þ;XbØ>3ÒŒ<Euv{w,2‚d+ª¿ âQ:/O˜;6¦/œýÎHA"ÔE5ÈÝž|FÚ?*ɇ­Ž¦*lÊʼn^“?Ô°å(oýPB.B¿Ø¹í,·!
­¿ÚÍõÇÜ*È
Àœ¾f¾»šÓr²” £ÃtÊ`¢ÂmÐ÷“õJJ?eþ¥ì®ñKöoÌR?¼Õæ?ÿ??‘͉Zìþã´+Ãþó ’7g}
?f4®Æܶê¯ýÌC‚waâ¼Áé]Óeß?Çm£S-ñ¦eÖ5$¨y̸ ª|Ä‘çˆØ fÙhO³óS@™Î0A± "…­uþæX@áà8Ä*‘Ô4½Yoâ,3šk|fV?çJ¥ýJZŠ?.Nf²š4ÂÞ9á¯d+»‹qïd !½D|a%ôÌ]hx„tænC¿nq?.¶j`/Š*YiQvøÆ6áïC¿åyó,]‹à‰Sx j`…³ÏZüÁB®§å¢4
[ÃPªP¥sÜAÔnMyZ’ò}ÔÓíüø€?S*å‹ÝÀ©†Û6uÑ5#*ी‡i› WQ`‡&¸lÏWù˜N[Þ§Ð~I`ávó0¥/…~cœÀWC’gÙ°´|1’
i:õ¨èá qñ¨P ÉC$ÿÙ

)

[2] => Array
(
[type] => text/plain
[cid] => example.txt
[filename] => example.txt
[body] => Detta är ett bild exempel.

)

)

)
</pre><hr/>'
 
well that look ok, doesn't it? you are getting your message parsed into three parts : the text part of the MMS and the image part and finally the smil (mobile encoding to tell the MMS receiver how to play the file. there might also sometimes be a music part.

so try something like this (note that this does not pick up the message body, just the image)
Code:
<?
$message = mysql_real_escape_string($mms->subject);
$phonenr = mysql_real_escape_string($mms->number);
$tariff  = isset($_POST['tariff']) ? (int)$_POST['tariff'] : 0;

foreach ($mms->parts as $part) {
	if ($part['type'] == 'image/jpeg'){
		$sql = "INSERT 
				INTO mms 
					(sender,message,tariff,tstamp)
				VALUES 
				('%s','%s',%d,NOW())";
		$sql = sprintf($sql,$phonenr,$message,$tariff);
		// execute
		$res = mysql_query($sql) or die(mysql_error());

		// save image in /data/
		$filename = 'data/'.mysql_insert_id().'.jpeg';
		file_put_contents($filename,$part['body']);
	}
}
?>
 
ok, i put in that code and bellow is what i have now, still i got this erro

'<br />
<b>Parse error</b>: parse error, unexpected $end in <b>C:\Sites\Single8\lunarplejs\webroot\mms\mms.php</b> on line <b>99</b><br />
'

Code:
<?php

require_once('Mail/mimeDecode.php');

// Definiera konstanter för databasanslutning
$MYSQL_HOST = 'orf-mysql1.brinkster.com';
$MYSQL_USER = 'lunarplejs';
$MYSQL_PASSWORD = 'powersupply';
$MYSQL_DATABASE = 'lunarplejs';

// Stäng av PHP:s felrapportering
error_reporting(0);

// Anslut till databasen
mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
mysql_select_db($MYSQL_DATABASE);

if($_SERVER['REQUEST_METHOD'] == 'POST') {
    $mms = new MMSDecoder();
echo "<hr/><pre>".print_r($mms, true)."</pre><hr/>";
    foreach ($mms->parts as $part) {
        // values
$message = mysql_real_escape_string($mms->subject);
$phonenr = mysql_real_escape_string($mms->number);
$tariff  = isset($_POST['tariff']) ? (int)$_POST['tariff'] : 0;

foreach ($mms->parts as $part) {
    if ($part['type'] == 'image/jpeg'){
        $sql = "INSERT
                INTO mms
                    (sender,message,tariff,tstamp)
                VALUES
                ('%s','%s',%d,NOW())";
        $sql = sprintf($sql,$phonenr,$message,$tariff);
        // execute
        $res = mysql_query($sql) or die(mysql_error());

        // save image in /data/
        $filename = 'data/'.mysql_insert_id().'.jpeg';
        file_put_contents($filename,$part['body']);
    }
}

////////////////////////////////////////////////////////////////

class MMSDecoder {
	var $subject;
	var $number;
	var 

$parts;

	function MMSDecoder() {
		

// texten som din tjänst matchades på (antingen ämme eller en text i meddelandet)
		$this->subject = 

$_SERVER['HTTP_MOSMS_SUBJECT'];
		

// avsändarens telefonnummer
		$this->number = $_SERVER['HTTP_MOSMS_NUMBER'];		

		

// MMS-meddelandet från telefonen kodat i MIME
		$mimedata = file_get_contents('php://input');
		$headers  = 

"Content-Type: {$_SERVER['CONTENT_TYPE']}\n";
		$headers .= "Content-Length: {$_SERVER['CONTENT_LENGTH']}\n";

		

// avkoda MMS-meddelandet
		$params = array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' 

=> true);
		$decoder = new Mail_mimeDecode($headers . "\n" . $mimedata);
		$decoded = 

$decoder->decode($params);
		
		$this->parts = array();
		
		foreach 

($decoded->parts as $part) {
			$temp = array();
			

// MIME-typ till exempel: text/plain, image/jpeg, application/smil
			$temp['type'] = $part->ctype_primary 

. '/' . $part->ctype_secondary;
			

// content-id, används i vissa SMIL-dokument för att referera till bilder, ljud och andra objekt
			if 

(isset($part->headers['content-id'])) {
				$temp['cid'] = trim($part->headers['content-id'], 

'<>');
			}
			if (isset($part->d_parameters['filename'])) {
				

$temp['filename'] = $part->d_parameters['filename'];
			}
			$temp['body'] = 

$part->body;

			$this->parts[] = $temp;
		}
	}
}

?>
 
a little bit of self-help and a look at sleipnir214's FAQ on debugging would have got you there. you had not closed a curly brace.
Code:
<?php

require_once('Mail/mimeDecode.php');

// Definiera konstanter för databasanslutning
$MYSQL_HOST = 'orf-mysql1.brinkster.com';
$MYSQL_USER = 'lunarplejs';
$MYSQL_PASSWORD = 'powersupply';
$MYSQL_DATABASE = 'lunarplejs';

// Stäng av PHP:s felrapportering
error_reporting(0);

// Anslut till databasen
mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
mysql_select_db($MYSQL_DATABASE);

if($_SERVER['REQUEST_METHOD'] == 'POST') {
    $mms = new MMSDecoder();
	//debug only
	//echo "<hr/><pre>".print_r($mms, true)."</pre><hr/>";

	$message = mysql_real_escape_string($mms->subject);
	$phonenr = mysql_real_escape_string($mms->number);
	$tariff  = isset($_POST['tariff']) ? (int)$_POST['tariff'] : 0;

	foreach ($mms->parts as $part) {
		if ($part['type'] == 'image/jpeg'){
			$sql = "INSERT
					INTO mms
						(sender,message,tariff,tstamp)
					VALUES
					('%s','%s',%d,NOW())";
			$sql = sprintf($sql,$phonenr,$message,$tariff);
			// execute
			$res = mysql_query($sql) or die(mysql_error());
	
			// save image in /data/
			$filename = 'data/'.mysql_insert_id().'.jpeg';
			file_put_contents($filename,$part['body']);
		} else {
		//do nothing
		} //close internal if
	}	//close foreach
[red]}[/red] //close master If
////////////////////////////////////////////////////////////////

class MMSDecoder {
    var $subject;
    var $number;
	var $parts;

    function MMSDecoder() {
        

// texten som din tjänst matchades på (antingen ämme eller en text i meddelandet)
        $this->subject = $_SERVER['HTTP_MOSMS_SUBJECT'];
        

// avsändarens telefonnummer
        $this->number = $_SERVER['HTTP_MOSMS_NUMBER'];        

        

// MMS-meddelandet från telefonen kodat i MIME
        $mimedata = file_get_contents('php://input');
        $headers  = "Content-Type: {$_SERVER['CONTENT_TYPE']}\n";
        $headers .= "Content-Length: {$_SERVER['CONTENT_LENGTH']}\n";

// avkoda MMS-meddelandet
        $params = array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers'=> true);
        $decoder = new Mail_mimeDecode($headers . "\n" . $mimedata);
        $decoded = $decoder->decode($params);
                
        foreach($decoded->parts as $part) {
            $temp = array();
            // MIME-typ till exempel: text/plain, image/jpeg, application/smil
            $temp['type'] = $part->ctype_primary. '/' . $part->ctype_secondary;
            
			// content-id, används i vissa SMIL-dokument för att referera till bilder, ljud och andra objekt
            if(isset($part->headers['content-id'])) {
                $temp['cid'] = trim($part->headers['content-id'],'<>');
            }
            
			if (isset($part->d_parameters['filename'])) {
                $temp['filename'] = $part->d_parameters['filename'];
            }
            $temp['body'] = $part->body;
			$this->parts[] = $temp;
        }
    }
}

?>
 
URGENT
please make sure that you change your db username and password. it will be in the search engines by now, so red-flagging is not a viable mitigation strategy any more.

your db server is exposed to the internet and the username is not host restricted meaning that using these data you can get, for example, all the users email addresses from each of your ___users tables.
 
Noticed :) bad misstake i made

the datbase on that addres was just a test, but i hcanged the password and check the logs, nothing happend to it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top