PDA

View Full Version : سوال در مورد موتور جستجو



mimlike
پنج شنبه 12 آذر 1394, 11:00 صبح
درود
دوستان من ی اسکریپ موتور جستجو ساده برای پروژه دانشگاهی نوشتم
ولی ی مشکلی دارم
میخوام وقتی تو فرم ادرس سایتی رو اضافه میکنم(یا ی سایتی بهش اضافه میکنم)
تمامی مطالب سایت رو تو دیتابیس ثبت کنه؟
ممنون میشم کمک کنید

H:Shojaei
پنج شنبه 12 آذر 1394, 12:34 عصر
درود
دوستان من ی اسکریپ موتور جستجو ساده برای پروژه دانشگاهی نوشتم
ولی ی مشکلی دارم
میخوام وقتی تو فرم ادرس سایتی رو اضافه میکنم(یا ی سایتی بهش اضافه میکنم)
تمامی مطالب سایت رو تو دیتابیس ثبت کنه؟
ممنون میشم کمک کنید
اول سورس سایت رو میگیرید بعد هم کل سورس رو به دنبال آدرس های دیگه که داخلش هست میگردید قطعا هر صفحه ای یه دکمه و یه آدرس با صفحات دیگه داره دیگه وقتی دارید سورس شاخه ها یا همون آدرسهای مختلف رو میگیرید و به دنبال لینکهاش میگردید تایتل و تگ توضیحات هر صفحه رو میگیرید و داخل دیتابیس به نام آدرس خود صفحه تو دیتابیس ثبت میکنید حالا تعدادی رکورد دارید با هرکدوم یه آدرس و یه تایتل و یه توضیحات سایت...

mimlike
پنج شنبه 12 آذر 1394, 13:51 عصر
این کد ها کدهای فایل که سایت رو ثبت میکنن addurl.php
ممنون میشم اگر بهش کد های ثبت لینک های سایت و عکس ها و ویدیو ها رو تو دیتابیس اضافه کنید؟


<?php
function PageMain() {
global $TMPL;

$text = $_GET['a'];
$addurl = htmlspecialchars(urldecode($_GET['q']), ENT_QUOTES);
$url = $_POST['url'];
$urls = array($_POST['urls']);



if(isset($_POST['url'])) {
$content = getUrl($url);
preg_match('#<title>(.*)</title>#i', $content, $title);
preg_match_all('/<img src=.([^"\' ]+)/', $content, $img);
preg_match('/<head>.+<meta name="description" content=.([^"\']+)/is', $content, $description);
preg_match('/<head>.+<meta name="author" content=.([^"\']+)/is', $content, $author);
preg_match_all('/href=.([^"\' ]+)/i', $content, $anchor);
preg_match('/<body.*?>(.*?)<\/body>/is', $content, $body);

$body_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$body[0])))); $bodyContent = substr(preg_replace('/\s+/', ' ', $body_trim), 0, 255);

$description_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$description[1])))); $descContent = substr(preg_replace('/\s+/', ' ', $description_trim), 0, 255);

$bodyContent = str_replace('\'', '', $bodyContent);
$descContent = str_replace('\'', '', $descContent);
$date = date("d M Y");
$purl = parse_url($url);

print_r($description[0]);
print_r($body_trim);

if(!isset($purl['path'])) {
$selectData = "SELECT * FROM web WHERE url = '$url'";
if(mysql_fetch_row(mysql_query($selectData)) === false) {
if(!empty($title[1]) AND !empty($description[1]) || !empty($body[1])) {
$insertData = "INSERT INTO `web` (`url` , `title` , `description` , `body` , `author`, `date`) VALUES ('".$url."', '".@$title[1]."', '".@$descContent."', '".$bodyContent."', '".$author[1]."', '".$date."')";
mysql_query($insertData);
$TMPL['success'] = '<div class="success">You have successfuly added <strong>'.$url.'</strong> to our search engine.</div>';
}
} else {
$TMPL['error'] = '<div class="error">The <strong>'.$url.'</strong> is already in our database.</div>';
}
}
}



if(isset($_POST['urls'])) {
foreach($urls as $url) {
$content = getUrl($url);
preg_match('#<title>(.*)</title>#i', $content, $title);
preg_match_all('/<img src=.([^"\' ]+)/', $content, $img);
preg_match('/<head>.+<meta name="description" content=.([^"\']+)/is', $content, $description);
preg_match('/<head>.+<meta name="author" content=.([^"\']+)/is', $content, $author);
preg_match_all('/href=.([^"\' ]+)/i', $content, $anchor);
preg_match('/<body.*?>(.*?)<\/body>/is', $content, $body);

$body_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$body[0])))); $bodyContent = substr(preg_replace('/\s+/', ' ', $body_trim), 0, 255);
$description_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$description[1])))); $descContent = substr(preg_replace('/\s+/', ' ', $description_trim), 0, 255);

$bodyContent = str_replace('\'', '', $bodyContent);
$descContent = str_replace('\'', '', $descContent);

$date = date("d M Y");
$purl = parse_url($url);

if(!isset($purl['path'])) {
$selectData = "SELECT * FROM web WHERE url = '$url'";
if(mysql_fetch_row(mysql_query($selectData)) === false) {
if(!empty($title[1]) AND !empty($description[1]) || !empty($body[1])) {
$insertData = "INSERT INTO `web` (`url` , `title` , `description` , `body` , `author`, `date`) VALUES ('".$url."', '".@$title[1]."', '".@$descContent."', '".@$bodyContent."', '".@$author[1]."', '".$date."')";
mysql_query($insertData);
$TMPL['success'] = '<div class="success">You have successfuly added '.$url.' and/or other domains to our search engine.</div>';
}
} else {
$TMPL['error'] = '<div class="error">The '.$url.' is already in our database.</div>';
}
}
foreach($anchor[1] as $k) {
$content = getUrl($k);
$url = parse_url($k);
if(!isset($url['path'])) {
$selectData = "SELECT * FROM web WHERE url = '$k'";
if(mysql_fetch_row(mysql_query($selectData)) === false) {
preg_match('#<title>(.*)</title>#i', $content, $title);
preg_match_all('/<img src=.([^"\' ]+)/', $content, $img);
preg_match('/<head>.+<meta name="description" content=.([^"\']+)/is', $content, $description);
preg_match('/<head>.+<meta name="author" content=.([^"\']+)/is', $content, $author);
preg_match_all('/href=.([^"\' ]+)/i', $content, $anchor);
preg_match('/<body.*?>(.*?)<\/body>/is', $content, $body);
if(!empty($title[1]) AND !empty($description[1]) || !empty($body[1])) {
$description_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$description[1])))); $descContent = substr(preg_replace('/\s+/', ' ', $description_trim), 0, 255);
$date = date("d M Y");
$body_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$body[0])))); $bodyContent = substr(preg_replace('/\s+/', ' ', $body_trim), 0, 255);

$bodyContent = str_replace('\'', '', $bodyContent);
$descContent = str_replace('\'', '', $descContent);

$insertData = "INSERT INTO `web` (`url` , `title` , `description` , `body` , `author`, `date`) VALUES ('".$k."', '".@$title[1]."', '".@$descContent."', '".@$bodyContent."', '".@$author[1]."', '".$date."')";
mysql_query($insertData);
}
}
}
}
}
}

$text = 'content';

$queryTitle = "SELECT title from users where id = '1'";
$resultTitle = mysql_fetch_row(mysql_query($queryTitle));

$TMPL['title'] = 'Add URL - '.$resultTitle[0].'';

$skin = new skin("addurl/$text");
return $skin->make();
}
?>
درواقع منظورم اینکه شما کدی رو به این کد ها اضافه کنید که وقتی ی سایت رو ثبت میکنن به همراهش لینک ها و عکس ها و ویدیو ها (و هرچیزی که یک موتور جستجو نیاز داره )تو دیتابیس ذخیره شه

mimlike
پنج شنبه 12 آذر 1394, 20:34 عصر
کسی بلد نیست؟:گریه:

H:Shojaei
پنج شنبه 12 آذر 1394, 21:42 عصر
درباره کلاس simple_html_dom اگر اشتباه نگفته باشم اسمشو تحقیق کنید...
با این کلاس شما میتونید کل اشیاء یک سورس صفحه رو به صورت آرایه بگیرید و به مشخصه های مورد نظر هم دسترسی داشته باشید...
مثلا میتونید مشخصه src عکس ها رو بگیرید یا مثلا مشخصه href از لینک ها و...

mimlike
پنج شنبه 12 آذر 1394, 22:29 عصر
اگر امکانش هست کد زیر رو باتوجه به روشی که میگید تکمیل کنید که تمامی اطلاعات مهم برای موتور جستجو رو از ادرسی که بهش داده میشه دریافت کنه

<?phpfunction PageMain() { global $TMPL; $text = $_GET['a']; $addurl = htmlspecialchars(urldecode($_GET['q']), ENT_QUOTES); $url = $_POST['url']; $urls = array($_POST['urls']); if(isset($_POST['url'])) { $content = getUrl($url); preg_match('#<title>(.*)</title>#i', $content, $title); preg_match_all('/<img src=.([^"\' ]+)/', $content, $img); preg_match('/<head>.+<meta name="description" content=.([^"\']+)/is', $content, $description); preg_match('/<head>.+<meta name="author" content=.([^"\']+)/is', $content, $author); preg_match_all('/href=.([^"\' ]+)/i', $content, $anchor); preg_match('/<body.*?>(.*?)<\/body>/is', $content, $body); $body_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$body[0])))); $bodyContent = substr(preg_replace('/\s+/', ' ', $body_trim), 0, 255); $description_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$description[1])))); $descContent = substr(preg_replace('/\s+/', ' ', $description_trim), 0, 255); $bodyContent = str_replace('\'', '', $bodyContent); $descContent = str_replace('\'', '', $descContent); $date = date("d M Y"); $purl = parse_url($url); print_r($description[0]); print_r($body_trim); if(!isset($purl['path'])) { $selectData = "SELECT * FROM web WHERE url = '$url'"; if(mysql_fetch_row(mysql_query($selectData)) === false) { if(!empty($title[1]) AND !empty($description[1]) || !empty($body[1])) { $insertData = "INSERT INTO `web` (`url` , `title` , `description` , `body` , `author`, `date`) VALUES ('".$url."', '".@$title[1]."', '".@$descContent."', '".$bodyContent."', '".$author[1]."', '".$date."')"; mysql_query($insertData); $TMPL['success'] = '<div class="success">You have successfuly added <strong>'.$url.'</strong> to our search engine.</div>'; } } else { $TMPL['error'] = '<div class="error">The <strong>'.$url.'</strong> is already in our database.</div>'; } } } if(isset($_POST['urls'])) { foreach($urls as $url) { $content = getUrl($url); preg_match('#<title>(.*)</title>#i', $content, $title); preg_match_all('/<img src=.([^"\' ]+)/', $content, $img); preg_match('/<head>.+<meta name="description" content=.([^"\']+)/is', $content, $description); preg_match('/<head>.+<meta name="author" content=.([^"\']+)/is', $content, $author); preg_match_all('/href=.([^"\' ]+)/i', $content, $anchor); preg_match('/<body.*?>(.*?)<\/body>/is', $content, $body); $body_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$body[0])))); $bodyContent = substr(preg_replace('/\s+/', ' ', $body_trim), 0, 255); $description_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$description[1])))); $descContent = substr(preg_replace('/\s+/', ' ', $description_trim), 0, 255); $bodyContent = str_replace('\'', '', $bodyContent); $descContent = str_replace('\'', '', $descContent); $date = date("d M Y"); $purl = parse_url($url); if(!isset($purl['path'])) { $selectData = "SELECT * FROM web WHERE url = '$url'"; if(mysql_fetch_row(mysql_query($selectData)) === false) { if(!empty($title[1]) AND !empty($description[1]) || !empty($body[1])) { $insertData = "INSERT INTO `web` (`url` , `title` , `description` , `body` , `author`, `date`) VALUES ('".$url."', '".@$title[1]."', '".@$descContent."', '".@$bodyContent."', '".@$author[1]."', '".$date."')"; mysql_query($insertData); $TMPL['success'] = '<div class="success">You have successfuly added '.$url.' and/or other domains to our search engine.</div>'; } } else { $TMPL['error'] = '<div class="error">The '.$url.' is already in our database.</div>'; } } foreach($anchor[1] as $k) { $content = getUrl($k); $url = parse_url($k); if(!isset($url['path'])) { $selectData = "SELECT * FROM web WHERE url = '$k'"; if(mysql_fetch_row(mysql_query($selectData)) === false) { preg_match('#<title>(.*)</title>#i', $content, $title); preg_match_all('/<img src=.([^"\' ]+)/', $content, $img); preg_match('/<head>.+<meta name="description" content=.([^"\']+)/is', $content, $description); preg_match('/<head>.+<meta name="author" content=.([^"\']+)/is', $content, $author); preg_match_all('/href=.([^"\' ]+)/i', $content, $anchor); preg_match('/<body.*?>(.*?)<\/body>/is', $content, $body); if(!empty($title[1]) AND !empty($description[1]) || !empty($body[1])) { $description_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$description[1])))); $descContent = substr(preg_replace('/\s+/', ' ', $description_trim), 0, 255); $date = date("d M Y"); $body_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$body[0])))); $bodyContent = substr(preg_replace('/\s+/', ' ', $body_trim), 0, 255); $bodyContent = str_replace('\'', '', $bodyContent); $descContent = str_replace('\'', '', $descContent); $insertData = "INSERT INTO `web` (`url` , `title` , `description` , `body` , `author`, `date`) VALUES ('".$k."', '".@$title[1]."', '".@$descContent."', '".@$bodyContent."', '".@$author[1]."', '".$date."')"; mysql_query($insertData); } } } } } } $text = 'content'; $queryTitle = "SELECT title from users where id = '1'"; $resultTitle = mysql_fetch_row(mysql_query($queryTitle)); $TMPL['title'] = 'Add URL - '.$resultTitle[0].''; $skin = new skin("addurl/$text"); return $skin->make();}?>

mimlike
جمعه 13 آذر 1394, 12:17 عصر
ی نفر لطفا مشکل مارو حل کنه:گریه::گریه::گریه::گریه:

H:Shojaei
جمعه 13 آذر 1394, 13:33 عصر
اگر امکانش هست کد زیر رو باتوجه به روشی که میگید تکمیل کنید که تمامی اطلاعات مهم برای موتور جستجو رو از ادرسی که بهش داده میشه دریافت کنه

منظورتون اینه که من پروژه شمارو بنویسم!؟
خوب این چیزی که میگید ۱-۲ ساعت که نیست دوست عزیز بعدم اینجا کسی کد نمینویسه تحویل بده مگر چی بشه و یا این که کد پیچیده باشه که احساس بشه طرف مشکل مفهومی داره یا این که کد یه تیکه کد باشه نه یه پروژه...

Unique
جمعه 13 آذر 1394, 13:35 عصر
ی نفر لطفا مشکل مارو حل کنه

اینکه دوست عزیز مشکل نیست ، اینجا کسی برای کسی معمولا کد نمینویسه مگه در شرایط خاص.
شما برو تحقیق کن ، کدت را بنویس ، سوالات را اینجا بپرس تا راهنمایی کنن.

us1234
جمعه 13 آذر 1394, 16:27 عصر
شما باید به این سایت مراجعه کنید :


parscoders.com