Issue with upload_media

I'm trying to run this script (alterations in bold, "UNALTERED CODING" refers to coding that was NOT altered - I only pasted the coding in question), but I can't seem to get it to work. When I run the script, it comes back as a blank screen.

upload_media.php

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

----------------------------- UNALTERED CODING ----------------------------------------

<script type="text/javascript">
function wrapperFunc()
{

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;

}
function checkRules()
{
if (getCookie("rules") == '')
{
document.getElementById('rulesdiv').style.display = "inherit";
return false;
}

return true;
}

</script>

-----------------------------MORE UNALTERED CODING ----------------------------------------


$ret .= '<div id="rulesdiv" style="display: none">';
$ret .= '<p>Please accept our rules.</p>';

$ret .= '<ul>';
$ret .= '<li>Rule 1.</li>';
$ret .= '<li>Rule 2.</li>';
$ret .= '<li>Rule 3.</li>';
$ret .= '</ul>';

$ret .= '<p><a href="javascript:document.getElementById('rulesdiv').style.display = 'none';javascript:set_cookie('rules', 1, 31);document.postform.submit();">I agree.</a></p>';
$ret .= '</div>';


-----------------------------MORE UNALTERED CODING ----------------------------------------

$ret .= '<form enctype="multipart/form-data" action="' . $oMedia -> aMediaConfig['url']['media'] . '?show=' . $oMedia -> sMediaType . '" method="post" onsubmit="return wrapperFunc()">';

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

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

I've gone over the code over and over, but I'm not well versed in PHP. So if there's something wrong with the code, I'm not seeing it. Can anyone offer me some help here? I'd really like to get this working.

Quote · 6 Dec 2009

What exactly is your issue here?  Your altering code, not telling us what the alteration is for and providing excerpts of yoru file without providing the full file or what error your getting.

 

Perhaps a little more information will get you a better response.

Quote · 6 Dec 2009

The full coding is posted below ...

The goal, is to require the person submitting the photo to accept a list of rules. This is saved in cookies so repeat visitors do not have to click "I agree" every time they want to submit a photo.

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

upload_media.php

As before, what is bold is the alterations I've made to the document to achieve the above results.

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

**************************
<?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 = '';
$ret .= '
<script type="text/javascript">

function wrapperFunc()

{

function checkForm()

{
return true;

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;
}

}
{
function checkRules()
{
if (getCookie("rules") == '')
{
document.getElementById('rulesdiv').style.display = "inherit";
return false;
}
return true;
}
}

</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 check wrapperFunc()">';

$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;
}

?>

Quote · 6 Dec 2009

What version of Dolphin are you using?  On D 6.1.6 (and in your code) your calling for a switch for private photos.  This is modified code if your on 6.1.6.  The original file goes as:


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

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

 $show = $_REQUEST['show'];
 switch( $show )
 {
  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 = '';

   $ret .= '

 

 


And you have:

 

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 = '';
$ret .= '


Please take a moment to note the Orange in the 2nd section of code.  I'll look at this more, but it appears you may have an issue with this private photo modification that's in here too.  Don't know until I look at it further.

Quote · 6 Dec 2009

Also take a look at this line here:

 

document.getElementById('rulesdiv').style.display = "inherit";

 

 

Perhaps:

 

el = document.getElementById('rulesdiv').style.display = "inherit";

 

might work better, as this will tell the server what your getting the rulesdiv for.  I'm shooting in the dark here, as you have some other mods to this file beyond what you did, but working under the assumption all worked fine before you attempted your own changes.  (Meaning the private photo mod was working correctly.)

Quote · 6 Dec 2009

The Private Photo appears (emphasis on appears) to be working fine. But I would not object to you verifying that it works. For confirmation, I am using D6.1.6.

I didn't originally bold the Private Photo mod because that wasn't giving me the issue. It was the addition of the new coding.

It goes as follows;

//Insert

<div id="rulesdiv" style="display: none">
<p>You have to agree to the rules before you can post, sorry.</p>

<ul>
<li>Your 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>

//Insert into Form tag

onsubmit="return checkRules();"


When I try reloading the page (upload_media.php) to test the script, it only loads a blank page. No header, no nothing.

Quote · 6 Dec 2009

I'll try it again with "el" ... if I haven't already thanked you, Thank you for helping me ...

I'll let you know if it work

Quote · 6 Dec 2009

nope, same results when using "el"

Quote · 6 Dec 2009

 

The Private Photo appears (emphasis on appears) to be working fine. But I would not object to you verifying that it works. For confirmation, I am using D6.1.6.

 

I didn't originally bold the Private Photo mod because that wasn't giving me the issue. It was the addition of the new coding.

 

It goes as follows;

 

//Insert

 

<div id="rulesdiv" style="display: none">
<p>You have to agree to the rules before you can post, sorry.</p>

<ul>
<li>Your 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>

 

 

 

//Insert into Form tag

onsubmit="return checkRules();"

 


When I try reloading the page (upload_media.php) to test the script, it only loads a blank page. No header, no nothing.

Where in the file your provided does the above appear?  I've done a search and researched and researched it and none of it is showing up anyhwere. 

 

Next up, you have <?php at the beginning of the file, change it to <? and dump the php, you should be using short tags and thus the php is not needed.  The beginning of your file should look like this:


 

<?

/***************************************************************************
*                            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
***************************************************************************/

 


This makes the code easier for editors like Notepad++ and your server to follow since most of D's files utilize short tags, not sure why this one has the long tag on it.

 

Please provide a line# where the code you have is located in the upload_media.php file that you provided to us.

Quote · 6 Dec 2009

Okay, looking closer I've managed to find part of it.  But not all of the code your mentioning.  Take a look at how you have it.

 

Here's what you said it should be:

 


//Insert

<div id="rulesdiv" style="display: none">
<p>You have to agree to the rules before you can post, sorry.</p>

<ul>
<li>Your 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>

//Insert into Form tag

onsubmit="return checkRules();"


 

Note this is how your file has it that your provided:

 


 

$ret = '';
$ret .= '
<script type="text/javascript">

function wrapperFunc()

{
function checkForm()

{
return true;

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;
}

}
{
function checkRules()
{
if (getCookie("rules") == '')
{
document.getElementById('rulesdiv').style.display = "inherit";
return false;
}
return true;
}

 


 

 Notice that it's not all the code and it's not even in the correct order.  It looks like you have 2 javascripts riding one on top of the other and did not close out the first before starting the second one.  Then it doesn't  have anyplace to say what should be on the screen in what you actually have in the file.  It's like a very large part of what you meant to put into the file is missing.  You need to refer to the instructions and try this again.  Perhaps you might want to set a back-up of the files on the server (also the DB if you altered it also) and try this mod again.  Use Notepad++ and make sure your FTP Client is set to Binary mode. 

 

What I'm seeing here is definitely not what your sayin should be in the file and without the instructions your looking at it's hard to tell exactly where to fix this mess. 

 

If you like, you can PM me and I can take a closer look at this if you like.

 

 

Quote · 6 Dec 2009

I sent you a message.

Quote · 6 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.