- Hounddog / phpcs
- Check if remote file has changed
- Check if remote file has changed
- How to find latest last modified directory on ftp
- Last modification date of a webpage using php [duplicate]
- File_get_contents not working for remote files
- Saved searches
- Use saved searches to filter your results more quickly
- thecodeholic/php-file-watcher
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- License
- szyryanov/files-warden
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
Hounddog / phpcs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
#! /bin/bash |
# Go to root of the repository |
echo ‘ Checking PHPCS ‘ ; |
width= $( tput cols ) ; |
if [ ` git rev-parse —verify HEAD ` ] ; then |
against= ‘ HEAD ‘ |
else |
against= ‘ 4b825dc642cb6eb9a060e54bf8d69288fbee4904 ‘ |
fi |
commitFiles= ` git diff-index —cached —name-only $against ` |
args= » -s —report-width= $width —standard=PSR « |
phpFiles= » » ; |
phpFilesCount=0 ; |
for f in $commitFiles ; do |
if [[ ! -e $f ]] ; then |
continue ; |
fi |
if [[ $f =~ \. (php | ctp)$ ]] ; then |
phpFilesCount= $phpFilesCount +1 |
phpFiles= » $phpFiles $f « |
fi |
done ; |
if [[ $phpFilesCount = 0 ]] ; then |
exit 0 ; |
fi |
if [[ $phpFilesCount > 2 ]] ; then |
args= » $args —report=summary « |
fi |
vendor/bin/phpcs $args $phpFiles —ignore= * /data/Doctrine/Migration/ * , * /application/proxies/ * , * /script/hooks/ * |
Check if remote file has changed
I’m using PHP cURL module to extract timestamp of a remote file via HTTP headers. Currently i am getting last modified file.
Check if remote file has changed
I’m using PHP cURL module to extract timestamp of a remote file via HTTP headers. I’ve managed to grab modification timestamp by using CURLOPT_FILETIME constant. Of course, I’m doing this in order too see if the remote file has changed without downloading it’s contents.
$ch = curl_init($url); /* create URL handler */ curl_setopt($ch, CURLOPT_NOBODY, TRUE); /* don't retrieve body contents */ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); /* follow redirects */ curl_setopt($ch, CURLOPT_HEADER, FALSE); /* retrieve last modification time */ curl_setopt($ch, CURLOPT_FILETIME, TRUE); /* get timestamp */ $res = curl_exec($ch); $timestamp = curl_getinfo($ch, CURLINFO_FILETIME); curl_close($ch);
What is, in your opinion the best way to check if remote file has changed? Should I go with timestamp check only? Or are there some other clever options that didn’t came to my mind?!
Your approach looks good for finding the Last-Modified time value. (Need to watch out for -1 return for CURLINFO_FILETIME, meaning that no Last-Modified header value was identified.)
You could save the time returned, and in future checks see if it has changed. If it’s changed, fetch the new file via Curl.
Another option would be to save ETag and Last-Modified headers, then use a conditional request to get the image again. This would be more complex, but you’d save the additional HEAD request each time. You can see some of the details in this SO question: if-modified-since vs if-none-match.
Php — file_get_contents not working for remote files, Stack Overflow Public questions & answers Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers Talent Build your employer brand Advertising Reach developers & technologists worldwide
How to find latest last modified directory on ftp
I am developing an application in php. There is lots of file handling. I want to last modified folder on ftp. Currently i am getting last modified file. But i want that file with last modified folder also.
$ftp_server='xxxxxxx'; $ftp_user_name='xxxxxxxx'; $ftp_user_pass='xxxxxxxx'; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if ((!$conn_id) || (!$login_result)) < echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; >else <> $folder= ftp_pwd ( $conn_id ); ftp_pasv($conn_id, true); $get_folder_namesss = ftp_nlist($conn_id, '.'); $folder_name = array() ; $local_file=''; $folder = '/abc/def/ghi/2014/02/'; $handle=''; $time=''; $handle1=''; $files = ftp_nlist($conn_id, $folder); if (!count($files)) < echo "folder is empty"; return false; >$mostRecent = array ( 'time' => 0, 'file' => null ); foreach ($files as $file) < if (!preg_match('~\w+.xls$~ism', $file)) continue; $time = ftp_mdtm($conn_id, $file); echo "$file was last modified on : " . date("F d Y H:i:s.", $time); if ($time >$mostRecent['time']) < $mostRecent['time'] = $time; $mostRecent['file'] = $file; >> $local_file = '../ftp/'.basename($mostRecent['file']); if (file_exists($local_file)) <> else < $handle = fopen($local_file, 'w'); if (ftp_fget($conn_id, $handle, $mostRecent['file'], FTP_ASCII, 0)) <>else < return "There was a problem while downloading ".$mostRecent['file']." to $local_file\n"; >fclose($handle); $handle1 = fopen($local_file,"r"); $t=1; $vales = array(); while (($data = fgetcsv($handle1, 1000, ",")) !== FALSE) < $num = count($data); for ($c=0; $c < $num; $c++) < $vales[$t]=$data[$c] ; $t++; >> fclose($handle1); >
$folder = ‘/abc/def/ghi/2014/02/’; is my folder path. The last two folder is year and month. There is many folder like 2011,2012,2013,2014 which is sorted by year wise. I want to find latest folder and it is 2014. Please suggest. Thanks.
You can get the folder created time with use of stat function.
$folder = stat('/abc/def/ghi/2014/02/'); echo 'Modification time: ' . $folder['mtime']; // will show unix time stamp.
Please try anything you can able to do with this
Php — Get the last modified date of a remote file, I would like to get the last modified date of a remote file by means of curl. Does anyone know how to do that?
Last modification date of a webpage using php [duplicate]
I want to get last modification date of different webpage using php for example last modification date of google , yahoo , or a weblog or .
echo "document.write('".date( "F d, Y. H:i:s a", filemtime($filename)));
but it works only for files not webpages ! and for web pages it returns something like this:
document.write('January 01, 1970. 01:00:00 am');
The manual for filemtime states:
As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to Supported Protocols and Wrappers to determine which wrappers support stat() family of functionality.
It also states for the http:// wrapper that it does not support stat().
So you can’t use filemtime to get what you want. However, sites may expose their last modified time in the Last-Modified HTTP response header. For this, you could use the built-in get_headers :
$headers = get_headers('http://www.mst.edu/'); var_dump($headers['Last-Modified']);
Or you could use cURL, as in this answer.
Php — Get the last modified dir, A little stuck on this and hoping for some help. I’m trying to get the last modified dir from a path in a string. I know there is …
File_get_contents not working for remote files
file_get_contents not working in hostgator but working fine in localhost
$query = file_get_contents('http://xxxxxxxxxxxx/test.php'); print_r($query); echo $query;
i need to get data from above url .
The problem is that some hosts disable allow_url_fopen in the php.ini file. Maybe hostgator disabled it. Read more here.
You can use cURL for this problem.
Getting modified time of a remote file in PHP, adb install: downloaded apkm file from ApkMirror.com doesn’t end with .apk Most practical method for a secret demographic to get its news? more hot questions
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Watch file or folder and execute code when something is changes inside
thecodeholic/php-file-watcher
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Watch file or folder and execute code when something is changed inside
You can run the following command to see how the script works
php index.php FILE_OR_FOLDER_PATH
$watcher = new \tc\fswatcher\Watcher('FILE_OR_FOLDER_PATH_TO_WATCH', function ($event) < // Do whatever you want when file or folder is changed. if ($event->isAddition())< // File was added and file path will be $event->file > else if ($event->isModification())< // File was modified and file path will be $event->file > >); $watcher->watch();
$watcher = new \tc\fswatcher\Watcher('FILE_OR_FOLDER_PATH_TO_WATCH', 'callback', [ 'watchInterval' => 5, 'cacheChanges' => true ]);
Option | Default value | Description |
---|---|---|
watchInterval | 1 | How often the file changes should be checked |
cacheChanges | true | Gather file modifications in single check and trigger event once |
About
Watch file or folder and execute code when something is changes inside
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A simple but useful PHP tool to check changed files on a website.
License
szyryanov/files-warden
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
A simple but useful PHP tool to check changed files on a website.
Changes can be done by you as a website author. and by a malicious software like viruses. Using this tool, you can detect that your website is infected, even if it continues to look good.
The tool saves a current state (directories and files list with date/time and size information) into a json file. Then, after some time, you run the tool again, and it compares the saved state and present one. The following changes can are detected:
- directory added
- directory deleted
- file added
- file edited (data/time or size changed)
- file deleted
- directory converted to file (with the same name)
- file converted to directory
You can exclude some directories and/or files from the scan if they change during normal website work (e.g. log files, data files etc.).
Most likely, any modern Linux hosting with PHP will be suitable. Tested on Apache 2.4 and PHP 5.5 environment.
- Download the sources.
- Edit index.php: add some authentication code at the beginning. Look at your CMS or website admin part sources for the guide. For example, for some websites it can be something like following:
session_start(); if(!isset($_SESSION['user_name']))
Check changes from time to time. Accept your own changes (e.g. when you add or edit site content, install CMS plugins, and so on). If you see unexpected changes — be afraid, and investigate the source of the changes.
- Initial path for scanning. The path is new FilesWarden() constructor parameter. By default it’s set one level up from the tool script (i.e. «..» ). If you change the initial path after state saving, then you will see changes like old path was deleted, and new one was added.
- Excluded files and directories. Call $filesWarden->AddExclusion() to exclude some path from scanning. The excluding path is relative to the initial path. By default index.php calls $filesWarden->AddExclusion(‘files-warden/data’); to exclude own data because they change every time you do scan. You can add additional exclusions. For the AddExclusion() parameter you can copy/paste path from change details popup title:
About
A simple but useful PHP tool to check changed files on a website.