-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
include or require_once is showing error while using jumi.
kicken replied to borhan_safa's topic in Applications
Your server's php.ini is configured to not allow you to include a URL. If the files you want to include are on the same server you should include them using a filesystem path rather than a URL. If you are trying to include an external file you need to either re-configure the server to allow it, or more likely stop using include() and use something else like file_get_contents().- 3 replies
-
- jumi
- joomla 2.5
-
(and 1 more)
Tagged with:
-
You can pass an array of values to str_replace and it will replace each one str_replace(array('R', ','), '', $deposit);
-
You would use something like exec() to run the appropriate command. For my windows 7 setup it seems to be the c:\windows\system32\wfs.exe program that you would run.
-
Have a read through this page: Caching Tutorial
-
Then the answer is no. PHP can't affect the client's PC, only the server computer. There isn't anything that would let you do such a thing with Javascript either as far as I am aware.
-
Rather than doing a blind substr() to a specific length, you'd need to create sort of a mini-parser to go through the string an determine if your in an HTML tag or not. Only count characters when your not inside a tag and also keep track of which tags have been opened. When you reach your target character count you can substr() to that position, then close any tags that are still open. I posted a function that does something like this quite a while ago I believe, you could try searching for it. If I can find it I'll post the link.
-
Add each token into an array as you gather them in the loop, then later on you can loop through the array of tokens to output them into your textarea. You can use the URL as the key for your array and put the token as the value that way you can easily find the token as you loop through the URLs when putting them into the textarea.
-
If you want to have your template php file executed and get the result as a string rather than it being output to the browser, then you'll want to use output buffering. For example: ob_start(); include('template.php'); $content = ob_get_clean(); ///do whatever with $content.
-
Fatal error: Call to undefined function gmp_intval()
kicken replied to denc's topic in PHP Coding Help
Create a file called phpinfo.php and put in it the following code: <?php phpinfo(); ?> When you load it you'll see a bunch of information about PHP's configuration and it's loaded extensions. There should be a section somewhere in there for GMP if it is enabled. -
Mysql has a GROUP_CONCAT function you can use to generate the comma-separated list SELECT title, GROUP_CONCAT(author) FROM books b INNER JOIN authors a ON b.book_id=a.book_id GROUP BY title For other DB's that don't have such a function you'd just have to select the title and authors together then group them in your program later on.
-
Fatal error: Call to undefined function gmp_intval()
kicken replied to denc's topic in PHP Coding Help
No, they come from an extension which you have to enable, either with a flag when compiling PHP or specifying it in the php.ini file. If you're using a hosting company then you should contact their support to see if they can enable it for you (or give you instructions on how to enable it yourself). -
You're probably going to need to explain your problem better. Near as I can tell you're asking how to do a loop to download a bunch of URL's and extract some token from their source. The code you posted already appears to handle that successfully. If there is some issue you need to define what that issue is and probably provide some sample data such as the source of one of the pages your downloading and what it is you want to extract out of it. The only thing I see off hand that you might need is a call to curl_setopt in your downloadUrl function to set CURLOPT_COOKIEFILE to the same cookie.txt file you're using in the login function in order to carry over the login/session cookie, assuming there is one.
-
You could do something like a SELECT ... INTO OUTFILE and use a REPLACE on any affected fields to remove the extra slashes but it'd probably be just as much work to do that as it would be to write a PHP script (unless it's a small number of table/fields). Assuming selecting to an outfile is an option for you, which if it's a shared host it probably isn't. Might be able to do a dump file and do a find-replace using your text editor to remove the slashes also. Probably something like find \\\' and replace with just \'. Someone else may know of a better solution if it wait a bit for some more responses.
-
Having magic quotes on doesn't affect the data returned from the database (unless magic_quotes_runtime is on which is uncommon), it only affects data posted to a script. Unless the database actually contains slashes in it's data (meaning they originally code it wrong) there shouldn't be any issue pulling the data out as an export then importing it to another DB. If it was done wrong originally and there are slashes in the data, then have a PHP script generate a .sql file and run the fields though stripslashes before sticking them into the output SQL.
-
Indeed, I tend to do something like this (jQuery): $(function(){ $('a.popup').click(function(e){ e.preventDefault(); window.open(this.href, 'popup'); return false; }); }); Then in the html code I just do : <a href="http://www.example.com/" class="popup">Example!</a> If JS is enabled, it will open a new window, if it's not it works as a normal link. You can also style it differently by just adding styles for the popup class if you want, such as an icon indicating an external link.
-
Questions: Sessions, information storing and security
kicken replied to Worqy's topic in PHP Coding Help
It needs to be saved somewhere. The same place as the username and password are stored is as good as anywhere else. The salt is not sensitive information, it's just there to make sure the password can't be found on a rainbow table and to make it so anyone trying to crack it would have to re-generate a table for every user (which is time consuming). That would be fine, you could just do a string of random letters to if you wanted. I generate a string of 22 random letters for my salt values using a simple little function: function GenerateNewSalt($len, $alphabet='abcdefghijklmnopqrstuvwxyz0123456789'){ $ret = ''; $alen = strlen($alphabet)-1; if ($alen > 0){ for ($x=0; $x<$len; $x++){ $ret .= $alphabet[mt_rand(0, $alen)]; } } return $ret; } -
Some google searches on that warning message suggest you may need to enable passive transfer mode using ftp_pasv. Do so just after you call ftp_login.
-
Why are you trying to change directories after you download the file? Perhaps you should be doing that before the ftp_get?
-
Websockets would be the best method, and you can get decent support by using a library such as Socket.IO. Otherwise you'll need to use either Long Polling, Short Polling or just page refreshing. None of them are that great when it comes to efficiency. Long Polling will tie up server threads/resources for each person connected while it waits for new data. Short polling won't tie up server threads, but creates a lot of traffic by constantly connecting, eating bandwidth and processing time. Page refreshing is basically like short polling but worse because you're regenerating the entire page rather than just passing message data. Long polling can be made more efficient if you write your own server to handle the connections rather than route them through something like Apache. Doing so properly can be a bit of a challenge though.
-
Try creating the local file first so you can tell if that is failing or something with the ftp. You can use ftp_fget to download to a file stream, eg: $lf = fopen($local_file, 'w'); if (!$lf){ die('Failed to create local file.'); } if (!ftp_fget($conn_id, $lf, $remote_file, FTP_ASCII)){ die('Failed to download file from FTP server.'); } fclose($lf);
-
There is still a potential for collision, albeit small. For example: rand(1,9) = 5 $primary_key = 17865 rand(0,9) = 6 = 17876 rand(1,9) = 5 $primary_key = 17867 rand(0,9) = 4 = 17876
-
$_POST['select'] or $_GET['select'], depending on what the method of your form is.
-
After reading the powershell help for a bit, this appears to work for me: system('powershell -Command "& {Get-WmiObject win32_service -ComputerName SERVER1} | Where { $_.StartMode -eq \'Auto\' }"');
-
My web crawler stope working when i close my browser?
kicken replied to aahaider's topic in PHP Coding Help
You should be running the script as a command-line script rather than via your browser. You'd SSH into the server and run the script there and put it into the background (or in a screen session).- 1 reply
-
- php
- web crawler
-
(and 1 more)
Tagged with:
-
Rather than rely on strtotime to figure out what you want, you could just figure it out explicitly: <?php $month = 5; $year = 2013; $lastDay = mktime(0, 0, 0, $month+1, 1, $year) - 86400; $wday = date('w', $lastDay); $targetDay = 1; $offset = $wday<$targetDay?abs(7-$targetDay+$wday):$wday-$targetDay; echo date('r', $lastDay-($offset*86400)); edit: more generic