|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
I'm Lenny2 Bitch
Join Date: Mar 2001
Location: On top of my soapbox
Posts: 13,449
|
I replaced link codes on literally thousands of pages and I want to upload them to my server and overwrite the old ones.
The problem is they are in folders that also have alot of images and videos and the program I'm currently using only allows me to either overwrite all or skip all. I need one that will allow me to set the parameters to overwrite html files and skip all the others.
__________________
sig too big |
|
|
|
|
|
#2 |
|
Confirmed User
Join Date: Jun 2007
Posts: 262
|
winscp it will let you use wildcards and such to exclude certain file types.
|
|
|
|
|
|
#3 |
|
►SouthOfHeaven
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
|
i have a php script that will do that..
i'll take a look and see if i can find it.. you gotta be very carefull though it can really mess things up if you are not carefull
__________________
hatisblack at yahoo.com |
|
|
|
|
|
#4 |
|
►SouthOfHeaven
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
|
gfy usually fucks up the code but here goes..
p.s. before using this , test it out on a test folder to get used to how it works first . save the following as doit.php make changes as needed Code:
<?php
require_once('fandr.php');
//folder to search and all subdirs
$path = "folder";
// logfile
$logFile = "/result.txt";
// find this
$find = "test";
//replace with this
$replace = "nast2code";
$obj = new TextSearch();
// extensions to search
$obj->setExtensions(array('html','txt'));
$obj->addExtension('htm');
$obj->setSearchKey("$find");
$obj->setReplacementKey("$replace");
$obj->startSearching($path);
$obj->showLog();
$obj->writeLogToFile($logFile);
?>
no editing needed Code:
<?php
class TextSearch
{
var $extensions = array();
var $searchKey = '';
var $replacementKey = '';
var $caseSensitive = 0;
var $findAllExts = 1;
var $isReplacingEnabled = 0;
var $logString = '';
var $errorText = '';
var $totalFound = 0; //total matches
function setExtensions($extensions = array())
{
$this->extensions = $extensions;
if(sizeof($this->extensions))
{
$this->findAllExts = 0; //not all extensions
}
}//End of Method
function addExtension($extension)
{
array_push($this->extensions, $extension);
$this->findAllExts = 0; //not all extensions
}//End of function
function setSearchKey($searchKey, $caseSensitive = 0)
{
$this->searchKey = $searchKey;
if($caseSensitivity)
{
$this->caseSensitive = 1;
}
}//End of function
function setReplacementKey($replacementKey)
{
$this->replacementKey = $replacementKey;
$this->isReplacingEnabled = 1;
}//End of function
function startSearching($path)
{
$this->findDirFiles($path);
}//EO Method
function findDirFiles($path)
{
$dir = opendir ($path);
while ($file = readdir ($dir))
{
if (($file == ".") or ($file == ".."))
{
continue;
}
if (filetype ("$path/$file") == "dir")
{
$this->findDirFiles("$path/$file"); //recursive traversing here
}
elseif($this->matchedExtension($file)) //checks extension if we need to search this file
{
if(filesize("$path/$file"))
{
$this->searchFileData("$path/$file"); //search file data
}
}
} //End of while
closedir($dir);
}//EO Method
function findExtension($file)
{
return array_pop(explode(".",$file));
}//End of function
function matchedExtension($file)
{
if($this->findAllExts) //checks if all extensions are to be searched
{
return true;
}
elseif(sizeof(array_keys($this->extensions, $this->findExtension($file)))==1)
{
return true;
}
return false;
}//EO Method
function searchFileData($file)
{
$searchKey = preg_quote($this->searchKey);
if($this->caseSensitive)
{
$pattern = "/$searchKey/U";
}
else
{
$pattern = "/$searchKey/Ui";
}
$subject = file_get_contents($file);
$found = 0;
$found = preg_match_all($pattern, $subject, $matches, PREG_PATTERN_ORDER);
$this->totalFound +=$found;
if($found)
{
$foundStr = "Found in $found places";
$this->appendToLog($file, $foundStr);
}
if($this->isReplacingEnabled && $this->replacementKey && $found)
{
// $this->replacementKey = "$replace";
$outputStr = preg_replace($pattern, $this->replacementKey, $subject);
$foundStr = "Found in $found places";
$this->writeToFile($file, $outputStr);
$this->appendToLog($file, $foundStr, $this->replacementKey);
}
elseif($this->isReplacingEnabled && $this->replacementKey == '')
{
$this->errorText .= "Replacement Text is not defined\n";
$this->appendToLog($file, "Replacement Text is not defined", $this->replacementKey);
}
elseif(!found)
{
$this->appendToLog($file, "No matching Found", $this->replacementKey);
}
}//EO Method
function writeToFile($file, $data)
{
if(is_writable($file))
{
$fp = fopen($file, "w");
fwrite($fp, $data);
fclose($fp);
}
else
{
$this->errorText .= "Can not replace text. File $file is not writable. \nPlease make it writable\n";
}
}//EO Method
function appendToLog($file, $matchStr, $replacementKey = null)
{
if($this->logString == '')
{
$this->logString = " --- Searching for '".$this->searchKey."' --- \n";
}
if($replacementKey == null)
{
$this->logString .= "Searching File $file : " . $matchStr."\n";
}
else
{
$this->logString .= "Searching File $file : " . $matchStr.". Replaced by '$replacementKey'\n";
}
}//EO Method
function showLog()
{
$this->dBug("------ Total ".$this->totalFound." Matches Found -----");
$this->dBug(nl2br($this->logString));
if($this->errorText!='')
{
$this->dBug("------Error-----");
$this->dBug(nl2br($this->errorText));
}
}//EO Method
function writeLogToFile($file)
{
$fp = fopen($file, "wb") OR die("Can not open file <b>$file</b>");
fwrite($fp, $this->logString);
fwrite($fp, "\n------ Total ".$this->totalFound." Matches Found -----\n");
if($this->errorText!='')
{
fwrite($fp, "\n------Error-----\n");
fwrite($fp, $this->errorText);
}
fclose($fp);
}//EO Method
function dBug($dump)
{
echo "<pre>";
print_r($dump);
echo "</pre>";
}//EO Method
} //End of class
?>
this will search all files of the extension you specify in doit.php and find and replace text.. some things to be carefull of.. if you have lots of files make sure your php doesnt cutoff scripts at 30 seconds ( default ) this will replace everything in the dir you specify AND all subdirectories if you have a question , ask first
__________________
hatisblack at yahoo.com |
|
|
|
|
|
#5 | |
|
I'm Lenny2 Bitch
Join Date: Mar 2001
Location: On top of my soapbox
Posts: 13,449
|
Quote:
__________________
sig too big |
|
|
|
|
|
|
#6 |
|
Confirmed User
Join Date: Mar 2004
Posts: 147
|
If it's just one big folder, why can't you just view all files, sort by extension, then shift-select all the .html files (since they'll be grouped) and click the upload button.
__________________
Vidlock DRM Service - Add DRM to your website today http://www.vidlock.com Coming Soon - Vidpass |
|
|
|
|
|
#7 | |
|
I'm Lenny2 Bitch
Join Date: Mar 2001
Location: On top of my soapbox
Posts: 13,449
|
Quote:
Everything is in a subfolder. I structured things that way to keep them organized....go figure
__________________
sig too big |
|
|
|
|