The way that I understand it is that variables are defined first, then functions are defined (including custom user defined functions), then from that data any E_Notice errors are generated. After that, I am guessing that it goes through a conversion process (into binary) which is when the fatal errors are produced then is interperated from top to bottom except the custom functions which were defined earlier.
I am not saying that is exactly how it is goes but from my experience that is how I believe it goes.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
If you want the secure folder sessions to not be read from any other folder, then at the top of all your php files in the secure folder place the following code and it will make the session data in that folder only viewable within that folder.
<?
session_name("srmcvkdoejh48fo4mnf8");
session_start();
diafol commented: Nice one cwarn23, that's relly useful +3
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I'm not too sure as to what the second line should be but the first line should look as follows:
$urlres = preg_match_all('/<img[^>]+\>/i', $site, $matches);
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Try something along the lines of the following:
<?
$file='file.txt'; //set the file name and path
$lines=explode('
',file_get_contents($file));
foreach ($lines AS $line) {
if ($_POST['username']==$line) {
$userfound='true'; break;
}
}
if ($userfound=='true') {
//script for if user is found in text file
}
?>
Although the above code should work you may find that the function preg_match will be more recourse efficient.
Have a nice day.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
<?
$file=$_GET['page'];
echo translate(file_get_contents($file),'en',$_GET['language']);
?>
To make life easier, I have made an example of another way to use the function so that you can include an external php (or html) file to include the contents instead of having to worry about escaping the quotes. So basically, you have one or more page(s) that contains just that function and nothing else. Then when linking to another page, just link to index.php?page=newpage.php to load the the page named newpage.php in the same directory. And that may seem ugly so you can then use a htaccess file the rewrite the url to something more pritty like /newpage/.
So basically, the example above acts like the include() function which will translate while including. That will give you something to fiddle with. Hope it helps solve the puzzle.
Edit: You will need the full fuction code in index.php or whatever page the above example which was provided earlier.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
If it still is not working then simply startup the apache and mysql service by loading up the xampp control pannel and clicking the tick boxes beside apache and mysql. The control panel is located at C:\xampp\xampp-control.exe
A reboot may then be needed. Also make sure these two services startup automatically on bootup.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I checked the error in the attachment and SQL Admin should at all costs be disabled as it is so buggy and has so many memory clashes (at least on my version). Instead it is recommended that you use phpmyadmin which does exactly the same thing. Also phpmyadmin comes with xampp. I have version 1.6.7
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
And lastly, is that php regex legit?
Yes it is php regex as the c++ command prompt is communicating with the php-gtk application. Anyways, I tried the code ya supplied and it returned " \
Also I just tried putting the expected output into a batch file and the program blew up. That is it wouldn't work. I discovered that as soon as I removed the the middle double quotation mark then it worked. But I need to be able to use both types of quotations in my code though. So this isn't so much a c++ error but a dos type command line error.
Somehow I need to force php to accept the double quotes which I am working on so if I bump into more c++ errors in relation to this code then I shall post here.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Hi, I have been working on a simple command line program that will simply store my data in the code variable then submit that data to another program. Although I have the thory right, I don't understand why the middle double quote ( " ) seems to escape the quotes that surround the variable when it is used on the next line (variable: var).
So when I use the below code, I get the error "`[h]ref\` is not recognized as an internal or external command, operable program or batch file.". I don't understand why the quotation mark is escaping the string when it has been escaped twice and yes I have tried escaping it three times and just with the single slash. Can anybody see what is wrong with my script as I rarly use c++.
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
string code = "var_dump(preg_split('/(href\\=\\'|href\\=\\\"|[h]ref\\=)/is','adslkfajal;sdfjhref=test.com/test.htm'));";
std::string var = "C:\\z_php-gtk\\test4\\php-gtk2\\php -r \" "+code+" \"";
cout << code << endl;
system (var.c_str());
system("PAUSE");
return EXIT_SUCCESS;
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Try changing your script to as follows as some of your variables were difined with the wrong name:
<?php
/* Subject and Email Variable*/
$emailSubject = 'Email from Clients';
$to = 'tracyn2k2@yahoo.com';
/* Gathering Data Variables */
$name = $_POST['name'];
$email = $_POST['email'];
$phonenumber = $_POST['phonenumber'];
$comments = $_POST['comments'];
$body = <<<EOD
Email: $email <br>
Name: $name <br>
Phone number: $phonenumber <br>
Comments: $comments <br>
EOD;
$header = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($to, $emailSubject, $body, $header);
/* Result sender */
echo "Your Email sent to us. Thank for your inquiries. We will reply you within 24 hours";
?>
And if nessecary you can use the following:
<?php
/* Subject and Email Variable*/
$emailSubject = 'Email from Clients';
$to = 'tracyn2k2@yahoo.com';
/* Gathering Data Variables */
$name = $_POST['name'];
$email = $_POST['email'];
$phonenumber = $_POST['phonenumber'];
$comments = $_POST['comments'];
$body = "Email: ".$email." <br>
Name: ".$name." <br>
Phone number: ".$phonenumber." <br>
Comments: ".$comments." <br>";
$header = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($to, $emailSubject, $body, $header);
/* Result sender */
echo "Your Email sent to us. Thank for your inquiries. We will reply you within 24 hours";
?>
Hope that helps ya.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Try this as your code:
$result = mysql_query("SELECT * FROM `member`");
while ($row = mysql_fetch_array($result))
{
if(mysql_num_rows($result) == 0)
{
$result = mysql_query("UPDATE `member` SET `flgCurrent` = 'false' WHERE `idMember` ='" .$row[0]."'");
}
echo $row."<br />";
}
Also the logic in the if function just won't work. You have said the following in the script:
- assign the mysql query
- use the query the fetch the first row
- after the first & second & third & fourth etc rows are fetch, check if zero rows are fetched from the original mysql query
- If zero rows are fetched from the original mysql query then update a mysql table.
Does that seem logical to you because you are telling the script to ask itself if zero rows are fetched when it knows for sure that at least one row is fetched. So most of the code I gave above is fine but the following piece of that code will need a rethink design wise:
if(mysql_num_rows($result) == 0)
{
$result = mysql_query("UPDATE `member` SET `flgCurrent` = 'false' WHERE `idMember` ='" .$row[0]."'");
}
Thats all the bugs I can think of. Hope I explained that clearly and didn't confuse you.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Windows has nothing to do with it, he's probably using WAMP or XAMPP, and doesn't know how to configure the .ini file.
Google, my friend; Google.
Hi and I have been having having the same problem with the mail function but yes I know how to configure and instantly located the php.ini file. And yes I am using XAMPP. However I have found that it would take a genious to make this function work under windows. I have managed to modify the php.ini file in a way that will nolonger display the error message (with error messaging enabled) but the mail is never sent. I believe this is because the mail function was origionaly design for unix/linux but when importing to windows, not everything works 100%.
As fustrating as it may seem, I will share with you what I did to my php.ini file (with xampp and mailsender.exe) to make the error disappear (but no emails send though). First location the following string:
[mail function]
Then below alter the code as follows. But not to replace the email address me@gmail.com with your gmail address.
; For Win32 only.
SMTP = smpt.gmail.com
smtp_port = 465
;above default: 25
; For Win32 only.
sendmail_from = me@gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "\xampp\sendmail\sendmail.exe -t"
sendmail_path = "\xampp\sendmail\sendmail.exe"
The above may only work if you are using XAMPP due to the last couple of lines. Then in the file located \xampp\sendmail\sendmail.ini …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Download Malwarebytes' Anti-Malware (http://www.majorgeeks.com/Malwarebytes_Anti-Malware_d5756.html) to your desktop.
* Double-click mbam-setup.exe and follow the prompts to install the program.
* At the end, be sure to checkmark the Update Malwarebytes' Anti-Malware and Launch Malwarebytes' Anti-Malware, then click Finish.
* If an update is found, it will download and install the latest version.
* Once the program has loaded, select Perform full scan, then click Scan.
* When the scan is complete, click OK, then Show Results to view the results.
* Be sure that everything is checked, and click Remove Selected.
* When completed, a log will open in Notepad.
That may not 100% work. From my understanding of the situation, the difference from the http protocole and the https protocole is that the https protocole prevents man-in-the-middle attacks. This means there is something between the data transfer of your browser and the server your reading from which with the features of the https protocole, that something will be ignored. So why won't what in the above quote work. Well after you have installed Anti-Malware, it is most likely that you won't be able to update it unless it uses the https protocole (or download updates from another computer). And by looking at your log file I see you have spybot search and destroy installed. If you have allready have the updates for spybot search and destroy then I would suggest to use it. Also, I am not sure if your version of …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Well there is one possibility but that is depending on what the system restore did. If the system restore restored files at
{installationdirectory}/mysql/data/
then you could place your old files in there and that might display in PhpMyAdmin but don't over-right any files during the process. That is all I can think of.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Please post the form related to this??
I shall post a page with the translator fully embeded and you can select from the menu what language you want. However this requires a $_GET variable in the url bar when not viewing english pages. The only other alternative to not having the $_GET variable in the url bar is to use sessions. Anyway below is a fully setup example that you can use.
<?php
function translate($textSource, $langSource, $langTarget='')
{
$textSource=explode('<>',$textSource);
if ($langTarget=='') {$langTarget='en';}
$idz=0;
while (isset($textSource[$idz]))
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' . urlencode($textSource[$idz]) . '&langpair=' . urlencode($langSource . '|' . $langTarget),
CURLOPT_RETURNTRANSFER => true
));
$ret = json_decode(curl_exec($ch), true);
curl_close($ch);
$endresult.=$ret['responseData']['translatedText'];
$idz+=2;
}
return $endresult;
}
echo "<form method='get' style='padding:0px; margin:0px;'>
<select name='language'>
<option value='ar'>Arabic
<option value='bg'>Bulgarian
<option value='ca'>Catalan
<option value='zh-CN'>Chinese
<option value='hr'>Croatian
<option value='cs'>Czech
<option value='da'>Danish
<option value='nl'>Dutch
<option value='en'>English
<option value='tl'>Filipino
<option value='fr'>French
<option value='de'>German
<option value='el'>Greek
<option value='iw'>Hebrew
<option value='hi'>Hindi
<option value='id'>Indonesian
<option value='it'>Italian
<option value='ja'>Japanese
<option value='ko'>Korean
<option value='lv'>Latvian
<option value='lt'>Lithuanian
<option value='no'>Norwegian
<option value='pl'>Polish
<option value='pt'>Portuguese
<option value='ro'>Romanian
<option value='ru'>Russian
<option value='sr'>Serbian
<option value='sk'>Slovak
<option value='sl'>Slovenian
<option value='es'>Spanish
<option value='sv'>Swedish
<option value='uk'>Ukrainian
<option value='vi'>Vietnamese
</select><input type='submit' value='submit'></form>";
//now to use the translate function
echo translate("<font face='arial'><b>This is the text.</b>
You may place all your html in here and it will translate the text and not the code.
<br>But note that whenever you use a quote example:\" You will need a backslash before it but
that is only for the type …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
include doesn't return the contents of a file.
you would need to do a ob_start(), then include, then ob_get_contents() to get the file contents from an include.
i would use file_get_contents();
That is technically incorrect. Include can retieve the contents of a php file if the php file is designed to submit the contents. Below is an example to prove that.
<?
//index.php
$var=include('myfile.php');
echo "<hr>";
echo $var;
echo "<hr>";
echo $myvar;
?>
<?
//myfile.php
$output="<html>";
$output.="<body bgcolor=#00FFFF>";
$output.="This is the body";
$myvar='This is a test';
$output.="</body>";
$output.="</html>";
//submit output.
return $output;
?>
As you can see, in my example you can include a php file and return the execution of php code. Really simple but you must return the contents as displayed html will not be passed on. This means for my above example to work, you cannot use the echo or print function within the myfile.php and all the code in the php file need to be pure php (in myfile.php). Just a note to keep in mind.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
If you have php version 5 then use the following:
$html = file_get_contents("stuff.html");
echo $html;
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I answered a simular question on phpfreaks.com about embedding the google translator into your website and the script I came up with is as follows:
<?php
function translate($sentence,$languagefrom,$languageto)
{
$homepage = file_get_contents('http://translate.google.com/translate_t');
if ($homepage==false) {$homepage='';}
preg_match_all("/<form[^>]+ction=\"\/translate_t\".*<\/form>/",$homepage,$botmatch);
$botmatch[0][0]=preg_replace("/<\/form>.*/",'',$botmatch[0][0]);
preg_match_all("/<input[^>]+>/",$botmatch[0][0],$botinput);
$id=0;
while (isset($botinput[0][$id]))
{
preg_match_all("/value=(\"|'|[^\"'])[^\"']+(\"|'|[^\"'])?( |>| )/",$botinput[0][$id],$tmp);
$tmp[0][0]=preg_replace('/((\'|")?[^\'"]+)/','$1',$tmp[0][0]);
$tmp[0][0]=preg_replace('/(\'|")/','',$tmp[0][0]);
$tmp[0][0]=preg_replace('/.*value=/i','',$tmp[0][0]);
$len=strlen($tmp[0][0]);
$len-=1;
$tmp[0][0]=substr($tmp[0][0],0,$len);
preg_match_all("/name=(\"|'|[^\"'])[^\"']+(\"|'|[^\"'])?( |>| )/",$botinput[0][$id],$tmpname);
$tmpname[0][0]=preg_replace('/((\'|")?[^\'"]+)/','$1',$tmpname[0][0]);
$tmpname[0][0]=preg_replace('/(\'|")/','',$tmpname[0][0]);
$tmpname[0][0]=preg_replace('/.*name=/i','',$tmpname[0][0]);
$len=strlen($tmpname[0][0]);
$len-=1;
$tmpname[0][0]=substr($tmpname[0][0],0,$len);
if (strlen($tmpname[0][0])>0 && !in_array($tmpname[0][0],array('text','sl','tl')))
{
$vars.=$tmpname[0][0]."=".$tmp[0][0].'&';
}
unset($tmp);
unset($tmpname);
$id+=1;
}
$curl_handle=curl_init('http://translate.google.com/translate_t');
curl_setopt($curl_handle, CURLOPT_HEADER, true);
curl_setopt($curl_handle, CURLOPT_FAILONERROR, true);
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox
curl_setopt($curl_handle, CURLOPT_POST, true);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $vars.'text='.$sentence.'&sl='.$languagefrom.'&tl='.$languageto);
curl_setopt($curl_handle, CURLOPT_NOBODY, false);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,false);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
$buffer=strip_tags($buffer,'<div>');
preg_match_all("/\<div id\=result_box dir\=\"[^\"]+\"\>[^<]+\<\/div\>/",$buffer,$match);
$match[0][0]=strip_tags($match[0][0]);
return $match[0][0];
}
//now to use the translate function
echo translate('This is the text','en','iw');
?>
And of course another option is you can also convert the ajax function to a php function like the member Daniel0 on phpfreaks did and is as follows:
<?php
function translate($textSource, $langSource, $langTarget)
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' . urlencode($textSource) . '&langpair=' . urlencode($langSource . '|' . $langTarget),
CURLOPT_RETURNTRANSFER => true
));
$ret = json_decode(curl_exec($ch), true);
curl_close($ch);
if ($ret['responseStatus'] != '200') {
throw Exception('Translation failed.');
}
return $ret['responseData']['translatedText'];
}
echo translate('this is the text', 'es', 'en');
?>
Also to help understand how to use the functions above (both scripts are used the same way) is by entering the text to be translated in the first field. …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I would sugest making a form with two fields (a drop-down menu and password field) for the download precess. The drop-down menu or known as a combo box is where a user can choose from a the file to download in the password field is the password required for that download. If it is important or sensitive stuff you are trying to protect I would strongly recommend using a database system instead of a file system to store these downloads. So when the user selects the file and enters the password, php will do something like the following:
<?
if (isset($_POST['file']))
{
$qresult=mysql_query("SELECT * FROM `downloads` WHERE `file`='".$_POST['file']."' AND `password`='".hash('crc32b',hash('whirlpool',$_POST['password']))."'");
if (mysql_num_rows($qresult)!==0)
{
//Retrieve file from mysql database for download.
}
}
?>
So after that code has been compiled/executed and reaches within the last if statement brackets, it will then get from the mysql database the file you need for download. If it is binary files you are talking about then it might be a bit tricky but if it is text files then should be easy to do. Also they are binary files, you will need to set the table column to binary or if it is a mixture of binary and text files you may need two columns, one for binary and one for text. Also you can encode the passwords in the same format as the above script with the following function but this is just from the top of my head:
<?
function truehash ($hashzzz) …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
OMG - I just solved it. When I installed mediawiki under localhost, because mediawiki had full permissions, it changed my password. (before I had no password for root). And I soon discovered that it was actually only mediawiki that would work. So to find out my password, I just went into the mediawiki LocalSettings.php file and there the new password was.
I can't believe how this happened but from your reply I found the phpmyadmin settings to be the same as what I thought they should be and that is when I realised one of my cms's failed to load. Then I checked the other cms's I had and they all except mediawiki failed to access mysql. And it was only like 2 days ago I installed mediawiki and that is why I didn't notice the others to fail.
Thanks for the reply as I wouldn't have checked if you didn't post that.
*Solved*
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
A week ago phpmyadmin was working fine but now whenever I try and access phpmyadmin, (in xampp localhost) it displays 2 error messages and nothing more. They are as follows:
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
Cannot connect: invalid settings.
What I don't understand is that my other webpages can read the mysql databases fine but phpmyadmin cannot. I have checked the configuration file of phpmyadmin and everything seems to be normal. So has anybody had this problem or know how to solve it because I really need to be able to manage my databases for development reasons.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Transferring data to the https protocol is not as simple as it may seem. From what I have read, you will need to purchase ssl certificates (they are not cheap) and the entire website would be under the https protocol. A brief article about the certificates of the https protocol can be found at http://www.entrust.net/certificate-https.htm
However, you may be able to make a deal with your web host about these certificates and if that is possible, it would be the logical thing to do. That covers most of the basics of the https protocol and isn't that greater deal to use it from my point of view. Also could I ask why you want to use this protocol as it only prevents man-in-the-middle attacks. I would have to say there is a lot of other inexpensive things you can do to secure almost any php website. Example: Filter $_GET array to remove malicious data that can delete your website.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Sorry about the late reply but this is the code that I have now made:
<?
if (isset($_POST['subject']) && $_POST['message']!=='')
{
$address = "your_real_email@domain.com"; //change this to the receiving address.
$subject = "Website Email: ".$_POST['subject'];
if ($_POST['name']!=='')
{
$body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>Birthday: "
.$_POST['birthday']." of ".$_POST['birthmonth']." ".$_POST['birthyear']."<br>Gender: ".
$_POST['gender']."<p>".$_POST['message']."<br>
<br>
Yours Sincerely<br>
".$_POST['name']."
<p>
Email: ".$_POST['email']."</td></tr></table>";
} else {
$body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>Birthday: "
.$_POST['birthday']." of ".$_POST['birthmonth']." ".$_POST['birthyear']."<br>Gender: ".
$_POST['gender']."<p>".$_POST['message']."<p>Email: ".$_POST['email']."</td></tr></table>";
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: do_not_reply@your_website_form' . "\r\n";
mail($address,$subject,$body,$headers);
}
//below displays the form while above processes it.
echo "<form method='post'><table border=0 cellpadding=0 cellspacing=0><tr><td>Subject:</td><td align=left colspan=1><input type=text value='' maxlength=100 name='subject' size=35></td></tr><tr><td>Email:</td><td align=left colspan=1><input type=text value='' name='email' size=35></td></tr><tr><td>Birthday:</td><td colspan=1 rowspan=2><table border=0 cellpadding=0 cellspacing=0><tr><td colspan=2><select name='birthday' size=1>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option>
</select><select name='birthmonth' size=1>
<option value='January'>Jan</option>
<option value='February'>Feb</option>
<option value='March'>Mar</option>
<option value='April'>Apr</option>
<option value='May'>May</option>
<option value='June'>Jun</option>
<option value='July'>Jul</option>
<option value='August'>Aug</option>
<option value='September'>Sep</option>
<option value='October'>Oct</option>
<option value='November'>Nov</option>
<option value='December'>Dec</option>
</select><input size=7 maxlength=4 name='birthyear'></td></tr><tr><td> Male:<input type='radio' name='gender' value='Male'></td><td align='right'>Female:<input type='radio' name='gender' value='Female'></td></tr></table></td></tr><tr><td>Gender:</td></tr><tr><td colspan=3><textarea cols=35 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name' size=28><input type='submit' value='submit'></td></tr></table></form>";
?>
Above is the form …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I'm using the php executable from Terminal to load the php-gtk code (located in /usr/local/php-gtk in my Mac OS 10.5 after installing this DMG package).
Thanks for the advice and it is the information in that statement that allowed me to find out how to run the debugger. And since I have 2 computers, instead of installing the official software twice (I like the unofficial stuff) I simply just copied the 2 files (php.exe and php5ts.dll) from the computer with the official software to a selected directory in the computer without the official software where I could use a batch file to do the hard work. I then placed in my batch file the below commands and it works like a charm.
@echo -
@php -l index.php
@echo -------------------------------
@pause
Pitty this isn't obvious to find on the internet.
So *Solved*
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
There was a simular post not long ago located at http://www.daniweb.com/forums/thread61688.html
However, it was mentioned in the link above that it is not free to send a sms from a website. You will need to subscribe to a provider that can provide you with php code for your website. An example of a php+sms provider is at http://www.clickatell.com/developers/php.php so the code will vary from provider to provider. Try asking the providers for the best sms+php deals as you will need to pay somebody to deliver the sms messages (and php can't read the protocole for that).
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I am guessing the below code might work but I am not sure as you are reading from a variable and not a file. So try the following and if it does not work, you will need to use something simular but use the gd library/binary to allow the
list($width, $height, $type, $attr) = getimagesize($row[poza]);
The above code theoratically stores the width and height in the variables $width and $height which you can call after that line has been executed/ran. If you are wondering where to place it, place it after the below couple of lines:
while ($row = mysql_fetch_array($result))
{ print $row[poza]; }
As I said it might not work and might need some sort of conversion but it's worth a try as that is in the official documentation.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I thought I would mention I have just solved this myself and line 70 should be replaced with the following:
<li><a href='http://cwarn23.info/cms/blog/'><font color=#0000FF>Blog</font></a><ul><li><a href='http://cwarn23.info/cms/blog/category/'><font color=#0000FF>category</font></a></li></ul></li></ul></td>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Yes, It works.
Thanks. My current code is below and displays a row of buttons at the top. The only other thing I need to know is if there is any software that will display the error messages from any errors in my php file. I have tried enabling error reporting in the php.ini file of the compilation but makes no difference but other than that it works great and love the tutorials you linked to.
Below code does the job:
<?php
if (!class_exists('gtk')) {
die("Please load the php-gtk2 module in your php.ini\r\n");
}
function pressed()
{
echo "Hello again - The button was pressed!\n";
}
function pressed2()
{
echo "Hello again - The button was pressed!\n";
}
$window = new GtkWindow();
$window->resize(800,600);
$window->set_title('My Diary');
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
$button1 = new GtkButton('January');
$button1->connect_simple('clicked', 'pressed');
$button2 = new GtkButton('February');
$button2->connect_simple('clicked', 'pressed2');
$button3 = new GtkButton('March');
$button3->connect_simple('clicked', 'pressed2');
$button4 = new GtkButton('April');
$button4->connect_simple('clicked', 'pressed2');
$button5 = new GtkButton('May');
$button5->connect_simple('clicked', 'pressed2');
$button6 = new GtkButton('June');
$button6->connect_simple('clicked', 'pressed2');
$button7 = new GtkButton('July');
$button7->connect_simple('clicked', 'pressed2');
$button8 = new GtkButton('August');
$button8->connect_simple('clicked', 'pressed2');
$button9 = new GtkButton('September');
$button9->connect_simple('clicked', 'pressed2');
$button10 = new GtkButton('October');
$button10->connect_simple('clicked', 'pressed2');
$button11 = new GtkButton('November');
$button11->connect_simple('clicked', 'pressed2');
$button12 = new GtkButton('December');
$button12->connect_simple('clicked', 'pressed2');
$buttonbox = new GtkHButtonBox(); // or GtkHButtonBox for horizontal placement
$buttonbox->add($button1);
$buttonbox->add($button2);
$buttonbox->add($button3);
$buttonbox->add($button4);
$buttonbox->add($button5);
$buttonbox->add($button6);
$buttonbox->add($button7);
$buttonbox->add($button8);
$buttonbox->add($button9);
$buttonbox->add($button10);
$buttonbox->add($button11);
$buttonbox->add($button12);
$buttonboxparrent = new GtkAlignment(0, 0, 0.01, 0.01);
$buttonboxparrent->add($buttonbox);
$window->add($buttonboxparrent);
$window->show_all();
//$window->set_resizable(false);
Gtk::main();
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I have just started learning php-gtk 2 but am a bit stuck. First is that are there any php-gtk 2 debuggers or error loggers that I can use because at the moment, if there is a bug in my script, the exported exe file made from my php-gtk script is simply currupted or won't open. So does any body know of such program to read my script and tell if there are bugs and what roughly lines the bugs are on. Note: This is php-gtk - not plain php.
Also I have encountered a multi object problem where only the first button will be displayed on the screen. Below is the code I am using and do you know why the button $button2 wont show.
<?php
function pressed()
{
echo "Hello again - The button was pressed!\n";
}
function pressed2()
{
echo "Hello again - The button was pressed!\n";
}
$window = new GtkWindow();
$window->resize(800,600);
$window->set_title('My Diary');
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
$button1 = new GtkButton('Jan');
$button1->connect_simple('clicked', 'pressed');
$button1parrent = new GtkAlignment(0, 0, 0.01, 0.01);
$button1parrent->add($button1);
$window->add($button1parrent);
$button2 = new GtkButton('February');
$button2->connect_simple('clicked', 'pressed2');
$button2parrent = new GtkAlignment(0, 0, 0.01, 0.01);
$button2parrent->add($button2);
$window->add($button2parrent);
$window->show_all();
//$window->set_resizable(false);
Gtk::main();
?>
In case if you are wondering what php-gtk is, it is like php but with more libraries/binaries and instead of creating webpages, it creates programs.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Why not do what is usually done in MS Word and make the letter o in superscript. So try the below code:
<?
echo "It is 20<sup>o</sup>C.";
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I have made a standard email form and is below. The only thing you need to change is the variable $address (about line 4) to your real email address to receive website emails. Also this email form supports html formatting.
<?
if (isset($_POST['subject']) && $_POST['message']!=='')
{
$address = "your_real_email@domain.com"; //change this to the receiving address.
$subject = "Website Email: ".$_POST['subject'];
if ($_POST['name']!=='')
{
$body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message']."<br>
<br>
Yours Sincerely<br>
".$_POST['name']."</td></tr></table>";
} else {
$body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message'].
"</td></tr></table>";
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: do_not_reply@your_website_form' . "\r\n";
mail($address,$subject,$body,$headers);
}
//below displays the form while above processes it.
echo "<form method='post'>Subject: <input type=text value='' maxlength=100 name='subject' size=30><br>
<textarea cols=30 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name'>
<input type='submit' value='submit'></form>";
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
according to your solution if I have 1,00,00,000 user will I define those user in that number of veriables ?????????? is this thing feasible ?????????
Yes because all you need to do is check that the username (which should be unique from all the others) is correct and that at option, the password for security reasons is correct. So just to explain, I shall write a basic login system for you.
Below is login.php
session_start();
//mysql connect code
$result=mysql_query("SELECT * FROM `users` WHERE `username`='".$_POST['username']."' AND `password`='".$_POST['password']."'");
if (isset($_POST['username']) && mysql_num_rows($result)==1)
{
$row=mysql_fetch_array($result);
$_SESSION['username111']==$row['username'];
unset($row);
header('Location: index.php?login=true');
//there should be no browser output before this line.
}
?>
<form method='post'>
<input type='text' value='Admin' name='username'><br>
<input type='text' value='password' name='password'>
<input type='submit' value='submit'>
</form>
index.php (at top)
<?
session_start();
if ($_GET['login']=='true' && !isset($_SESSION['username111']))
{
echo "<h1>You need to be logged in to view this page!</h1>";
exit;
}
//no browser output before this line.
Sorry if there is a small bug but that login system is from the top of my head and I have used simular ones in the past. Hope that example helps
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
If you want it case sensitive then because php is case sensitive, just get php to check if the 2 values = each other. So use the following:
<?
//mysql connections
$username='Admin'; //from mysql in your script
if (isset($_POST['username']) && $_POST['username']==$username)
{
//login
echo "test";
}
?>
<form method='post'>
<input type='text' value='adMiN' name='username'>
<input type='submit' value='submit'>
</form>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
For that you could just convert both values to lower case with strtolower(); So try the following and I have included the form.
<?
//mysql connections
$username='Admin'; //from mysql in your script
$username=strtolower($username);
if (isset($_POST['username']))
{
$_POST['username']=strtolower($_POST['username']);
if ($_POST['username']==$username)
{
//login
}
}
?>
<form method='post'>
<input type='text' value='adMiN' name='username'>
<input type='submit' value='submit'>
</form>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
<form method='post'>
Username: <input type='text' value='' name='user'><br>
Password: <input type='text' value='' name='password'><br>
</form>
Well there are 2 main easy ways that you can do the activation process. Assuming above is the form you allready have, then if you just want to check there is only a space used or no password at all then the below lines of code will work:
<?
if ($_POST['password']!==' ' && strlen($_POST['password'])>0 && isset($_POST['password']))
{
//activate account
}
?>
Or you could just set a minimum password length of something like 8 letters/numbers/characters which is done like the following:
<?
$minimum_length=8;
if (strlen($_POST['password'])>=$minimum_length && isset($_POST['password']))
{
//activate account
}
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
This is only from the top of my head but if what you place in those 2 fields (area, rname) need to match percisely what are in those 2 columns within the mysql database then you could use something along the following:
<?
//mysql connections
if (isset($_POST['area']) && isset($_POST['rname']))
{
$result=mysql_query("SELECT * FROM `table` WHERE `area`='".$_POST['area']."' AND `rname`='".$_POST['rname']."'");
echo "<table border=1 cellpadding=4 cellspacing=0><tr><td>area</td><td>rname</td><td>column3</td></tr>";
while ($rowid=mysql_fetch_array($result))
{
//perform actions for earch row found
echo "<tr><td>".$rowid['area']."</td>";
echo "<td>".$rowid['rname']."</td>";
echo "<td>".$rowid['column3']."</td></tr>";
}
echo "</table>";
}
?>
<form method='post'>
area=<input type='text' name='area'><br>
rname=<input type='text' name='rname'><br>
<input type='submit' value='submit'>
</form>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I have just checked the create_function() element/function in the official documentation but I can't see how impliment it into my code. However, I have made a second piece of that that might calculate pi (haven't confirmed this new method follows the algorithom) which should solve my first problem leaving my digit problem. The code I currently have is as follows:
<?
function realpi()
{
$pival=1;
while ($pirow<25)
{
$pirow+=1;
$pisubrow=0;
$tempval="0";
while ($pisubrow<$pirow)
{
$tempval=sqrt(2+$tempval);
$pisubrow+=1;
}
$pival=0.5*$tempval*$pival;
var_dump($tempval);
echo "<br>";
}
$pival=$pival*2;
return $pival;
unset($pirow);
}
echo realpi();
?>
But the only problem is that php is rounding it to the eleventh digit. Is there any way around it because I need 1 million digits.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I have just discovered a major bug in php and an example is the below code. For some reason php rounds the variable $var to the number 2 and displays "2" instead of 1.99999999999999999999999999999999999999. So how would I make php display 1.99999999999999999999999999999999999999 while keeping the variable an integre for mathematical calculations as I need to display a 1 million digit number?
$var=1.99999999999999999999999999999999999999;
echo $var;
//displays "2" without the quotes
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I have been working on a function which creates a 1 million digit value of pi but php is treating a theoretical numeric variable as a string. Below is the code I used and for now I have put a small limit on the digits but it is line 22 that wont calculate. Does anybody know how to make it so that a function inside a variable can be executed with its mathematical calculations?
<?
function realpi()
{
$pival=1;
while ($pirow<6)
{
$pirow+=1;
$pisubrow=1;
$tempval="(0.5*sqrt(2";
while ($pisubrow<$pirow)
{
$tempval.="+sqrt(2";
$pisubrow+=1;
}
$pisubrow=1;
while ($pisubrow<$pirow)
{
$tempval.=")";
$pisubrow+=1;
}
$tempval.="))";
$pival=$pival*$tempval;
var_dump($tempval);
echo "<br>";
}
$pival=$pival/2;
return $pival;
unset($pirow);
}
echo realpi();
?>
With the echo functions inside the code, the below is echoed
string(13) "(0.5*sqrt(2))"
string(21) "(0.5*sqrt(2+sqrt(2)))"
string(29) "(0.5*sqrt(2+sqrt(2+sqrt(2))))"
string(37) "(0.5*sqrt(2+sqrt(2+sqrt(2+sqrt(2)))))"
string(45) "(0.5*sqrt(2+sqrt(2+sqrt(2+sqrt(2+sqrt(2))))))"
string(53) "(0.5*sqrt(2+sqrt(2+sqrt(2+sqrt(2+sqrt(2+sqrt(2)))))))"
0
All except the last line in the above box is a var_dump of the looped variable which will not perform the mathematical and function calculations. The last line is the answer that the function has got for pi. The reason why it is zero is because of line 22 where $tempval is a string. But it needs to be a mathematical string as it has functions that need to execute. Does anyone know how to execute this variable?
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
You may want to note that if you are on a proxy server or on a Virtual Private Network and sometimes if you are on a Local Area Network then you will need to configure those settings into your web browsers. So in Internet Explorer, open the Options window then click the connections tab and configure with the appropriate options and buttons what they should be.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
If you are using Xampp then you will need to enable the rewrite module in the apache httpd.conf file to use the .htaccess files(located C:/xampp/apache/conf/httpd.conf). To do this, first create a copy of the file located C:/xampp/apache/conf/httpd.conf or relative to your installation folder then open the original in notepad. After opening it in notepad, search for the term "LoadModule rewrite_module" without the quotes and when you find it, remove the hash at the beginning of the line. Then search for "AllowOverride None" without the quotes and at least twice will be found and need replacing with "AllowOverride All" (without the quotes). Then save the file and you should be able to use .htacess files. Another set of instructions just reworded of what I have said can be found at http://www.knowledgebase-script.com/demo/article-599.html
You may wonder how I know this, because I also have Xampp. Also when renaming a text file to ".htaccess", you may find that to be impossible to do due to a windows explorer error bug so just open notepad and save the file as ".htaccess" and that will create the file.
Also if it is all files you want to not have the extension use the following code in the .htaccess file.
RewriteEngine On
RewriteRule ^([^.]+)$ $1.php
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Although I don't know anything about it there is a function called http_request(); and the official documentation can be found at http://php.net/manual/kr/function.http-request.php
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I have created a script for you to fiddle with and is below. The below script is a function where you can enter the number of days, months and years untill the future date and the function will return what that date is.
<?
function count_to_date($day,$month,$year)
{
$d=date(j)+$day;
$m=date(n)+$month;
$y=date(Y)+$year;
if ($d>31)
{
while ($d>31)
{
$d-=31;
$m+=1;
}
}
if ($m>12)
{
while ($m>12)
{
$m-=12;
$y+=1;
}
}
//below sets sequence: day/month/year
$r=$d.'/'.$m.'/'.$y;
return $r;
}
//below returns a future date (day/month/year)
echo count_to_date(3,0,0);
//a bit of theory
//count_to_date(number_of_days,number_of_months,number_of_years);
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
this might be a little bit different from what you want but you can place an index.php file inside myhost/docs/default and place a code index.php which will redirect you to any page that you wish in this case default.php
or just add default.php to the default document list along with index.php etc...
or use the include("default.php") inside index.php
Those sound like pritty patchy solutions to me and why not do what wikipedia does of many people who own a copy of the mediawiki/wikipedia content management system. The way wikipedia does it is by using an apachie httpd.conf file modification to contain 2 rules simular to the following and more about that can be found about half way down the page at
http://www.mediawiki.org/wiki/Manual:Short_URL
The link has according to the preview being replaced with a smily so I have also placed the above link in the codebox below:
http://www.mediawiki.org/wiki/Manual:Short_URL
And those rules as they are called are:
Alias /wiki /path/to/your/wiki/index.php
Alias /wiki /var/www/w/index.php
If you wish to edit apachie for faster performance then you may do so with more information at the above link the the prefered method that most people do is using a .htaccess file as it does not require root access. So place at myhost/docs/ a file named '.htaccess' without the quotes and place the following code in it.
RewriteEngine On
RewriteRule ^default$ default.php
There is also a syntax you can use if you are doing this to multiple files. So generally I would use the …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I have just done a few tests and it looks like you need to use the http protocole and not the file protocole under the windows operating system due to some windows security feature. I tried both php and javascript to access a file under the file protocole and the error as you mentioned occured. So try locating the file from an address like:
http://domain.com/folder/file.doc
-or via ip-
http://184.294.495.304/folder/file.doc
If you choose to use the ip method you will need apachie installed and the web directory setup. Also you will only be able to access through the http protocole what is theoretically online although the files can be hidden from other users via htaccess. Other than that, I would suggest using a more dedicated client side language such as Java to do the job.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
It is because you are using the "file" protocole. When managing documents with php, use a relative path which does not breach apachies web root settings. So if your script is in the directory "C:/xampp/htdocs/example/test/index.php" and you want to unlink/delete a file in the web root directory then you would use the string "../../file.php" but with xampp for example, you can't delete anything above the htdocs folder as that is the web root. So try and use relative paths that do not breach the web root.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
hi cwarn23
i have that line of code in my index so when i execute php.info function within a
web server still shows upload_max_filesize = 2mb.what can should i do restart
apache and what inpact will pose to the program that using apache.thanks
Try adding the following line of code to the top of your file and confirm if what I said in my first post is true (line needed replacing) or not.
ini_set('memory_limit','3M'); //3 Megabites
If you place the above code at the top of your php file it will overright the default memory limit.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
if you are uploading through the browser then perhaps you have a html input field that is prevent the larger files from being uploaded. On most uploading examples you will see this is a line of code:
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
(100KB file limit)
But what you want is this:
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
(3000KB/3MB limit)
So search for that line of code and make sure it is 3000000 (with 6 zeros on the end).
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
I have just done a few tests and I don't see how it is possible to have the two name= fields exactly identicle but what you can do is put arrays in the name= fields and retrieve the $_POST as a 2 dimensional array. Below is an example of what I have done.
<form method='post'>
<input type='text' name='test[0]' value='111'><br>
<input type='text' name='test[1]' value='222'><input type=submit value='submit'></form><br>
<?
var_dump($_POST); //dumps the variable
echo "<p><hr>";
echo $_POST['test'][0];
echo "<br>";
echo $_POST['test'][1];
?>
Also you need to click the submit button for the above example to work. The above example shows about displaying what information the $_POST array holds and shows about using 2 dimensional $_POST arrays. Other than using arrays in the name= field,or changing the name of the field to be unique, you will find that only the last field of its duplicate name will be recorded in php.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
Although cookies are useful for long-term storage, I find that people can so easily disable them making your site not work. That is why I have invented what I call server-side cookies. These are cookies all stored within a mysql database and a retrieved by the users ip address. To help extend this topic I shall post the code for server-side cookies and explain how to use them. First you will need to create the mysql database which can be done just by configuring and running/executing the following code.
<?
$dbhost='localhost'; //database host (usually localhost)
$accountname='root'; //database username.
$password=''; //database password
$database='my_database'; //database name - not table
//configure the above variables.
$linkID = @mysql_connect($dbhost,$accountname,$password)
or die("Could not connect to MySQL server");
@mysql_select_db($database) or die("Could not select database");
mysql_query('CREATE TABLE `'.$database.'`.`cookies` (`name` TEXT NOT NULL, `value` TEXT NOT NULL,
`ip` TEXT NOT NULL, `expires` TEXT NOT NULL) ENGINE = MyISAM') or die(mysql_error());
echo "Table named 'cookies' has been created successfully."
?>
So after configuring the mysql variables at the top of that code and running/executing that code, you then may delete the file containing the above code. Then next is to add the functions to be able to use server-side cookies. So place the following code near the top of the page.
$dbhost='localhost';
$accountname='root';
$password='';
$database='my_database';
$linkID = @mysql_connect($dbhost,$accountname,$password)
or die("Could not connect to MySQL server");
@mysql_select_db($database) or die("Could not select database");
function ssl_cookie_make($cookies_minutes_till_expire,$cookies_houres_till_expire,$cookies_days_till_expire,$cookiename,$cookievalue)
{
$cookiename=str_replace("'",'"',$cookiename);
$cookies_months_till_expire=0;
$cookieexpiresy=date(Y);
$cookieexpiresm=date(m)+$cookies_months_till_expire;
$cookieexpiresj=date(j)+$cookies_days_till_expire;
$cookieexpiresg=date(G)+$cookies_houres_till_expire;
$cookieexpiresi=date(i)+$cookies_minutes_till_expire;
if ($cookieexpiresi>59)
{
while ($cookieexpiresi>59)
{
$cookieexpiresg+=1;
$cookieexpiresi-=60;
} …