Where to look in order to edit text on PHP website? - php

A friend of mine asked me to help him edit and add content to his PHP website. It was originally created by a professional company which has now became his opponent.
I thought it would be easy to edit some texts and adding content based on an original template. I downloaded all the files from a server, but couldn't find any files that contained the text I wanted to edit.
How could I use the text search keyword in all those files: PHP & JS without opening them one by one to find it as it seems to having too many files related with one simple website?
What is the best way to check whether or not I am in need of the original files in order to finish this project?

This doesn't sound like a programming question.
Searching the files largely depends on what operating system you're using and what tools you have available. There are many tools such as grep/awk on Unix/Linux systems, and file search tools on Windows and Mac.
The text you want to edit may be stored in a database. Often, PHP sites are part of a LAMP (Linux, Apache, MySQL, PHP) stack with MySQL being the database layer. If this is the case, you would need to get the information from the database, too.

This definitely not a programming question as calvinf said .... and there are tools you can use to search keywords in all the files of your project...
Try Zend Studio and after making a project in it search for your keywords in All Files option...
Another possibility you would not be able to find files is because the text might be saved in the db and extracted at the runtime...
so in my opinion if later is the case you would have to have a look at the templates stored in your db...
But i won't mind to have a go at Zend if i were you, anyways.

Related

File and Folder Attributes - Programming API

I knew that PHP is able to read file content by different ways, for example: fread, file_get_contents, file, readfile, etc.
Currently, I am looking for an API that can read real index of files and folders in specific partition or folder, for example:
drive d:\ in windows contains three folders (folder1, folder2, folder3), and each folder contains some files, we can get these directory structure using PHP (opendir, scandir, readdir, etc) and list them as I want, however, windows saved file and folder names inside hard-disk with their attributes (size, last modified, created on, etc).
How I can read hard-disc using PHP and retrieving all file and folder attributes for a specific path?
for instance, if we consider last modified time we can use (filemtime()) function, but this attribute not saved inside the file, its saved some where else inside hard-drive, other attributes also saved in other location not inside the file.
When windows user copying file from flash-drive to local hard, windows will copy all file and folder attributes and saves them inside local hard drive. When using PHP for copying file, it depends on OS to handle this job, its not native support (as I think) for file and folder operations.
Do you have any idea?
There are many recovery program that uses this technology for reading hard-drive indexes, however, for PHP: I cant find any source for this problem.
Applications if I get correct answer:
I can check if such file securely deleted from my hard-drive? I can create secure delete application using PHP, or clearing hard-drive indexes for a given file.
Your help appreciated.
Problems with the proposition
The attributes of files, such as timestamps, permission flags etc, are stored in the file system (FAT, NTFS, Ext3 etc). As you say some of them can be read using PHPs different file and directory methods, but they all act through the OS file system abstraction and cant have access to block level information on the disk, such as what precise byte on disk stores the archive flag for file X. The whole point of the OS and FS is to abstract away this information from the user/client programs.
As suggested there are external tools, written in c or similar, that does have this access and that you can call from inside PHP. If you want a 'native' PHP way of doing this you'll have to compile a c extension for PHP that exposes these low level functions to you.
I'd say external tools is the way to go if you want to stick with PHP but for the task at hand, as far as we can see from your description, I'd go with another language that has more low level access. Like C or C++. PHP is a high level language for HTML pre processing and as such is a poor choice for low level system programming.
Practical advice
After looking through the PHP documentation and assorted third party libraries:
An of the shelf solution for reading file system information on a file allocation table level doesn't exist for PHP. The lowest level you get is the fstat() function, and that is not very far for what you want.
External tools
No mater exactly what you want to do there is probably a small binary that does it. PHP can be integrated with these programs, as suggested elsewhere, via the exec() function. This is probably the easiest approach for you unless you have serious amounts of time and/or development resources to devote to this problem.
Wrapping a library
There are libraries that solves this problem for you, written in low level languages. An open source library can be wrapped with SWIG to expose it to PHP. This will give you access to the low level methods you need, but it's a non trivial task. These kind of libraries also often require sole access to the device while they work on it, something that is difficult to achieve in most normal operating environments.
Note also that you will probably need a library per file system. Microsofts VFAT extension to FAT12/16/32 requiers a licens to use. So if you want to work with FAT and have files with long names (not 8.3 format) you'll have to fork up some dough to be legit.
Low level implementation
A last middle ground would be to write your own CLI tool that uses an external library to access the low level FS functions. You can then use exec() from inside PHP to interact with your own implementation.
This might be a reasonable path if you cant find an existing tool that solves your problem and you are not willing to spend the time to wrap a library.
In closing
You give a very narrow problem description with little to go on as for what the application is about. A broader discussion (in another forum) might yield better results since the problem might be better solved in another way entirely.
I found something on PHP.net which appears to do what you want:
http://php.net/manual/en/function.readdir.php#103418
Edit: I mis-understood the question. Attributes such as the last modified time, last accessed date and the like are stored in the file systems master file table. As far as I can tell, this isn't accessible with PHP, and if you were to write your own method to do this then you'd also have to account for different file systems as they all handle the storage of these attributes in their own unique way.
It could be that to get all of the information you're looking for is not possible with PHP without writing some form of extension to PHP itself.
Edit 2: Upon researching a little more...
http://php.net/manual/en/function.fileinode.php
This function could be an interesting one to look at.
Well if I understand correctly you just want to securely delete a file. You can just call [shred][1]
[1]: http://linux.die.net/man/1/shred via system or exec if you are on linux and you are good to go

PHP un-editable pdf/file export option

I am developing an application in the Kohana PHP framework that assesses performance. The end result of the process is a webpage listing the overall scoring and a color coded list of divs and results.
The original idea was to have the option to save this as a non-editable PDF file and email the user. After further research I have found this to be non as straight forward as I hoped.
The best solution seemed to be installing the unix application wkhtmltopdf but as the destination is shared hosting I am unable to install this on the server.
My question is, what's the best option to save a non editable review of the assessment to the user?
Thank you for help with this.
I guess the only way to generate a snapshot, or review how you call it, is by storing it on the server side and only grant access via a read only protocol. So basically by offering it as a 'web page'.
Still everyone can save and modify the markup. But that is the case for every file you generate, regardless of the type of file. Ok, maybe except DRM infected files. But you don't want to do that, trust me.
Oh, and you could also print the files. Printouts are pretty hard to be edited. Though even that is not impossible...
I found a PHP version that is pre-built as a Kohana Module - github.com/ryross/pdfview

Cross Browser Cross OS File Dialog (with ability to select directory only as well as files) Non Java

So I am looking for a method of opening a browsers file dialog, and allowing users to either select a directory and have it populate the path, or select a file or set of (within the same directory). The isn't a Java Applet. Is there a means of this type of dialog? That can support IE 7 and up? Or am I stuck with a Java solution?
We currently have a Java Based solution that was written by someone years ago, which is starting to fail more and more due to new versions of Java coming out, due to OS's getting more tighter on security, and so on and so forth. So I am trying to find alternative solutions that will hopefully be a bit more easy to maintain, that don't require (preferably) java to do it.
I am ultimately just stuck with where to look to even begin to start finding any of the right methods to do this if its possible in the first place. Seems every search I do, just brings me in circles with answers that dont apply
EDIT
I should put emphasis, that the only goal of this dialog is so I can get a directory and or file path from the user on their local machine, without having the user key in the full path themselves.
As far as my knowledge go, it's only Java or possibly some AIR+Flash hybrid in this case, really. Reason for this being that you will need some technology to:
recognize your selection as file or directory
read all files and possibly sub-folders from the selected directory
queue them for upload and then be possibly able to recover their structure on the server-side
Therefore you at least need something that can natively work with file structure of the client, as well as optionally something that will re-create the same structure on your server.
EDIT: you may also want to check this: Upload a folder in ASP.NET of Flash or Silverlight

Tools to understand website source code

I recently had a website developed by an external source. They gave me the source code as well as sql files.
When I extract the source code I see folders like Smarty, fckeditor and many php files. I want to start editing these as I find it to be the best way to learn. What tool should I use. I tried using trial version of PHPdesigner, but it just doesnt open my php files.
Is there any tool that can take all these files in the form of a project and simultaneously show me a visual display of any changes that I make.
I suppose it is very clear that I am new to this. Any help will be greatly appreciated.
Just use simple text editor with some code highlight like Notepad++
It is free to use, very fast and it does what you need.
First of all try to know what are the different file types and which lanuguage are those targeted to. Once you know that you can then decide on the editor.
What i recommend is you try to find out if they used a framework for the website, something like CakePHP or CodeIgniter. The next step after you find out is to go the framework website and start reading the documentation.
If the site id developed in php most likely any type of WYSIWYG editing is going to inaccurate. This is because a number of different files need to be processed and combined by the php interpreter before they come together to make any given page or view. Thus the only way to really preview is to run it on a server. Since you say there are sql files he has laso used a DB to store something so most likely any changes you would need to make are going to be spread between both the php source files and the records in the db.
Aptana (Which is Eclipse based) is great at handling many different file type in one IDE. I would use Studio 2 w/ the plugins you need or if you feel cutting edge try Studio 3. It's cross platform so Linux/Windows or OSX.

php editor source question

Is there a php editor on the market witch can read sources straight from a mysql database?
No....and maybe.
There is no reason why anyone should write a MySQL based editor.
Your best chance to archive this is to find a greedy and/or lunatic programmer that will write you a MySQL-virtual drive.
Yes this IS possible, and at least on windows it does not take much skills.
Well, you could use one of the existing php online editors, and hack the Horde VFS backend in, allowing you to read local files or a database file storage. Another alternative was writing your own FUSE driver. Most sensible however would be to make your database contents available over WebDAV, allowing you to use Eclipse or so

Categories