Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Modules
Author Message
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Thu Aug 05, 2010 4:41 am Reply with quote

Greetings All,

I have created a New Video Mod for use with You Tube.

Now before you go running to download and install this...
This is Version 1 and I do not recommand that you use this on a production site.

I am a piss poor coder and I am sure there is something I did wrong that will get you hacked. (and I wrote this from scratch)

Link removed for the moment...

Ol' Great RN Staff...Would you please take a look at this and point me in the right direction so that I might learn?

Feel free to tear me a new one...pick it apart...It works and works well...but I know I screwed something up!

Thank you for your time.

Dawg


Last edited by Dawg on Thu Aug 05, 2010 3:41 pm; edited 1 time in total 
View user's profile Send private message
Dawg







PostPosted: Thu Aug 05, 2010 4:45 am Reply with quote

Issue #1

I used Greybox javascript to run the videos in. I could not jquery to work with it.

Issue #2

My Santizer code? Did I do this right? I need to make sure that code is santized correctly before it is input into the database.

Those are the two BIG ones that I see!

Dawg
 
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Thu Aug 05, 2010 2:55 pm Reply with quote

I get white screens on both the admin and module. I'll try and look at it tonight.

HP Parse error: syntax error, unexpected $end in /modules/RN_Video/admin/index.php on line 1358

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
Dawg







PostPosted: Thu Aug 05, 2010 3:40 pm Reply with quote

Palbin,

Thank You for looking. I am running an older version of RN with a custom 1 off theme. I will go install current RN and get it working and repost it.

Dawg
 
Dawg







PostPosted: Thu Aug 05, 2010 5:36 pm Reply with quote

OK....I fixed it.

It was a couple of minor issues mostly related to my theme.

Try this...Should work right out of the box.

Only registered users can see links on this board! Get registered or login!

Thank You for your time!

Dawg
 
Palbin







PostPosted: Thu Aug 05, 2010 6:52 pm Reply with quote

Still get these.

Code:


[05-Aug-2010 18:49:45] PHP Parse error:  syntax error, unexpected $end in /modules/RN_Video/index.php on line 333

[05-Aug-2010 18:50:23] PHP Parse error:  syntax error, unexpected $end in /modules/RN_Video/admin/index.php on line 1359
 
Dawg







PostPosted: Thu Aug 05, 2010 8:00 pm Reply with quote

Pablin,

That is wierd...I have it on a FRESH install...I mean FRESH...

Hmmm....

I checked the rar file to make sure I updated it.

I also just uploaded a fresh copy.

Look at the top of the index file....

Does it say this?

line 18-19
// $index = 0;
// $hideleft=1;

If it does not....Download a fresh version

Dawg
 
Dawg







PostPosted: Fri Aug 06, 2010 4:33 am Reply with quote

A few changes here....

I went through tidy and did all the corrections I could find.

User side should be 100%
Admin side had some left in the theme itself....but the MOD should be clean anyway.

Thanks for the help!

Dawg

New RN_Video/Index.php

Code:


<?php
/**********************************************/
/* RN Video by Dawg
/* Version 1.2 Beta
/* This should NOT be used in Production Sites
/*Help and Support at http://www.ravenphpscripts.com
/**********************************************/


if ( !defined('MODULE_FILE') )
{
    die('You can\'t access this file directly...');
}

require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
 // $index = 0;
// $hideleft=1;
$admingid= '25'; //(The number of posts before people can add videos)
include('header.php');
global $user,$cookie,$prefix,$nukeuser,$db,$prefix;   
cookiedecode($user);
$username = $cookie[1];

if ($username == "") {
   $username = "Anonymous";
}
         
if (is_user($user)) {
   list($uid, $username) = explode(":", $nukeuser);
   $querystr = "SELECT user_posts FROM ".$prefix."_users WHERE user_id=$uid" ;
   $result = $db->sql_query($querystr) ;
      if (!$result) {
         echo 'Could not run query: ' . mysql_error();
         exit;
      }
   $row = mysql_fetch_row($result);
   $postcount = $row[0];
   echo $postcount;
}
if (!isset($op)) $op = '';

switch($op) {
   default:
        display_video();
    break;
      case list_video:
        list_video();
    break;
      case list_single_category:
        list_single_category();
    break;
       break;
      case video_admin_menu:
        video_admin_menu();
   }
die();
///////////////////////////////////////// START ADMIN MENU /////////////////////////////////
function video_admin_menu() {
global $postcount, $admingid,$db,$prefix;
?>

<br />
<center>
<a href='modules.php?name=RN_Video&amp;file=user_admin&amp;op=user_add_video_main'><font size='3'>User Video Admin</font></a>
&nbsp;|&nbsp;
<a href='modules.php?name=RN_Video&amp;file=user_admin&amp;op=user_add_video'><font size='3'>Add Video</font></a>
&nbsp;|&nbsp;
<a href='modules.php?name=RN_Video&amp;file=user_admin&amp;op=user_edit_video'><font size='3'>Edit YOUR Videos</font></a>
&nbsp;|&nbsp;
<a href='modules.php?name=RN_Video&amp;file=user_admin&amp;op=user_edit_video'><font size='3' color='#ff0000'>Delete YOUR Videos</font></a>
</center>
<br />
<?

}
///////////////////////////////////////// FINISH ADMIN MENU /////////////////////////////////

///////////////////////////////////////// START NAV MENU /////////////////////////////////
function nav_video() {
global $postcount, $admingid,$db,$prefix;
if ($postcount>=$admingid) {
video_admin_menu();
}
?>
<br />
<center>
<a href='modules.php?name=RN_Video'><font size='3'>Video Home</font></a>
&nbsp;|&nbsp;
<a href='modules.php?name=RN_Video&amp;op=list_single_category'><font size='3'>List Single Category</font></a>
&nbsp;|&nbsp;
<a href='modules.php?name=RN_Video&amp;op=list_video'><font size='3' color='#ff0000'>Category View</font></a>
</center>
<?
}
///////////////////////////////////////// FINISH NAV MENU /////////////////////////////////

///////////////////////////////////////// Start MOST RECENT /////////////////////////////////
function display_video() {
OpenTable();
global $user,$cookie,$prefix,$nukeuser,$db,$prefix;
?>
<center>
<br /><font size='6' color='#0000ff'>Most Recent Videos</font><br />
</center>
<?
nav_video();
?>
<br /><hr width='80%' /><br />
<table width="100%">
  <tr>
<?
$query ="SELECT video FROM ".$prefix."_rnvideo WHERE aut='1'";
 $result = $db->sql_query($query)
 or die ("invalid query in video display");
 //$result= $db->sql_query($query);
$rows=$db->sql_numrows($result);
//// Set number of Videos per page here
$ppp=10;
$nop= ceil($rows / $ppp);
$z=0;
echo "<td><p><font size='2'>Page : </font>";
for ($i = 1 ; $i <= $nop ; $i++)
{
echo "&nbsp;&nbsp;<a href='/modules.php?name=RN_Video&amp;page=$i'><font size=2> $i </font></a>&nbsp;";
}
echo "</p></td>";
if (isset($_GET['page'])){$page = $_GET['page'];}else{$page = 1;}
$start= ($page - 1) * $ppp;
$ranking=0;
$ranking=(($ranking+$ppp)*$page)-($ppp-1);
$query="SELECT video,title,code,counter FROM ".$prefix."_rnvideo WHERE aut='1' ORDER BY time DESC LIMIT $start,$ppp";
$result = $db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$video=$row['0'];
$title=$row['1'];
$code=$row['2'];
$counter=$row['3'];
 if ($z % 2 != 1)
   {
echo "<tr align='center'>";
   }

?>
<td><div align="center">
<font size='3' color='#0000ff'><b><? echo strtoupper($title); ?></b></font>
<br /><br />
<?
for($i=1;$i < 5;$i++)
{
if(file_get_contents("http://i$i.ytimg.com/vi/$code/default.jpg"))
{

 ?>
 
<table><tr><td>
<a href="modules.php?name=RN_Video&amp;file=most_player&amp;video=<? echo $video; ?>" rel="gb_page_center[640, 425]" title="<? echo $title; ?>" rev="width: 700px; height: 410px; scrolling: no;"><img src='http://i<? echo $i; ?>.ytimg.com/vi/<? echo $code; ?>/default.jpg' width='175' /></a>
</td></tr></table>
<?
Break;
}
}
?>
<font size='3' color='#0000ff'>Views </font><font size='3' color='#ff0000'><b><? echo $counter; ?></b></font>
&nbsp; | &nbsp;
<font size='3' color='#0000ff'>Ranking </font><font size='3' color='#ff0000'><b><? echo $ranking; ?></b></font><br /><hr width='80%' /><br />
</div></td>
<?
$z++;
$ranking++;
 }

?>
</tr></table>

<br /><hr  width="80%" size="5" /><br />
<?
CloseTable();
include('footer.php');
    }
///////////////////////////////////////// END VIDEO DISPLAY /////////////////////////////////


///////////////////////////////////////// Start List Categories /////////////////////////////////
function list_video() {
OpenTable();
global $user,$cookie,$prefix,$nukeuser,$db,$prefix;
?>
<center>
<br /><font size='6' color='#0000ff'>List All Categories</font><br />
</center>
<?
nav_video();
?>
<br /><hr width='80%' /><br />
<table width='80%' align='center'>
  <tr>
<?

$sql = "SELECT uid, uname FROM nuke_users";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$result = $db->sql_query("SELECT * FROM ".$prefix."_rnvideo_category");
   while($myrow = $db->sql_fetchrow($result)){
   // while($myrow = mysql_fetch_array($result)){
      $catid=$myrow[0];
      $category=$myrow[1];
         echo "<td valign='top' align='center' width='200'>";
         echo "<br /><font size='4' color='#0000ff'>$category</font><br /><br />";
         echo "<hr width='80%' size='3' />";
$result2 = $db->sql_query("SELECT video,category,title,code,counter FROM ".$prefix."_rnvideo WHERE aut='1' AND category='$catid' ORDER BY time DESC");
   while($myrow2 = $db->sql_fetchrow($result2)){
      $video=$myrow2[0];
      $category=$myrow2[1];
      $title=$myrow2[2];
         echo "<font size='3' color='#0000ff'><b>$title</b></font>";
         echo "<br />";
      $code=$myrow2[3];
      $counter=$myrow2[4];
         echo "<br />";
?>
<a href="modules.php?name=RN_Video&amp;file=most_player&amp;video=<? echo $video; ?>" rel="gb_page_center[640, 425]" title="<? echo $title; ?>" rev="width: 700px; height: 410px; scrolling: no;"><img src='http://i<? echo $i; ?>.ytimg.com/vi/<? echo $code; ?>/default.jpg' width='200' /></a>
<?
         echo "<br />";
         echo "Views $counter";
         echo "<br />";
         echo "<br />";
         echo "<hr width='80%' size='3' />";
         echo "<br />";
   }
         echo"</td>";
   }
      
?>
</table><br /><hr width='80%' /><br />
<?
CloseTable();
include('footer.php');
}
///////////////////////////////////////// End List Categories /////////////////////////////////

///////////////////////////////////////// Begin List Single Catergory/////////////////////////////////
function list_single_category() {
OpenTable();
global $user,$cookie,$prefix,$nukeuser,$db,$prefix;
?>
<center>
<br /><font size='6' color='#0000ff'>List Single Categories</font><br />
</center>
<?
nav_video();
?>
<br /><hr width='80%' /><br />
<table width="100%">
  <tr>
<?
///// SET CATEGORY HERE BY ID
$value="89";

///   THIS NEEDS TO BE FIXED
$query ="SELECT video FROM ".$prefix."_rnvideo WHERE aut='1' AND category='$value'";
//$query ="SELECT video FROM ".$prefix."_rnvideo WHERE category='73'";
$result = $db->sql_query($query)
 or die ("invalid query in video display");
$rows=$db->sql_numrows($result);
// echo "ROWS = $rows";
//// Set number of Videos per page here
$ppp=10;
$nop= ceil($rows / $ppp);
// echo "NOP=$nop";
$z=0;
echo "<td><p><font size='2'>Page : </font>";
for ($i = 1 ; $i <= $nop ; $i++)
{
echo "&nbsp;&nbsp;<a href='/modules.php?name=RN_Video&amp;op=list_single_category&amp;page=$i'><font size=2> $i </font></a>&nbsp;";
}
echo "</p></td>";
if (isset($_GET['page'])){$page = $_GET['page'];}else{$page = 1;}
$start= ($page - 1) * $ppp;
$ranking=0;
$ranking=(($ranking+$ppp)*$page)-($ppp-1);
$query="SELECT video,title,code,counter FROM ".$prefix."_rnvideo WHERE aut='1' ORDER BY time DESC LIMIT $start,$ppp";
$result = $db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$video=$row['0'];
$title=$row['1'];
$code=$row['2'];
$counter=$row['3'];
 if ($z % 2 != 1)
   {
echo "<tr align='center'>";
   }

?>
<td><div align="center">
<?
         echo "<font size='3' color='#0000ff'><b>$title</b></font>";
         echo "<br />";
for($i=1;$i < 5;$i++)
{
if(file_get_contents("http://i$i.ytimg.com/vi/$code/default.jpg"))
{

 ?>
<table><tr><td>
<a href="modules.php?name=RN_Video&amp;file=most_player&amp;video=<? echo $video; ?>" rel="gb_page_center[640, 425]" title="<? echo $title; ?>" rev="width: 700px; height: 410px; scrolling: no;"><img src='http://i<? echo $i; ?>.ytimg.com/vi/<? echo $code; ?>/default.jpg' width='175' /></a>
</td></tr></table>
<?
Break;
}
}
?>
<font size='3' color='#0000ff'>Views </font><font size='3' color='#ff0000'><b><? echo $counter; ?></b></font>
&nbsp; | &nbsp;
<font size='3' color='#0000ff'>Ranking </font><font size='3' color='#ff0000'><b><? echo $ranking; ?></b></font><br /><hr width='80%' /><br />
</div></td>
<?
$z++;
$ranking++;
 }

?>
</tr></table>
<br /><hr width='80%' /><br />
<?
CloseTable();
include('footer.php');
    }
///////////////////////////////////////// End List Single Catergory/////////////////////////////////
?>
 
Dawg







PostPosted: Fri Aug 06, 2010 4:38 am Reply with quote

New RN_Video/admin/index.php

Code:
<?php

/**********************************************/
/* RN Video by Dawg
/* Version 1.2 Beta
/* This should NOT be used in Production Sites
/*Help and Support at http://www.ravenphpscripts.com
/**********************************************/

if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
// $hideleft= "1";
include_once("header.php");
$querystr = "SELECT radminsuper, admlanguage FROM ".$prefix."_authors where aid='$aid'";
$result = $db->sql_query($querystr, $db) or die ("invalied query");
list($radminsuper) = $db->sql_fetchrow($result);
if ($radminsuper==1)
 {
   switch($op) {
      case "admin_video_main":
   admin_video_main();
   break;
   
   case "add_video_nav":
   add_video_nav();
   break;
   
   case "edit_bottom_nav":
   edit_bottom_nav();
   break;
   
   case "Sanitizer":
   Sanitizer();
   break;
   
   case "add_video":
   add_video();
   break;
   
   case "add_video2":
   add_video2();
   break;
   
   case "edit_video":
   edit_video();
   break;
   
   case "edit_video2":
   edit_video2();
   break;
   
   case "edit_video3":
   edit_video3();
   break;
   
   case "admin_category_display":
   admin_category_display();
   break;
   
   case "admin_category_delete":
   admin_category_delete();
   break;
   
   case "admin_category_edit":
   admin_category_edit();
   break;
   
   case "admin_category_edit2":
   admin_category_edit2();
   break;
   
   case "admin_category_add":
   admin_category_add();
   break;
   
   case "admin_category_add2":
   admin_category_add2();
   break;
   }
}
else {

OpenTable();


echo "<center>
<font size='3'>Sorry Dude,  You Do NOT have Permission to use this feature</font>
<br /><br />
<font size='3'>Contact your Site Admin to be included in this Group</font>
<br /><br />
<a href='modules.php?name=RN_Video'><font size='3'>RN Video Main Page</font></a>
</center>";
CloseTable();
include('footer.php');

}
admin_video_main();


function test()

   global $admin, $bgcolor2, $prefix, $db,$user,$cookie,$nukeuser;   
include_once("header.php");
OpenTable();
?>
<br /><hr width='80%' />

<div align="center">
  <p><strong><font size="5"><br />
        <font color="#0000FF">Howdy </font></font></strong></p>
  <p><img src="modules/RN_Video/images/RN_Video.png" width="400" height="294" /></p>
  <p><strong><font color="#0000FF" size="5">Pick a Link above to get started    </font></strong><br />
    </p>
</div>
<?
CloseTable();
include('footer.php');
    }

///////////////// Sanitizer Start ////////////////
function Sanitizer($variable)

$variable=trim($variable);
$variable=strip_tags($variable);
$variable=htmlentities($variable);
$variable=addslashes($variable); 
return $variable;
}
///////////////// Sanitizer Finish ////////////////


//////////////////////////  Admin Nav /////////////////
function add_video_nav() {
?>
<center>
<a href='admin.php?op=admin_video_main'><font size='3'>Video Admin Home</font></a>
&nbsp;|&nbsp;
<a href='admin.php?op=add_video'><font size='3'>Add Video</font></a>
&nbsp;|&nbsp;
<a href='admin.php?op=edit_video'><font size='3'>Edit Videos</font></a>
&nbsp;|&nbsp;
<a href='admin.php?op=edit_video'><font size='3' color='#ff0000'>Delete Videos</font></a>
<br /><br />
<a href='admin.php?op=admin_category_display'><font size='3'>Display Category</font></a>
&nbsp;|&nbsp;
<a href='admin.php?op=admin_category_add'><font size='3'>Add Category</font></a>
&nbsp;|&nbsp;
<a href='admin.php?op=admin_category_display'><font size='3'>Edit Category</font></a>
&nbsp;|&nbsp;
<a href='admin.php?op=admin_category_display'><font size='3' color='#ff0000'>Delete Category</font></a>
</center>
<?
}

//////////////////////////  Edit Bottom  Nav /////////////////

function edit_bottom_nav() {
echo "<center>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_video_main'><font color='#ff0000'><b>Video Home</b></font></a>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_video_main&amp;op=add_video'><font color='#ff0000'><b>Add A Video</b></font></a>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_video_main&amp;op=edit_video'><font color='#ff0000'><b>Edit A Video</b></font></a>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_video_main&amp;op=user_edit_video'><font color='#ff0000'><b>Return to Main Admin Page</b></font></a>";
echo "<br /><br />";
echo "</center>";
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                                ADMIN VIDEO MAIN                                                                                                                                             //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function admin_video_main() {
   global $admin, $bgcolor2, $prefix, $db,$user,$cookie,$nukeuser;   
include_once("header.php");
OpenTable();
?>
<br /><hr width='80%' />
<?
add_video_nav();
?>
<div align="center">
  <p><strong><font size="5"><br />
        <font color="#0000FF">Welcome to the Video Admin Area </font></font></strong></p>
  <p><img src="modules/RN_Video/images/RN_Video.png" width="400" height="294" /></p>
  <p><strong><font color="#0000FF" size="5">Pick a Link above to get started    </font></strong><br />
    </p>
</div>
<hr width='80%' /><br />


<center>
<font size='1'>Page generated in <? $end=microtime();$lapsus=($end-$start); echo $lapsus; ?> seconds
<br />
</center>
</td>
  </tr>
</table>
<?
CloseTable();
include('footer.php');
    }
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                               Add Video                                                                                                                                                               //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function add_video() {
global $user,$cookie,$prefix,$nukeuser,$db,$prefix;   
cookiedecode($user);
    $username = $cookie[1];
   list($uid, $username) = explode(":", $nukeuser);
OpenTable();
?>
<br /><hr width='80%' />
<?
add_video_nav();
?>
  <table width="100%" style="border-collapse:collapse;">
    <tr>
      <td width="70%" valign="top">
        <center><br />
          <?
        // echo "Username = $username";
        // echo "UID = $uid";
        $user_id = $uid;
        echo "<font size='3' color='#0000ff'><b>Add New Video</b></font>";
echo "<form action='admin.php?op=add_video2' method='post'>";
echo "<font size='3'>TITLE</font>";
echo "<br />";;
echo "<input type='text' name='title' size='50' maxlength='50' />";
echo " <font color='#ff0000'>";
echo "<br />";
echo "50 char max</font>";
echo "<br /><br />";
echo "<font size='3'>YOUTUBE EMBED CODE</font>";
echo "<br />";
echo "<textarea cols='60' rows='7' name='code'></textarea>";
echo "<br /><br />";
echo "<font size='3'>Insert this video into category</font>";
echo "<br />";
$query="SELECT * FROM ".$prefix."_rnvideo_category ORDER BY catid DESC";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$catid=$row['catid'];
$category=$row['category'];
$or=1;
for($i=0; $i < count($category); $i++)
{
if($or > 6){echo "<br /><br />";$or=1;}
echo "<input type='radio' name='category' value='$category' />$category";
//echo "<input type='radio' name='category' value='$category[$i]'> ".strtoupper($category[$i])."";
echo "&nbsp; &nbsp; &nbsp;";

$or++;
}
}
echo "<br />";
echo "<input type='hidden' name='user_id' value='$user_id' />";
echo "<input type='hidden' name='action' value='Insert_Video' />";
echo "<br />";
echo "<center><input type='submit' value='Insert Video' /></center>";
echo "</form>";
?>
          </center>    </td>
    </tr>
  </table>     
<br /><hr width='80%' /><br />
<center>
<font size='1'>Page generated in <? $end=microtime();$lapsus=($end-$start); echo $lapsus; ?> seconds
<br />
<font color='#ff0000'><? $time=date("D, d M Y - H:i");echo $time; ?>  Server Time</font>
</center>
        </td>
 </tr>
</table>
<?
CloseTable();
include('footer.php');
    }    
      
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                                Add Video 2                                                                                                                                                            //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function add_video2() {
global $gid, $admingid,$db,$prefix;
include_once("header.php");
OpenTable();
$action=Sanitizer($_POST['action']);

if($action=="Insert_Video")
{
echo "<center>";
echo "<font size='3' color='#0000ff'><b>Attemping to Insert Video</b></font>";
echo "<br />";
echo "<br />";
 $title=Sanitizer($_POST['title']);
echo "<font size='3' color='#0000ff'><b>$title</b></font>";
echo "<br />";
echo "<br />";
if(empty($title))
{
echo "<center><font size='3' color='#0000ff'>You Forgot to add a Title</font><br /><br /><font size='3' color='#ff0000'><b>So Sorry...Try Again</b></font></center>";
edit_bottom_nav();
CloseTable();
include('footer.php');
}

if(strlen($title) > 50 )
{

echo "<center>TITLE SIZE TOO LARGE ( only titles of 50 chars. max. allowed )<br /><font color='#ff0000'><b>TRY AGAIN, PLEASE</b></font></center>";
edit_bottom_nav();
CloseTable();
include('footer.php');
}

 $censored_word= array('f***', 'bitch', 'whore', 'suck', 'harlot', 'cock', 'boobs', 'teats', 'ass', 'cunt');

if(in_array($title, $censored_word))
{
echo "<center><font size='3' color='#0000ff'>Censored word<br />Play Nice Please!</font><br /><br /><font size='3' color='#ff0000'><b>So Sorry...Try Again</b></font></center>";
edit_bottom_nav();
CloseTable();
include('footer.php');
}

for ($i = 0; $i < strlen($title); $i++)
{
if (!eregi("[- _ .  a-zA-Z0-9]" , $title[$i] ) )
{
echo "<center>";
echo "<font color='#ff0000'>WARNING !! INCORRECT TITLE</font>";
echo "<br />";
echo "<font size='3' color='#0000ff'>That is an Invalid symbol";
echo "<br />";
echo "<font size='4' color='#ff0000'><b>$title[$i]</b></font>";
echo " <br />";
echo "Only Letters and Numbers are allowed";
echo "<br /></center>";
edit_bottom_nav();
CloseTable();
include('footer.php');
}                                     
}
}
////////////////////////////// ADD VIDEO ERRORS ///////////////////////////////////////////
 $code=$_POST['code'];
$code= stristr($code, "http://www.youtube.com/v/");
// echo "<br />";
// echo "Code 2 = $code";
// echo "<br />";
$code= str_replace("http://www.youtube.com/v/","",$code);
$code= str_replace("&hl","",$code);


// echo "<br />";
// echo "Code 3 = $code";
// echo "<br />";



$code= explode('&amp;',$code);



// echo "<br />";
// echo "Code 4 = $code";
// echo "<br />";



$code=Sanitizer($code['0']);
$code2=Sanitizer($code['1']);
$category=Sanitizer($_POST['category']);
$video=Sanitizer($_POST['video']);


// echo "<br />";
// echo "Code 5-0 = $code";
// echo "<br />";
// echo "Code 5-1 = $code2";
// echo "<br />";
//edit_bottom_nav();
////////////////////////////// NO VIDEO SUBMITTED ///////////////////////////////////////////
if(empty($code))
{
echo "<center><font size='3' color='#0000ff'>You Forgot Something...<br />The Embed Code</font><br /><br /><font size='3' color='#ff0000'><b>So Sorry...Try Again</b></font></center>";
edit_bottom_nav();
CloseTable();
include('footer.php');
}
////////////////////////////// VIDEO ALREADY EXISTS ///////////////////////////////////////////



 

$query="SELECT video FROM ".$prefix."_rnvideo WHERE code='$code'";
$result=$db->sql_query($query);
if($db->sql_numrows($result)==1)
{
echo "<br /><br />";
echo "<center><font size='3' color='#0000ff'>Video Already Exists<br />Sorry Dude</font><br /><br /><font size='3' color='#ff0000'><b>Please Try Again</b></font></center>";
edit_bottom_nav();
CloseTable();
include('footer.php');
}



 

////////////////////////////// NO CATEGORY ///////////////////////////////////////////
$category=Sanitizer($_POST['category']);

if(empty($category))
{
echo "<center><font size='3' color='#0000ff'>No Category Selected<br />You MUST pick a Category</font><br /><br /><font size='3' color='#ff0000'><b>So Sorry...Try Again</b></font></center>";
edit_bottom_nav();
CloseTable();
include('footer.php');
}
////////////////////////////// NO CATEGORY ///////////////////////////////////////////
 $query="SELECT * FROM ".$prefix."_rnvideo_category WHERE category='$category'";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$catid=$row['catid'];
//$category=$row['category'];
 }
 
 
 // echo "Category =$category";
  // echo "<br /><br />";
 // echo "Title = $title";
  // echo "<br /><br />";
 // echo "Code = $code";
  // echo "<br /><br />";





$query="SELECT * FROM ".$prefix."_rnvideo_category WHERE category='$category'";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$catid=$row['catid'];
$category=$row['category'];
 }
 $now = time();
  $user_id=Sanitizer($_POST['user_id']);
  // echo "User_Id = $user_id";
 // echo "CatID = $catid";
   // echo "<br /><br />";
 // echo "Category = $category";
   // echo "<br /><br />";
$queryup="INSERT INTO ".$prefix."_rnvideo SET category='$catid',title='$title',code='$code',time='$now',aut='1',user_id='$user_id'";
$resultup=$db->sql_query($queryup) or die(mysql_error());


echo "<br /><br />";
echo "<center><font size='3' color='#0000ff'>WOOT WOOT<br />New Video Inserted</font><br /><br /><font size='3' color='#ff0000'><b>Thank You for Sharing</b></font></center>";
edit_bottom_nav();
CloseTable();
include('footer.php');
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                                Edit VIDEO                                                                                                                                                            //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function edit_video() {
global $gid, $admingid,$db,$prefix,$uid,$username;
include_once("header.php");
OpenTable();
?>
<br /><hr width='80%' />
<?

// echo "User ID = $uid";
// $user_id = $uid;
add_video_nav();
$action=Sanitizer($_POST['action']);
$action= $_POST['action'];

if($action=="Disallow")
{
$video=$_POST['video'];

$query="UPDATE ".$prefix."_rnvideo SET aut='0' WHERE video='$video'";
$result=$db->sql_query($query) or die(mysql_error());
echo "<center>";
echo "<br /><br />";
echo "<font size='3'>Video number <b>$video</b> Has been Suspended</font>";
echo "<br /><br />";
edit_bottom_nav();
CloseTable();
include('footer.php');
}

if($action=="Readmit")
{
$video=$_POST['video'];

$query="UPDATE ".$prefix."_rnvideo SET aut='1' WHERE video='$video'";
$result=$db->sql_query($query) or die(mysql_error());


echo "<center>";
echo "<br /><br />";
echo "<font size='3'>Video number <b>$video</b> Has been Readmited</font>";
echo "<br /><br />";
edit_bottom_nav();
CloseTable();
include('footer.php');
}

if($action=="Delete_Video")
{
$video=$_POST['video'];

$query="DELETE FROM ".$prefix."_rnvideo WHERE video='$video'";
$result=$db->sql_query($query) or die(mysql_error());


echo "<br /><br />";
echo "<center><font size='3'>Video number <b>$video</b> Has been Deleted</font></center>";
echo "<br /><br />";
edit_bottom_nav();
CloseTable();
include('footer.php');
}
////////////////////// End Delete Video Video ///////////////////////////
////////////////////// Start Edit Video ///////////////////////////
if($action=="edit")
{
$video=$_POST['video'];
//echo $video;
?>
<br /><br />

<CENTER>
<TABLE width="100%" style="border-collapse:collapse;">
<TR>
<TD width="70%" valign="top">
<center>
<?
$query="SELECT * FROM ".$prefix."_rnvideo WHERE video=$video";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$video=$row['video'];
$category=$row['category'];
$title=$row['title'];
$code=$row['code'];
$counter=$row['counter'];
$aut=$row['aut'];
}
//echo $code;
echo "<font size='3' color='#0000ff'><b>Editing Video #$video<br />$title</b></font>";
echo "<br />";
//echo "<font size='3'><b>Category $category</b></font>";
//echo "<br />";
echo "<form action='modules.php?name=RN_Video&amp;file=user_admin&amp;op=user_edit_video3' method='post'>";
echo "<font size='3'>Title</font><br />";
echo "<input type='hidden' name='video' value='$video'";
echo "TITLE";
echo "<br />";
echo "<input type='text' name='title' size='30' maxlength='50' value='$title' />";
echo " <font color='#ff0000'>";
echo "<br />";
echo "50 char max</font>";
echo "<br /><br />";
echo "<font size='3'>Paste YouTube Embed Code Below</font>";
echo "<br />";
echo "<textarea cols='60' rows='7' name='code'>$code</textarea>";
echo "<br /><br />";
echo " <font size='3'>Insert this video into category</font>";
echo "<br />";
$category2=$category;
//echo "Category 2_1 = $category";
$query="SELECT * FROM ".$prefix."_rnvideo_category ORDER BY catid DESC";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$catid=$row['catid'];
$category=$row['category'];
$or=1;
for($i=0; $i < count($category); $i++)
{
if($or > 6){echo "<br /><br />";$or=1;}
echo "<input type='radio' name='category' value='$category' />";
if ($category2==$catid){
echo "checked";
}
echo "><font size='3'>$category</font>";
echo "&nbsp; &nbsp; &nbsp;";

$or++;
}
}

echo "<br />";
//echo $video;
echo "<input type='hidden' name='video' value='$video' />";
echo "<input type='hidden' name='action' value='Insert_Video' />";
echo "<br />";
echo "<center><input type='submit' value='Edit Video' /></center>";
echo "</form>";
?>
</center>
</TD>
</TR>
</TABLE>
</CENTER>
<br /><hr width='80%' /><br />
</td>
  </tr>
</table>

<?
edit_bottom_nav();
CloseTable();
include('footer.php');
    }
////////////////////// Start Edit Video ///////////////////////////



// echo "User ID = $uid";
$user_id = $uid;
// echo "User ID = $user_id";
$query="SELECT video FROM ".$prefix."_rnvideo ORDER BY video DESC";
$result= $db->sql_query($query);
$rows=$db->sql_numrows($result);

$ppp=10;
$nop= ceil($rows / $ppp);

echo "<p><font size='2'>Page : </font>";
for ($i = 1 ; $i <= $nop ; $i++)
{
echo "&nbsp;<a href='./admin.php?op=admin_video_main&amp;op=edit_video&amp;page=$i'><font size=2> $i </font></a>&nbsp;";
}
echo "</p>";

if (isset($_GET['page'])){$page = $_GET['page'];}else{$page = 1;}

$start= ($page - 1) * $ppp;

$query="SELECT * FROM ".$prefix."_rnvideo ORDER BY video DESC LIMIT $start,$ppp";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{

$video=$row['video'];
$category=$row['category'];
$title=$row['title'];
$code=$row['code'];
$counter=$row['counter'];
$aut=$row['aut'];

$query2="SELECT * FROM ".$prefix."_rnvideo_category WHERE catid='$category'";
$result2=$db->sql_query($query2);
while($row2=$db->sql_fetchrow($result2))
{
$category2=$row2['category'];
}
?>
<div align="center">
<TABLE width='90%' border='1' bordercolor='#0000ff' style='border-collapse:collapse;' cellpadding='5'>
<TR>
<TD width='20%' valign='middle'>
<center>
<a href="modules.php?name=RN_Video&amp;file=most_player&amp;video=<? echo $video; ?>" rel="gb_page_center[640, 425]" title="<? echo $title; ?>" rev="width: 700px; height: 410px; scrolling: no;">Video ID<font color='#ff0000'><? echo $video; ?></a>
</TD>

<TD width='70%' valign='middle'>
<center>
<table border='0' bordercolor='#0000ff' style='border-collapse:collapse;'>
<tr>
<td valign="middle">
<center>

<a href="modules.php?name=RN_Video&amp;file=most_player&amp;video=<? echo $video; ?>" rel="gb_page_center[640, 425]" title="<? echo $title; ?>" rev="width: 700px; height: 410px; scrolling: no;">

<?
echo "Title = ".strtoupper($title)."";

echo "<br />";
echo "<br />";
for($i=1;$i < 5;$i++)
{
if(file_get_contents("http://i$i.ytimg.com/vi/$code/default.jpg"))
{
?>
<a href="modules.php?name=RN_Video&amp;file=most_player&amp;video=<? echo $video; ?>" rel="gb_page_center[640, 425]" title="<? echo $title; ?>" rev="width: 700px; height: 410px; scrolling: no;"><img src='http://i<? echo $i; ?>.ytimg.com/vi/<? echo $code; ?>/default.jpg' width='175' /></a>
<?
echo "<br />";
echo "<br />";
echo "CatID= $category";
echo "<br />";
echo "Category = $category2";
echo "<br />";
Break;
}
}
?>
<br />
<font size='2' color='#ff0000'><b><? echo $counter; ?></b></font> <font size='2'>Views
</a>
</td></tr></table>
</TD>

<?if($aut==1){?>

<TD>
<center>
<form action='admin.php?op=edit_video&amp;action=Disallow' method='post'>
<input type='hidden' name='action' value='Disallow' />
<input type='hidden' name='video' value='<? echo $video; ?>' />
<input type='submit' name='submit' value='Disallow' />
</form>
</center>
</TD>
<?}else{?>
<TD>
<center>
<form action='admin.php?op=edit_video&amp;action=Readmit' method='post'>
<input type='hidden' name='action' value='Readmit' />
<input type='hidden' name='video' value='<? echo $video; ?>' />
<input type='submit' name='submit' value='Readmit' />
</form>
</center>
</TD>
<?}?>
<TD>
<center>
<form action='admin.php?op=edit_video&amp;action=edit' method='post'>
<input type='hidden' name='action' value='edit' />
<input type='hidden' name='video' value='<? echo $video; ?>' />
<input type='submit' name='submit' value='edit' />
</form>
</center>
</TD>

<TD>
<center>
<form action='admin.php?op=edit_video&amp;action=Delete' method='post'>
<input type='hidden' name='action' value='Delete_Video' />
<input type='hidden' name='video' value='<? echo $video; ?>' />
<input type='submit' name='submit' value='Delete' />
</form>
</center>
</TD>
</TR>
</TABLE>
</div>

<br />
<?
}

echo "<p>";
echo "Page ";
for ($i = 1 ; $i <= $nop ; $i++)
{
echo "&nbsp;<a href='./admin_edit_videos.php?page=$i'><font size=2> $i </font></a>&nbsp;";
}
echo "</p>";
?>
<br /><hr width='80%' /><br />

<center>
<font size='1'>Page generated in <? $end=microtime();$lapsus=($end-$start); echo $lapsus; ?> seconds
<br />
<font color='#ff0000'><? $time=date("D, d M Y - H:i");echo $time; ?>  Server Time</font>
</center>
<?
CloseTable();
include('footer.php');
    }
////////////////////// End Edit Video ///////////////////////////
////////////////////// End Edit Video 2///////////////////////////
 function edit_video2() {
global $user,$cookie,$prefix,$nukeuser,$db,$prefix;   
cookiedecode($user);
    $username = $cookie[1];
   list($uid, $username) = explode(":", $nukeuser);

?>
<br /><hr width='80%' />
<?
user_add_video_nav();
?>
  <table width="100%" style="border-collapse:collapse;">
    <tr>
      <td width="70%" valign="top">
        <center><br />
          <?
        echo "Username = $username";
        echo "UID = $uid";
        $user_id = $uid;
echo "<form action='modules.php?name=RN_Video&amp;file=user_admin&amp;op=user_edit_video3' method='post'>";
echo "<font size='3'>TITLE</font>";
echo "<br />";;
echo "<input type='text' name='title' size='50' maxlength='50' />";
echo " <font color='#ff0000'>";
echo "<br />";
echo "50 char max</font>";
echo "<br /><br />";
echo "<font size='3'>YOUTUBE EMBED CODE</font>";
echo "<br />";
echo "<textarea cols='60' rows='7' name='code'></textarea>";
echo "<br /><br />";
echo "<font size='3'>Insert this video into category</font>";
echo "<br />";
$query="SELECT * FROM ".$prefix."_rnvideo_category ORDER BY catid DESC";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$catid=$row['catid'];
$category=$row['category'];
$or=1;
for($i=0; $i < count($category); $i++)
{
if($or > 6){echo "<br /><br />";$or=1;}
echo "<input type='radio' name='category' value='$category'>$category";
//echo "<input type='radio' name='category' value='$category[$i]'> ".strtoupper($category[$i])."";
echo "&nbsp; &nbsp; &nbsp;";

$or++;
}
}
echo "<br />";
echo "<input type='hidden' name='user_id' value='$user_id' />";
echo "<input type='hidden' name='action' value='Insert_Video' />";
echo "<br />";
echo "<center><input type='submit' value='Insert Video' /></center>";
echo "</form>";
?>
          </center>    </td>
    </tr>
  </table>     
<br /><hr width='80%' /><br />
<center>
<font size='1'>Page generated in <? $end=microtime();$lapsus=($end-$start); echo $lapsus; ?> seconds
<br />
<font color='#ff0000'><? $time=date("D, d M Y - H:i");echo $time; ?>  Server Time</font>
</center>
        </td>
 </tr>
</table>
<?
CloseTable();
include('footer.php');
    }
    ////////////////////// End Edit Video 2///////////////////////////
    ////////////////////// End Edit Video 3///////////////////////////
 function edit_video3() {
global $user,$cookie,$prefix,$nukeuser,$db,$prefix;   
cookiedecode($user);
    $username = $cookie[1];
   list($uid, $username) = explode(":", $nukeuser);
include_once("header.php");
   $code=$_POST['code'];
      // $code=Sanitizer($code);
   $title=$_POST['title'];
      $title=Sanitizer($title);
   $catid=$_POST['catid'];
      $catid=Sanitizer($catid);
   $video=$_POST['video'];
      $video=Sanitizer($video);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  This needs to be looked at.  Running strister on Code before sanitizer has been through it
if(stristr($code, 'http://www.youtube.com/v/') === FALSE) {
   // $code=$_POST['code'];
      //$code=Sanitizer($code);
//echo "Code1= $code";
$query="SELECT video FROM ".$prefix."_rnvideo WHERE code='$code'";
$result=$db->sql_query($query);
if(mysql_numrows($result)==1)
{

 $catid=Sanitizer($_POST['catid']);
 $category=Sanitizer($_POST['category']);
 $video=Sanitizer($_POST['video']);
 
$query="SELECT * FROM ".$prefix."_rnvideo_category WHERE category='$category'";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$catid=$row['catid'];
$category=$row['category'];
 }
     $now = time();
   // echo "Time = $now";
$queryup="UPDATE ".$prefix."_rnvideo SET category='$catid', title='$title', code='$code', time='$now' WHERE video='$video'";
$resultup=$db->sql_query($queryup) or die(mysql_error());
echo "<center>";
echo "<br /><br />";
echo "<center><font size='3' color='#0000ff'><b>VIDEO $title Edited</b></font><br /><br /><font size='3' color='#ff0000'><b>Thank you for sharing</b></font></center>";
edit_bottom_nav();
CloseTable();
include('footer.php');
}
}
   ///////////////////////////////////////////////////////// END  IF /////////////////////////////////////////////////////


 $code=$_POST['code'];

$code= stristr($code, "http://www.youtube.com/v/");



// echo "<br />";
// echo "Code 2 = $code";
// echo "<br />";




$code= str_replace("http://www.youtube.com/v/","",$code);



echo "<br />";
echo "Code 3 = $code";
echo "<br />";



$code= explode('&amp;',$code);



echo "<br />";
echo "Code 4 = $code";
echo "<br />";



$code=Sanitizer($code['0']);
// echo "Code = $code";
 ///////////////////////////////////////////////////////// END IF /////////////////////////////////////////////////////
 
 
 
$category=Sanitizer($_POST['category']);




 echo "Category =$category";
  echo "<br /><br />";
 echo "Title = $title";
  echo "<br /><br />";
 echo "Code = $code";
   echo "<br /><br />";
 echo "Category = $category";
   echo "<br /><br />";
echo "Line 160 Code= $code";
   echo "<br /><br />";
   echo "video = $video";


$query="SELECT video FROM ".$prefix."_rnvideo WHERE video='$video'";
$result=$db->sql_query($query);
if($db->sql_numrows($result)==1)
{








   echo "<br /><br />";
 echo "CatID = $cat_table";
   echo "<br /><br />";
 echo "CatID = $category";
   echo "<br /><br />";
 $query="SELECT * FROM ".$prefix."_rnvideo_category WHERE category='$category'";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$catid=$row['catid'];
//$category=$row['category'];
 }
    echo "<br /><br />";
 echo "CatID = $catid";
   echo "<br /><br />";
    echo "Category = $category";
    $now = time();
   // echo "Time = $now";
$queryup="UPDATE ".$prefix."_rnvideo SET category='$catid', title='$title', code='$code',time='$now' WHERE video='$video'";
$resultup=$db->sql_query($queryup) or die(mysql_error());
echo "<br /><br />";
echo "<a href='admin_add_video.php'><font color='#ff0000'><b>Add A Video</b></font></a>";
echo "<br /><br />";
echo "<a href='admin_edit_videos.php'><font color='#ff0000'><b>Edit A Video</b></font></a>";
echo "<br /><br />";
echo "<a href='admin_main.php'><font color='#ff0000'><b>Return to Main Admin Page</b></font></a>";
echo "</center>";
}
CloseTable();
include('footer.php');
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            Category Admin                                                                                                                                                          //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   
function admin_category_display() {
global $gid, $admingid,$db,$prefix;
include_once("header.php");
OpenTable();
?>
<center>
<br />
<font size="3" color = "#0000ff"><b>Edit Categories Administration Page</b></font>
<br /><br />
</center>
<?
add_video_nav();
?>
<br /><hr width='80%' /><br />

<?
$query="SELECT category FROM ".$prefix."_rnvideo_category ORDER BY catid DESC";
$result= $db->sql_query($query);
$rows=$db->sql_numrows($result);


$query="SELECT * FROM ".$prefix."_rnvideo_category ORDER BY catid DESC";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$video=$row['catid'];
$category=$row['category'];
?>
<TABLE width='90%' align = 'center' border='1' bordercolor='#0000ff' style='border-collapse:collapse;' cellpadding='5'>
<TR>
<TD width='20%' valign='middle'>
<center>
<font size="3" color = "#0000ff"><b><? echo $category; ?></b></font>
<br /><font size="1"><b>Category #
<? echo $video; ?></b></font>
</TD>



<TD width='20%' valign='middle'>
<center>
<form action='admin.php?op=admin_category_edit' method='post'>
<input type='hidden' name='action' value='edit_category' />
<input type='hidden' name='category' value='<? echo $category; ?>' />
<input type='submit' name='submit' value='edit' />
</form>
</center>
</TD>

<TD width='20%' valign='middle'>
<center>
<form action='admin.php?op=admin_category_delete' method='post'>
<input type='hidden' name='action' value='Delete_category' />
<input type='hidden' name='category' value='<? echo $category; ?>' />
<input type='submit' name='submit' value='Delete' />
</form>
</center>
</TD>
</TR>
</TABLE>
</CENTER>

<br />
<?
}


?>
<br /><hr width='80%' /><br />

<center>
<font size='1'>Page generated in <? $end=microtime();$lapsus=($end-$start); echo $lapsus; ?> seconds
<br />
<font color='#ff0000'><? $time=date("D, d M Y - H:i");echo $time; ?>  Server Time</font>
</center>
<?
CloseTable();
include('footer.php');
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            Category Admin Edit                                                                                                                                                          //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   
///////////////////////////FUNCTION DELETE CATEGORY////////////////////////////////////////////////////////
function admin_category_delete()

   global $admin, $bgcolor2, $prefix, $db,$user,$cookie,$nukeuser;   
include_once("header.php");
OpenTable();
?>
<center>
<br />
<font size="3" color = "#0000ff"><b>Delete Category Administration Page</b></font>
<br /><br />
</center>
<?
add_video_nav();
$action=Sanitizer($_POST['action']);
if($action=="Delete_category")
{
$category=$_POST['category'];
//echo $category;
$query="DELETE FROM ".$prefix."_rnvideo_category WHERE category='$category'";
$result=$db->sql_query($query) or die(mysql_error());

echo "<center>";
echo "<br /><br />";
echo "<font size='3' color='#0000ff'>Category <b>$category</b> Has been Deleted</font>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_category_add'><font color='#ff0000'><b>Add a Category</b></font></a>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_category_display'><font color='#ff0000'><b>Edit Categories</b></font></a>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_category_display'><font color='#ff0000'><b>Category Admin Page</b></font></a>";
echo "</center>";
}

CloseTable();
include('footer.php');
}

///////////////////////////FUNCTION Edit Categories////////////////////////////////////////////////////////
function admin_category_edit()

   global $admin, $bgcolor2, $prefix, $db,$user,$cookie,$nukeuser;   
include_once("header.php");
OpenTable();
?>
<center>
<br />
<font size="3" color = "#0000ff"><b>Edit Category Administration Page</b></font>
<br /><br />
</center>
<?
add_video_nav();
echo "<br /><hr color='#0000ff' width='80%'><br />";
$action=Sanitizer($_POST['action']);
if($action=="edit_category")
{
$category=$_POST['category'];
$query="SELECT * FROM ".$prefix."_rnvideo_category WHERE category='$category'";
$result=$db->sql_query($query);
while($row=$db->sql_fetchrow($result))
{
$catid=$row['catid'];
$category=$row['category'];
}
//echo $catid;
echo "<form action='admin.php?op=admin_category_edit2' method='post'><center>";
echo "<font size='3' color='#0000ff'><b>Edit Category</b></font>";
echo "<br /><br />";
echo "<input type='text' name='category' size='50' maxlength='50' value='$category' />";
echo "<br /><font size='2' color='#ff0000'><b>50 char max</b></font><br />";
echo "<input type='hidden' name='action' value='Edit_Category2' />";
echo "<input type='hidden' name='catid' value='$catid' />";
echo "<br />";
echo "<center><input type='submit' value='Edit Category' /></center>";
echo "</form>";
echo "<br /><hr color='#0000ff' width='80%'><br />";
}
CloseTable();
include('footer.php');

}
///////////////////////////FUNCTION Edit Category2////////////////////////////////////////////////////////
function admin_category_edit2()

   global $admin, $bgcolor2, $prefix, $db,$user,$cookie,$nukeuser;   
include_once("header.php");
OpenTable();
?>
<center>
<br />
<font size="3" color = "#0000ff"><b>Edit Category Administration Page</b></font>
<br /><br />
</center>
<?
add_video_nav();
echo "<br /><hr color='#0000ff' width='80%'><br />";
$action=Sanitizer($_POST['action']);
if($action=="Edit_Category2")
{
//echo $action;
$category=$_POST['category'];
$catid=$_POST['catid'];
// echo "<br />";
// echo "Category = $category";
// echo "<br />";
// echo "CatID = $catid";
// echo "<br />";
$query="UPDATE ".$prefix."_rnvideo_category SET `category` = '$category' WHERE `catid` =$catid";
$result=$db->sql_query($query);

while($row=$db->sql_fetchrow($result))
{
$catid=$row['catid'];
$category=$row['category'];
}
echo "<center>";
echo "<font size='3' color='#0000ff'>Category <b>$category</b> Has been Edited</font>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_category_add'><font color='#ff0000'><b>Add a Category</b></font></a>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_category_display'><font color='#ff0000'><b>Edit Categories</b></font></a>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_category_display'><font color='#ff0000'><b>Category Admin Page</b></font></a>";
echo "</center>";
echo "<br /><hr color='#0000ff' width='80%'><br />";
}
CloseTable();
include('footer.php');

}
   
///////////////////////////Function ADD Category////////////////////////////////////////////////////////   
function admin_category_add()

   global $admin, $bgcolor2, $prefix, $db,$user,$cookie,$nukeuser;   
include_once("header.php");
OpenTable();
?>
<center>
<br />
<font size="3" color = "#0000ff"><b>Add Category Administration Page</b></font>
<br /><br />
</center>
<?
add_video_nav();
?>

<br /><hr width='80%' /><br />
   
  <TABLE width="100%" style="border-collapse:collapse;">
    <TR>
      <TD width="70%" valign="top">
        <center>
          <?
echo "<form action='admin.php?op=admin_category_add2' method='post'>";
echo "<font size='3' color='#0000ff'><b>Add Category</b></font>";
echo "<br />";;
echo "<input type='text' name='category' size='50' maxlength='50' />";
echo "<br /><font size='2' color='#ff0000'><b>50 char max</b></font><br />";
echo "<input type='hidden' name='action' value='Insert_Category' />";
echo "<br />";
echo "<center><input type='submit' value='Insert Category' /></center>";
echo "</form>";
?>
</center>
</TD>
</TR>
  </TABLE>
  <br /><hr width='80%' /><br />
<?

CloseTable();
include('footer.php');
}

///////////////////////////Function ADD Category2////////////////////////////////////////////////////////   
function admin_category_add2()

   global $admin, $bgcolor2, $prefix, $db,$user,$cookie,$nukeuser;   
include_once("header.php");
OpenTable();
?>
<center>
<br />
<font size="3" color = "#0000ff"><b>Insert Category Administration Page</b></font>
<br /><br />
</center>
<?
add_video_nav();
?>

<br /><hr width='80%' /><br />
  <?

$action=Sanitizer($_POST['action']);
$category=Sanitizer($_POST['category']);
//echo $action;
if($action=="Insert_Category")
{
echo "<center>";
echo "<font size='3' color='#0000ff'><b>$action</b></font>";
echo "<br />";
echo "<br />";
echo "<font size='3' color='#0000ff'><b>$category</b></font>";
echo "<br />";
echo "<br />";
if(empty($category))
{
echo "<font size='3' color='#0000ff'><b>NO TITLE SUBMITTED.<br />";
echo "<a href='admin.php?op=admin_category_add'><font size='3' color='#ff0000'><b>TRY AGAIN, PLEASE</b></font></a>";
echo "</center>";
CloseTable();
include('footer.php');
}

if(strlen($category) > 50 )
{
echo "<font size='3' color='#0000ff'><b>Catregory SIZE TOO LARGE ( only titles of 50 chars. max. allowed )</b></font><br />";
echo "<a href='admin.php?op=admin_category_add'><font size='3' color='#ff0000'><b>TRY AGAIN, PLEASE</b></font></a>";
echo "</center>";
CloseTable();
include('footer.php');
}

 $censored_word= array('f***', 'bitch', 'whore', 'suck', 'harlot', 'cock', 'boobs', 'teats', 'ass', 'cunt');

if(in_array($category, $censored_word))
{
echo "<font size='3' color='#0000ff'><b>Censored word.</b></font><br />";
echo "<a href='admin.php?op=admin_category_add'><font size='3' color='#ff0000'><b>TRY AGAIN, PLEASE</b></font></a>";
echo "</center>";
CloseTable();
include('footer.php');
}

for ($i = 0; $i < strlen($category); $i++)
{
if (!eregi("[- _ .  a-zA-Z0-9]" , $category[$i] ) )
{
echo "<center>";
echo "<font size='3' color='#0000ff'><b>WARNING !! INCORRECT TITLE</b></font>";
echo "<br />";
echo "<font size='3' color='#0000ff'><b>That is an Invalid symbol</b></font>";
echo "<br />";
echo "<font size='3' color='#0000ff'><b>$category[$i]</b></font>";
echo " <br />";
echo "<font size='3' color='#0000ff'><b>Only Letters and Numbers are allowed</b></font>";
echo "<br />";
echo "<a href='admin.php?op=admin_category_add'><font size='3' color='#ff0000'>TRY AGAIN PLEASE</font></a></font>";
echo "</center>";
CloseTable();
include('footer.php');
}                                     
}


//Insertimg cat into database
$queryup="INSERT INTO ".$prefix."_rnvideo_category VALUES('null', '$category')";
$resultup=$db->sql_query($queryup) or die(mysql_error());
echo "<font size='3' color='#0000ff'><b>Category $category INSERTED</b></font><br /><br />";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_category_add'><font color='#ff0000'><b>Add a Category</b></font></a>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_category_display'><font color='#ff0000'><b>Edit Categories</b></font></a>";
echo "<br /><br />";
echo "<a href='admin.php?op=admin_category_display'><font color='#ff0000'><b>Category Admin Page</b></font></a>";
echo "</center>";
CloseTable();
include('footer.php');
}
}

?>
 
Dawg







PostPosted: Tue Aug 10, 2010 4:45 am Reply with quote

Palbin

Did that fix that for you?

Dawg
 
Palbin







PostPosted: Tue Aug 10, 2010 5:01 am Reply with quote

I'll try it tonight if I remember Wink.
 
Dawg







PostPosted: Tue Aug 10, 2010 5:11 am Reply with quote

Thank You for the help.

What I am really interested in is the Santizer code and making sure I am cleaning everything right before I put it in the database.

Again Thank You for the help!

Dave
 
Palbin







PostPosted: Tue Aug 10, 2010 4:52 pm Reply with quote

Found the problem. You should be using < ?php ? > instead of < ? ? >. Some people my disagree with me, but I would sugest to people not to do this at all. Simply just echo the html out.

I know you are still working on this, but you really need to indent you code better. It is just about impossible to follow.

I'm still having problems will report back later.
 
Dawg







PostPosted: Tue Aug 10, 2010 5:19 pm Reply with quote

Palbin wrote:
Found the problem. You should be using < ?php ? > instead of < ? ? >. Some people my disagree with me, but I would sugest to people not to do this at all. Simply just echo the html out.

I know you are still working on this, but you really need to indent you code better. It is just about impossible to follow.

I'm still having problems will report back later.


Thank You for any and all feedback.

Give me a few mins and I will indent it correctly....or so I think...

Dawg
 
Palbin







PostPosted: Tue Aug 10, 2010 6:40 pm Reply with quote

First thing is that you should not have case statements for "utility functions" like Sanitizer. I'm only going to mention few things to get you started ,and we can refine it later once you have made corrections, removed unneeded code and functions, and general code clean up.

1. I do not think you should be using a function to "generally" filter your variables. You should just validate them as you use them.

2. You need to read this article about MagicQuotes. http://www.tizag.com/phpT/php-magic-quotes.php

3. Instead of strip_tags use the following instead. It will take care of conditionally removing MagicQuotes as discussed above.
Code:
$somevar = check_html($_post['somevar'], 'nohtml');


4. You do not have to do check_html() on every variable. If it is supposed to be a number just use intval() on it. If it is not an integer it will return 0.

5. htmlentites and htmlspecialchars can get a little tricky, but generally speaking you should only be using these when displaying info on the screen. Either from the user or from the database.

6. addslashes() should only be used when variables are being inserted or used to query the database. You should not do this to variables you are displaying on the screen. You would have to addslashes later if you are doing both.


I hope you got all that Wink If not just ask and later on we can dig a little deeper.
 
Dawg







PostPosted: Wed Aug 11, 2010 10:25 pm Reply with quote

Palbin,

Thank You for your time.

I will take a week or so for me to digest this....Thank You for helping me learn!

Dawg
 
Dawg







PostPosted: Sun Aug 22, 2010 5:16 am Reply with quote

Palbin,


Palbin wrote:

you really need to indent you code better. It is just about impossible to follow.


I worked my way through the main index...and indented the code. I could not really find ANYTHING that said do this like XYZ....so I tried to go about it in a logical fashion....

If I did not get it right...PLEASE CORRECT ME...Show me right and I will do it right.


You talked about the <? and ?> so I changed all of them to <?php

I am still opening and closing....but once we hit the end of all of this....I will go through and echo everything. To me it is easier to write it this way so that when I make changes I can test the code real easy.


Code:
<?php

/**********************************************/
/* RN Video by Dawg
/* Version 1.0 Beta
/* This should NOT be used in Production Sites
/*Help and Support at http://www.ravenphpscripts.com
/**********************************************/


if ( !defined('MODULE_FILE') )
   {
      die('You can\'t access this file directly...');
   }

require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$index = 0;
$hideleft=1;
$admingid= '25'; //(The number of posts before people can add videos)
include('header.php');
global $user,$cookie,$prefix,$nukeuser,$db,$prefix;   
cookiedecode($user);
$username = $cookie[1];

if ($username == "")
   {
      $username = "Anonymous";
   }
         
if (is_user($user))
   {
      list($uid, $username) = explode(":", $nukeuser);
      $querystr = "SELECT user_posts FROM ".$prefix."_users WHERE user_id=$uid" ;
      $result = $db->sql_query($querystr) ;
      if (!$result)
         {
            echo 'Could not run query: ' . mysql_error();
            exit;
         }
      $row = mysql_fetch_row($result);
      $postcount = $row[0];
      echo $postcount;
   }
if (!isset($op)) $op = '';

switch($op)
   {
      default:
         display_video();
      break;
      case list_video:
         list_video();
      break;
      case list_single_category:
         list_single_category();
      break;
      case video_admin_menu:
         video_admin_menu();
      break;
   }
die();
///////////////////////////////////////// START ADMIN MENU /////////////////////////////////
function video_admin_menu()
   {
      global $postcount, $admingid,$db,$prefix;
      ?>
      <br />
      <center>
      <a href='modules.php?name=RN_Video&file=user_admin&op=user_add_video_main'><font size='3'>User Video Admin</font></a>
      &nbsp;|&nbsp;
      <a href='modules.php?name=RN_Video&file=user_admin&op=user_add_video'><font size='3'>Add Video</font></a>
      &nbsp;|&nbsp;
      <a href='modules.php?name=RN_Video&file=user_admin&op=user_edit_video'><font size='3'>Edit YOUR Videos</font></a>
      &nbsp;|&nbsp;
      <a href='modules.php?name=RN_Video&file=user_admin&op=user_edit_video'><font size='3' color='#ff0000'>Delete YOUR Videos</font></a>
      </center>
      <br />
      <?php
   }
///////////////////////////////////////// FINISH ADMIN MENU /////////////////////////////////

///////////////////////////////////////// START NAV MENU /////////////////////////////////
function nav_video()
   {
      global $postcount, $admingid,$db,$prefix;
      if ($postcount>=$admingid)
         {
            video_admin_menu();
         }
      ?>
      <br />
      <center>
      <a href='modules.php?name=RN_Video'><font size='3'>Video Home</font></a>
      &nbsp;|&nbsp;
      <a href='modules.php?name=RN_Video&op=list_single_category'><font size='3'>List Single Category</font></a>
      &nbsp;|&nbsp;
      <a href='modules.php?name=RN_Video&op=list_video'><font size='3' color='#ff0000'>Category View</font></a>
      </center>
      <?php
   }
///////////////////////////////////////// FINISH NAV MENU /////////////////////////////////

///////////////////////////////////////// Start MOST RECENT /////////////////////////////////
function display_video()
   {
      OpenTable3();
      global $user,$cookie,$prefix,$nukeuser,$db,$prefix;
      ?>
      <center>
      <br /><font size='6' color='#0000ff'>Most Recent Videos</font><br />
      </center>
      <?php
      nav_video();
      ?>
      <br /><hr color="#0000ff" width='80%'><br />
      <table width="100%">
      <tr>
      <?php
      $query ="SELECT video FROM ".$prefix."_rnvideo WHERE aut='1'";
      $result = $db->sql_query($query)
         or die ("invalid query in video display");
         //$result= $db->sql_query($query);
         $rows=$db->sql_numrows($result);
      //// Set number of Videos per page here
      $ppp=10;
      $nop= ceil($rows / $ppp);
      $z=0;
      echo "<td><p><font size='2'>Page : </font>";
      for ($i = 1 ; $i <= $nop ; $i++)
         {
            echo "&nbsp;&nbsp;<a href='/modules.php?name=RN_Video&page=$i'><font size=2> $i </font></a>&nbsp;";
         }
      echo "</p></td>";
      if (isset($_GET['page']))
         {
            $page = $_GET['page'];
         }
      else
         {
            $page = 1;
         }
      $start= ($page - 1) * $ppp;
      $ranking=0;
      $ranking=(($ranking+$ppp)*$page)-($ppp-1);
      $query="SELECT video,title,code,counter FROM ".$prefix."_rnvideo WHERE aut='1' ORDER BY time DESC LIMIT $start,$ppp";
         $result = $db->sql_query($query);
         while($row=$db->sql_fetchrow($result))
            {
               $video=$row['0'];
               $title=$row['1'];
               $code=$row['2'];
               $counter=$row['3'];
               if ($z % 2 != 1)
                  {
                     echo "<tr align='center'>";
                  }

               ?>
               <td><div align="center">
               <font size='3' color='#0000ff'><b><?php echo strtoupper($title); ?></b></font>
               <br /><br />
               <?php
               for($i=1;$i < 5;$i++)
                  {
                     if(file_get_contents("http://i$i.ytimg.com/vi/$code/default.jpg"))
                  {
                     ?>
                     <table><tr><td>
                     <a href="modules.php?name=RN_Video&file=most_player&video=<?php echo $video; ?>" rel="gb_page_center[640, 425]" title="<?php echo $title; ?>" rev="width: 700px; height: 410px; scrolling: no;"><img src='http://i<?php echo $i; ?>.ytimg.com/vi/<?php echo $code; ?>/default.jpg' width='175' /></a>
                     </td></tr></table>
                     <?php
                     Break;
                  }
                  }
               ?>
               <font size='3' color='#0000ff'>Views </font><font size='3' color='#ff0000'><b><?php echo $counter; ?></b></font>
               &nbsp; | &nbsp;
               <font size='3' color='#0000ff'>Ranking </font><font size='3' color='#ff0000'><b><?php echo $ranking; ?></b></font><br /><hr color="#0000ff" width='80%'><br />
               </div></td>
               <?php
               $z++;
               $ranking++;
            }

      ?>
      </tr></table>
      <br /><hr  width="80%" size="5" color="#0000ff"><br />
      <?php
      CloseTable3();
      include('footer.php');
   }
///////////////////////////////////////// END VIDEO DISPLAY /////////////////////////////////


///////////////////////////////////////// Start List Categories /////////////////////////////////
function list_video()
   {
      OpenTable3();
      global $user,$cookie,$prefix,$nukeuser,$db,$prefix;
      ?>
      <center>
      <br /><font size='6' color='#0000ff'>List All Categories</font><br />
      </center>
      <?php
      nav_video();
      ?>
      <br /><hr color="#0000ff" width='80%'><br />
      <table width='80%' align='center'>
      <tr>
      <?php
      $sql = "SELECT uid, uname FROM nuke_users";
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $result = $db->sql_query("SELECT * FROM ".$prefix."_rnvideo_category");
      while($myrow = $db->sql_fetchrow($result))
         {
            $catid=$myrow[0];
            $category=$myrow[1];
            echo "<td valign='top' align='center' width='200'>";
            echo "<br /><font size='4' color='#0000ff'>$category</font><br /><br />";
            echo "<hr width='80%' size='3' />";
            $result2 = $db->sql_query("SELECT video,category,title,code,counter FROM ".$prefix."_rnvideo WHERE aut='1' AND category='$catid' ORDER BY time DESC");
            while($myrow2 = $db->sql_fetchrow($result2))
               {
                  $video=$myrow2[0];
                  $category=$myrow2[1];
                  $title=$myrow2[2];
                  echo "<font size='3' color='#0000ff'><b>$title</b></font>";
                  echo "<br />";
                  $code=$myrow2[3];
                  $counter=$myrow2[4];
                  echo "<br />";
                  ?>
                  <a href="modules.php?name=RN_Video&file=most_player&video=<?php echo $video; ?>" rel="gb_page_center[640, 425]" title="<?php echo $title; ?>" rev="width: 700px; height: 410px; scrolling: no;"><img src='http://i<?php echo $i; ?>.ytimg.com/vi/<?php echo $code; ?>/default.jpg' width='200' /></a>
                  <?php
                  echo "<br />";
                  echo "Views $counter";
                  echo "<br />";
                  echo "<br />";
                  echo "<hr width='80%' size='3' />";
                  echo "<br />";
               }
            echo"</center></td>";
         }
      
      ?>
      </table><br /><hr color="#0000ff" width='80%'><br />
      <?php
      CloseTable3();
      include('footer.php');
   }
///////////////////////////////////////// End List Categories /////////////////////////////////

///////////////////////////////////////// Begin List Single Catergory/////////////////////////////////
function list_single_category()
   {
      OpenTable3();
      global $user,$cookie,$prefix,$nukeuser,$db,$prefix;
      ?>
      <center><br /><font size='6' color='#0000ff'>List Single Categories</font><br /></center>
      <?php
      nav_video();
      ?>
      <br /><hr color="#0000ff" width='80%'><br />
      <table width="100%">
      <tr>
      <?php
      ///// SET CATEGORY HERE BY ID
      $value="89";

      ///THIS NEEDS TO BE FIXED
      $query ="SELECT video FROM ".$prefix."_rnvideo WHERE aut='1' AND category='$value'";
      $result = $db->sql_query($query)
         or die ("invalid query in video display");
      $rows=$db->sql_numrows($result);
      // echo "ROWS = $rows";
      //// Set number of Videos per page here
      $ppp=10;
      $nop= ceil($rows / $ppp);
      // echo "NOP=$nop";
      $z=0;
      echo "<td><p><font size='2'>Page : </font>";
      for ($i = 1 ; $i <= $nop ; $i++)
         {
            echo "&nbsp;&nbsp;<a href='/modules.php?name=RN_Video&op=list_single_category&page=$i'><font size=2> $i </font></a>&nbsp;";
         }
      echo "</p></td>";
      if (isset($_GET['page']))
         {
            $page = $_GET['page'];
         }
      else
         {
         $page = 1;
         }
      $start= ($page - 1) * $ppp;
      $ranking=0;
      $ranking=(($ranking+$ppp)*$page)-($ppp-1);
      $query="SELECT video,title,code,counter FROM ".$prefix."_rnvideo WHERE aut='1' ORDER BY time DESC LIMIT $start,$ppp";
      $result = $db->sql_query($query);
      while($row=$db->sql_fetchrow($result))
         {
            $video=$row['0'];
            $title=$row['1'];
            $code=$row['2'];
            $counter=$row['3'];
            if ($z % 2 != 1)
               {
                  echo "<tr align='center'>";
               }
            ?>
            <td><div align="center">
            <?php
            echo "<font size='3' color='#0000ff'><b>$title</b></font>";
            echo "<br />";
            for($i=1;$i < 5;$i++)
               {
                  if(file_get_contents("http://i$i.ytimg.com/vi/$code/default.jpg"))
                     {
                        ?>
                        <table><tr><td>
                        <a href="modules.php?name=RN_Video&file=most_player&video=<?php echo $video; ?>" rel="gb_page_center[640, 425]" title="<?php echo $title; ?>" rev="width: 700px; height: 410px; scrolling: no;"><img src='http://i<?php echo $i; ?>.ytimg.com/vi/<?php echo $code; ?>/default.jpg' width='175' /></a>
                        </td></tr></table>
                        <?php
                        Break;
                     }
               }
            ?>
            <font size='3' color='#0000ff'>Views </font><font size='3' color='#ff0000'><b><?php echo $counter; ?></b></font>
            &nbsp; | &nbsp;
            <font size='3' color='#0000ff'>Ranking </font><font size='3' color='#ff0000'><b><?php echo $ranking; ?></b></font><br /><hr color="#0000ff" width='80%'><br />
            </div></td>
            <?php
            $z++;
            $ranking++;
         }
      ?>
      </tr></table>
      <br /><hr color="#0000ff" width='80%'><br />
      <?php
      CloseTable3();
      include('footer.php');
   }
///////////////////////////////////////// End List Single Catergory/////////////////////////////////
?>


Last edited by Dawg on Sun Aug 22, 2010 5:34 am; edited 1 time in total 
Dawg







PostPosted: Sun Aug 22, 2010 5:32 am Reply with quote

Palbin,
So now lets talk about MagicQuotes.

I read your link and it makes sence but before I dig into the next part I want to make sure I understand what you are saying.

If I read all this right....I should check to see if MagicQuotes is enabled....and if it is I need to run through stripslashes to get rid of the slashes....Is that correct?


Now we get to the tricky part....Cleaning the code before inserting it.

This is where I always hit a wall becasue I do not really know what I am checking for?

Here is a couple of examples of the main piece of the you tube puzzle...


ChwX__tdqQA
dw2h1qpeU1c
T8taFYpSJs4

This is not an interger....It can have CAPS....lower case.....numbers and symbols in it.

How do I check this or clean this?

I do not expect you to write code for me....A link will do fine...I want to make sure that I clean this code as good as I can to make sure none gets hacked because of something I wrote.

Thank You THANK YOU and thank you for your help!

Dawg
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sun Aug 22, 2010 7:14 am Reply with quote

Quote:

4. You do not have to do check_html() on every variable. If it is supposed to be a number just use intval() on it. If it is not an integer it will return 0.


Just to add slightly: you also need to make sure that an integer value of 0 doesn't cause a logic problem which also could do bad things. So, consider someone entering in text data in that field, as Palbin says, it will force the value to a 0. If you are not expressly handling that condition or the code and/or db data is such that a 0 could cause a different kind of failure (either immediate or downstream)... not good also.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Palbin







PostPosted: Sun Aug 22, 2010 11:05 am Reply with quote

Dawg wrote:
Palbin,
If I read all this right....I should check to see if MagicQuotes is enabled....and if it is I need to run through stripslashes to get rid of the slashes....Is that correct?


Yes, but if you use check_html() it takes care of the slashes for you if they are enabled. This is important to not because if you strip slashes twice you could be removing legitimate ones (not that you have any).

Basically if you are displaying submitted text or inserting it into the db you should be running check_html() on it. So typically a person would be using check_html() so they would not have to worry about stripping slashes, but you need to be aware for when specific cases come up.

As I said above if you are expecting a certain variable to be a number only you do not have to worry about slashes or check_html() because when you do intval() if one of those characters exist it will return 0.

PHP as some built in functions that can also be used to filter.validate your data.
http://www.php.net/manual/en/ref.var.php
Specifically look at the is_* functions: is_array, is_numeric, is_string, is_null, is_array, etc.

Also the ctype functions can be used.
http://www.php.net/manual/en/book.ctype.php
The mains ones are: ctype_alnum, ctype_alpha, ctype_digit, etc.
 
Palbin







PostPosted: Sun Aug 22, 2010 11:15 am Reply with quote

Dawg, also about indenting your code. There are no official rules on how to do so. Typically speaking every time you have have a set of {} be that for a function or an if statement etc you should indent the code between those one time. The code will step in or out as you close the bracket.

Take a look at this.
http://rnwiki.ravennuke.com/wiki/RNTeam:Coding_Standards
 
Dawg







PostPosted: Wed Oct 27, 2010 6:31 am Reply with quote

Palbin wrote:
Dawg, also about indenting your code. There are no official rules on how to do so. Typically speaking every time you have have a set of {} be that for a function or an if statement etc you should indent the code between those one time. The code will step in or out as you close the bracket.

Take a look at this.
http://rnwiki.ravennuke.com/wiki/RNTeam:Coding_Standards


I have not worked on this as of late...but I wanted to say THANK YOU for this piece of advice!

I am now taking the time to indent the code as I go and WOW that sure has helped me see the logic.

I am hopeing over X-Mas this year I will be able to take the time to revisit this video mod...it is pretty cool.

The Wiki...

Guys...This is one of the best resources around for a guy like me...PLEASE continue to update it with examples.

I can just about recite the Coding Standards
http://rnwiki.ravennuke.com/wiki/RNTeam:Coding_Standards

This is the type of things make people like me want to create new stuff for RN!

Thank You again for your time!!

Dawg
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©