Adult Script Pro Community Forums

Create, help and share your ideas with the community!

You are not logged in.

#1 2015-03-23 20:36:03

thiva7
Member
Registered: 2011-04-30
Posts: 988

Dead Hotlinked videos

Hey Guys ,

Last few month am trying to learn coding smile , 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... wink
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

#2 2015-03-24 05:12:02

symtab
Administrator
Registered: 2010-08-23
Posts: 7,213
Website

Re: Dead Hotlinked videos

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 - PopAds

Offline

#3 2015-03-24 13:49:58

thiva7
Member
Registered: 2011-04-30
Posts: 988

Re: Dead Hotlinked videos

symtab wrote:

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 smile

Yeah add it if is possible ,its nice feature and need one.

1) i check it but is pro coding for my skills big_smile
2) i will update this.
3) same as 2.

now am trying to make it module but i have some troubles tongue

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 sad

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

#4 2015-03-24 17:24:12

symtab
Administrator
Registered: 2010-08-23
Posts: 7,213
Website

Re: Dead Hotlinked videos

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 - PopAds

Offline

#5 2015-03-24 17:42:47

thiva7
Member
Registered: 2011-04-30
Posts: 988

Re: Dead Hotlinked videos

symtab wrote:

in components/check.php add this:

$tpl->load(array('header', 'video_check', 'footer'));

nah you not understand me smile . 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

#6 2015-03-24 18:00:06

symtab
Administrator
Registered: 2010-08-23
Posts: 7,213
Website

Re: Dead Hotlinked videos

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 - PopAds

Offline

Board footer

Powered by FluxBB