mod to upload_media

Goal: I have some basic html/javascript that I would like to implement into my upload_media.php

Idea: The basic concept for the code is when someone clicks "submit", the posting process is suspended and it will display a small DIV containing a list of rules. You have to agree to the rules before you can continue with the post. When you click "I agree", it will continue the post process. It keeps Cookies so if you post again, you won't be required to accept the rules every time you want to post.

Problem: I've used this script before on other sites. When I try to implement the coding into upload_media all I get is a blank page.

I'm hoping someone here will be able to help me.

Below I've pasted my upload_media file. I do have "Private Photos" mod so my doc isn't standard.

Below that is the "gutted" doc I want to merge into upload_media.php (gutted = only the parts I want to use).

***********************************************************************

upload_media.php

***********************************************************************

<?

/***************************************************************************
*                            Dolphin Smart Community Builder
*                              -----------------
*     begin                : Mon Mar 23 2006
*     copyright            : (C) 2006 BoonEx Group
*     website              : http://www.boonex.com/
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
* http://creativecommons.org/licenses/by/3.0/
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Creative Commons Attribution 3.0 License for more details.
* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/


require_once('inc/header.inc.php');
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'images.inc.php' );


$_page['name_index']    = 62;
$_page['css_name']        = 'upload_media.css';

$_page['extra_js'] = '
<script type="text/javascript">
active= new Image();
active.src="' . $site['url'] . 'templates/base/images/media_tab_active.png;";
passive= new Image();
passive.src="' . $site['url'] . 'templates/base/images/media_tab_passive.png;";
hover= new Image();
hover.src="' . $site['url'] . 'templates/base/images/media_tab_hover.png;";
</script>
';

$logged['member'] = member_auth( 0 );

$_page['header'] = _t( "_Profile Photos" );
//$_page['header_text'] = _t( "_UPLOAD_MEDIA", $site['title'] );


$_ni = $_page['name_index'];
$_page_cont[$_ni]['page_main_code'] = PageCompMainCode();

PageCode();

function PageCompMainCode()
{
global $tmpl, $_page, $oTemplConfig;

$iProfileID = (int)$_COOKIE['memberID'];

$show = $_REQUEST['show'];
switch( $show )
{
case 'private_photo':
require_once( BX_DIRECTORY_PATH_ROOT . 'uploadPrivatePhoto.php' );
$oMedia = new UploadPrivatePhoto( $iProfileID );
$oMedia -> getMediaArray();
$_page['header_text'] = _t( "_My Private Photos" );   
break;
case 'photo':
default:
require_once( BX_DIRECTORY_PATH_ROOT . 'uploadPhoto.php' );
$oMedia = new UploadPhoto( $iProfileID );
$oMedia -> getMediaArray();
$_page['header_text'] = _t( "_My Photos" );
break;
}

$ret = '';

$_page['extra_js']  .= '<script type="text/javascript" language="JavaScript" src="inc/js/functions.js"></script>';
$ret .= '
<script type="text/javascript">
function checkForm()
{


var el;
var hasErr = false;
var fild = "";

el = document.getElementById("mediaTitle");
if( el.value.length < ' . $oMedia -> aMediaConfig['min']['mediaTitle'] . ' )
{
el.style.backgroundColor = "pink";
el.style.border = "1px solid silver";
hasErr = true;
fild += "\n ' . _t( '_title_min_lenght', $oMedia -> aMediaConfig['min']['mediaTitle'] ) . '";
}
else
{
el.style.backgroundColor = "#fff";
}

if (hasErr)
{
alert( fild )
return false;

}
else
{
return true;
}


return false;
}
</script>

';

if( $oTemplConfig -> customize['upload_media']['showMediaTabs'] )
{
$ret .= '<div class="choiseBlock">';
$ret .= getMediaTabs( $oMedia -> sMediaType, $oMedia -> aMediaConfig['enable'] );
$ret .= '</div>' . "\n";
$ret .= '<div class="clear_both"></div>';
}
else
{
$ret .= '<div class="choiseBlock">';
$ret .= getMediaTabsView( $oMedia -> sMediaType, $oMedia -> aMediaConfig['enable'] );
$ret .= '</div>' . "\n";
$ret .= '<div class="clear_both"></div>';
}


if( $oTemplConfig -> customize['upload_media']['showAddButton'] )
{
$ret .= '<div class="addNew">';
$ret .= '<a href="javascript:void(0);" onclick="return BxShowBlock(\'addNewBlock\');">' . _t('_add_new', _t('_' . $oMedia -> sMediaType . '')) . '</a>';
$ret .= '</div>' . "\n";
}

$ret .= '<div id="addNewBlock" style="display:' . $oTemplConfig -> customize['upload_media']['addNewBlock_display'] . ';">';

if( $oMedia -> iMediaCount >= $oMedia -> aMediaConfig['max'][$oMedia -> sMediaType] )
{
$ret .= _t_action('_too_many_files');
}
else
{
$ret .= '<form enctype="multipart/form-data" action="' . $oMedia -> aMediaConfig['url']['media'] . '?show=' . $oMedia -> sMediaType . '" method="post" onsubmit="return checkForm()">';
$ret .= '<div>';
$ret .= _t('_Title');
$ret .= '&nbsp;(&nbsp;<span id="charCount" class="charCount">' . $oMedia -> aMediaConfig['max']['mediaTitle'] . '</span>';
$ret .= '<span class="charCount">' . _t('_characters_left') . '</span>&nbsp;)';
$ret .= '</div>' . "\n";
$ret .= '<div>';
$ret .= '<input type="text" name="title" class="title" id="mediaTitle" onkeydown="return charCounter(\'mediaTitle\', ' . $oMedia -> aMediaConfig['max']['mediaTitle'] . ', \'charCount\');" onkeyup="return charCounter(\'mediaTitle\', ' . $oMedia -> aMediaConfig['max']['mediaTitle'] . ', \'charCount\');"  />';
$ret .= '</div>' . "\n";
$ret .= '<div>';
$ret .= '<input type="file" size="34" name="' . $oMedia -> sMediaType . '" class="file" />';
$ret .= '</div>' . "\n";
$ret .= '<div>';
$ret .= '<input type="submit" value="' . _t('_Submit') . '">';
$ret .= '<input type="hidden" name="media_type" value="' . $oMedia -> sMediaType . '" />';
$ret .= '<input type="hidden" name="show" value="' . $oMedia -> sMediaType . '" />';
$ret .= '<input type="hidden" name="action" value="upload" />';
$ret .= '</div>' . "\n";
$ret .= '</form>';
}
$ret .= '</div>' . "\n";

$action = $_REQUEST['action'];
if( $_POST['makePrim'] || isset($_POST['makePrim_x'] ) )
{
$action = 'makePrim';
}
elseif( $_POST['makePrimCouple'] || isset($_POST['makePrimCouple_x'] ) )
{
$action = 'makePrimCouple';
}
elseif( $_POST['makeRable'] )
{
$action = 'makeRable';
}
elseif( $_POST['deletePhoto'] || isset($_POST['deletePhoto_x']) )
{
$action = 'deletePhoto';
}

$iPhotoID = (int)$_REQUEST['photoID'];
$iMediaID = (int)$_REQUEST['mediaID'];

switch($action)
{
case 'upload':
$ret .= $oMedia -> uploadMedia();
header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType );
break;
case 'makePrim':
$ret .= $oMedia -> makePrimPhoto( $iPhotoID );
header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
break;
case 'makeRable':
$ret .= $oMedia -> makeRablePhoto( $iPhotoID );
header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
break;
case 'makePrimCouple':
$ret .= $oMedia -> makePrimPhoto( $iPhotoID, true );
header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
break;
case 'deletePhoto':
$ret .= $oMedia -> deleteMedia( $iPhotoID );
header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
break;
case 'delete':
$ret .= $oMedia -> deleteMedia( $iMediaID );
header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
break;
}


switch( $show )
{
case 'private_photo':
if( $_REQUEST['photoID'] )
{
$iPhotoId = (int)$_REQUEST['photoID'];
$ret .= $oMedia -> getMediaPage($iPhotoId);
}
else
{
$ret .= $oMedia -> getMediaPage();
}
break;
case 'photo':
default:
if( $_REQUEST['photoID'] )
{
$iPhotoId = (int)$_REQUEST['photoID'];
$ret .= $oMedia -> getMediaPage($iPhotoId);
}
else
{
$ret .= $oMedia -> getMediaPage();
}
break;
}

return $ret;
}

function getMediaTabs( $show = 'photo', $aMediaConf ) {
$aItems = array( 'private_photo', 'photo' );

foreach( $aItems as $sItem )
{
if( $aMediaConf[$sItem] )
{
if( $sItem == $show )
{
$ret .= '<div class="item">';
$ret .= '<div class="active">';
$ret .= _t('_' . $sItem . '');
$ret .= '</div>';
$ret .= '</div>';
}
else
{
$ret .= '<div class="item">';
$ret .= '<div class="passive" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'passive\'">';
$ret .= '<a href="' . $_SERVER['PHP_SELF'] . '?show=' . $sItem . '">' . _t('_' . $sItem . '') . '</a>';
$ret .= '</div>';
$ret .= '</div>';
}
}
else
{
$ret .= '';
}
}

return $ret;
}

?>

******************************************************************

Scripting desired

******************************************************************

<div id="rulesdiv" style="display: none">
<p>You have to agree to the rules before you can post.</p>
<ul>
<li>Rules</li>
</ul>
<p><a href="javascript:document.getElementById('rulesdiv').style.display = 'none';javascript:set_cookie('rules', 1, 31);document.postform.submit();">I agree.</a></p>
</div>
...............................................................................................................
<script type="text/javascript">
function checkRules()
{
if (getCookie("rules") == '')
{
document.getElementById('rulesdiv').style.display = "inherit";
return false;
}

return true;
}
</script>
..............................................................................................................
<form name="postform" id="postform" action="board.php" method="post" enctype="multipart/form-data" onsubmit="return checkRules();">

********************************************************************
I have tried several varying combinations but all I turn up with is a blank page when I go to "refresh". I've checked my error logs, but nothing is coming back concerning the script. If you have any assistance in this, it would be greatly appriciated.
Quote · 7 Dec 2009

While I don't have the full answer for you, I am noticing that your calling an <a href="javascript.document... before your telling the browser that you have javascript.

 

Look at line 6 of the scripting desired.  perhaps proceeding it with <script type="text/javascript"> before line 6 will help you out here better.  Also, you need to make sure that this makes it into the page maincode section of the file so that it appears correctly.  More than likely your going to need to break this into different sections and place them where each belongs. 

 

Good luck with it.  It might also help if people know what your trying to accomplish in this.

Quote · 7 Dec 2009

I tried entering the code in that manner and it didn't take. I got the same response. I'm not sure what I'm doing wrong here.

Quote · 7 Dec 2009

just as an inquiry, have you tried to create a custom page in the admin panel, and inject your jscript into the tinymce editor? i see you have prescribed a css file, and maybe thats why you are trying to hard code a page. at any rate, didnt take the time for a full assessment, just a quick scan, and that question is what arose.

Regards,

DosDawg

When a GIG is not enough --> Terabyte Dolphin Technical Support - Server Management and Support
Quote · 7 Dec 2009

just as an inquiry, have you tried to create a custom page in the admin panel, and inject your jscript into the tinymce editor? i see you have prescribed a css file, and maybe thats why you are trying to hard code a page. at any rate, didnt take the time for a full assessment, just a quick scan, and that question is what arose.

Regards,

DosDawg

I don't know too much about php, but how would the script function if it is on a completely different page?

Quote · 7 Dec 2009

 

just as an inquiry, have you tried to create a custom page in the admin panel, and inject your jscript into the tinymce editor? i see you have prescribed a css file, and maybe thats why you are trying to hard code a page. at any rate, didnt take the time for a full assessment, just a quick scan, and that question is what arose.

 

Regards,

DosDawg

 DD, he's trying to basically use a lytebox, from what I can tell that also sets a cookie to show that they have agreed to the Upload TOS and thus they don't have to click it every time they go to upload something.  Please correct me if I'm wrong 10chan. 

 

The more I think about this, the more I think there is a better, easier, more efficient way to do it.  Follow me for a second if you could.  A cookies is browser specific, so if they login to the site from a 2nd browser then they will have to agree again, however if another user logs in on the same browser they will bypass it.  Not a good result if you think about it.

 

Perhaps a better solution would be to run a query on the DB that checks to see if they have agreed in the past to the TOS and if they have, then it bypasses the TOS screen and goes straight to the upload file page.  If they have not agreed, then they get a TOS Screen they must agree to.  Now this could be made to run of the memberID instead of a cookie and would be far more effective than a cookie is.

 

What is your thoughts on doing it this way DD?

Quote · 7 Dec 2009

Sorry if this goes through double, for some reason it didn't post last time.

I'm bias to this whole thing, but I enjoy the idea of a lightbox. I think it would "pop" more  - members might be more opt to actually reading the data that's displayed to them. However, I do not want to use the TOS. For me, the TOS is more Shared Media specific, and I have a different set of guidelines pertaining to Profile Photos.

But I do like the idea of a lightbox, and I think it would be easier to set up. I'm using one on my homepage now. So how would we go about setting this up? I doubt it will be as easy as it was for the home page.

Ideally, I only want the lightbox to display (if the cookies aren't present) AFTER they click "Submit". That is, I want them to be able to edit their photos and only show the lightbox when they attempt to Upload a photo.

Can we do that?

Quote · 7 Dec 2009

Take a look at the code you used for the homepages lytebox, it'll be useful in guiding you through the rest.

 

As far as using your code goes, that's not hard to do at all.  You need to isolate in the upload_media.php file where it's pulling the language key for the TOS, then just alter it to a new language key and go into the admin panel and create it there.  For example, if the current LK is _TOS then just change it in the file to _TOS1 and then create that LK with the text you want to appear. 

 

By dumping the cookie idea and instead utilizing a DB Table and a quick verification, you'll cut down on your bandwidth from the site (while note a huge amount, it will help) and when the sites busy, this will simply mean it's quicker page resolve to the members.  Keep in mind, anything you can do to reduce server resources is a plus in the eyes of both hosting costs and end user satisfaction as they get to what they want quicker.

 

Perhaps someone who knows how to do this for you correctly, the whole thing, will stop in and toss you a hand in completing this trick. 

Quote · 7 Dec 2009

I already appriciate the help you guys have given me so far. I will attempt at trying to incorporate the lightbox on the main page to the upload_media.php ... never hurts to try. But I will check here every so often to see if anyone offers some assistance in creating the lightbox. Either way, if it fails, I'll be back here letting you guys know.

Thanks again.

Quote · 7 Dec 2009

Ok, I thought this was going to be fairly easy (and I bet it probably is), but I am lost when it comes to altering this to fit my needs. Below is the instructions for the lightbox I have.

**********************************************************************************

Install:

Open the file /disclaimer/ak14-fr1.js and edit links for your site.
Find:
document.write("<br /><img src='http://www.yoursite.com/disclaimer/disclaimer.png' alt='ATTENTION' />");


Be sure to chane the yoursite.com part to your actual site, so the image shows up properly.
*Then save the changes you make to this file.
--You may want to change a few others in this file which will be explained later.


Now after you made the above change upload the contents of this zip to your dolphin site keeping the folder structure like so:
yoursite.com/disclaimer/ak14-fr1.js
yoursite.com/disclaimer/disclaimer.png
yoursite.com/disclaimer/.htaccess

The only Dolphin related file to edited is yoursite.com/templates/base/_header.html although this is a simple edit it's always a good idea to download a backup first. After you download the backup...

Open:
yoursite.com/templates/base/_header.html

Insert the following line before the closing head tag </head> tag:
<script type="text/javascript" src="disclaimer/ak14-fr1.js"></script>

So it would look something like:


<script type="text/javascript" src="disclaimer/ak14-fr1.js"></script>

</head>
<body>

Save and/or re-upload the changes to your dolphin base _header.html




Changing the output/appearance:

You can edit the .js file for any text you wish and for your site.

Open disclaimer/ak14-fr1.js with a text editor such as word pad:



!!-Near the top find:
if (document.cookie.indexOf('test_cook')<=-1){window.location.replace('http://www.yoursite.com/cookie.php?url=' + escape(window.location));}

(change yoursite.com) to your actual site.

!!-To make this script work properly if your site uses the www prefix be sure to include it.
!!-If your script does not use the www prefix be sure to omit it such as:
if (document.cookie.indexOf('test_cook')<=-1){window.location.replace('http://yoursite.com/cookie.php?url=' + escape(window.location));}



You may want to change the display height and width, find this line:
document.write("<div style='position:absolute;z-index:1000;width:96%;height:90%;min-height:1024px;margin-left:2%;margin-right:2%;margin-top:10px;margin-bottom:10px;border:0px red solid; background-color:#ffffff;filter:alpha(opacity=95);-moz-opacity:0.95;opacity: 0.95;text-align:center;line-height: normal ; clear: both;'>");

(simply change width:96%;height:90%;min-height:1024px) etc to your liking. This is for the background semi-transparent area.

Scan through the .js file with word pad, and change text to your own disclaimer or statement. Change the link at the bottom to reflect your site, change the google.com link for "leave" to something else, etc.

This file is relatively small and should be very easy to change any text, links, or other.

Things like:
document.write("<br /><strong>Adult Warning @ Yoursite.com</strong><br />");

(Just change to youractualsite.com or anything you want...etc...etc...

Then save the changes and re-upload.

Simply refresh your site in your browser.



To remove/uninstall:
Delete the folder/directory and all the contents inside of yoursite.com/disclaimer

Remove the line from the base header:
yoursite.com/templates/base/_header.html

<script type="text/javascript" src="disclaimer/ak14-fr1.js"></script>

Save _header.html and re-upload the changes.

Quote · 7 Dec 2009

wheres your mod maker??lol pm me i will put it in for you...this is too complex to go thru forum postings.....the cookies not set....wrong url....css display:none  could be many things or a comb of 2-3

I have video tutorials to help you mrpowless.com
Quote · 7 Dec 2009

wheres your mod maker??lol pm me i will put it in for you...this is too complex to go thru forum postings.....the cookies not set....wrong url....css display:none  could be many things or a comb of 2-3

Yea I have no idea what I'm doing lol

script language goes something like this for me;

HTML - English

Java - French

PHP - German

lol

I can look at it, and give a "rough" idea of what happens, but I'm far from reading and no where near writing!

I just shot you a message. Hopefully there's a solution to be found.

Quote · 7 Dec 2009

I have every idea..i fix these things constantly.

I have video tutorials to help you mrpowless.com
Quote · 7 Dec 2009
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.