hi all,
i have written a plugin which checks how many youtube videos are added in message/thread/post.
it individualy checks all videos, and finds if they are ios/iphone compatible.
if video is not ios compatible it shows error. all the code is working fine, but i am not able to show errror. the error is not showing and post is submitting.
any idea???
my code is attacked in a separate php file.
===================================
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
// user report hooks
$plugins->add_hook("parse_message_start", "haltmedia_run");
# tried with all following but no luck yet.
//$plugins->add_hook("parse_message_end", "haltmedia_run");
//$plugins->add_hook("parse_message", "haltmedia_run");
//$plugins->add_hook("post_output_page", "haltmedia_run");
//$plugins->add_hook("text_parse_message", "haltmedia_run");
function haltmedia_run(&$message){
echo 'i am here ' . THIS_SCRIPT." File: ".__FILE__ . " Line: " .__LINE__; #i am here newthread.php File: C:\wamp\www\propertytribes\inc\plugins\yts.php Line: 11
$data_in_post = $message;
$lines = explode(PHP_EOL, $data_in_post);
$pattern = 'http://www.youtube.com/watch?v=';
if(preg_match_all("#\[video=youtube](.*?)\[/video]#s", $data_in_post, $addresses))
{
foreach ($addresses[1] as $key => $val) {
if (strlen(strstr($val, $pattern)) > 0) {
$videoid = substr($val, strlen($pattern));
}
$feedURL2= trim('http://gdata.youtube.com/feeds/api/videos/'.$videoid); # i.e, http://gdata.youtube.com/feeds/api/videos/kffacxfA7G4
$input = @file_get_contents($feedURL2);
$iphone = 1;
$msgip= '';
$flv = '';
if (strlen(strstr($input, "format='1'")) > 0) {
$iphone = 1;
$msgip.="IPhone=YES";
} else {
$iphone = 0;
$msgip.="IPhone=NO";
}
if (strlen(strstr($input, "format='5'")) > 0) {
$flv .=",FLASH=YES";
} else {
$flv .=",FLASH=NO";
}
if(!$iphone){
$error = 'this video does not support for ios : remove ti : '.$addresses[0][$key];
error($error);
#tried the following too but no luck
// $error_inline.= $error;
// eval("\$errorr_inline = \"".$templates->get("error_inline")."\";");
// output_page($error_inline);
// break;
// exit;
// return $message;
}
}
}
}
function yts_info() {
return array(
"name" => "youtube video stop",
"description" => 'The Youtube Video Plugin Checks whether youtube video for ios is supported or not.',
"website" => '',
"author" => "[email protected]",
"authorsite" => "",
"version" => "1.0",
"guid" => "yts123youname789goeshere000",
"compatibility" => "16*"
);
}
function yts_install(){
global $db, $mybb, $templates, $lang, $plugins;
}
function yts_activate(){
global $db, $mybb, $templates, $lang, $plugins;
$yts_group = array(
'gid' => 'NULL',
'name' => 'yts',
'title' => 'Youtube Video Check For iPhone',
'description' => 'Settings For youtube Video check for iPhone.',
'disporder' => "1",
'isdefault' => 'no',
);
$dup_group_title ='';
$errors= '';
$query = $db->simple_select("settinggroups", "title", "name='yts'");
if($db->num_rows($query) > 0)
{
$dup_group_title = $db->fetch_field($query, 'title');
}
if(empty($dup_group_title) || $dup_group_title == null ){
$db->insert_query('settinggroups', $yts_group);
}
rebuild_settings();
}
function yts_uninstall()
{
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='yts'");
rebuild_settings();
}
function yts_deactivate() {
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='yts'");
rebuild_settings();
}
?>
=== videos i am using here :
/*
try these videos in post or thread or in reply.
video=youtube]http://www.youtube.com/watch?v=_OBlgSz8sSM[/video]
video=youtube]http://www.youtube.com/watch?v=d_czxTedXpc[/video]
video=dailymotion]http://www.dailymotion.com/video/xkm1em_adalat-29th-august-2011-at-www-apnatvforum-com-pk_shortfilms[/video]
video=youtube]http://www.youtube.com/watch?v=6Jlv8F9cerA[/video]
video=youtube]http://www.youtube.com/watch?v=zBbMAJgBymA[/video]
video=dailymotion]http://www.dailymotion.com/video/xkm1em_adalat-29th-august-2011-at-www-apnatvforum-com-pk_shortfilms[/video]
video=youtube]http://www.youtube.com/watch?v=4JipHEz53sU[/video]
*/
i have written a plugin which checks how many youtube videos are added in message/thread/post.
it individualy checks all videos, and finds if they are ios/iphone compatible.
if video is not ios compatible it shows error. all the code is working fine, but i am not able to show errror. the error is not showing and post is submitting.
any idea???
my code is attacked in a separate php file.
===================================
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
// user report hooks
$plugins->add_hook("parse_message_start", "haltmedia_run");
# tried with all following but no luck yet.
//$plugins->add_hook("parse_message_end", "haltmedia_run");
//$plugins->add_hook("parse_message", "haltmedia_run");
//$plugins->add_hook("post_output_page", "haltmedia_run");
//$plugins->add_hook("text_parse_message", "haltmedia_run");
function haltmedia_run(&$message){
echo 'i am here ' . THIS_SCRIPT." File: ".__FILE__ . " Line: " .__LINE__; #i am here newthread.php File: C:\wamp\www\propertytribes\inc\plugins\yts.php Line: 11
$data_in_post = $message;
$lines = explode(PHP_EOL, $data_in_post);
$pattern = 'http://www.youtube.com/watch?v=';
if(preg_match_all("#\[video=youtube](.*?)\[/video]#s", $data_in_post, $addresses))
{
foreach ($addresses[1] as $key => $val) {
if (strlen(strstr($val, $pattern)) > 0) {
$videoid = substr($val, strlen($pattern));
}
$feedURL2= trim('http://gdata.youtube.com/feeds/api/videos/'.$videoid); # i.e, http://gdata.youtube.com/feeds/api/videos/kffacxfA7G4
$input = @file_get_contents($feedURL2);
$iphone = 1;
$msgip= '';
$flv = '';
if (strlen(strstr($input, "format='1'")) > 0) {
$iphone = 1;
$msgip.="IPhone=YES";
} else {
$iphone = 0;
$msgip.="IPhone=NO";
}
if (strlen(strstr($input, "format='5'")) > 0) {
$flv .=",FLASH=YES";
} else {
$flv .=",FLASH=NO";
}
if(!$iphone){
$error = 'this video does not support for ios : remove ti : '.$addresses[0][$key];
error($error);
#tried the following too but no luck
// $error_inline.= $error;
// eval("\$errorr_inline = \"".$templates->get("error_inline")."\";");
// output_page($error_inline);
// break;
// exit;
// return $message;
}
}
}
}
function yts_info() {
return array(
"name" => "youtube video stop",
"description" => 'The Youtube Video Plugin Checks whether youtube video for ios is supported or not.',
"website" => '',
"author" => "[email protected]",
"authorsite" => "",
"version" => "1.0",
"guid" => "yts123youname789goeshere000",
"compatibility" => "16*"
);
}
function yts_install(){
global $db, $mybb, $templates, $lang, $plugins;
}
function yts_activate(){
global $db, $mybb, $templates, $lang, $plugins;
$yts_group = array(
'gid' => 'NULL',
'name' => 'yts',
'title' => 'Youtube Video Check For iPhone',
'description' => 'Settings For youtube Video check for iPhone.',
'disporder' => "1",
'isdefault' => 'no',
);
$dup_group_title ='';
$errors= '';
$query = $db->simple_select("settinggroups", "title", "name='yts'");
if($db->num_rows($query) > 0)
{
$dup_group_title = $db->fetch_field($query, 'title');
}
if(empty($dup_group_title) || $dup_group_title == null ){
$db->insert_query('settinggroups', $yts_group);
}
rebuild_settings();
}
function yts_uninstall()
{
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='yts'");
rebuild_settings();
}
function yts_deactivate() {
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='yts'");
rebuild_settings();
}
?>
=== videos i am using here :
/*
try these videos in post or thread or in reply.
video=youtube]http://www.youtube.com/watch?v=_OBlgSz8sSM[/video]
video=youtube]http://www.youtube.com/watch?v=d_czxTedXpc[/video]
video=dailymotion]http://www.dailymotion.com/video/xkm1em_adalat-29th-august-2011-at-www-apnatvforum-com-pk_shortfilms[/video]
video=youtube]http://www.youtube.com/watch?v=6Jlv8F9cerA[/video]
video=youtube]http://www.youtube.com/watch?v=zBbMAJgBymA[/video]
video=dailymotion]http://www.dailymotion.com/video/xkm1em_adalat-29th-august-2011-at-www-apnatvforum-com-pk_shortfilms[/video]
video=youtube]http://www.youtube.com/watch?v=4JipHEz53sU[/video]
*/
With Regards and many thanks.
------------------------------------------
------------------------------------------