nukeSEO.com - PHPNuke SEO Search engine optimization, professional tools including nukeSEO, nukeSPAM, nukeFEED, nukePIE, nukeWYSIWYG and more

 

. Welcome to nukeSEO.com  ! 
.
.
.

Tag This



.
nukeSEO.com: Forums


 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Write to file
 
 
Post new topic   Reply to topic    nukeSEO.com Forum Index -> General / Other Stuff
View previous topic :: View next topic  
Author Message
Guardian
webmaster


Joined: Dec 25, 2005
Posts: 364
Location: Vsetin, Czech Republic

PostPosted: Tue Feb 28, 2006 6:14 pm    Post subject: Write to file Reply with quote

Well it did say 'other stuff" lol
How would one grab data from a DB, lets call it
nuke_spamlist which contains to fileds
`domain` varchar(200) NOT NULL default '',
`added` date NOT NULL default '0000-00-00'

I need to grab the data from 'domain' and write it to a file using <-|-> as a delimiter
e.g. mydomain.com<-|->yourdomain.com<-|->
There is no http or ww to parse out and they | character is a 'pipe'
  
Back to top
View user's profile Send private message
montego
webmaster


Joined: Dec 26, 2005
Posts: 254

PostPosted: Thu Mar 02, 2006 7:27 am    Post subject: Re: Write to file Reply with quote

I'll take on that "challenge"... give me a few minutes or a day. Wink
  
Back to top
View user's profile Send private message Visit poster's website
montego
PostPosted: Thu Mar 02, 2006 7:41 am    Post subject: Re: Write to file Reply with quote

Ok, here is one possible "skeleton":

Code:
//NOTES: This has no "bufferring" for writing and can be done several different ways.

//I am simply choosing the simplest that I could think of to make this example
//quick to devise.  Also, I have included NO ERROR CHECKING!!!

$sContent = "";
$sDelim = "|";
$sMyDomain = "www.yourdomain.com";

//Issue the query

$sql = "SELECT `domain` FROM `".$prefix."_spamlist`";
$result = $db->sql_query( $sql );

//I have not included any error checking - cycle through the results to build the file contents

while ( $row = $db->sql_fetchrow( $result ) ) {
   $sDomain = stripslashes( $row['domain'] );
   $sContent .= $sMyDomain . $sDelim . $sDomain . "\n";
}

//Write out the content to the file - remember that you must have proper permissions to write
//Give <<path>> and <<filename>> appropriate values - actually, just make sure the whole thing
//goes to the file you want and in the directory that you want.  However, the directory itself
//might have to be 777.

$sFile = "./modules/$msnl_sModuleNm/<<path>>/<<filename>>";
@touch( $sFile );
@chmod( $sFile, 0766 );
$hFile = @fopen( $sFile, "w" );
@fwrite( $hFile, $sContent );
@fclose( $hFile );

//And, there ya' go!!
//Note, you can also chmod it back to something a little less "open" if you feel like.


Edited by montego: sorry, forgot the end-of-line character on the *$sContent .=* line.
  
Back to top
Guardian
PostPosted: Thu Mar 02, 2006 1:28 pm    Post subject: Re: Write to file Reply with quote

Wo, I never actually expected anyone to reply let alone offer an potential solution - thank you very much!!
I just about have my module ready for release so this will help in its maintenance (your code or a derivative will not be released as its just for my own version of the module as I need it to maintain the content of a file which will, be public.
I bet your intrgued now Wink
  
Back to top
montego
PostPosted: Thu Mar 02, 2006 1:49 pm    Post subject: Re: Write to file Reply with quote

Quote:
I bet your intrgued now


Always! Laughing Laughing Laughing Laughing Wink Exclamation Exclamation
  
Back to top
Display posts from previous:       
Post new topic   Reply to topic    nukeSEO.com Forum Index -> General / Other Stuff All times are GMT - 5 Hours
 
 Page 1 of 1

 

Jump to:   
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001-2008 phpBB Group


Page Generation: 0.05 Seconds