/** * Saves a comment to the database * @param option from URL * @todo Implement system to allow only one comment per user. */ function saveComment($option) { global $rsgConfig, $mainframe; $my = JFactory::getUser(); $database = JFactory::getDBO(); //Retrieve parameters $user_ip = $_SERVER['REMOTE_ADDR']; $rsgOption = rsgInstance::getVar('rsgOption', ''); $subject = rsgInstance::getVar('ttitle', ''); $user_name = rsgInstance::getVar('tname', ''); $comment = get_magic_quotes_gpc() ? rsgInstance::getVar('tcomment', '') : addslashes(rsgInstance::getVar('tcomment', '')); $item_id = rsgInstance::getInt('item_id', ''); $catid = rsgInstance::getInt('catid', ''); //Check if commenting is enabled $redirect_url = JRoute::_("index.php?option=" . $option . "&page=inline&id=" . $item_id); if ($rsgConfig->get('comment') == 0) { $mainframe->redirect($redirect_url, JText::_('Commenting is disabled')); exit; } //Check if user is logged in if ($my->id) { $user_id = $my->id; //Check if only one comment is allowed if ($rsgConfig->get('comment_once') == 1) { //Check how many comments the user already made on this item $sql = "SELECT COUNT(1) FROM #__rsgallery2_comments WHERE user_id = '{$user_id}' AND item_id='{$item_id}'"; $database->setQuery($sql); $result = $database->loadResult(); if ($result > 0) { //No further comments allowed, redirect $mainframe->redirect($redirect_url, JText::_('User can only comment once')); } } } else { if (!$rsgConfig->get('comment_allowed_public')) { $mainframe->redirect($redirect_url, JText::_('You must login to comment.')); } $user_id = 0; //Check for unique IP-address and see if only one comment from this IP=address is allowed } if ($rsgConfig->get('comment_security') == 1) { $checkSecurity = null; $userEntry = JRequest::getVar('securityImageRSGallery2', false, '', 'CMD'); $mainframe->triggerEvent('onSecurityImagesCheck', array($userEntry, &$checkSecurity)); //Check if security check was OK if ($checkSecurity == false) { $mainframe->redirect($redirect_url, JText::_('Incorrect CAPTCHA check, comment is NOT saved!')); } } //If we are here, start database thing $sql = "INSERT INTO #__rsgallery2_comments (id, user_id, user_name, user_ip, parent_id, item_id, item_table, datetime, subject, comment, published, checked_out, checked_out_time, ordering, params, hits)" . " VALUES (" . "''," . "'{$user_id}'," . "'{$user_name}'," . "'{$user_ip}'," . "''," . "'{$item_id}'," . "'com_rsgallery2'," . "now()," . "'{$subject}'," . "'{$comment}'," . "1," . "''," . "''," . "''," . "''," . "''" . ")"; $database->setQuery($sql); if ($database->query()) { $mainframe->redirect($redirect_url, JText::_('Comment added succesfully!')); } else { $mainframe->redirect($redirect_url, JText::_('Comment could not be added!')); //echo $sql; } }
function showResults() { $database = JFactory::getDBO(); //Retrieve search string $searchtext = rsgInstance::getVar('searchtext', ''); //Check searchtext against database $sql = "SELECT *, a.name as itemname, a.id as item_id FROM #__rsgallery2_files as a, #__rsgallery2_galleries as b " . "WHERE a.gallery_id = b.id " . "AND (" . "a.title LIKE '%{$searchtext}%' OR " . "a.descr LIKE '%{$searchtext}%'" . ") " . "AND a.published = 1 " . "AND b.published = 1 " . "GROUP BY a.id " . "ORDER BY a.id DESC"; $database->setQuery($sql); $result = $database->loadObjectList(); //show results html_rsg2_search::showResults($result, $searchtext); }
function xmlFile() { $template = preg_replace('#\\W#', '', rsgInstance::getVar('xmlTemplate', 'meta')); $template = strtolower($template); // require generic template which all other templates should extend require_once JPATH_RSGALLERY2_SITE . '/templates/meta/xml.php'; // require the template specified to be used require_once JPATH_RSGALLERY2_SITE . '/templates/' . $template . '/xml.php'; // prepare and output xml $xmlTemplate = "rsgXmlGalleryTemplate_{$template}"; $xmlTemplate = new $xmlTemplate(rsgInstance::getGallery()); ob_start(); $xmlTemplate->prepare(); $content = ob_get_clean(); $xmlTemplate->printHead(); echo $content; die; // quit now so that only the xml is sent and not the joomla template // this is a saftey measure that should not be needed }
/** * Fetches and returns a given filtered variable. The string * filter deletes 'bad' HTML code, if not overridden by the mask. * This is currently only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @static * @param string $name Variable name * @param string $default Default value if the variable does not exist * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD) * @param int $mask Filter mask for the variable * @return string Requested variable * @since 1.5 */ function getString($name, $default = '', $hash = 'default', $mask = 0) { // Cast to string, in case JREQUEST_ALLOWRAW was specified for mask return (string) rsgInstance::getVar($name, $default, $hash, 'string', $mask); }
function image_batchUpload() { JToolBarHelper::title(JText::_('Batch Upload'), 'generic.png'); if (rsgInstance::getVar('uploaded', null)) { JToolBarHelper::custom('save_batchupload', 'upload.png', 'upload.png', JText::_('Upload'), false); } else { JToolBarHelper::custom('batchupload', 'forward.png', 'forward.png', JText::_('Next'), false); } //JToolBarHelper::save('save_image'); //JToolBarHelper::cancel(); //JToolBarHelper::back(); JToolBarHelper::spacer(); JToolBarHelper::help('screen.rsgallery2', true); }
/** * Saves the record on an edit form submit * @param database A database connector object */ function save($option) { global $rsgOption, $rsgAccess, $rsgConfig, $mainframe; $my =& JFactory::getUser(); $database =& JFactory::getDBO(); $row = new rsgGalleriesItem($database); if (!$row->bind(JRequest::get('post'))) { //here we get id, parent, ... from the user's input echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); //Make the alias for SEF if (empty($row->alias)) { $row->alias = $row->name; } $row->alias = JFilterOutput::stringURLSafe($row->alias); // save params $params = rsgInstance::getVar('params', array()); if (is_array($params)) { $txt = array(); foreach ($params as $k => $v) { $txt[] = "{$k}={$v}"; } $row->params = implode("\n", $txt); } // code cleaner for xhtml transitional compliance $row->description = str_replace('<br>', '<br />', $row->description); $row->date = date('Y-m-d H:i:s'); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->checkin(); $row->reorder(); //If acl is enabled, set permissions array and save them to the DB if ($rsgConfig->get('acl_enabled')) { $perms = $rsgAccess->makeArrayComplete(rsgInstance::getVar('perm', array())); $rsgAccess->savePermissions($perms, $row->id); } $mainframe->redirect("index2.php?option={$option}&rsgOption={$rsgOption}"); }
/** * Used in the consolidate database function * Creates images based on an image id or an image name */ function regenerateImage() { global $mainframe; global $rsgConfig; $database =& JFactory::getDBO(); //Check if id or name is set if (isset($_REQUEST['id'])) { $id = rsgInstance::getInt('id', null); $name = galleryUtils::getFileNameFromId($id); } elseif (isset($_REQUEST['name'])) { $name = rsgInstance::getVar('name', null); } else { $mainframe->redirect("index2.php?option=com_rsgallery2&task=batchupload", JText::_('No fileinformation found. This should never happen!')); } //Just for readability of code $original = JPATH_ORIGINAL . '/' . $name; $display = JPATH_DISPLAY . '/' . imgUtils::getImgNameDisplay($name); $thumb = JPATH_THUMB . '/' . imgUtils::getImgNameThumb($name); if (file_exists($original)) { //Check if display image exists, if not make it. if (!file_exists($display)) { imgUtils::makeDisplayImage($original, NULL, $rsgConfig->get('image_width')); } if (!file_exists($thumb)) { imgUtils::makeThumbImage($original); } } else { if (file_exists($display)) { copy($display, $original); } if (!file_exists($thumb)) { imgUtils::makeThumbImage($display); } } }
<?php /** * This file contains xxxxxxxxxxxxxxxxxxxxxxxxxxx. * @version xxx * @package RSGallery2 * @copyright (C) 2003 - 2006 RSGallery2 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * RSGallery is Free Software */ defined('_JEXEC') or die('Direct Access to this location is not allowed.'); require_once JPATH_RSGALLERY2_SITE . '/lib/rsgvoting/rsgvoting.class.php'; $cid = rsgInstance::getInt('cid', array(0)); $task = rsgInstance::getVar('task', ''); $id = rsgInstance::getInt('id', ''); switch ($task) { case 'save': saveVote($option); break; } function test($id) { echo "<pre>"; print_r($_COOKIE); echo "</pre>"; $cookie_prefix = strval("rsgvoting_" . $id); echo $cookie_prefix; if (!isset($_COOKIE[$cookie_prefix])) { //Cookie valid for 1 year! setcookie($cookie_prefix, $id, time() + 60 * 60 * 24 * 365, "/"); }
<?php defined('_JEXEC') or die('Restricted access'); JHTML::_('behavior.mootools'); $item = $this->currentItem; $templatePath = JURI_SITE . "components/com_rsgallery2/templates/" . rsgInstance::getVar('rsgTemplate', $rsgConfig->get('template')); $jsSwf = ' window.addEvent("domready", function() { var flashvars = {movie:"' . $item->display->url() . '", fgcolor: "0x000000", bgcolor: "0x000000", autoload: "on", autorewind: "on", volume: "70"}; swfobject.embedSWF("' . JURI_SITE . '/components/com_rsgallery2/flash/player.swf", "rsg2-flashMovie", "320", "240", "7", "' . JURI_SITE . '/components/com_rsgallery2/flash/expressInstall.swf", flashvars, { wmode: "transparent", loop:false, autoPlay:true } ); });'; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($jsSwf); $doc->addScript(JURI_SITE . '/components/com_rsgallery2/flash/script/swfobject.js'); ?> <div id="rsg2-flashMovie"><p><?php echo JText::_("The movie should appear here."); ?> </p></div>
function save_batchupload() { global $rsgConfig, $mainframe; $database = JFactory::getDBO(); //Try to bypass max_execution_time as set in php.ini set_time_limit(0); $FTP_path = $rsgConfig->get('ftp_path'); $teller = rsgInstance::getInt('teller', null); $delete = rsgInstance::getVar('delete', null); $filename = rsgInstance::getVar('filename', null); $ptitle = rsgInstance::getVar('ptitle', null); $descr = rsgInstance::getVar('descr', array(0)); $extractdir = rsgInstance::getVar('extractdir', null); //Check if all categories are chosen if (isset($_REQUEST['category'])) { $category = rsgInstance::getVar('category', array(0)); } else { $category = array(0); } if (in_array('0', $category) || in_array('-1', $category)) { $mainframe->redirect("index2.php?option=com_rsgallery2&task=batchupload", JText::_('_RSGALLERY_ALERT_NOCATSELECTED')); } for ($i = 0; $i < $teller; $i++) { //If image is marked for deletion, delete and continue with next iteration if (isset($delete[$i]) and $delete[$i] == 'true') { //Delete file from server unlink(JPATH_ROOT . "/media/" . $extractdir . '/' . $filename[$i]); continue; } else { //Setting variables for importImage() $imgTmpName = JPATH_ROOT . "/media/" . $extractdir . '/' . $filename[$i]; $imgName = $filename[$i]; $imgCat = $category[$i]; $imgTitle = $ptitle[$i]; $imgDesc = $descr[$i]; //Import image $e = imgUtils::importImage($imgTmpName, $imgName, $imgCat, $imgTitle, $imgDesc); //Check for errors if ($e !== true) { $errors[] = $e; } } } //Clean up mediadir fileHandler::cleanMediaDir($extractdir); // Error handling if (isset($errors)) { if (count($errors) == 0) { echo JText::_('Item uploaded succesfully!'); } else { foreach ($errors as $err) { echo $err->toString(); } } } else { //Everything went smoothly, back to Control Panel global $mainframe; $mainframe->redirect("index2.php?option=com_rsgallery2", JText::_('Item uploaded succesfully!')); } }
/** * @todo if thumbname size has changed, advise user to regenerate thumbs */ function saveConfig() { global $rsgConfig; $rsgConfig = new rsgConfig(); if ($rsgConfig->saveConfig($_REQUEST)) { HTML_RSGALLERY::printAdminMsg(JText::_('Configuration Saved')); // save successful, try creating some image directories if we were asked to if (rsgInstance::getVar('createImgDirs')) { HTML_RSGALLERY::printAdminMsg(JText::_('Creating Image directories not Implemented yet.'), true); } } else { HTML_RSGALLERY::printAdminMsg(JText::_('Error Saving Configuration')); } }
/** * Writes the edit form for new and existing record * * A new record is defined when <var>$row</var> is passed with the <var>id</var> * property set to 0. * @param rsgGallery The gallery object * @param array An array of select lists * @param object Parameters * @param string The option */ function edit(&$row, &$lists, &$params, $option) { global $rsgOption, $rsgAccess, $rsgConfig; jimport("joomla.filter.output"); $my =& JFactory::getUser(); $editor =& JFactory::getEditor(); JFilterOutput::objectHTMLSafe($row, ENT_QUOTES); $task = rsgInstance::getVar('task', ''); JHTML::_('behavior.formvalidation'); JHTML::_("Behavior.mootools"); ?> <script type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel') { submitform( pressbutton ); return; } // do field validation if (form.name.value == ""){ alert("<?php echo JText::_('YOU MUST PROVIDE A GALLERY NAME.'); ?> "); } else { <?php echo $editor->save('description'); ?> submitform( pressbutton ); } } function selectAll() { if(document.adminForm.checkbox0.checked) { for (i = 0; i < 12; i++) { document.getElementById('p' + i).checked=true; } } else { for (i = 0; i < 12; i++) { document.getElementById('p' + i).checked=false; } } } </script> <form action="index2.php" method="post" name="adminForm" id="adminForm" class="form-validate"> <table class="adminheading"> <tr> <th> <?php echo JText::_('Gallery'); ?> : <small> <?php echo $row->id ? 'Edit' : 'New'; ?> </small> </th> </tr> </table> <table width="100%"> <tr> <td width="60%" valign="top"> <table class="adminform"> <tr> <th colspan="2"> <?php echo JText::_('Details'); ?> </th> </tr> <tr> <td width="20%" align="right"> <?php echo JText::_('Name'); ?> </td> <td width="80%"> <input class="text_area required" type="text" name="name" size="50" maxlength="250" value="<?php echo stripslashes($row->name); ?> " /> </td> </tr> <tr> <td width="20%" align="right"> <?php echo JText::_('COM_RSGALLERY2_ALIAS'); ?> </td> <td width="80%"> <input class="text_area" type="text" name="alias" size="50" maxlength="250" value="<?php echo stripslashes($row->alias); ?> " /> </td> </tr> <tr> <td align="right"> <?php echo JText::_('Owner'); ?> </td> <td> <?php echo $lists['uid']; ?> </td> </tr> <tr> <td valign="top" align="right"> <?php echo JText::_('Description'); ?> </td> <td> <?php // parameters : areaname, content, hidden field, width, height, rows, cols echo $editor->display('description', stripslashes($row->description), '100%', '300', '10', '20', false); ?> </td> </tr> <tr> <td align="right"> <?php echo JText::_('Parent Item'); ?> </td> <td> <?php echo $lists['parent']; ?> </td> </tr> <tr> <td valign="top" align="right"> <?php echo JText::_('Gallery thumbnail'); ?> </td> <td> <?php echo imgUtils::showThumbNames($row->id, $row->thumb_id); ?> </td> </tr> <tr> <td valign="top" align="right"> <?php echo JText::_('Ordering'); ?> </td> <td> <?php echo $lists['ordering']; ?> </td> </tr> <tr> <td valign="top" align="right"> <?php echo JText::_('Published'); ?> </td> <td> <?php echo $lists['published']; ?> </td> </tr> </table> </td> <td width="40%" valign="top"> <table class="adminform"> <tr> <th colspan="1"> <?php echo JText::_('Parameters'); ?> </th> </tr> <tr> <td> <?php echo $params->render(); ?> </td> </tr> </table><br/> <table class="adminform"> <?php if ($rsgConfig->get('acl_enabled')) { ?> <tr> <th colspan="1"><?php echo JText::_('Permissions'); ?> </th> </tr> <?php if (!isset($row->id)) { ?> <tr> <td><?php echo JText::_('_RSGALLERY_GAL_DEF_PERM_CREATE'); ?> </td> </tr> <?php } else { $perms = $rsgAccess->returnPermissions($row->id); if (!$perms) { ?> <tr> <td colspan="6"><?php echo JText::_('RSGALLERY_GAL_NO_PERM_FOUND'); ?> </td> </tr> <?php } else { ?> <tr> <td> <table class="adminform" border="0" width="100%"> <tr> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Usertype'); ?> </span></td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('View<br/>Gallery</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Upload/Edit<br/>images</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Delete Image</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Modify<br/>Gallery</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Delete<br/>Gallery</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('View votes'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Vote'); ?> </td> </tr> <tr> <td><span style="font-weight:bold;"><?php echo JText::_('Public</span>'); ?> </td> <td><input id="p0" type="checkbox" name="perm[0]" value="1" <?php if ($perms->public_view == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p1" type="checkbox" name="perm[1]" value="1" <?php if ($perms->public_up_mod_img == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p2" type="checkbox" name="perm[2]" value="1" <?php if ($perms->public_del_img == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p3" type="checkbox" name="perm[3]" value="1" <?php if ($perms->public_create_mod_gal == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p4" type="checkbox" name="perm[4]" value="1" <?php if ($perms->public_del_gal == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p5" type="checkbox" name="perm[5]" value="1" <?php if ($perms->public_vote_view == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p6" type="checkbox" name="perm[6]" value="1" <?php if ($perms->public_vote_vote == 1) { echo "CHECKED"; } ?> ></td> </tr> <tr> <td><span style="font-weight:bold;"><?php echo JText::_('Registered</span>'); ?> </td> <td><input id="p7" type="checkbox" name="perm[7]" value="1" <?php if ($perms->registered_view == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p8" type="checkbox" name="perm[8]" value="1" <?php if ($perms->registered_up_mod_img == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p9" type="checkbox" name="perm[9]" value="1" <?php if ($perms->registered_del_img == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p10" type="checkbox" name="perm[10]" value="1" <?php if ($perms->registered_create_mod_gal == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p11" type="checkbox" name="perm[11]" value="1" <?php if ($perms->registered_del_gal == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p12" type="checkbox" name="perm[12]" value="1" <?php if ($perms->registered_vote_view == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p13" type="checkbox" name="perm[13]" value="1" <?php if ($perms->registered_vote_vote == 1) { echo "CHECKED"; } ?> ></td> </tr> <tr> <td colspan="6"><input type="checkbox" name="checkbox0" value="true" onClick='selectAll()'><?php echo ' ' . JText::_('Select/Deselect All'); ?> </td> </tr> </table> </td> </tr> <?php } } } ?> </table> </td> </tr> </table> <input type="hidden" name="id" value="<?php echo $row->id; ?> " /> <input type="hidden" name="rsgOption" value="<?php echo $rsgOption; ?> " /> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="task" value="" /> </form> <?php }
function batchupload_2($ziplist, $extractDir) { /* Info for javascript on input element names and values: Step 2 Button: Upload --> task=save_batchupload Delete checkbox name: delete[1] Item title field name: ptitle[] Gallery select name: category[] Description area name: descr[] */ global $rsgOption; JHTML::_('behavior.mootools'); $database = JFactory::getDBO(); //Get variables from form $selcat = rsgInstance::getInt('selcat', null); $ftppath = rsgInstance::getVar('ftppath', null); $xcat = rsgInstance::getInt('xcat', null); $batchmethod = rsgInstance::getVar('batchmethod', null); ?> <script language="javascript" type="text/javascript"> <!-- function submitbutton(pressbutton) { var form = document.adminForm, missingCat = false, categories = $$('#adminForm input[name^=category]', '#adminForm select[name^=category]'); for (i=0 ; i<categories.length ; i++) { if (categories[i].value <= 0) { alert("<?php echo JText::_('All images must be part of a galery'); ?> "+' (#'+i+')'); return; missingCat = true; break; } } if (pressbutton == 'save_batchupload'){ if (missingCat == true) { alert("<?php echo JText::_('All images must be part of a galery'); ?> "); } else { form.submit(); } } } //--> </script> <form action="index2.php" method="post" name="adminForm" id="adminForm"> <table class="adminform"> <tr> <th colspan="5" class="sectionname"><font size="4"><?php echo JText::_('Step 2'); ?> </font></th> </tr> <tr> <?php // Initialize k (the column reference) to zero. $k = 0; $i = 0; foreach ($ziplist as $filename) { $k++; //Check if filename is dir if (is_dir(JPATH_ROOT . '/media/' . $extractDir . '/' . $filename)) { continue; } else { //Check if file is allowed $allowed_ext = array('gif', 'jpg', 'png'); $allowedVideo_ext = array('flv', 'avi', 'mov'); $ext = fileHandler::getImageType(JPATH_ROOT . '/media/' . $extractDir . '/' . $filename); if (in_array($ext, $allowedVideo_ext)) { // build preview image $basePath = JPATH_SITE . '/media/' . $extractDir . '/'; require_once JPATH_RSGALLERY2_ADMIN . 'includes/video.utils.php'; Ffmpeg::capturePreviewImage($basePath . $filename, $basePath . $filename . '.png'); $displayImage = $filename . '.png'; $i++; } else { if (!in_array($ext, $allowed_ext)) { continue; } else { $displayImage = $filename; $i++; } } } ?> <td align="center" valign="top" bgcolor="#CCCCCC"> <table class="adminform" border="0" cellspacing="1" cellpadding="1"> <tr> <th colspan="2"> </th> </tr> <tr> <td colspan="2" align="right"><?php echo JText::_('Delete'); ?> #<?php echo $i - 1; ?> : <input type="checkbox" name="delete[<?php echo $i - 1; ?> ]" value="true" /></td> </tr> <tr> <td align="center" colspan="2"><img src="<?php echo JURI_SITE . "/media/" . $extractDir . "/" . $displayImage; ?> " alt="" border="1" width="100" align="center" /></td> </tr> <input type="hidden" value="<?php echo $filename; ?> " name="filename[]" /> <tr> <td><?php echo JText::_('Title'); ?> </td> <td> <input type="text" name="ptitle[]" size="15" /> </td> </tr> <tr> <td><?php echo JText::_('Gallery'); ?> </td> <td><?php if ($selcat == 1 && $xcat !== '0') { ?> <input type="text" name="cat_text" value="<?php echo htmlspecialchars(stripslashes(galleryUtils::getCatnameFromId($xcat))); ?> " readonly /> <input type="hidden" name="category[]" value="<?php echo $xcat; ?> " /> <?php } else { echo galleryUtils::galleriesSelectList(null, 'category[]', false); } ?> </td> </tr> <tr> <td><?php echo JText::_('Description'); ?> </td> <td><textarea cols="15" rows="2" name="descr[]"></textarea></td> </tr> </table> </td> <?php if ($k == 5) { echo "</tr><tr>"; $k = 0; } } ?> </table> <input type="hidden" name="teller" value="<?php echo $i; ?> " /> <input type="hidden" name="extractdir" value="<?php echo $extractDir; ?> " /> <input type="hidden" name="option" value="com_rsgallery2" /> <input type="hidden" name="rsgOption" value="<?php echo $rsgOption; ?> " /> <input type="hidden" name="task" value="save_batchupload" /> </form> <?php }
/** * Shows the top bar for the RSGallery2 screen */ function showRsgHeader() { $rsgOption = rsgInstance::getVar('rsgOption', ''); $gid = rsgInstance::getVar('gid', null); if (!$rsgOption == 'mygalleries' and !$gid) { ?> <div class="rsg2-mygalleries"> <a class="rsg2-mygalleries_link" href="<?php echo JRoute::_("index.php?option=com_rsgallery2&rsgOption=myGalleries"); ?> "><?php echo JText::_('My galleries'); ?> </a> </div> <div class="rsg2-clr"></div> <?php } }
function saveCat() { global $rsgConfig, $mainframe; $my = JFactory::getUser(); $database = JFactory::getDBO(); //If gallery creation is disabled, unauthorized attempts die here. if (!$rsgConfig->get('uu_createCat')) { die("User category creation is disabled by administrator."); } //Set redirect URL $redirect = JRoute::_("index.php?option=com_rsgallery2&rsgOption=myGalleries", false); $parent = rsgInstance::getVar('parent', 0); $id = rsgInstance::getInt('catid', null); $catname1 = rsgInstance::getstring('catname1', null); $description = rsgInstance::getVar('description', null, 'post', 'string', JREQUEST_ALLOWRAW); $published = rsgInstance::getInt('published', 0); $ordering = rsgInstance::getInt('ordering', null); $maxcats = $rsgConfig->get('uu_maxCat'); //escape strings for sql query $alias = $database->getEscaped(JFilterOutput::stringURLSafe($catname1)); $catname1 = $database->getEscaped($catname1); $description = $database->getEscaped($description); if ($id) { $database->setQuery("UPDATE #__rsgallery2_galleries SET " . "name = '{$catname1}', " . "description = '{$description}', " . "published = '{$published}', " . "parent = '{$parent}' " . "WHERE id = '{$id}' "); if ($database->query()) { $mainframe->redirect($redirect, JText::_('Gallery details updated!')); } else { $mainframe->redirect($redirect, JText::_('Could not update gallery details!')); } } else { //New category $userCatTotal = galleryUtils::userCategoryTotal($my->id); if (!isset($parent)) { $parent = 0; } if ($userCatTotal >= $maxcats) { ?> <script type="text/javascript"> //<![CDATA[ alert('<?php echo JText::_('MAX_USERCAT_ALERT'); ?> '); location = '<?php echo JRoute::_("index.php?option=com_rsgallery2&page=my_galleries", false); ?> '; //]]> </script> <?php //$mainframe->redirect( $redirect ,JText::_('MAX_USERCAT_ALERT')); } else { //Create ordering, start at last position $database->setQuery("SELECT MAX(ordering) FROM #__rsgallery2_galleries WHERE uid = '{$my->id}'"); $ordering = $database->loadResult() + 1; //Insert into database $database->setQuery("INSERT INTO #__rsgallery2_galleries " . "(name, description, alias, ordering, parent, published, user, uid, date) VALUES " . "('{$catname1}','{$description}','{$alias}','{$ordering}','{$parent}','{$published}','1' ,'{$my->id}', now())"); if ($database->query()) { //Create initial permissions for this gallery $database->setQuery("SELECT id FROM #__rsgallery2_galleries WHERE name = '{$catname1}' LIMIT 1"); $gallery_id = $database->loadResult(); $acl = new rsgAccess(); if ($acl->createDefaultPermissions($gallery_id)) { $mainframe->redirect($redirect, JText::_('New gallery created!')); } } else { $mainframe->redirect($redirect, JText::_('ALERT_NONEWCAT')); } } } //$mainframe->redirect( $redirect ); }
/** * This function is called when you select batchupload from the backend. It * detects whether you choose ZIP or FTP and acts accordingly. * When you choose ZIP it unzips the file you upload to "/media" for further * handling, if you choose FTP it reads the files from the directory you uploaded * the files to and copies them to "/media".(this dir must be on the local server). * @todo Better error trapping * @todo Check FTP handling bit */ function batch_uploadX($option) { global $mainframe, $rsgConfig; $database = JFactory::getDBO(); $FTP_path = $rsgConfig->get('ftp_path'); //Retrieve data from submit form $batchmethod = rsgInstance::getVar('batchmethod', null); $uploaded = rsgInstance::getVar('uploaded', null); $selcat = rsgInstance::getInt('selcat', null); $zip_file = rsgInstance::getVar('zip_file', null, 'FILES'); $ftppath = rsgInstance::getVar('ftppath', null); $xcat = rsgInstance::getInt('xcat', null); //Check if a gallery exists, if not link to gallery creation $database->setQuery("SELECT id FROM #__rsgallery2_galleries"); $database->query(); if ($database->getNumRows() == 0) { HTML_RSGALLERY::requestCatCreation(); return; } //New instance of fileHandler $uploadfile = new fileHandler(); if (isset($uploaded)) { if ($batchmethod == "zip") { //Check if file is really a ZIP-file if (!eregi('.zip$', $zip_file['name'])) { $mainframe->redirect("index2.php?option=com_rsgallery2&task=batchupload", $zip_file['name'] . ' ' . JText::_('NO_VALID_ARCHIVE_ONLY_ZIP_ALLOWED')); } else { //Valid ZIP-file, continue if ($uploadfile->checkSize($zip_file) == 1) { $ziplist = $uploadfile->handleZIP($zip_file); } else { //Error message $mainframe->redirect("index2.php?option=com_rsgallery2&task=batchupload", JText::_('ZIP-file is too big!')); } } } else { $ziplist = $uploadfile->handleFTP($ftppath); } HTML_RSGALLERY::batch_upload_2($ziplist, $uploadfile->extractDir); } else { HTML_RSGALLERY::batch_upload($option); } }