-
ايمپورت خودكار rss در محتواي مامبو (هك)
من در سايت esirjan.com متوجه شدم مطالب سايت ايرنا دقيقا به صورت كامل در محتواي سايت به صورت خود كار قرار ميگيره
وقتي سرچ كردم ديدم اين به دونه هك هست كه هم براي مامبو هست هم جوملا به اسم RSS 2 Mambo v1[1].1
داخلش يه فايل تكست بود كه اينجا مي ذارمش يكي دقيقان بگه بايد چكار كنيم يكم پيچيده بود!
محتواي فايل تكست :
<?php
// Sample RSS feeds to Joomla / Mambo importing script, hacked together by Max Soukhomlinov, [مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید]
//
// This script requires XML_RSS and PHP Pear Libraries
//
// There is an issue on some shared hosting sites that this will fail if ran via cron however if browsed to, it works just fine.
// this has to do with permissions, your hosting website uid does not have same rights as apache uid (under which script is executed when your browse to it)
// I am at the moment trying to work out a solution to it, if you can think of something that will help, please drop me a line.
// Happy importing :-)
//
/** the PEAR XML_RSS object/class is required */
require 'RSS.php';
/** DATABASE Configuration */
define("DB_HOSTNAME","localhost&quo t
; //Insert your DB server name here
define("DB_USERNAME","username"
; //DB username here
define("DB_PASSWD","password"
; // DB password here
define("DB_DATABASE","dbname"
; //DB name here
/** pull list of remote RSS feeds, via a remote RSS feed. */
$rss_feed = & new XML_RSS('[مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید]); //Insert your URL here
//$rss_feed = & new XML_RSS('feed.xml'
; //Used this for testing with local file, a bit quicker
// Change to your email address, if you do not want notifications, rem out line 187.
$admin_email = 'youremailaddresshere';
// Should not need to change anything from here onwards unless you know some basic php
// The advanced options are: A) Alter title formatting (lines 68 and 84);
// B) Alter introtext/maintext formatting (lines 85 and 86);
// C) Change formatting of notification email (lines 92-97 for per new item formatting and 164-182 for main body formatting).
// Next two lines are for duration runtime, which is reported via email
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];
// Function for shortening articles based on maximum length
function str_stop($string, $max_length){
if (strlen($string) > $max_length){
$string = substr($string, 0, $max_length);
$pos = strrpos($string, " "
;
if($pos === false) {return substr($string, 0, $max_length)."...";}
return substr($string, 0, $pos)."...";
}else{return $string;}
}
/** create the database connection object */
$obj_db = @mysql_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWD) or die (mysql_error());
/** select the intended database */
@mysql_select_db(DB_DATABASE,$obj_db) or die (mysql_error());
$rss_feed->parse();
$num_articles=0; //Variable used to count number of new articles, displayed in an email below
// Here we make sure that feed articles do not already exist in DB
// this uses title names, make sure to use the same title formatting here as you will use further down
// state = 1 not trashed
foreach ($rss_feed->getItems() as $item) {
$obj_query = @mysql_query("
SELECT
COUNT(id) AS link_match
FROM
mos_content
WHERE
title = '". str_stop(addslashes($item['title']),100) ."'
AND
state = '1'
",$obj_db) or die(mysql_error());
$int_count = @mysql_fetch_assoc($obj_query) or die(mysql_error());
mysql_free_result($obj_query);
if ($int_count['link_match'] == 0) {
$num_articles = $num_articles +1;
/**
* REFORMATTING CODE
**/
$titletext = str_stop(addslashes($item['title']),100);
$introtext = str_stop(addslashes($item['description']), 280); //Shorten description to 280 chars...
$maintext = addslashes($item['description']);
$publishdate = date('Y-m-d H:i:s', strtotime($item['pubdate'])); //Convert feed article publish date to mambo publish date
$publishdate_readable = date('d-m-Y, H:i', strtotime($item['pubdate'])); // I didnt like the standard date format, this is for email field
// the following used to notify admin of new articles (via email), this is parsed with each article
$feed_summary .= '
<tr>
<td>'. $publishdate_readable .'</td>
<td>'. $titletext .'</td>
<td>'. $introtext .'</td>
<td>'. $maintext .'</td>
</tr>
';
/**
* INSERT DATA
*/
// VERY IMPORTANT, changes will be required here for sure!
// THE attribs below are specific to my site but you can blank it all if you wish (default parameters)
// with attribs, make sure to type each on new line (ie line break as shown below otherwise mambo will not understand it)
// Ordering number, be fault it will be #99, i am yet to implement an auto detection as mambo/joomla does on its own
// for now all articles will be #99 so when publishing sort them by published date
@mysql_query("
INSERT INTO mos_content (
title,
introtext,
`fulltext`,
state,
sectionid,
mask,
catid,
created,
created_by,
checked_out,
publish_up,
attribs,
version,
access,
ordering
) VALUES (
'". $titletext ."',
'". $introtext ."',
'". $maintext ."',
'1',
'YOUR SECTION ID HERE',
'0',
'YOUR CATEGORY ID HERE',
'". $publishdate ."',
'ID OF THE USER YOU WANT TO BE SHOWN AS AUTHOR',
'0',
'". $publishdate ."',
'introtext=0
createdate=1',
'1',
'0',
'99'
)
",$obj_db) or die(mysql_error());
}
}
if ($obj_db) {
@mysql_close($obj_db);
}
// if we have downloaded new feeds, lets create a report for the admin
if ($feed_summary)
{
// runtime check, to tell admin on how long this script has been running, might be handy to know
$mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime;
/** EMAIL variables */
$email_subject = 'Your subject here';
$email_body = '
<html>
<table width="100%" border="0" cellspacing="1" cellpadding="5" bgcolor="#999999">
<tr>
<th bgcolor="#FFFFFF">Date</th>
<th bgcolor="#FFFFFF">Heading</th>
<th bgcolor="#FFFFFF">Intro text</th>
<th bgcolor="#FFFFFF">Full text</th>
</tr>
'. $feed_summary .'
<tr>
<td colspan="4" bgcolor="#FFFFFF">
<strong>This message was automatically generated by the rss importing process on your website.</strong><br /><br />
<strong>Script</strong>: '. getcwd() .'/yourscriptnamehere.php<br />
<strong>RSS Feed source:</strong> [مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید] />
<strong>Current date:</strong> '. date(r) .'<br />
<strong>Script execution time:</strong> '. round($totaltime,3) .' seconds.
</td>
</tr>
</table>
</html>
';
$from = "MIME-Version: 1.0\n";
$from .= "Content-type: text/html; charset=iso-8859-1\n";
$from .= "From: From Address name <script@sitename.com>\n";
mail($admin_email, $email_subject, $email_body, $from);
}
?>
جهت مشاهده لینک ها باید ثبت نام کنید یا لاگین کنید.
-
-
08-30-2006 07:27 PM
# ADS
تبلیغات در جوملا فارسی
علاقه مندی ها (Bookmarks)