|
|
i m new to the linux. and have a knowledge of c,c++ but want to learn linux programming.
please provide me starting lesson about c programming in linux environment?
|
|
|
|
|
http://www.advancedlinuxprogramming.com/alp-folder[^]
The PDF's are pretty good One even describes how to write a server in C
Good luck!
See if you can crack this: fb29a481781fe9b3fb8de57cda45fbef
The unofficial awesome history of Code Project's Bob!
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
Did you get anywhere?
See if you can crack this: fb29a481781fe9b3fb8de57cda45fbef
The unofficial awesome history of Code Project's Bob!
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
the best book for linux programming is "Beginning Linux Programming 4th Edition"
Neil Matthew, Richard Stones, Alan Cox
here it is :
"http://ebookee.org/go/?u=http://www.fileserve.com/file/KkqkRjD/Begining%20Linux%20Programming%204th%20edition.rar"
enjoy it.
|
|
|
|
|
I am having trouble attaching a wav file to email through PHP.
<code lang=php>
$to = "John.Doe@TryHarder.com";
$from = "John.Doe@TryHarder.com";
$subject = "Test Email";
$message = "This is your test email";
$fileatt = "[Removed]\E1002.wav";
$fileatttype = "application/wav";
$fileattname = "E1002.wav";
$headers = "From: $from";
$file = fopen( $fileatt, 'rb');
$data = fread( $file, filesize( $fileatt ) );
fclose( $file );
$semi_rand = md5( time() );
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "nMIME-Version: 1.0n".
"Content-Type: multipart/mixed;n" .
" boundary= {$mime_boundary}";
$message = "This is a multi-part message in MIME format.nn" .
"–{$mime_boundary}n" .
"Content-Type: text/plain; charset= iso-8859-1 n".
"Content-Transfer-Encoding: 7bitnn" .
$message . "nn";
$data = chunk_split( base64_encode( $data ) );
$message .= "–{$mime_boundary}n" .
"Content-Type: {$fileatttype};n".
" name= {$fileattname} n" .
"Content-Disposition: attachment;n".
" filename={$fileattname} n".
"Content-Transfer-Encoding: base64nn" .
$data . "nn" .
"–{$mime_boundary}–n";
$mail_sent = mail($to,$subject,$message,$headers);
echo $mail_sent ? "Mail sent" : "Mail failed";
</code>
It seems what ever MIME is doing ends up being the body of the email and the attachment doesn't come though.
If someone could point out what i am doing wrong i would be forever grateful.
I am fairly new to PHP so please forgive me if this comes of as basic.
|
|
|
|
|
I have figured out the issue i was a little off but got it working with the following code.
$to = "Brad.Harris@prosodiecrm.com";
$from = "John Do<WhoCares@Cant.com>";
$subject = "Test Email With WAV";
$message = "This is your test email";
$fileatt = "Removed\E1002.wav";
$fileatt_name = "E1002.wav";
$type = "audio/x-wav";
$name = "E1002.wav";
$headers = "From: $from";
$semi_rand = md5( time() );
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
$message = "This is an example" ;
$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";
$file = fopen( $fileatt, 'rb');
$data = fread( $file, filesize( $fileatt ) );
fclose( $file );
$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
$message.="--{$mime_boundary}--\n";
$mail_sent = mail($to,$subject,$message,$headers);
echo $mail_sent ? "Mail sent" : "Mail failed";
|
|
|
|
|
Dear Friends,
I want to execute a redirect a URL in which i have to call a gateway server in order to send a sms. The Server on which i want to redirect a url is Linux based and the file code is on PHP. The particular php file is executed as a cron job.
As a cron job runs in backgroud, we are not able to redirect (Response.redirect("url") not allowed) and also it runs at middle layer (not presentation layer); how one will be able to do the above task then?
Thanks
|
|
|
|
|
I spoke with a co-worker on this and he said you would need a few things. One you need a cell card to tie into the cell network. What device you use should also include a software library from sending message via SMS. With that you should need a commandline parameter list or API reference to the software. From there you can code the php to build the message and all need variables needed to pass to the software.
Hope that helps.
|
|
|
|
|
Dear Cjoki,
I think you haven't understand the question. Well I am replying it again to make you clear that, I want to execute a url in php file which is executing in a cron job. The url after executing will be sending a sms to the specified number in the url.
I hope you now understand the question and can give me a positive approach of solving it.
Thanks
Varun Sareen
|
|
|
|
|
From my reading of SMS on wikipedia it looks like that the SMS gateways need a user login for the connection. This may be why you are getting the message you are.
I wonder if you have tested your connect to the gateway outside of the php script? can you connect to the gateway using another application and send a message?
Here is the SMS info for your review. http://en.wikipedia.org/wiki/SMS[^] Maybe it will shed some light on your issue.
|
|
|
|
|
Dear Czoki,
It's really great and so nice of you that you are showing so much of involvement into my problem but i guess you still not able to get me, I wonder where i am going wrong. Well let me try again....
My question is that how a URL can be executed in a cron job. The URL is actually calling the gateway server ( a third party client) with all the credentials required (I have checked it manually, I am able to send the sms from this gateway server by executing the php file (containing the URL) manually).
But the problem is arising when I am executing the php script file from cron job, the url code is not getting executed and hence the sms is not being sent.
I hope now you can understand where the problem is coming and eagerly waiting for a gud and positive reply.
Thanks
|
|
|
|
|
OK Varum,
You are having an issue with cron running the php successfully?
You can manually run the php script with success?
What does your commandline look like that runs the php script?
|
|
|
|
|
Hello Cjoki,
There you go dear, I am happy that i made you understand my problem.
Well, Yes I am having an issue in php script code but not in running the php script through cron job but in executing a URL in the php code while executing the php script file through cron job (although I am able to execute the URL while executing the php file by typing the location of php file in the address bar).
In order to execute a URL in php script; I have to execute it in a iframe control but the particular iframe control code is not running when i execute the php file through cron job. The iframe code is as follows:
<iframe src="$strURL" height="0 width="0" "></iframe>
(where "strURL" is the location at which my php file is present)
Regards,
Varun Sareen
|
|
|
|
|
iframe s aren't PHP code, they are HTML elements that are interpreted by web browsers. You can't run a mixed HTML/PHP page using the stand-alone PHP interpreter. You must figure out what the HTML code emitted by the PHP script actually does when interpreted by a browser, then duplicate that action by a different script (possibly in another programming language).
|
|
|
|
|
markkuk is right here. Please understand that php runs on the server and your iFrame runs in the clients browser. I am not even sure how cron works into this as I thought you were making a shell program, not one that runs in a browser.
Beside that you also have issues with permissions that require attention and cross site scripting issues to boot.
I suspect your code logic is way off mark Varun ...sorry.
modified on Friday, October 1, 2010 10:27 AM
|
|
|
|
|
Dear Cjoki,
I just want to know the solution from you, friends and i very well understand that i can't run a html control code in cron job.
I was just asking that the thing wasn't working what's the other way out.
I wish i could have mentioned that: "I know why
<iframe></iframe> is not working in cron job otherwise i may be receiving some solution rather than such harsh comments from you friends. .
It's sad...
Well....
Thanks
Varun Sareen
|
|
|
|
|
Hi php folks...
I decided to try to make an PHP script that a webform could call, to send an email, so I doesn't need the ugly mailto:xxx@yyy.domain in the form action.
So I have 2 pages. 1 frontend (html) and 1 backend (php).
The frontend contain an webform that on submit using the backend php as action, so its like:
index.html
sendemail.php
action="sendemail.php" (in the index.html form).
Everything works fine, and I recieving the emails as supposed... I have configured the php.ini to use my own smtp server (which I use at work too, so I know the SMTP server works).
the issue now is, that I want to send my emails as utf-8 format, cuz the need of some special characters inside the email?!?
I'm using the mail($to, $subject, $body, $header); as function right now... And when I type in some utf-8 formatted characters like ø, its viewed as ?? in the recieved email
How can I send my email()'s as utf-8?
I have try following:
- Set header of the email to utf-8:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/plain; charset=utf-8' . "\r\n";
$headers .= 'From: ' . $_POST['email'] . "\r\n";
I'm using Eclipse PHP as php editor for development.
$dato = date("d-m-y");
$to = "your@domain.dk";
$subject = "Web $dato";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/plain; charset=utf-8' . "\r\n";
$headers .= 'From: ' . $_POST['email'] . "\r\n";
if($_POST['street'] != "")
$street = $_POST['street'];
if($_POST['no'] != "")
$no = $_POST['no'];
if($_POST['floor'] != "")
$floor = $_POST['floor'];
if($_POST['name'] != "")
$name = $_POST['name'];
$newline = "\r\n";
$body = "Date: $dato" . $newline .
$street . " " . $no . ", " . $floor . "." . $nnewline .
$navn;
mail($to, $subject, $body, $headers);
Whitebox test:
Input:
$street = "ø";
$no = "53st";
$floor = "2nd";
$name = "æøå";
$dato = "20-09-2010";
Output SHOULD be:
Date: 20-09-2010
ø 53st, 2nd.
æøå
Actual output:
Date: 20-09-2010
?? 53st, 2nd.
??????
|
|
|
|
|
Hi
There is a list of articles and i have added a tooltip for a summary. So when user hover mouse over the name of the articles - tooltip appears with the summary of the article.
But now i would like to add that bit of html summary to database so that i can retrieve it from php to be displayed in tooltip.
For instance:
<ul>
<li class="listing">first</li>
<li>second </li>
<li> third</li>
<li class="last">fourth</li>
</ul>
I have to insert something like above under ul and li tags. How to insert this(html text) to mysql ?
Thank You..
|
|
|
|
|
You can insert HTML into MySql just like you would regular text, using an 'insert into' Sql statement. You might want to read PHP & MySQL tutorial to help you get started.
|
|
|
|
|
oh yeah inserting was fine but retrieving the data is a pain.
I am trying to retrieve it using simple select statement - but it doesn't display the html on the page.
Thanks
|
|
|
|
|
|
Did you check it got stored OK in the DB? say using MyPHPAdmin?
BTW: you must deal with special characters, those that would upset your SQL statement; and you need to be careful about any single/double quotes you use, there is a pair for your class attribute, if all that sits in a string literal, you're in trouble.
|
|
|
|
|
PHP is a pain atm..
How does the Sessions work in php.
There is a form in page a - which calls page b on submit.
in page b - i am converting all the $_POST to $_SESSION
and then page processes further and goes to page c where the data is added to database.
Now lot of field is blank in database. I can't understand what exactly is going wrong - what is the best way to create session and when should i unset it ??
confusing
|
|
|
|
|