raysefo
-
Posts
18 -
Joined
-
Last visited
Posts posted by raysefo
-
-
Hi,
I wrote a simple php page and tested it locally via WAMP. It is OK. I decided to upload this code onto joomla. I set the menu items and add this page as a new artice as follows:
<p>{jumi [test.php]}</p>
Here is my sample test.php:
<html> <head> <title>TEST</title> <style type="text/css"> table.imagetable { font-family: verdana,arial,sans-serif; font-size:11px; color:#333333; border-width: 1px; border-color: #999999; border-collapse: collapse; } table.imagetable th { background:#b5cfd2 url('cell-blue.jpg'); border-width: 1px; padding: 8px; border-style: solid; border-color: #999999; } table.imagetable td { background:#dcddc0 url('cell-grey.jpg'); border-width: 1px; padding: 8px; border-style: solid; border-color: #999999; } table.center { margin-left:auto; margin-right:auto; } </style> </head> <BODY > <br> <?php function form($imageURL536,$imageURL640,$drawNo){ echo " <form method='get'> <center><img border='0' src='contest_winner.jpg' alt='' width='452' height='384' class='center'></center> <table class='imagetable center'> <tr> <th>5/36</th> <th>6/40</th> </tr> <tr> <td> <select name='game1'> <option value='1'>$drawNo</option> </select> </td> <td> <select name='game2'> <option value='1'>$drawNo</option> </select> </td> </tr> <tr> <td> <center><input name='send536' type='submit' value='Check'></center> </td> <td> <center><input name='send640' type='submit' value='Check'></center> </td> </tr> <tr> <td> <center><img border='0' src='$imageURL536' width='24' height='24' ></center> </td> <td> <center><img border='0' src='$imageURL640' width='24' height='24' ></center> </td> </tr> </table> </form>"; } function sendEmail($msg){ //Send Mail. require_once("class.phpmailer.php"); $cbsmail = new phpmailer(); $cbsmail->IsSMTP (); $cbsmail->IsHTML(true); $cbsmail->SMTPAuth = "TRUE"; $cbsmail->Username = "info"; $cbsmail->Password = "info/"; $cbsmail->Hostname = "111.11.11.1"; $cbsmail->Host = "111.11.11.1"; $cbsmail->port = '25'; $cbsmail->From = "test@test.com.tr"; $cbsmail->FromName = "Information"; $cbsmail->Subject = 'TEST ' .date("d/m/Y"); $body = chr(13) ."Dear All, " ."<br>"."<br>"; $cbsmail->Body = $body; $cbsmail->AddAddress("test@test.com.tr"); $cbsmail->Send(); unset($cbsmail); } $imageURL536 = "FAQ-icon.png"; $imageURL640 = "FAQ-icon.png"; $drawNo = "123456"; if (isset($_GET['send536'])){ ConnectFTP($drawNo); $imageURL536 = "Circle-apply-icon.png"; } if (isset($_GET['send640'])){ ConnectFTP($drawNo); $imageURL640 = "Circle-remove-icon.png"; } //Prepare Markup form($imageURL536,$imageURL640,$drawNo); function ConnectFTP($drawNo) { $ftp_server = "111.11.111.111"; $ftp_user = "user"; $ftp_pass = "pass!!!"; $ftp_port = "21"; $path536 = "/536/RESULTS/"; $path640 = "/640/RESULTS/"; $check_file536_exist = $path536."test-wins_5-36-1006.txt"; $check_file640_exist = $path640."test-wins_6-40-1456.txt"; // Open connection $conn_id = ftp_connect($ftp_server,$ftp_port) or die( "$ftp_server sunucusuna bağlantı kurulamadı"); // Login if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { // get the size of $file $res = ftp_size($conn_id, $check_file536_exist); if ($res != -1) { parseFile($check_file536_exist); } else { sendEmail("Couldn't find the file on FTP ".$check_file536_exist); } } else { sendEmail("Couldn't establish connection with $ftp_user "); } // Close connection ftp_close($conn_id); } function parseFile($check_file536_exist) { //Get Files to Parse $homepage = file_get_contents('ftp://user:pass!!!@111.11.111.1:21/640/RESULTS/test-wins_6-40-1010.txt'); $kw = explode("\n", $homepage); $totalNumRow = 0; $totalAmount = 0; // Loop the relevant records for($i=0;$i<count($kw);$i++){ if(substr($kw[$i], 0, 1) == "5" && substr($kw[$i], 1, 1) <> "/") { // echo $kw[$i]; $totalNumRow = $totalNumRow + 1; $originalstring = $kw[$i]; $delimiter = ","; if(strpos($originalstring,$delimiter) > 0){ $outarray = explode($delimiter,$originalstring); $amount = $outarray[1]; // echo $amount; $totalAmount = $totalAmount + $amount; } // echo "<br>"; } } } ?>
The problem is, when I click the check buttons, the page becomes blank! But when I tried on local machine, after button click, page displays the table again. What is wrong with this?
Best Regards.
-
Hi,
I am new to php. I wrote a sample code as follows;
try { //Get Files to Parse $homepage = file_get_contents('ftp://username:pass@111.11.11.111:21/RESULTS/test.txt'); $kw = explode("\n", $homepage); $totalNumRow = 0; $totalAmount = 0; for($i=0;$i<count($kw);$i++){ if(substr($kw[$i], 0, 1) == "5" && substr($kw[$i], 1, 1) <> "/") { // echo $kw[$i]; $totalNumRow = $totalNumRow + 1; $originalstring = $kw[$i]; $delimiter = ","; if(strpos($originalstring,$delimiter) > 0){ $outarray = explode($delimiter,$originalstring); // $variable1 = $outarray[0]; $amount = $outarray[1]; // echo $amount; $totalAmount = $totalAmount + $amount; } // echo "<br>"; } } } catch (Exception $e) { $msg = $e->getMessage(); sendEmail($msg); }
Lets say if the file is not in server ($homepage = file_get_contents('ftp://username:pass@111.11.11.111:21/RESULTS/test.txt') , is there a way to catch and send this error?
Best Regards.
-
grrrr it was just semicolon!!
-
yep, right now I am doing it on localhost and the image is under C:\wamp\www with the php file.
-
-
Now it is OK but no images, probably path problem?
<?php function form($imageURL){ echo " <form method='get'> <center><img border='0' src='contest_winner.jpg' alt='test' width='452' height='384' class='center'></center> <table class='imagetable center'> <tr> <th>5/36</th> <th>6/40</th> </tr> <tr> <td> <select name='game1'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> <td> <select name='game2'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> </tr> <tr> <td> <input name='send1' type='submit' value='Check'> </td> <td> <input name='send2' type='submit' value='Check'> </td> </tr> <tr> <td> <img border='0' src='<?=$imageURL;?>' width='24' height='24' > </td> <td> <img border='0' src='<?=$imageURL;?>' width='24' height='24' > </td> </tr> </table> </form>"; } $imageURL = "Circle-apply-icon.png"; form($imageURL);
-
Hi,
Here is my sample code, but I am getting Parse error: syntax error, unexpected '?' in C:\wamp\www\test.php on line 72
<?php function form(){ echo " <form method='get'> <center><img border='0' src='contest_winner.jpg' alt='test' width='452' height='384' class='center'></center> <table class='imagetable center'> <tr> <th>5/36</th> <th>6/40</th> </tr> <tr> <td> <select name='game1'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> <td> <select name='game2'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> </tr> <tr> <td> <input name='send1' type='submit' value='Check'> </td> <td> <input name='send2' type='submit' value='Check'> </td> </tr> <tr> <td> <img border='0' src="<?=$imageURL;?>" width='24' height='24' > </td> <td> <img border='0' src="<?=$imageURL;?>" width='24' height='24' > </td> </tr> </table> </form>";
-
Hello,
I have a table as follows;
echo " <form method='get'> <center><img border='0' src='contest_winner.jpg' alt='test' width='452' height='384' class='center'></center> <table class='imagetable center'> <tr> <th>5/36</th> <th>6/40</th> </tr> <tr> <td> <select name='game1'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> <td> <select name='game2'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> </tr> <tr> <td> <input name='send1' type='submit' value='Check'> </td> <td> <input name='send2' type='submit' value='Check'> </td> </tr> <tr> <td> <-------- image here -----------> </td> <td> <-------- image here -----------> </td> </tr> </table> </form>";
I would like to add an image between TD's at the last TR of the table. How can I do it dynamically?
Best Regards.
-
Hi,
Lets say I have something like this ;
<select name="games" size="3"> <option value="1">game1</option> <option value="2">game2</option> </select>
I would like to select one of them from the list and get the value of the selected one. How can I do it?
Best Regards.
-
Hi,
I would like to populate a drop down list box on my php page. How can I simply put a drop down on this php page?
Best Regards.
-
Hi,
My problem is there are couple of files on this FTP and increasing everyday. I need to get the closest file which is created/modified today. The other files are irrelevant.
-
Hi,
Hi,
I am getting files from FTP as follows:$homepage = file_get_contents('ftp://usr:pass@111.11.111.111:111/a/b/test-wins_6-40-1010.txt');
I wonder if there is a way to get the files according to the creation date or modification date?
or if it is NOT possible, can I somehow get the file name and get the 6-40-1010 portion as follows?
6-40
1010 -
thank you.
-
But how, the port number is different (not 21). How can I add this port number to the url?
-
hi cpd,
I installed WAMP and wrote some script like below;
<?php $homepage = file_get_contents('d:\php\test.txt'); $kw = explode("\n", $homepage); $totalNumRow = 0; $totalAmount = 0; for($i=0;$i<count($kw);$i++){ if(substr($kw[$i], 0, 1) == "5") { echo $kw[$i]; // echo "<br>"; $totalNumRow = $totalNumRow + 1; $originalstring = $kw[$i]; $delimiter = ","; if(strpos($originalstring,$delimiter) > 0){ $outarray = explode($delimiter,$originalstring); // $variable1 = $outarray[0]; $amount = $outarray[1]; echo $amount; $totalAmount = $totalAmount + $amount; } echo "<br>"; } } echo "<br>"; echo "Total records: ".$totalNumRow; echo "<br>"; echo "Total amount: ".$totalAmount; ?>
It works OK for local file. But the problem is I couldn't manage to get the contents of the file which is on FTP. Is there a way to use file_get_contents on ftp files?
Best Regards.
-
Hi cpd,
Thank you for your reply. Do I need to install something in order to work on php? or just a file editor is OK to write and run it.
Best Regards.
-
Hi,
I am new to PHP.So any help would be great. I would like to display a drop down list and a textbox on a page. This dropdown data will be populated from a textbox. What I would like to know is,
how to:- parse a file and extact some data from a txt file which is on a server.
- populate this dropdown on the page with the data
- also I would like to display another data on the textbox according to the data selected on the drop down list
and of couse how to test this script etc.
Best Regards.
ftp_connect problem?
in PHP Coding Help
Posted
Hi,
I am using WAP on my local pc to make a ftp connection to linux server as follows:
Code:
$conn_id = ftp_connect($ftp_server,$ftp_port) or die("Could not connect to FTP Server");
There is no problem when trying from local pc. The problem occurs when deploy this onto Joomla on a linux server. I can not make a ftp connection. What is wrong? Any suggestions? Or should I use ssh2_connect?
Best Regards.