DEDE 4.0 automatically collects source files
Put it in the website and Directory
Create a ***. cmd file in WINDOWS.
D: \ php-cgi E: \ wwwroot \ ** \ cj. php
Make another scheduled task (D: \ php-cgi E: \ wwwroot \ ** \ cj. php knows what it is)
In LINUX, the time-based task may not be the same if you run cj. php and you can reply to it.
Cj. php source file
Copy codeThe Code is as follows: <? Php
// Change the path to another directory
Require_once (dirname (_ FILE _). "/include/config_base.php ");
Require_once (dirname (_ FILE _). "/include/pub_collection.php ");
Require_once (dirname (_ FILE _). "/include/pub_datalist.php ");
Require_once (dirname (_ FILE _). "/include/inc_functions.php ");
Require_once (dirname (_ FILE _). "/include/pub_dedetag.php ");
Require_once (dirname (_ FILE _). "/include/inc_archives_view.php ");
Require_once (dirname (_ FILE _). "/include/inc_arclist_view.php ");
// Add a data collection topic name, collection topic ID, and foreground topic name. You can enter a few fields for the foreground topic ID.
$ Makearr = array ();
Array_push ($ makearr, array ('Collect 1 ', 1, 'classify 1', 25 ));
Array_push ($ makearr, array ('collection 2', 2, 'classification 2', 26 ));
// Other parameters
$ Makehtml = 1; // generate an article
$ Threadnum = 5; // Interval
$ Pagesize = 5; // set the thread
$ Islisten = 0; // additional options do not download the URL that has been downloaded-> 0; only download the content that has not been downloaded->-1; download all content again-> 1
$ Sptime = 0; // The Anti-Refresh site must be set to x seconds.
$ Channelid = 1; // imported article Model
$ Web = "www-data"; // web user
$ Webgroup = "www-data"; // web user group
$ Onlytitle = 1 ;//
While (sizeof ($ makearr)> 0 ){
$ Nid = $ makearr [0] [1]; // collection topic ID
$ Typeid = $ makearr [0] [3]; // foreground topic ID
Array_shift ($ makearr );
// Collect
// Set the multithreading mode for the first time
$ Co = new DedeCollection ();
$ Co-> Init ();
$ Co-> LoadFromDB ($ nid );
$ Co-> GetSourceUrl ();
$ Co-> dsql-> SetQuery ("Update #@__ conote set lasttime = '". mytime (). "'where nid = $ nid ");
$ Co-> dsql-> ExecuteNoneQuery ();
$ Co-> dsql-> SetQuery ("Select aid, url From #@__ courl where nid = $ nid ");
$ Co-> dsql-> Execute (99 );
While ($ row = $ co-> dsql-> GetObject (99 ))
{
$ Lrow = $ co-> dsql-> GetOne ("Select * From # @__ co_listenurl where url like
'". Addslashes ($ row-> url )."'");
If (is_array ($ lrow )){
If ($ islisten = 0) continue;
}
Else {
Echo $ inquery = "insert into #@__ co_listenurl (nid, url) VALUES ('$ nid ',
'". Addslashes ($ row-> url )."');";
$ Co-> dsql-> ExecuteNoneQuery ($ inquery );
}
$ Co-> DownUrl ($ row-> aid, $ row-> url );
If ($ sptime> 0) sleep ($ sptime );
}
$ Co-> Close ();
// Import to the current database and generate html
$ Dsql = new DedeSql (false );
$ Maxidrow = $ dsql-> GetOne ("Select max (ID) as maxid From #@__ archives where typeid = $ typeid
;");
$ Maxart_id = $ maxidrow ['maxid'];
$ Mrow = $ dsql-> GetOne ("Select count (*) as dd From # courl where nid = '$ nid '");
$ Totalcc = $ mrow ['dd']; //
$ Rrow = $ dsql-> GetOne ("Select typeid From #@__ conote where nid = '$ nid '");
$ Ruleid = $ rrow ['typeid'];
$ Rrow = $ dsql-> GetOne ("Select channelid From #@__ co_exrule where aid = '$ ruleid '");
$ Channelid = $ rrow ['channelid'];
If (! Isset ($ channelid) $ channelid = 0;
If (! Isset ($ typeid) $ typeid = 0;
If (! Isset ($ makehtml) $ makehtml = 0;
If (! Isset ($ onlytitle) $ onlytitle = 1;
$ Dsql = new DedeSql (false );
$ Row = $ dsql-> GetOne ("Select * From #@__ co_exrule where aid = '$ ruleid '");
If (! Is_array ($ row )){
Echo "the import rule cannot be found and the operation cannot be completed! ";
$ Dsql-> Close ();
Continue;
}
// Analyze rules and generate temporary SQL statements
$ Dtp = new DedeTagParse ();
$ Dtp-> LoadString ($ row ['rule']);
$ Noteinfo = $ dtp-> GetTagByName ('note ');
$ Tablenames = explode (",", $ noteinfo-> GetAtt ('tablename '));
$ Autofield = $ noteinfo-> GetAtt ('autofield ');
$ Synfield = $ noteinfo-> GetAtt ('synfield ');
$ Tablename1 = $ tablenames [0];
$ Tb1SqlKey = "Insert Into $ tablename1 (";
$ Tb1SqlValue = "Values (";
If (count ($ tablenames)> = 2 ){
$ Tablename2 = $ tablenames [1];
$ Tb2SqlKey = "Insert Into $ tablename2 (";
$ Tb2SqlValue = "Values (";
If ($ synfield! = ''){
$ Tb2SqlKey. = $ synfield;
$ Tb2SqlValue. = "'@ $ synfield @'";
}
}
Else {
$ Tablename2 = "";
$ Tb2SqlKey = "";
$ Tb2SqlValue = "";
}
$ ExKeys = Array ();
Foreach ($ dtp-> CTags as $ tagid => $ ctag)
{
If ($ ctag-> GetName () = 'field ')
{
$ Fieldname = $ ctag-> GetAtt ('name ');
$ Tbname = $ ctag-> GetAtt ('intable ');
If ($ tbname = $ tablename1 ){
$ Tb1SqlKey. = ", $ fieldname ";
If ($ ctag-> GetAtt ('source ')! = 'Value '){
$ Tb1SqlValue. = ", '@ # {$ tbname}. {$ fieldname }#@'";
} Else {
$ Nvalue = str_replace ('{tid}', $ typeid, $ ctag-> GetInnerText
());
$ Nvalue = str_replace ('{cid}', $ channelid, $ nvalue );
$ Nvalue = str_replace ('{rank}', 0, $ nvalue );
$ Nvalue = str_replace ('{admin}', "1", $ nvalue );
$ Tb1SqlValue. = ", '$ nvalue '";
}
}
Else if ($ tbname ==$ tablename2 ){
$ Tb2SqlKey. = ", $ fieldname ";
If ($ ctag-> GetAtt ('source ')! = 'Value '){
$ Tb2SqlValue. = ", '@ # {$ tbname}. {$ fieldname }#@'";
} Else {
$ Nvalue = str_replace ('{tid}', $ typeid, $ ctag-> GetInnerText
());
$ Nvalue = str_replace ('{cid}', $ channelid, $ nvalue );
$ Nvalue = str_replace ('{rank}', 0, $ nvalue );
$ Tb2SqlValue. = ", '$ nvalue '";
}
}
}
}
$ Tb1SqlKey = str_replace ('(,', '(', $ tb1SqlKey ).")";
$ Tb1SqlValue = str_replace ('(,', '(', $ tb1SqlValue ).");";
$ Tb1Sql = $ tb1SqlKey. $ tb1SqlValue;
If ($ tablename2! = "")
{
$ Tb2SqlKey = str_replace ("(,", "(", $ tb2SqlKey ).")";
$ Tb2SqlValue = str_replace ("(,", "(", $ tb2SqlValue ).");";
$ Tb2Sql = $ tb2SqlKey. $ tb2SqlValue;
}
// SQL operation for data export
$ Dsql-> SetQuery ("Select * From # @__ courl where nid = '$ nid' order by aid asc ");
$ Dsql-> Execute ();
While ($ row = $ dsql-> GetObject ())
{
$ TmpSql1 = $ tb1Sql;
$ TmpSql2 = $ tb2Sql;
$ Dtp-> LoadString ($ row-> result );
$ Aid = $ row-> aid;
If (! Is_array ($ dtp-> CTags) {continue ;}
If ($ onlytitle ){
$ Titletag = '';
Foreach ($ dtp-> CTags as $ ctag ){
$ Tvalue = $ ctag-> GetAtt ("name ");
If ($ tvalue = '#@__ archives. title' | $ tvalue =
$ Pai_dbprefix. 'archives. title '){
$ Titletag = $ ctag;
Break;
}
}
If (is_object ($ titletag )){
$ Title = trim (addslashes ($ titletag-> GetInnerText ()));
$ Testrow = $ dsql-> GetOne ("Select count (ID) as dd From #@__ archives
Where title like '% $ title % '");
If ($ testrow ['dd']> 0 ){
Echo "the database already has a document titled {$ title}, Which is blocked by the program
Import Data <br/> ";
Continue;
}
}
}
Foreach ($ dtp-> CTags as $ ctag)
{
If ($ ctag-> GetName ()! = "Field") continue;
$ Tvalue = $ ctag-> GetAtt ("name ");
$ TmpSql1 = str_replace ('@ #'. $ tvalue. '# @', addslashes ($ ctag-> GetInnerText
(), $ TmpSql1 );
If ($ tablename2! = ""){
$ TmpSql2 = str_replace ('@ #'. $ tvalue. '# @', addslashes ($ ctag-
> GetInnerText (), $ tmpSql2 );
}
}
$ TmpSql1 = ereg_replace ('@ # (. *) # @', '', $ tmpSql1 );
$ Rs = $ dsql-> ExecuteNoneQuery ($ tmpSql1 );
If ($ rs & $ tablename2! = ""){
If ($ synfield! = ""){
$ Lid = $ dsql-> GetLastID ();
$ TmpSql2 = str_replace ("@ $ synfield @", $ lid, $ tmpSql2 );
$ Rs = $ dsql-> ExecuteNoneQuery ($ tmpSql2 );
If (! $ Rs) $ dsql-> ExecuteNoneQuery ("Delete From $ tablename1 where
$ Autofield = '$ lid '");
}
Else $ dsql-> ExecuteNoneQuery ($ tmpSql2 );
}
$ Dsql-> ExecuteNoneQuery ("update #@__ courl set isex = 1 where aid = '$ aid '");
}
$ Dsql-> Close ();
// Generate html
If ($ channelid> 0 & $ makehtml = 1 ){
If (! $ Maxart_id) $ maxart_id = 0;
$ Dsql = new DedeSql (false );
$ Dsql-> SetQuery ("Select ID From #@__ archives where typeid = $ typeid and ID
> $ Maxart_id ;");
$ Dsql-> Execute ();
While ($ row = $ dsql-> GetObject ())
{
$ ID = $ row-> ID;
$ Ac = new Archives ($ ID );
$ Rurl = $ ac-> MakeHtml ();
$ Ac-> Close ();
}
$ Dsql-> Close ();
}
// Generate the homepage
$ Templet = "{style}/index.htm ";
$ Templet = str_replace ("{style}", $ pai_df_style, $ templet );
$ HomeFile = dirname (_ FILE _). "/index.html ";
$ HomeFile = str_replace ("\", "/", $ homeFile );
$ HomeFile = str_replace ("//", "/", $ homeFile );
$ Fp = fopen ($ homeFile, "w") or die ("the file name you specified is incorrect and cannot be created ");
Fclose ($ fp );
$ Pv = new PartView ();
$ Pv-> SetTemplet ($ pai_basedir. $ pai_templets_dir. "/". $ templet );
$ Pv-> SaveToHtml ($ homeFile );
$ Pv-> Close ();
}
$ Dsql = new DedeSql (false );
$ Dsql-> SetQuery ("Select ID, typedir From #@__ arctype ;");
$ Dsql-> Execute ();
While ($ row = $ dsql-> GetObject ())
{
// Generate the list html
$ Lv = new ListView ($ row-> ID );
$ Lv-> MakeHtml ();
$ Lv-> Close ();
}
$ Dsql-> Close ();
?>