The forum is here for legacy reasons. No new posts will be created. User registration is disabled! If you have any questions, please email us or check https://www.adultscriptpro.com for more details!
You are not logged in.
Pages: 1
Hey Guys ,
Last few month am trying to learn coding , so here my first "job" for asp.
i create a small script that check Hotlinked videos and if is dead delete it from DB.
PS: i didnt add option to delete thumbs too yet, i want to be sure first that work Perfectly.For me work well so far...
PS2: can added to cron to check every ~week or month etc
In line 6 edit "PREFIXvideo" with your video table, if you not use PREFIX make it video.
You can run it from browser OR you can add to cron.
If you want to see in browser the result of check just Uncomment
//echo "$video_url: <b>Working</b><br>";
AND
//echo "$broken: <b>Video deleted</b><br>";
<?php
define('_VALID', true);
require 'libraries/bootstrap.php';
$db = VF::factory('database');
$db->query("SELECT url FROM PREFIXvideo WHERE url != ''");
$videos = $db->fetch_rows();
function check_url($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch , CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, true);
$data = curl_exec($ch);
$headers = curl_getinfo($ch);
curl_close($ch);
return $headers['http_code'];
}
foreach ($videos as $video) { $video_url = $video['url'];
$check_url_status = check_url($video_url);
if ($check_url_status == '200') {
//echo "$video_url: <b>Working</b><br>";
}else {
$broken = $video_url;
$db->query("DELETE FROM aspvideo WHERE url = '$broken'");
//echo "$broken: <b>Video deleted</b><br>";
}
}
VF::close();
?>
Have fun.
Last edited by thiva7 (2015-03-23 23:34:39)
Offline
Pretty nice. I like the check functions. Maybe i will integrate something like this in admin :-)
A few ideas that you can use to make your code better:
1. Use the modules/video/helpers/manage.php to delete the video (you can check admin/modules/video/components/manage.php and see how its used).
2. Use $video_id, instead of $url when deleting (there is no key on $url and with 10k videos it will be slow).
3. Mark videos as deleted (this way search engines will still send you traffic and the visitor will select another video from the related videos).
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
Pretty nice. I like the check functions. Maybe i will integrate something like this in admin :-)
A few ideas that you can use to make your code better:
1. Use the modules/video/helpers/manage.php to delete the video (you can check admin/modules/video/components/manage.php and see how its used).
2. Use $video_id, instead of $url when deleting (there is no key on $url and with 10k videos it will be slow).
3. Mark videos as deleted (this way search engines will still send you traffic and the visitor will select another video from the related videos).
Thanks for checking
Yeah add it if is possible ,its nice feature and need one.
1) i check it but is pro coding for my skills
2) i will update this.
3) same as 2.
now am trying to make it module but i have some troubles
i create files and i have add codes and check should work on
index.php?q=video/check
but i cant "connect"
admin/module/video/components/check.php
with
admin/templates/default/video_check.tpl.php
i cant call my function from check php
if i learn that i guess i can create some simple modules like that....like Mp4 reconvert all flv videos etc... ( i have ready code for that )
Offline
in components/check.php add this:
$tpl->load(array('header', 'video_check', 'footer'));
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
in components/check.php add this:
$tpl->load(array('header', 'video_check', 'footer'));
nah you not understand me . I have done that ..it's OK .
the problem is I can't make functions to work in template file .
I mean this
in components/check.php I have
function check_url ( )
some php code
how I will call this function in template file?
Last edited by thiva7 (2015-03-24 17:45:32)
Offline
A method (which is in a class, like public function check_url()) will not work, however a function (a function is not included in the class, you have class whatever {} and after all code in the class is added, you can add function check_url()) and this function will work in the template (you call it with check_url(), not $this->check_url()). You can check modules/video/components/browse.php and see how i use functions.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
Pages: 1