Hi!
I need a simple PHP string replacement script, that would do the following:
------------
Log in (password protection).
Connect to DB
Show a list of domains (Domain field in new_ss_sites table), where the field "Status" NOT "Ready".
Under the list of domains display a "Build" button.
When the user presses the "Build" button, the string replacement script does the following:
For each record in new_ss_sites table where "Status" NOT "Ready", repeat:
----------------------------------------------------------------------------------------------------------------------
If the field Template in new_ss_sites table NOT NULL,
- Fill variable "TemplateName" with it's value.
- Fill variable "Folder" with value of field "FolderToCopy" ( TemplatesList table) where field TemplateName=TemplateName
If the field Template in new_ss_sites table is NULL,
- pick up a random record from table called TemplatesList
- fill variable "TemplateName" with value of field TemplateName ( in selected record of TemplateList table).
- fill variable "Folder" with value of field FolderToCopy ( in selected record of TemplateList table).
Copy the contents of folder "Folder" (it's in format of complete URL) to folder "/InWork/" (located right below the current script folder).
Rename the newly copied folder to value from variable "Domain".
Open all ASCII files in the renamed folder (and it's sub-folders)
For each record in table called like the contents of variable TemplateName, do the following:
---
- Search all open files for string(s) equal to value of OriginalText field.
- In case NewText NOT NULL - replace the found string(s) (OriginalText) with content of text file.
- In case NewTextFromFile NOT NULL - open that file, copy it's contents and replace the found string(s) with content of that text file.
- In case NewTextFromDBfield & NewTextFromDBtable NOT NULL - replace the found string(s) with content of appropriate -current- DB field.
- In case NewStringFromFunction NOT NULL - execute the function, and replace the found (OriginalText) string(s) with it's output.
---
(ATTENTION: both new and original strings may include several lines, with line breaks.)
When all original strings are replaced, save changes that were made to ASCII files.
Cut and paste the folder with all of it's content to folder "/Ready/" (located right below the current script folder).
Mark the field "Status" in current record if new_ss_sites table to "Ready".
Move to next record in new_ss_sites. Repeat all above steps until all records are marked "Ready".
When all records in new_ss_sites are marked "Ready", send an email to ADMIN, with following contents:
New sites ready to be uploaded:
[login to view URL] Site category: Category field from TempSitesTable
.......
(a list of all domains that were "processed" this time)
Thanks!