public function ManageBackups($MsgDesc = "", $MsgStatus = "") { if(isset($_GET['complete'])) { $MsgStatus = MSG_SUCCESS; if($_GET['complete'] == "remote") { $MsgDesc = GetLang('RemoteBackupComplete'); } else { $MsgDesc = sprintf(GetLang('LocalBackupComplete'), $_GET['complete']); } } else if(isset($_GET['failed'])) { $MsgStatus = MSG_ERROR; if($_GET['failed'] == 'local') { $MsgDesc = GetLang('LocalBackupFailed'); } else { $MsgDesc = GetLang('RemoteBackupFailed'); } } if($MsgDesc != "") { $GLOBALS["Message"] = MessageBox($MsgDesc, $MsgStatus); } $dir = realpath(ISC_BACKUP_DIRECTORY); $dir = isc_substr($dir, isc_strpos($dir, realpath(ISC_BASE_PATH))); $backups = $this->_GetBackupList(); $GLOBALS['BackupGrid'] = ''; // Loop through all of the existing backups foreach($backups as $file => $details) { $GLOBALS['FileName'] = isc_html_escape($file); $GLOBALS['ModifiedTime'] = Store_DateTime::niceTime($details['mtime']); if(isset($details['directory'])) { $GLOBALS['FileSize'] = "N/A"; $GLOBALS['DownloadOpen'] = GetLang('OpenBackup'); $GLOBALS['BackupImage'] = "backup_folder"; $GLOBALS['BackupType'] = GetLang('BackupFolder'); $GLOBALS['ViewLink'] = "backups/" . $GLOBALS['FileName']; } else { $GLOBALS['FileSize'] = Store_Number::niceSize($details['size']); $GLOBALS['DownloadOpen'] = GetLang('DownloadBackup'); $GLOBALS['BackupImage'] = "backup"; $GLOBALS['BackupType'] = GetLang('BackupFile'); $GLOBALS['ViewLink'] = "index.php?ToDo=viewBackup&file=" . $GLOBALS['FileName']; } $GLOBALS["BackupGrid"] .= $this->template->render('backup.manage.row.tpl'); } if($GLOBALS['BackupGrid'] == "") { $GLOBALS['DisplayGrid'] = "none"; $GLOBALS["Message"] = MessageBox(GetLang('NoBackups'), MSG_SUCCESS); $GLOBALS["DisableDelete"] = "DISABLED"; } $this->template->display('backups.manage.tpl'); }
/** * Strem the product for download as defined by the values in the $_GET['data'] variable. * The variable contains the item id, product id and order id which, if valid, will * be used to find and then stream the file for the product to the customer */ private function DownloadOrderItem() { if (isset($_GET['data'])) { $data = $this->DecryptDownloadKey($_GET['data']); $data_vals = explode(",", $data); if (count($data_vals) >= 5) { $item_id = (int)$data_vals[0]; $product_id = (int)$data_vals[1]; $order_id = (int)$data_vals[2]; $order_token = $data_vals[3]; // Select the number of downloads for this order item $query = sprintf(" select pd.downloadid, o.ordstatus from [|PREFIX|]product_downloads pd left join [|PREFIX|]order_products op on pd.productid=op.ordprodid inner join [|PREFIX|]orders o on op.orderorderid=o.orderid where pd.productid='%d' and o.orderid='%d' and o.deleted = 0 and op.orderprodid='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($product_id), $GLOBALS['ISC_CLASS_DB']->Quote($order_id), $GLOBALS['ISC_CLASS_DB']->Quote($item_id) ); $query .= " AND o.ordtoken = '".$GLOBALS['ISC_CLASS_DB']->Quote($order_token)."'"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 1); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $product_downloads = $GLOBALS['ISC_CLASS_DB']->Fetch($result); // We have a valid ordered product with downloads if ($product_downloads && OrderIsComplete($product_downloads['ordstatus'])) { // Downloading a particular file if (count($data_vals) == 6) { $download_id = (int)$data_vals[4]; // Fetch the file we're downloading $query = sprintf(" SELECT orddate, pd.downfile, od.numdownloads, od.downloadexpires, od.maxdownloads, ordstatus, pd.downexpiresafter, pd.downmaxdownloads, od.orddownid FROM [|PREFIX|]product_downloads pd INNER JOIN [|PREFIX|]products p ON pd.productid=p.productid LEFT JOIN [|PREFIX|]order_downloads od ON (od.orderid='%s' AND od.downloadid=pd.downloadid) INNER JOIN [|PREFIX|]orders o ON (o.orderid='%d') WHERE pd.downloadid='%d' AND p.productid='%d' AND o.deleted = 0", $GLOBALS['ISC_CLASS_DB']->Quote($order_id), $GLOBALS['ISC_CLASS_DB']->Quote($order_id), $GLOBALS['ISC_CLASS_DB']->Quote($download_id), $GLOBALS['ISC_CLASS_DB']->Quote($product_id) ); $query .= " AND o.ordtoken = '".$GLOBALS['ISC_CLASS_DB']->Quote($order_token)."'"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result); if ($row && OrderIsComplete($row['ordstatus'])) { // If there is no matching row in the order_downloads table for this download, we need to create it if(!$row['orddownid']) { // If this download has an expiry date, set it to now + expiry time $expiryDate = 0; if($row['downexpiresafter'] > 0) { $expiryDate = $row['orddate'] + $row['downexpiresafter']; } $newDownload = array( 'orderid' => (int)$order_id, 'downloadid' => (int)$download_id, 'numdownloads' => 0, 'downloadexpires' => $expiryDate, 'maxdownloads' => $row['downmaxdownloads'] ); $row['maxdownloads'] = $row['downmaxdownloads']; $row['downloadexpires'] = $expiryDate; $GLOBALS['ISC_CLASS_DB']->InsertQuery('order_downloads', $newDownload); } $expired = false; // Have we reached the download limit for this item? if ($row['maxdownloads'] != 0 && $row['numdownloads'] >= $row['maxdownloads']) { $expired = true; } // Have we reached the expiry limit for this item? if ($row['downloadexpires'] > 0 && time() >= $row['downloadexpires']) { $expired = true; } // Download has expired if ($expired == true) { $GLOBALS['ErrorMessage'] = GetLang('DownloadItemExpired'); $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("error"); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); return; } $filename = basename($row['downfile']); $filepath = realpath(ISC_BASE_PATH.'/' . GetConfig('DownloadDirectory')) . "/" . $row['downfile']; if (file_exists($filepath)) { // Strip the underscores and random numbers that are added when a file is uploaded $filename = preg_replace("#__[0-9]+#", "", $filename); $filesize = (double)sprintf('%u', filesize($filepath)); while (@ob_end_clean()) { // empty loop to clean all output buffers } // common headers for both full and partial responses header("Pragma: public"); header("Expires: 0"); header("Accept-Ranges: bytes"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Transfer-Encoding: binary"); $chunks = $this->getDownloadChunksFromRequestHeader($filesize); $boundary = false; $countDownload = false; // downloads should only be counted if the download includes byte 0 if ($chunks === false) { $countDownload = true; } else { foreach ($chunks as $chunk) { if ($chunk[0] == 0) { $countDownload = true; break; } } } if ($countDownload) { // increment the download counter by 1 $query = "UPDATE `[|PREFIX|]order_downloads` SET numdownloads=numdownloads + 1 WHERE orderid='" . (int)$order_id . "' AND downloadid='" . (int)$download_id . "'"; $GLOBALS['ISC_CLASS_DB']->Query($query); } if ($chunks === false) { // send the full response header('HTTP/1.1 200 OK'); // browsers need a little extra help from these headesr to always force the "save" dialog header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=\"" . $filename . "\";"); header("Content-length: " . $filesize); // reconfigure the chunks array to include the full response because we'll use it in the fread loops below $chunks = array( array(0, $filesize, false) ); } else { // send a partial download header('HTTP/1.1 206 Partial content'); // these requests should only ever be sent by download managers or non-interactive saving processes (ie. clicking "resume" in chrome) so a save dialog does not need to show if (count($chunks) == 1) { // send a single range request as a non-mime response as this is probably more compatible with download managers // if this turns out to not be the case, it may be necessary to remove this section and send all partial responses as MIME $chunk = $chunks[0]; $begin = $chunk[0]; $end = $chunk[1]; $length = $end - $begin + 1; header("Content-type: application/octet-stream"); // @todo does this need to be an accurate content type for partial responses? header('Content-range: bytes ' . $begin . '-' . $end . '/' . $filesize); header('Content-length: ' . $length); } else { // multiple download ranges are sent as a multipart MIME response // @todo this has not been tested $boundary = 'BOUNDARY' . md5(uniqid(mt_rand(), true)); header('Content-type: multipart/x-byteranges; boundary=' . $boundary); $length = 0; foreach ($chunks as &$chunk) { $begin = $chunk[0]; $end = $chunk[1]; // fill in the 3rd element of each chunk with its MIME boundary $chunk[3] = "\r\n"; $chunk[3] .= "--" . $boundary . "\r\n"; $chunk[3] .= "Content-type: application/octet-stream"; // @todo does this need to be an accurate content type for partial responses? $chunk[3] .= "Content-range: bytes " . $begin . "-" . $end . "/" . $filesize . "\r\n"; $chunk[3] .= "\r\n"; // add the length of the MIME boundary and the chunk to the total content length $length += strlen($chunk[3]) + ($end - $begin + 1); } header('Content-length: ' . $length); } } // don't abort the script on user disconnect during a stream so we can clean up the file handles properly ignore_user_abort(true); $outputBufferLength = 16384; // loop over each requested download chunk and stream it to the browser, adding MIME boundaries if necessary foreach ($chunks as $chunk) { $begin = $chunk[0]; $end = $chunk[1]; $boundary = @$chunk[2]; $length = $end - $begin + 1; // set a new time limit, resetting the timer to 0 @set_time_limit(30); if ($boundary) { echo $boundary; flush(); } $fp = fopen($filepath, 'rb'); fseek($fp, $begin); while ($length && !feof($fp)) { // at the end of the chunk, the buffer length may be longer than the remaining length, so we only need to read up to the end of the chunk $readLength = min($length, $outputBufferLength); echo fread($fp, $readLength); @flush(); $length -= $readLength; if (connection_aborted()) { break; } } // @todo if tracking of downloads by bytes is ever done, log it here fclose($fp); } die(); } else { // File doesn't exist $GLOBALS['ErrorMessage'] = GetLang('DownloadItemErrorMessage'); $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("error"); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); } } else { // Product doesn't exist or the download doesn't exist. $GLOBALS['ErrorMessage'] = GetLang('DownloadItemErrorMessage'); $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("error"); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); } } else { $GLOBALS['SNIPPETS']['AccountDownloadItemList'] = ''; $query = sprintf("select prodname from [|PREFIX|]products where productid='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($product_id)); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $prodName = $GLOBALS['ISC_CLASS_DB']->FetchOne($result); $GLOBALS['DownloadTitle'] = sprintf(GetLang('ProductDownloads'), $prodName); $GLOBALS['DownloadIntro'] = sprintf(GetLang('ProductDownloadsIntro'), $prodName); // Show a listing of the downloadable files within this product $query = sprintf(" select orddate, orderprodid, ordprodid, o.orderid, o.ordtoken, pd.downloadid, pd.downfile, pd.downname, pd.downfilesize, pd.downdescription, pd.downmaxdownloads, pd.downexpiresafter, od.numdownloads, od.maxdownloads, od.downloadexpires, od.orddownid, ordprodqty from [|PREFIX|]product_downloads pd left join [|PREFIX|]order_products op on pd.productid=op.ordprodid inner join [|PREFIX|]orders o on op.orderorderid=o.orderid left join [|PREFIX|]order_downloads od on od.downloadid=pd.downloadid and od.orderid=o.orderid where pd.productid='%d' and o.orderid='%d' and o.deleted = 0 and op.orderprodid='%d' order by downname", $product_id, $order_id, $item_id ); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $expired = false; $Color = ''; $ExpiresDays = ''; $ExpiresDownloads = ''; $GLOBALS['ExpiryInfo'] = ''; if(!$row['orddownid']) { $row['maxdownloads'] = $row['downmaxdownloads']; if($row['downexpiresafter'] > 0) { $row['downloadexpires'] = $row['downexpiresafter'] + $row['orddate']; } } // Have we reached the expiry limit for this item? if ($row['downexpiresafter'] > 0) { $diff = $row['downloadexpires']; if ($row['downloadexpires'] <= time()) { $expired = true; } else { $remaining_days = ceil(($diff-time())/86400); if ($remaining_days > 0 && ($remaining_days % 365) == 0) { if ($remaining_days/365 > 1) { $ExpiresDays = number_format($remaining_days/365)." ".GetLang('YearsLower'); } else { $ExpiresDays = number_format($remaining_days/365)." ".GetLang('YearLower'); } } else if ($remaining_days > 0 && ($remaining_days % 30) == 0) { if ($remaining_days/30 > 1) { $ExpiresDays = number_format($remaining_days/30)." ".GetLang('MonthsLower'); } else { $ExpiresDays = number_format($remaining_days/30)." ".GetLang('MonthLower'); } } else if ($remaining_days > 0 && ($remaining_days % 7) == 0) { if ($remaining_days/7 > 1) { $ExpiresDays = number_format($remaining_days/7)." ".GetLang('WeeksLower'); } else { $ExpiresDays = number_format($remaining_days/7)." ".GetLang('WeekLower'); } } else { if ($remaining_days > 1) { $ExpiresDays = number_format($remaining_days)." ".GetLang('DaysLower'); } else { $ExpiresDays = number_format($remaining_days)." ".GetLang('TodayLower'); $Color = "DownloadExpiresToday"; } } } } // Have we reached the download limit for this item? if ($row['maxdownloads'] > 0) { $remaining_downloads = $row['maxdownloads']-$row['numdownloads']; if ($remaining_downloads <= 0) { $expired = true; } else { $string = 'DownloadExpiresInX'; if ($ExpiresDays) { $string .= 'Download'; } else { $string .= 'Time'; } if ($remaining_downloads != 1) { $string .= 's'; } else { $Color = "DownloadExpiresToday"; } $ExpiresDownloads = sprintf(GetLang($string), $remaining_downloads); } } $GLOBALS['DownloadColor'] = $Color; $GLOBALS['DownloadName'] = isc_html_escape($row['downname']); if ($expired == true) { $GLOBALS['DisplayDownloadExpired'] = ''; $GLOBALS['DisplayDownloadLink'] = 'none'; } else { $GLOBALS['DisplayDownloadExpired'] = 'none'; $GLOBALS['DisplayDownloadLink'] = ''; $GLOBALS['DownloadItemEncrypted'] = $this->EncryptDownloadKey($row['orderprodid'], $row['ordprodid'], $row['orderid'], $row['ordtoken'], $row['downloadid']); $GLOBALS['DownloadName'] = sprintf("<a href=\"%s/account.php?action=download_item&data=%s\">%s</a>", $GLOBALS['ShopPathSSL'], $GLOBALS['DownloadItemEncrypted'], $GLOBALS['DownloadName']); if ($ExpiresDays && $ExpiresDownloads) { $GLOBALS['ExpiryInfo'] = sprintf(GetLang('DownloadExpiresBoth'), $ExpiresDays, $ExpiresDownloads); } else if ($ExpiresDays) { $GLOBALS['ExpiryInfo'] = sprintf(GetLang('DownloadExpiresTime'), $ExpiresDays); if ($Color == "DownloadExpiresToday") { $GLOBALS['ExpiryInfo'] = GetLang('DownloadExpiresTimeToday'); } } else if ($ExpiresDownloads) { $GLOBALS['ExpiryInfo'] = sprintf(GetLang('DownloadExpires'), $ExpiresDownloads); } } if($row['ordprodqty'] > 1) { $GLOBALS['DownloadName'] = $row['ordprodqty']. ' X '.$GLOBALS['DownloadName']; } $GLOBALS['DownloadSize'] = Store_Number::niceSize($row['downfilesize']); $GLOBALS['DownloadDescription'] = isc_html_escape($row['downdescription']); $GLOBALS['OrderId'] = $row['orderid']; $GLOBALS['SNIPPETS']['AccountDownloadItemList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AccountDownloadItemList"); } $GLOBALS['ISC_LANG']['OrderId'] = sprintf(GetLang('OrderId'), $order_id); $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(sprintf("%s - %s", GetConfig('StoreName'), GetLang('DownloadItems'))); $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("account_downloaditem"); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); } } else { // This order does not have any downloadable products that exist $GLOBALS['ErrorMessage'] = GetLang('DownloadItemErrorMessage'); $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("error"); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); } } else { // Bad download details in the URL $GLOBALS['ErrorMessage'] = GetLang('DownloadItemErrorMessage'); $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("error"); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); } } else { $this->ViewOrders(); } }
/** * Sets up the template variables used for displaying the control panel footer * */ public function setupFooter() { if(GetConfig('DebugMode') == 1) { $end_time = microtime_float(); $GLOBALS['ScriptTime'] = number_format($end_time - ISC_START_TIME, 4); $GLOBALS['QueryCount'] = $GLOBALS['ISC_CLASS_DB']->NumQueries; if (function_exists('memory_get_peak_usage')) { $GLOBALS['MemoryPeak'] = "Memory usage peaked at ".Store_Number::niceSize(memory_get_peak_usage(true)); } else { $GLOBALS['MemoryPeak'] = ''; } if (isset($_REQUEST['debug'])) { echo "<ol class='QueryList' style='font-size: 13px;'>\n"; foreach ($GLOBALS['ISC_CLASS_DB']->QueryList as $query) { echo "<li style='line-height: 1.4; margin-bottom: 4px;'>".isc_html_escape($query['Query'])." — <em>".number_format($query['ExecutionTime'], 4)."seconds</em></li>\n"; } echo "</ol>"; } $GLOBALS['DebugDetails'] = "<p>Page built in ".$GLOBALS['ScriptTime']."s with ".$GLOBALS['QueryCount']." queries. ".$GLOBALS['MemoryPeak']."</p>"; } else { $GLOBALS['DebugDetails'] = ''; } $replacements = array( '%%EDITION%%' => $GLOBALS['AppEdition'], '%%VERSION%%' => PRODUCT_VERSION ); $GLOBALS['AdminCopyright'] = strtr(getConfig('AdminCopyright'), $replacements); $this->template->assign('bodyScripts', $this->bodyScripts); $this->template->assign('idletime', ((int) GetConfig('PCILoginIdleTimeMin') * 60 * 1000)); }
/** * Generate the HTML for the list of templates in a specific directory * for the email template editor. * * @param string The relative directory path to fetch the files in (relative to base template directory) * @param string The ID of the parent row for the templates to sit under (nested directories) * @return string The generated HTML. */ public function GetEmailTemplateRows($directory='', $parentRow='') { $templateDirectories = $this->GetEmailTemplateDirectories(); $validPath = false; foreach($templateDirectories as $fullPath) { $root = realpath($fullPath.'/'.$directory); //replace back slashes with forward slashes in the paths, so the strpos function would also work in windows server $root = str_replace('\\', '/',$root); $fullPath = str_replace('\\', '/',$fullPath); if($root && strpos($root, $fullPath) !== false && is_dir($root)) { $validPath = true; break; } } // Path doesn't exist at all! if(!$validPath) { return ''; } // Fetch all of the files in each directory $files = array(); foreach($templateDirectories as $type => $path) { if(!is_dir($path)) { continue; } $directoryFiles = scandir($path.'/'.$directory); $directoryFiles = array_fill_keys($directoryFiles, $type); $files = array_merge($files, $directoryFiles); } if(empty($files)) { return ''; } $output = ''; foreach($files as $file => $type) { // Skip hidden and special directories if(substr($file, 0, 1) == '.') { continue; } $filePath = $templateDirectories[$type].'/'.$directory.'/'.$file; $GLOBALS['FileName'] = isc_html_escape($file); $relativePath = trim($directory.'/'.$file, '/'); $GLOBALS['RelativePath'] = $relativePath; $level = substr_count($relativePath, '/') * 30; if($level > 0) { $GLOBALS['NestingIndent'] = 'padding-left: '.$level.'px'; } else { $GLOBALS['NestingIndent'] = ''; } $GLOBALS['ParentClass'] = ''; if($parentRow) { $GLOBALS['ParentClass'] = 'Child_'.isc_html_escape($parentRow); } $GLOBALS['RowId'] = md5($relativePath); if(is_dir($filePath)) { $GLOBALS['FileSize'] = GetLang('NA'); $GLOBALS['FileDate'] = GetLang('NA'); $output .= $this->template->render('Snippets/EmailTemplateDirectory.html'); } else { $GLOBALS['FileSize'] = Store_Number::niceSize(filesize($filePath)); $GLOBALS['FileDate'] = isc_date(GetConfig('ExtendedDisplayDateFormat'), filemtime($filePath)); $output .= $this->template->render('Snippets/EmailTemplate.html'); } } return $output; }
public function GetDownloadsGrid($productId=0, $productHash='') { if($productId > 0) { $where = sprintf("pd.productid='%d'", $productId); } else { $where = sprintf("pd.prodhash='%s'", $productHash); } $query = sprintf(" select pd.*, sum(od.numdownloads) as numdownloads from [|PREFIX|]product_downloads pd left join [|PREFIX|]order_downloads od on (od.downloadid=pd.downloadid) where %s group by pd.downloadid", $where); $grid = ''; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $GLOBALS['DownloadId'] = $row['downloadid']; $GLOBALS['DownloadFile'] = $row['downfile']; $GLOBALS['NumDownloads'] = number_format($row['numdownloads']); $GLOBALS['DownloadName'] = $row['downname']; if($row['downdescription']) { $GLOBALS['DownloadName'] = sprintf("<span onmouseover=\"ShowQuickHelp(this, '%s', '%s');\" onmouseout=\"HideQuickHelp(this);\" class=\"HelpText\">%s</span>", $GLOBALS['DownloadName'], str_replace("'", "\\'", $row['downdescription']), $GLOBALS['DownloadName']); } $GLOBALS['DownloadSize'] = Store_Number::niceSize($row['downfilesize']); if($row['downmaxdownloads'] == 0) { $GLOBALS['MaxDownloads'] = GetLang('Unlimited'); } else { $GLOBALS['MaxDownloads'] = $row['downmaxdownloads']; } if($row['downexpiresafter']) { $days = $row['downexpiresafter']/86400; if(($days % 365) == 0) { $GLOBALS['ExpiresAfter'] = number_format($days/365)." ".GetLang('YearsLower'); } else if(($days % 30) == 0) { $GLOBALS['ExpiresAfter'] = number_format($days/30)." ".GetLang('MonthsLower'); } else if(($days % 7) == 0) { $GLOBALS['ExpiresAfter'] = number_format($days/7)." ".GetLang('WeeksLower'); } else { $GLOBALS['ExpiresAfter'] = number_format($days)." ".GetLang('DaysLower'); } } else { $GLOBALS['ExpiresAfter'] = GetLang('Never'); } $grid .= $this->template->render('product.form.downloadrow.tpl'); } return $grid; }
public function display(array $context) { // line 1 echo " "; // line 2 $context['util'] = $this->env->loadTemplate("macros/util.tpl", true); echo "<p class=\"intro\"> \t"; // line 4 echo getLang("GiftCertificatesIntro"); echo "</p> <table class=\"GridPanel SortableGrid AutoExpand\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" id=\"GiftCertificates\" style=\"width:100%;\"> \t"; // line 7 echo " \t<tr class=\"Heading3\"> \t\t<td>Template</td> \t\t<td>File Size</td> \t\t<td>Last Updated</td> \t\t<td>Enabled</td> \t\t<td>Action</td> \t</tr> \t \t"; // line 16 echo " \t"; // line 17 $context['_parent'] = (array) $context; $context['_seq'] = twig_iterator_to_array((isset($context['GiftCertificateThemes']) ? $context['GiftCertificateThemes'] : null)); $countable = is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof Countable); $length = $countable ? count($context['_seq']) : null; $context['loop'] = array( 'parent' => $context['_parent'], 'index0' => 0, 'index' => 1, 'first' => true, ); if ($countable) { $context['loop']['revindex0'] = $length - 1; $context['loop']['revindex'] = $length; $context['loop']['length'] = $length; $context['loop']['last'] = 1 === $length; } foreach ($context['_seq'] as $context['_key'] => $context['theme']) { echo "\t<tr class=\"GridRow GiftCertificate\" giftcertificate:id=\""; // line 18 echo twig_escape_filter($this->env, $this->getAttribute((isset($context['theme']) ? $context['theme'] : null), "id", array(), "any"), "1"); echo "\"> \t\t<td width=\"60%\">"; // line 19 echo twig_escape_filter($this->env, $this->getAttribute((isset($context['theme']) ? $context['theme'] : null), "name", array(), "any"), "1"); echo "</td> \t\t<td>"; // line 20 echo Store_Number::niceSize(twig_escape_filter($this->env, $this->getAttribute((isset($context['theme']) ? $context['theme'] : null), "fileSize", array(), "any"), "1")); echo "</td> \t\t<td>"; // line 21 echo $this->getEnvironment()->getExtension('interspire')->dateFormat(twig_escape_filter($this->env, $this->getAttribute((isset($context['theme']) ? $context['theme'] : null), "lastModified", array(), "any"), "1"), "ExtendedDisplayDateFormat"); echo "</td> \t\t<td> \t\t\t<a class=\"toggleEnabledLink\" href=\"#\"> \t\t\t"; // line 24 echo twig_escape_filter($this->env, $this->getAttribute((isset($context['util']) ? $context['util'] : null), "enabledSwitch", array($this->getAttribute((isset($context['theme']) ? $context['theme'] : null), "isEnabled", array(), "any"), ), "method"), "1"); echo " \t\t\t</a> \t\t</td> \t\t<td style='white-space:nowrap;'> \t\t\t<a class=\"previewLink\" href='#'>Preview</a> \t\t\t<a class=\"editLink\" href='#'>Edit</a> \t\t\t<a class=\"restoreLink\" href='#'>Restore</a> \t\t</td> \t</tr> \t"; ++$context['loop']['index0']; ++$context['loop']['index']; $context['loop']['first'] = false; if ($countable) { --$context['loop']['revindex0']; --$context['loop']['revindex']; $context['loop']['last'] = 0 === $context['loop']['revindex0']; } } $_parent = $context['_parent']; unset($context['_seq'], $context['_iterated'], $context['_key'], $context['theme'], $context['_parent'], $context['loop']); $context = array_merge($_parent, array_intersect_key($context, $_parent)); // line 33 echo "\t \t"; // line 35 echo " \t<tr class=\"giftCertificateEditForm\" style=\"display:none\"> \t\t<td colspan=\"4\"> \t\t\t<div class=\"editBox\" style=\"margin:10px\"></div> \t\t\t<div style=\"padding-bottom:10px; padding-left: 10px;\"> \t\t\t\t<input class=\"FormButton saveButton\" type=\"button\" value=\""; // line 40 echo getLang("Save"); echo "\"/> \t\t\t\t<input class=\"FormButton previewButton\" type=\"button\" value=\""; // line 41 echo getLang("Preview"); echo "\"/> \t\t\t\tor \t\t\t\t<a class=\"cancelLink\" href=\"#\">"; // line 43 echo getLang("Cancel"); echo "</a> \t\t\t</div> \t\t</td> \t\t<td> </td> \t</tr> </table> "; // line 50 echo " <div id=\"giftCertificatePreviewModal\" style=\"display: none;\"> \t<div class=\"ModalTitle\">"; // line 52 echo getLang("GiftCertificatePreview"); echo "</div> \t<div class=\"ModalContent\"> \t\t<table class=\"Panel\" width=\"100%\"> \t\t\t<tr> \t\t\t\t<td><span id=\"giftCertificatePreviewFrame\"></span></td> \t\t\t</tr> \t\t</table> \t</div> \t<div class=\"ModalButtonRow\"> \t\t<input type=\"button\" class=\"closeGiftCertificatePreviewButton FormButton\" value=\""; // line 61 echo getLang("Close"); echo "\"/> \t</div> </div> <script type=\"text/javascript\" src=\"script/layout.giftcertificates.js?"; // line 65 echo twig_escape_filter($this->env, (isset($context['JSCacheToken']) ? $context['JSCacheToken'] : null), "1"); echo "\"></script> <script type='text/javascript'> \$('document').ready(function(){ \tlang.GiftCertificateRestoreConfirmation = '"; // line 68 echo Interspire_Template_Extension::jsFilter(getLang("GiftCertificateRestoreConfirmation"), "'"); echo "'; \t \tLayout.GiftCertificates.Urls = { \t\tedit : 'index.php?ToDo=editGiftCertificateTheme', \t\tsave : 'index.php?ToDo=saveGiftCertificate', \t\trestore : 'index.php?ToDo=restoreGiftCertificate', \t\tpreview : 'index.php?ToDo=exampleGiftCertificate', \t\ttoggleEnabled : 'index.php?ToDo=toggleGiftCertificateEnabled', \t}; \t \tLayout.GiftCertificates.init(); }); </script>"; }
/** * Upload a new image from the Image Manager or TinyMCE itself. Images are thrown in the uploaded_images * directory. Invalid images (no dimensions available, mismatched type) are not accepted. Will output * a JSON encoded array of details about the image just uploaded. */ private function UploadImage() { if(empty($_FILES['Filedata'])) { exit; } $_FILES['Filedata']['filesize'] = Store_Number::niceSize($_FILES['Filedata']['size']); $_FILES['Filedata']['id'] = substr(md5($_FILES['Filedata']['name']), 0, 10); $_FILES['Filedata']['errorfile'] = false; $_FILES['Filedata']['imagepath'] = GetConfig('AppPath').'/'.GetConfig('ImageDirectory').'/uploaded_images/'; $_FILES['Filedata']['duplicate'] = false; if($_FILES['Filedata']['error'] != UPLOAD_ERR_OK) { $_FILES['Filedata']['erorrfile'] = 'badupload'; die(isc_json_encode($_FILES)); } // Sanitise uploaded image file name. $tmpName = $_FILES['Filedata']['tmp_name']; $name = slugify(basename($_FILES['Filedata']['name'])); $info = pathinfo($name); if ($info['filename'] == '') { $name = uniqid().$name; } $destination = ISC_BASE_PATH.'/'.GetConfig('ImageDirectory').'/uploaded_images/'.$name; if(!$this->IsImageFile(isc_strtolower($name))) { $_FILES['Filedata']['errorfile'] = 'badname'; } else if(file_exists($destination)) { $_FILES['Filedata']['duplicate'] = true; } else if(!@move_uploaded_file($tmpName, $destination)) { $_FILES['Filedata']['errorfile'] = 'badupload'; } else if(!$this->IsValidImageFile($destination)) { $_FILES['Filedata']['errorfile'] = 'badtype'; @unlink($destination); } if (!($_FILES['Filedata']['errorfile'] || $_FILES['Filedata']['duplicate'])) { isc_chmod($destination, ISC_WRITEABLE_FILE_PERM); // Get the image dimensions so we can show a thumbnail list($imgWidth, $imgHeight) = @getimagesize($destination); if(!$imgWidth || !$imgHeight) { $imgWidth = 200; $imgHeight = 150; } $_FILES['Filedata']['origwidth'] = $imgWidth; $_FILES['Filedata']['origheight'] = $imgHeight; if($imgWidth > 200) { $imgHeight = (200/$imgWidth) * $imgHeight; $imgWidth = 200; } if($imgHeight > 150) { $imgWidth = (150/$imgHeight) * $imgWidth; $imgHeight = 150; } $_FILES['Filedata']['width'] = $imgWidth; $_FILES['Filedata']['height'] = $imgHeight; $_FILES['Filedata']['name'] = $name; unset($_FILES['Filedata']['tmp_name']); } echo isc_json_encode($_FILES); exit; }
/** * Given a picnik token and a remote file, downloads and processes the remote image, updating and cleaning up local data as required, and sets up template data for displaying to the browser * * @param array $token * @param string $remoteFile * @return bool True on success, false on error - on error, a template variable named 'PicnikError' will be assigned as non-false */ public function receivePicnik($token, $remoteFile) { $this->template->assign('PicnikError', false); $sourceFile = $this->getSourceFileForImage($token['imagetype'], $token['imageid']); if (!$sourceFile) { $this->template->assign('PicnikError', GetLang('PicnikError_NoSourceFile')); return false; } $errorType = null; if (!$this->downloadToFile($remoteFile, $sourceFile, $errorType)) { if ($errorType == 1) { $this->template->assign('PicnikError', GetLang('PicnikError_NoWrite')); } else { $this->template->assign('PicnikError', GetLang('PicnikError_NoDownload')); } return false; } $imageSize = @getimagesize($sourceFile); if (!$imageSize) { $this->template->assign('PicnikError', GetLang('PicnikError_Invalid')); return false; } $callbackData = array(); // the source file has been replaced, now regenerate other files based on it if necessary switch ($token['imagetype']) { case ISC_PICNIK_TYPE_PRODUCTIMAGE: $image = new ISC_PRODUCT_IMAGE((int)$token['imageid']); $image->removeResizedFiles(); $image->saveToDatabase(true); $callbackData['thumbnail'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true); $callbackData['zoom'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true); break; case ISC_PICNIK_TYPE_IMAGEMANAGER: $callbackData['name'] = basename($sourceFile); $callbackData['size'] = Store_Number::niceSize(filesize($sourceFile)); $callbackData['url'] = GetConfig('ShopPathSSL') . '/' . GetConfig('ImageDirectory') . '/uploaded_images/' . $callbackData['name']; $callbackData['dimensions'] = $imageSize[0] . ' x ' . $imageSize[1]; $callbackData['id'] = md5($callbackData['name']); $callbackData['displaywidth'] = $imageSize[0]; $callbackData['displayheight'] = $imageSize[1]; if ($callbackData['displaywidth'] > 200) { $callbackData['displayheight'] = (200 / $callbackData['displaywidth']) * $callbackData['displayheight']; $callbackData['displaywidth']= 200; } if ($callbackData['displayheight'] > 150) { $callbackData['displaywidth'] = (150/$callbackData['displayheight']) * $callbackData['displaywidth']; $callbackData['displayheight'] = 150; } break; } $this->removeToken($token['picniktokenid']); $this->template->assign('PicnikCallbackData', isc_json_encode($callbackData)); return $callbackData; }
public function SetPanelSettings() { $GLOBALS['FooterScripts'] = ''; $GLOBALS['HideLogoutLink'] = 'display: none'; if(CustomerIsSignedIn()) { $GLOBALS['HideLogoutLink'] = ''; } if($_SERVER['REQUEST_METHOD'] == 'POST') { $baseURL = getConfig('ShopPathNormal'); } else { $baseURL = getCurrentLocation(); } if(strpos($baseURL, '?') === false) { $baseURL .= '?'; } else { $baseURL .= '&'; } $fullSiteLink = $baseURL.'fullSite=1'; $GLOBALS['ISC_CLASS_TEMPLATE']->assign('FullSiteLink', $fullSiteLink); // Show Mobile Site link if(canViewMobileSite()) { $mobileSiteURL = preg_replace('/(&)?fullSite=\d*/i', '', $baseURL); $GLOBALS['MobileSiteURL'] = $mobileSiteURL.'fullSite=0'; $GLOBALS['MobileSiteLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('MobileSiteLink'); } // Show "All prices are in [currency code]" $currency = GetCurrencyById($GLOBALS['CurrentCurrency']); if(is_array($currency) && $currency['currencycode']) { $GLOBALS['AllPricesAreInCurrency'] = sprintf(GetLang('AllPricesAreInCurrency'), isc_html_escape($currency['currencyname']), isc_html_escape($currency['currencycode'])); } if(GetConfig('DebugMode') == 1) { $end_time = microtime_float(); $GLOBALS['ScriptTime'] = number_format($end_time - ISC_START_TIME, 4); $GLOBALS['QueryCount'] = $GLOBALS['ISC_CLASS_DB']->NumQueries; if (function_exists('memory_get_peak_usage')) { $GLOBALS['MemoryPeak'] = "Memory usage peaked at ".Store_Number::niceSize(memory_get_peak_usage(true)); } else { $GLOBALS['MemoryPeak'] = ''; } if (isset($_REQUEST['debug'])) { $GLOBALS['QueryList'] = "<ol class='QueryList' style='font-size: 13px;'>\n"; foreach($GLOBALS['ISC_CLASS_DB']->QueryList as $query) { $GLOBALS['QueryList'] .= "<li style='line-height: 1.4; margin-bottom: 4px;'>".isc_html_escape($query['Query'])." — <em>".number_format($query['ExecutionTime'], 4)."seconds</em></li>\n"; } $GLOBALS['QueryList'] .= "</ol>"; } $GLOBALS['DebugDetails'] = "<p>Page built in ".$GLOBALS['ScriptTime']."s with ".$GLOBALS['QueryCount']." queries. ".$GLOBALS['MemoryPeak']."</p>"; } else { $GLOBALS['DebugDetails'] = ''; } // Do we have any live chat service code to show in the footer $modules = GetConfig('LiveChatModules'); if(!empty($modules)) { $liveChatClass = GetClass('ISC_LIVECHAT'); $GLOBALS['LiveChatFooterCode'] = $liveChatClass->GetPageTrackingCode('footer'); } // Load our whitelabel file for the front end require_once ISC_BASE_PATH.'/includes/whitelabel.php'; // Load the configuration file for this template $poweredBy = 0; require_once ISC_BASE_PATH.'/templates/'.GetConfig('template').'/config.php'; if(isset($GLOBALS['TPL_CFG']['PoweredBy'])) { if(!isset($GLOBALS['ISC_CFG']['TemplatePoweredByLines'][$GLOBALS['TPL_CFG']['PoweredBy']])) { $GLOBALS['TPL_CFG']['PoweredBy'] = 0; } $poweredBy = $GLOBALS['TPL_CFG']['PoweredBy']; } // Showing the powered by? $GLOBALS['PoweredBy'] = ''; if($GLOBALS['ISC_CFG']['DisableFrontEndPoweredBy'] == false && isset($GLOBALS['ISC_CFG']['TemplatePoweredByLines'][$poweredBy])) { $GLOBALS['PoweredBy'] = $GLOBALS['ISC_CFG']['TemplatePoweredByLines'][$poweredBy]; } if(empty($GLOBALS['OptimizerConversionScript']) && empty($GLOBALS['OptimizerTrackingScript']) && empty($GLOBALS['OptimizerControlScript'])) { $this->setGwoCookieCrossDomain(); } $GLOBALS['SitemapURL_HTML'] = isc_html_escape(SitemapLink()); $GLOBALS['SNIPPETS']['SitemapLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('SitemapLink'); if (Interspire_TaskManager::hasTasks()) { // hasTasks is only implemented for Internal so this will (should) never run for Resque-based task manager $GLOBALS['FooterScripts'] .= Interspire_TaskManager::getTriggerHtml('json'); } if (ISC_CATEGORY::areCategoryFlyoutsEnabled()) { // this needs to be output from php into the body since it's based on config vars // @todo use the stuff gaston is working on instead // bgiframe fixes some IE-related issues with CSS menus (like hovering over SELECT elements) $GLOBALS['FooterScripts'] .= '<script type="text/javascript" src="' . GetConfig('AppPath') . '/javascript/superfish/js/jquery.bgiframe.min.js?' . GetConfig('JSCacheToken') . '"></script>' . "\n"; $GLOBALS['FooterScripts'] .= '<script type="text/javascript" src="' . GetConfig('AppPath') . '/javascript/superfish/js/superfish.js?' . GetConfig('JSCacheToken') . '"></script>' . "\n"; $GLOBALS['FooterScripts'] .= '<script type="text/javascript"> $(function(){ if (typeof $.fn.superfish == "function") { $("ul.sf-menu").superfish({ delay: ' . ((float)GetConfig('categoryFlyoutMouseOutDelay') * 1000) . ', dropShadows: ' . isc_json_encode(GetConfig('categoryFlyoutDropShadow')) . ', speed: "fast" }) .find("ul") .bgIframe(); } }) </script> '; } if (GetConfig('FastCartAction') == 'popup' && GetConfig('ShowCartSuggestions')) { $GLOBALS['SNIPPETS']['FastCartThickBoxJs'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('FastCartThickBoxJs'); } }
private function View() { $GLOBALS['BreadcrumEntries'][GetLang('ManageImages')] = 'index.php?ToDo=manageImages'; // Display within the template $this->template->Assign('PageTitle', 'Manage Images'); $this->template->Assign('PageIntro', 'ManageCatIntro'); $this->template->Assign('CreateItem', 'CreateCategory'); $this->template->Assign('DisplayFilters', 0); $this->template->Assign('MaxFileSize', GetMaxUploadSize()); $currentPage = max((int)@$_GET['page'], 1); if(isset($_GET['perpage'])){ $perPage = (int)$_GET['perpage']; }elseif(isset($_SESSION['imageManagerPagingPerPage']) && (int)$_SESSION['imageManagerPagingPerPage'] > 0){ $perPage = (int)$_SESSION['imageManagerPagingPerPage']; }elseif(isset($_COOKIE['imageManagerPagingPerPage']) && (int)$_COOKIE['imageManagerPagingPerPage'] > 0){ $perPage = (int)$_COOKIE['imageManagerPagingPerPage']; }else{ $perPage = ITEMS_PER_PAGE; } $validSort = array("name.asc", "name.desc", "modified.asc", "modified.desc", "size.asc", "size.desc"); $sortby = ''; if(isset($_GET['sortby'])){ $sortby = $_GET['sortby']; }elseif(isset($_SESSION['imageManagerSortBy'])){ $sortby = $_SESSION['imageManagerSortBy']; }elseif(isset($_COOKIE['imageManagerSortBy'])){ $sortby = $_COOKIE['imageManagerSortBy']; } if(empty($sortby) || !in_array($sortby, $validSort, true)){ $sortby = 'name.asc'; } setcookie('imageManagerSortBy', $sortby, time()+(60*60*24*365), '/'); $_SESSION['imageManagerSortBy'] = $sortby; $sortBits = explode('.', $sortby); $sortField = $sortBits[0]; $sortDirection = $sortBits[1]; $this->template->Assign('Sort'.ucfirst(isc_strtolower($sortField)).ucfirst(isc_strtolower($sortDirection)), "selected=\"selected\""); setcookie('imageManagerPagingPerPage', $perPage, time()+(60*60*24*365), '/'); $_SESSION['imageManagerPagingPerPage'] = $perPage; $imageDir = new ISC_IMAGEDIR($sortDirection, $sortField); $dirCount = $imageDir->CountDirItems(); if($imageDir->CountDirItems() == 0){ $this->template->Assign('hasImages', false); }else{ $this->template->Assign('hasImages', true); } $imageDir->sortField = $sortField; $imageDir->sortDirection = $sortDirection; if ($perPage > 0) { $imageDir->start = ($perPage * $currentPage) - $perPage; $imageDir->finish = ($perPage * $currentPage); } $numPages = 1; if ($perPage == 0) { $this->template->Assign('PerPageAllSelected', "selected=\"selected\""); } else { $numPages = ceil($dirCount / $perPage); $this->template->Assign('paging', $this->GetNav($currentPage, $dirCount, $perPage)); $this->template->Assign('PerPage'.$perPage.'Selected', "selected=\"selected\""); } $this->template->Assign('PageNumber', $currentPage); $this->template->Assign('sessionid', SID); // authentication checks the token stored in the cookie, however the flash uploader doesn't send cookies so we need to store the token in the session and then retrieve it $_SESSION['STORESUITE_CP_TOKEN'] = $_COOKIE['STORESUITE_CP_TOKEN']; if ($numPages > 1) { $this->template->Assign('ImagesTitle', sprintf(GetLang('imageManagerCurrentImages'), $imageDir->start+1, min($imageDir->finish, $dirCount), $dirCount)); } else { $this->template->Assign('ImagesTitle', sprintf(GetLang('imageManagerCurrentImagesSingle'), $dirCount, $dirCount)); } // generate list of images $images = $imageDir->GetImageDirFiles(); $imagesList = ""; foreach ($images as $image) { $image_name = isc_html_escape($image['name']); $image_size = isc_html_escape(Store_Number::niceSize($image['size'])); $imagesList .= sprintf("AdminImageManager.AddImage('%s', '%s', '%s', '%s', '%s', '%s', '%s');\n", isc_html_escape($image['name']), isc_html_escape($image['url']), isc_html_escape(Store_Number::niceSize($image['size'])), $image['width'], $image['height'], $image['origheight'] . " x " . $image['origwidth'], $image['id'] ); } $this->template->Assign("imagesList", $imagesList); $this->template->Assign("sessionid", session_id()); if (!empty($images)) { $this->template->Assign('hideHasNoImages', 'none'); } else { $this->template->Assign('hideImages', 'none'); } $this->engine->PrintHeader(); $this->template->display('imgman.view.tpl'); $this->engine->PrintFooter(); }
/** * Generate the configurable product fields if this product has any. */ public function LoadProductFieldsLayout() { $output = ''; $productId = $this->productClass->GetProductId(); $fields = $this->productClass->GetProductFields($productId); if(empty($fields)) { return; } foreach($fields as $field) { $GLOBALS['ProductFieldType'] = isc_html_escape($field['type']); $GLOBALS['ItemId'] = 0; $GLOBALS['ProductFieldId'] = (int)$field['id']; $GLOBALS['ProductFieldName'] = isc_html_escape($field['name']); $GLOBALS['ProductFieldInputSize'] = ''; $GLOBALS['ProductFieldRequired'] = ''; $GLOBALS['FieldRequiredClass'] = ''; $GLOBALS['CheckboxFieldNameLeft'] = ''; $GLOBALS['CheckboxFieldNameRight'] = ''; $GLOBALS['HideCartFileName'] = 'display:none'; $GLOBALS['HideDeleteFileLink'] = 'display:none'; $GLOBALS['HideFileHelp'] = "display:none"; $snippetFile = 'ProductFieldInput'; switch ($field['type']) { case 'textarea': { $snippetFile = 'ProductFieldTextarea'; break; } case 'file': { if(!$GLOBALS['ISC_CLASS_TEMPLATE']->getIsMobileDevice()) { $GLOBALS['HideFileHelp'] = ""; $GLOBALS['FileSize'] = Store_Number::niceSize($field['fileSize']*1024); $GLOBALS['FileTypes'] = $field['fileType']; } if($field['required']) { $this->hasRequiredFileFields = true; } break; } case 'checkbox': { $GLOBALS['CheckboxFieldNameLeft'] = isc_html_escape($field['name']); $snippetFile = 'ProductFieldCheckbox'; break; } case 'select': $options = explode(',', $field['selectOptions']); $optionStr = '<option value="">' . GetLang('PleaseChooseAnOption') . '</option>'; foreach ($options as $option) { $option = trim($option); $optionStr .= "<option value=\"" . isc_html_escape($option) . "\">" . isc_html_escape($option) . "</option>\n"; } $GLOBALS['SelectOptions'] = $optionStr; $snippetFile = 'ProductFieldSelect'; break; default: break; } if($field['required']) { $GLOBALS['ProductFieldRequired'] = '<span class="Required">*</span>'; $GLOBALS['FieldRequiredClass'] = 'FieldRequired'; } $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippetFile); } $GLOBALS['SNIPPETS']['ProductFieldsList'] = $output; }
function GetMaxUploadSize() { $sizes = array( "upload_max_filesize" => ini_get("upload_max_filesize"), "post_max_size" => ini_get("post_max_size") ); $max_size = -1; foreach ($sizes as $size) { if (!$size) { continue; } $unit = isc_substr($size, -1); $size = isc_substr($size, 0, -1); switch (isc_strtolower($unit)) { case "g": $size *= 1024; case "m": $size *= 1024; case "k": $size *= 1024; } if ($max_size == -1 || $size > $max_size) { $max_size = $size; } } return Store_Number::niceSize($max_size); }
public function EditConfigurableFieldsInCart() { $quote = getCustomerQuote(); if(!isset($_REQUEST['itemid']) || !$quote->hasItem($_REQUEST['itemid'])) { return false; } $output = ''; $item = $quote->getItemById($_REQUEST['itemid']); $existingConfiguration = $item->getConfiguration(); $GLOBALS['ItemId'] = $item->getId(); $GLOBALS['ISC_CLASS_PRODUCT'] = GetClass('ISC_PRODUCT'); $GLOBALS['CartProductName'] = isc_html_escape($item->getName()); $fields = $item->getConfigurableOptions(); foreach($fields as $field) { $GLOBALS['ProductFieldType'] = isc_html_escape($field['fieldtype']); $GLOBALS['ProductFieldId'] = (int)$field['productfieldid']; $GLOBALS['ProductFieldName'] = isc_html_escape($field['fieldname']); $GLOBALS['ProductFieldRequired'] = ''; $GLOBALS['FieldRequiredClass'] = ''; $GLOBALS['ProductFieldValue'] = ''; $GLOBALS['ProductFieldFileValue'] = ''; $GLOBALS['HideCartFileName'] = 'display: none'; $GLOBALS['CheckboxFieldNameLeft'] = ''; $GLOBALS['CheckboxFieldNameRight'] = ''; $GLOBALS['HideDeleteFileLink'] = 'display: none'; $GLOBALS['HideFileHelp'] = "display:none"; $configurableField = array( 'type' => '', 'name' => '', 'fileType' => '', 'fileOriginalName' => '', 'value' => '', 'selectOptions' => '', ); if(isset($existingConfiguration[$field['productfieldid']])) { $configurableField = $existingConfiguration[$field['productfieldid']]; } $snippetFile = 'ProductFieldInput'; switch ($field['fieldtype']) { case 'textarea': { $GLOBALS['ProductFieldValue'] = isc_html_escape($configurableField['value']); $snippetFile = 'ProductFieldTextarea'; break; } case 'file': { $fieldValue = isc_html_escape($configurableField['fileOriginalName']); $GLOBALS['HideDeleteCartFieldFile'] = ''; $GLOBALS['CurrentProductFile'] = $fieldValue; $GLOBALS['ProductFieldFileValue'] = $fieldValue; $GLOBALS['HideFileHelp'] = ""; $GLOBALS['FileSize'] = Store_Number::niceSize($field['fieldfilesize']*1024); if($fieldValue != '') { $GLOBALS['HideCartFileName'] = ''; } if(!$field['fieldrequired']) { $GLOBALS['HideDeleteFileLink'] = ''; } $GLOBALS['FileTypes'] = isc_html_escape($field['fieldfiletype']); break; } case 'checkbox': { $GLOBALS['CheckboxFieldNameLeft'] = $GLOBALS['ProductFieldName']; if($configurableField['value'] == 'on') { $GLOBALS['ProductFieldValue'] = 'checked'; } $snippetFile = 'ProductFieldCheckbox'; break; } case 'select': $options = explode(',', $configurableField['selectOptions']); $optionStr = '<option value="">' . GetLang('PleaseChooseAnOption') . '</option>'; foreach ($options as $option) { $option = trim($option); $selected = ''; if ($option == $configurableField['value']) { $selected = 'selected="selected"'; } $optionStr .= "<option value=\"" . isc_html_escape($option) . "\" " . $selected . ">" . isc_html_escape($option) . "</option>\n"; } $GLOBALS['SelectOptions'] = $optionStr; $snippetFile = 'ProductFieldSelect'; break; default: { $GLOBALS['ProductFieldValue'] = isc_html_escape($configurableField['value']); break; } } if($field['fieldrequired']) { $GLOBALS['ProductFieldRequired'] = '<span class="Required">*</span>'; $GLOBALS['FieldRequiredClass'] = 'FieldRequired'; } $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('Cart'.$snippetFile); } $GLOBALS['SNIPPETS']['ProductFieldsList'] = $output; $editProductFields = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CartEditProductFieldsForm'); echo $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($editProductFields, $GLOBALS['SNIPPETS']); }