Opening modal window after clicking on image - php

I'm trying to open modal window with full picture inside for every thumbnail on list after clicking on it. There is my code with my tries of doing that. Does anyone know how should I do that?
<?php
$directory = 'uploads/delivery-pictures/';
// Zamieniamy znaki, bo w nazwach plikow nie ma znaku /
$npsNumber = str_replace('/', '_', $model->getNps());
$images = glob($directory . $npsNumber . '_' . $model->delivery_no . '*' .'*_m.jpg', GLOB_BRACE);
$i = 0;
if (empty($images)) {
echo 'Brak zdjęć';
}
foreach($images as $image) {
$i = $i + 1;
$id = $npsNumber . '_' . $model->delivery_no . '_' . $i;
echo '<img id=' . $id . ' src=https://produkcja.onix.lh/' . $image . ' />';
}
Modal::begin([
'header'=>'<h4>Zdjęcie dla dostawy'. $model->delivery_no .'</h4>',
'id' => 'modal',
'size'=>'modal-lg',
]);
echo "<div id='modalContent'>Zawartosc</div>";
Modal::end();
$this->registerJs(
"
$('".$id."').click(function (){
$('#modal').modal('show')
.find('#modalContent');
//.load($(this).attr('value'));
});
"
);
?>

I have found the solution, if someone is interested in it, I have pasted my code below.
<?php
$directory = 'uploads/delivery-pictures/';
// Zamieniamy znaki, bo w nazwach plikow nie ma znaku /
$npsNumber = str_replace('/', '_', $model->getNps());
$images = glob($directory . $npsNumber . '_' . $model->delivery_no . '*' .'*_m.jpg', GLOB_BRACE);
$i = 0;
if (empty($images)) {
echo 'Brak zdjęć';
}
echo "<script>
function showImg(srcImg){
console.log('debug2');
$('#modalImg').attr('src', srcImg);
$('#modal').modal('show');
};
</script>";
foreach($images as $image) {
$i = $i + 1;
$id = $npsNumber . '_' . $model->delivery_no . '_' . $i;
$fullImage = str_replace('_m', '_d', $image);
echo '<img id="' . $id . '" src="https://produkcja.onix.lh/' . $image . '" />';
echo "<script>
var currentId = \"".$id."\";
console.log(currentId);
$('#".$id."').click(function(){showImg(\"https://produkcja.onix.lh/" . $fullImage . "\")});
</script>";
}
Modal::begin([
'header'=>'<center><h4>Zdjęcie dla dostawy '. $model->delivery_no .'</h4></center>',
'id' => 'modal',
'size'=>'modal-lg',
]);
echo '<center><img id="modalImg" src="https://produkcja.onix.lh/' . $fullImage . '" /></center>';
Modal::end();
?>

Related

php truncate file path to display file name

Trying to display filename but code is resulting in full file url displaying
if (trim($s) == "") continue;
$arrfilename = explode("\/", $s);
$shortfilename = $arrfilename[count($arrfilename)-1];
$path_parts = pathinfo($s);
$dir = $path_parts['dirname'];
$basename = $path_parts['basename'];
$ext = $path_parts['extension'];
$fn = $path_parts['filename'];
$sliderimage = $dir . '/' . $fn . '.' . $ext;
if (!file_exists($sliderimage) && !file_exists('../' . $sliderimage)) $sliderimage = $s;
$output .= '[setslideshowlinkattributes ssrs="' . $s . '"]<img src="/' . $sliderimage . '" alt="' .$shortfilename . '" /></a>';
}
$output .= '</div>';
$output .= ' <div id="htmlcaption" style="display: inline;">' . $this->options->slideshowcaption . '</div>';
$output .= '</div>';

Different Variables with same value effecting change on the other

Question:
Is there something weird about date-time that would affect the assignment of a variable?
The situation:
From Controller I'm passing a variable $startDate and on the view assigning it to different variables $day1, $day2, etc etc. I go through a loop on $day1 and I modify the day to increment $day1 by 1 using $day1->modify("+1 day")
$day2 the loop (in the else portion) doesn't trigger because the value of $startDate is too high. however, it's value should be the same as $day1 before modification.
the Code:
The controller
public function appointmentSearch()
{
$counselor = $this->session->userdata('idUser');
if($this->input->post('SearchAppointments'))
{
$fromDate = $_POST['fromDate'];
$fromTimeSlot = $this->Admin_model->TimeConversion($_POST['fromTime']);
$toDate = $_POST['toDate'];
$toTimeSlot = $this->Admin_model->TimeConversion($_POST['toTime']);
$theStart = new DateTime($fromDate);
$theEnd = new DateTime($toDate);
$difference = $theEnd->diff($theStart);
$dayCount = $difference->d;
$timeCount = (int)$toTimeSlot-(int)$fromTimeSlot;
$data['schedule'] = true;
$data['days'] = $dayCount;
$data['slots'] = $timeCount;
$data['dayStart'] = $theStart;
$data['dayEnd'] = $theEnd;
$data['slotStart'] = $fromTimeSlot;
$data['slotEnd'] = $toTimeSlot;
$data['r1Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,1);
$data['r2Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,2);
$data['r3Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,3);
$data['r4Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,4);
$data['r5Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,5);
$data['r6Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,6);
$data['r7Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,7);
$data['r8Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,8);
$data['r9Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,9);
$data['r10Data'] = $this->Admin_model->GetOpenApptTimes($fromDate,$fromTimeSlot,$toDate,$toTimeSlot,10);
$this->load->view('admin/scheduler',$data);
}
}
The View:
<?php
if($schedule == true)
{ //if false we have search results
//classes for the form
$attributes = array('class' => 'row');
//normal attributtes for the time slots if they are blacked out
$subAttUnav = array('class' => 'btn btn-secondary btn-sm');
// if the used time slot is someone they can ask to move
$subAttMove = array('class' => 'btn btn-secondary btn-sm', 'style' => 'background:darkgrey;');
// it's wide open
$subAttOpen = array('class' => 'btn btn-secondary btn-sm');
if(count($r1Data) >= 1)
{ //room 1 has appoints scheduled during the time frame queried
echo '<div class="row" style="width:70%;margin:0 auto;"><h3 class="highlight">Room 1</h3>';
$day1 = $dayStart;
while($day1 <= $dayEnd)
{
$day1format = $day1->format('Y-m-d-H-i-s');
$dayArray = explode('-',$day1format);
for($i = 0;$i <= $slots; $i++)
{
$timeslot = $slotStart + $i;
$label = 'Book: ' . $timeslot . ':00 on ' . $dayArray[1] . '/' . $dayArray[2] . ' ';
foreach($r1Data as $index)
{
$row = explode('-',$index);
//var_dump($row);
$thisDay = $dayArray[0] . '/' . $dayArray[1] . '/' . $dayArray[2];
//echo '$thisDay =' . $thisDay . '</br>';
$apptDay = $row[6] . '/' . $row[7] . '/' . $row[8];
//echo '$apptDay =' . $apptDay . '</br>';
//echo '$timeslot =' . $timeslot . '</br>';
//echo '$row[9] =' . $row[9] . '</br>';
if($thisDay == $apptDay && $timeslot == (int)$row[9])
{ // the appointment date and timeslot matches current slide
echo '<div class="btn btn-secondary btn-sm m-1" style="background:black;" title="Time unavailable">' . $label . '</div>';
}
else
{
echo form_open('AdminForms/booking/' . $dayArray[0] . '/' . $dayArray[1] . '/' . $dayArray[2] . '/' . $timeslot . '/1', $attributes);
echo form_submit("Book",$label,$subAttOpen);
echo form_close();
}
}
}
$placeholder = $day1->modify('+1 day');
$day1 = $placeholder;
}
echo '</div><!-- End of Room 1 data -->';
}
else
{ // no results on query the time frame is wide open
echo '<div class="row" style="width:70%;margin:0 auto;"><h3 class="highlight">Room 1</h3>';
$day1 = $dayStart;
while($day1 <= $dayEnd)
{
$day1format = $day1->format('Y-m-d-H-i-s');
$dayArray = explode('-',$day1format);
for($i = 0;$i <= $slots; $i++)
{
$timeslot = $slotStart + $i;
$label = 'Book: ' . $timeslot . ':00 on ' . $dayArray[1] . '/' . $dayArray[2] . ' ';
echo form_open('AdminForms/booking/' . $dayArray[0] . '/' . $dayArray[1] . '/' . $dayArray[2] . '/' . $timeslot . '/1', $attributes);
echo form_submit("Book",$label,$subAttOpen);
echo form_close();
}
$placeholder = $day1->modify('+1 day');
$day1 = $placeholder;
}
echo '</div><!-- End of Room 1 data -->';
var_dump($dayStart);
}
if(count($r2Data) >= 1)
{ //room 1 has appoints scheduled during the time frame queried
echo '<div class="row" style="width:70%;margin:0 auto;"><h3 class="highlight">Room 2</h3>';
$day2 = $dayStart;
while($day2 <= $dayEnd)
{
$day2format = $day2->format('Y-m-d-H-i-s');
$day2Array = explode('-',$day2format);
for($i = 0;$i <= $slots; $i++)
{
$timeslot = $slotStart + $i;
$label = 'Book: ' . $timeslot . ':00 on ' . $day2Array[1] . '/' . $day2Array[2] . ' ';
foreach($r2Data as $index)
{
$row = explode('-',$index);
//var_dump($row);
$thisDay = $day2Array[0] . '/' . $day2Array[1] . '/' . $day2Array[2];
//echo '$thisDay =' . $thisDay . '</br>';
$apptDay = $row[6] . '/' . $row[7] . '/' . $row[8];
//echo '$apptDay =' . $apptDay . '</br>';
//echo '$timeslot =' . $timeslot . '</br>';
//echo '$row[9] =' . $row[9] . '</br>';
if($thisDay == $apptDay && $timeslot == (int)$row[9])
{ // the appointment date and timeslot matches current slide
echo '<div class="btn btn-secondary btn-sm m-1" style="background:black;" title="Time unavailable">' . $label . '</div>';
}
else
{
echo form_open('AdminForms/booking/' . $day2Array[0] . '/' . $day2Array[1] . '/' . $day2Array[2] . '/' . $timeslot . '/1', $attributes);
echo form_submit("Book",$label,$subAttOpen);
echo form_close();
}
}
}
$placeholder2 = $day2->modify('+1 day');
$day2 = $placeholder2;
}
echo '</div<!-- End of Room 2 data -->';
}
else
{ // no results on query the time frame is wide open
echo '<div class="row" style="width:70%;margin:0 auto;"><h3 class="highlight">Room 2</h3>';
$day2 = $startDate;
while($day2 <= $dayEnd)
{
$day2format = $day2->format('Y-m-d-H-i-s');
$day2Array = explode('-',$day2format);
for($i = 0;$i <= $slots; $i++)
{
$timeslot = $slotStart + $i;
$label = 'Book: ' . $timeslot . ':00 on ' . $day2Array[1] . '/' . $day2Array[2] . ' ';
echo form_open('AdminForms/booking/' . $day2Array[0] . '/' . $day2Array[1] . '/' . $day2Array[2] . '/' . $timeslot . '/1', $attributes);
echo form_submit("Book",$label,$subAttOpen);
echo form_close();
}
$placeholder2 = $day2->modify('+1 day');
$day2 = $placeholder2;
}
echo '</div><!-- End of Room 2 data -->';
}

Magento 2 : Allow customer to edit custom options on Cart

I am trying to add functionality to allow a customer to edit options.
I have created a Module Vendor/COptions.
This is loading custom options and select, however is not getting user selected options.
I would like to know how to received selected options and check if the option is selected.
At the moment this line in Select.php is not receiving anything, and the variable $checked is null.
$configValue = $this->getProduct()->getPreconfiguredValues()->getData('options/' . $_option->getId());
in Vendor/COptions\view\frontend\templates\cart\item\default.phtml :
<?php $selectedOptions = $block->getSelectedOptionList(); ?>
<?php //$_options = Mage::helper('core')->decorateArray($block>getOptions())
$_options = $block->getOptions() ?>
<?php if ($_options AND count($_options)):?>
<dl>
<?php foreach($_options as $_option): ?>
<?php echo $this->getOptionHtml($_option) ?>
<?php endforeach; ?>
</dl>
<?php endif; ?>
in Vendor\COptions\Helper\Rewrite\Product:
public function getCustomOptions(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item, $simple="")
{
$product = $item->getProduct();
$coptions = [];
$coptions = $product->getOptions();
$options = array();
if ($coptions) {
foreach ($coptions as $option) {
$itemOption = $item->getOptionByCode('option_' . $option->getId());
/** #var $group \Magento\Catalog\Model\Product\Option\Type\DefaultType */
$group = $option->groupFactory($option->getType())
->setOption($option)
->setConfigurationItem($item)
->setConfigurationItemOption($itemOption);
if ('file' == $option->getType()) {
$downloadParams = $item->getFileDownloadParams();
if ($downloadParams) {
$url = $downloadParams->getUrl();
if ($url) {
$group->setCustomOptionDownloadUrl($url);
}
$urlParams = $downloadParams->getUrlParams();
if ($urlParams) {
$group->setCustomOptionUrlParams($urlParams);
}
}
}
if($simple == "Y"){
array_push($options, $itemOption['value']);
}else{
$options[] = [
'label' => $option->getTitle(),
'value' => $group->getFormattedOptionValue($itemOption['value']),
'print_value' => $group->getFormattedOptionValue($itemOption['value']),
'option_id' => $option->getId(),
'option_type' => $option->getType(),
'custom_view' => $group->isCustomizedView(),
];
}
}
}
$addOptions = $item->getOptionByCode('additional_options');
if ($addOptions) {
$options = array_merge($options, $this->serializer->unserialize($addOptions->getValue()));
}
return $options;
}
in Vendor/COptions\Block\Rewrite\Catalog\Product\View\Options\Type\Select.php:
public function getValuesHtml()
{
$_option = $this->getOption();
$configValue = $this->getProduct()->getPreconfiguredValues()->getData('options/' . $_option->getId());
$store = $this->getProduct()->getStore();
$this->setSkipJsReloadPrice(1);
// Remove inline prototype onclick and onchange events
if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN ||
$_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_MULTIPLE
) {
$require = $_option->getIsRequire() ? ' required' : '';
$extraParams = '';
$select = $this->getLayout()->createBlock(
\Magento\Framework\View\Element\Html\Select::class
)->setData(
[
'id' => 'select_' . $_option->getId(),
'class' => $require . ' product-custom-option admin__control-select'
]
);
if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN) {
$select->setName('options[' . $_option->getid() . ']')->addOption('', __('-- Please Select --'));
} else {
$select->setName('options[' . $_option->getid() . '][]');
$select->setClass('multiselect admin__control-multiselect' . $require . ' product-custom-option');
}
foreach ($_option->getValues() as $_value) {
$priceStr = $this->_formatPrice(
[
'is_percent' => $_value->getPriceType() == 'percent',
'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent'),
],
false
);
$select->addOption(
$_value->getOptionTypeId(),
$_value->getTitle() . ' ' . strip_tags($priceStr) . '',
['price' => $this->pricingHelper->currencyByStore($_value->getPrice(true), $store, false)]
);
}
if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_MULTIPLE) {
$extraParams = ' multiple="multiple"';
}
if (!$this->getSkipJsReloadPrice()) {
$extraParams .= ' onchange="opConfig.reloadPrice()"';
}
$extraParams .= ' data-selector="' . $select->getName() . '"';
$select->setExtraParams($extraParams);
if ($configValue) {
$select->setValue($configValue);
}
return $select->getHtml();
}
if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_RADIO ||
$_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX
) {
$selectHtml = '<div class="options-list nested" id="options-' . $_option->getId() . '-list">';
$require = $_option->getIsRequire() ? ' required' : '';
$arraySign = '';
switch ($_option->getType()) {
case \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_RADIO:
$type = 'radio';
$class = 'radio admin__control-radio';
if (!$_option->getIsRequire()) {
$selectHtml .= '<div class="field choice admin__field admin__field-option">' .
'<input type="radio" id="options_' .
$_option->getId() .
'" class="' .
$class .
' product-custom-option" name="options[' .
$_option->getId() .
']"' .
' data-selector="options[' . $_option->getId() . ']"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' value="" checked="checked" /><label class="label admin__field-label" for="options_' .
$_option->getId() .
'"><span>' .
__('None') . '</span></label></div>';
}
break;
case \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX:
$type = 'checkbox';
$class = 'checkbox admin__control-checkbox';
$arraySign = '[]';
break;
}
$count = 1;
foreach ($_option->getValues() as $_value) {
$count++;
$priceStr = $this->_formatPrice(
[
'is_percent' => $_value->getPriceType() == 'percent',
'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent'),
]
);
$htmlValue = $_value->getOptionTypeId();
if ($arraySign) {
$checked = is_array($configValue) && in_array($htmlValue, $configValue) ? 'checked' : '';
} else {
$checked = $configValue == $htmlValue ? 'checked' : '';
}
$dataSelector = 'options[' . $_option->getId() . ']';
if ($arraySign) {
$dataSelector .= '[' . $htmlValue . ']';
}
$selectHtml .= '<div class="field choice admin__field admin__field-option' .
$require .
'">' .
'<input type="' .
$type .
'" class="' .
$class .
' ' .
$require .
' product-custom-option"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' name="options[' .
$_option->getId() .
']' .
$arraySign .
'" id="options_' .
$_option->getId() .
'_' .
$count .
'" value="' .
$htmlValue .
'" ' .
$checked .
' data-selector="' . $dataSelector . '"' .
' price="' .
$this->pricingHelper->currencyByStore($_value->getPrice(true), $store, false) .
'" />' .
'<label class="label admin__field-label" for="options_' .
$_option->getId() .
'_' .
$count .
'"><span>' .
$_value->getTitle() .
'</span> ' .
$priceStr .
'</label>';
$selectHtml .= '</div>';
}
$selectHtml .= '</div>';
return $selectHtml;
}
}

php str_replace strip file extension

I'm trying to make a str_replace in php where i'll strip the file extension of any kind from a db output.
full php script
<?php
/* YOU CAN PLACE YOUR CUSTOM FUNCTIONS IN HERE TO MAKE UPDATING EASIER. THEY WILL NOT BE OVERWRITTEN BY UPDATES */
//display video player
function displayPlayerHtml5($rrow, $width = 590, $height = 475, $skipAutoPlay = false) {
global $domain;
global $licenseKeyHTML5;
global $basehttp;
global $video_url;
global $player_streamer;
global $encodeTrailer;
global $modsec_enabled;
global $adultCentroPassword;
global $player_watermark_url;
global $video_path;
if ($player_streamer == 'rtmp') {
unset($video_url);
}
if (strpos($width, '%') === false) {
$width = $width . 'px';
}
if (strpos($height, '%') === false) {
$height = $height . 'px';
}
if ($rrow['embed']) {
echo resizeEmbedded($rrow['embed'], $width, $height);
} else {
if ($rrow['hotlinked']) {
if (stripos($rrow['hotlinked'], 'adultcentro') !== false) {
$defaultFile = $basehttp . '/index.php' . urlencode('?controller=adultCentroGetLink&id=' . str_replace('adultcentro', '', $rrow['hotlinked']) . '&hash=' . md5($adultCentroPassword . str_replace('adultcentro', '', $rrow['hotlinked']) . $_SERVER['REMOTE_ADDR']));
} else {
$defaultFile = $rrow['hotlinked'];
}
} else {
$video_file = $rrow['filename'];
$subdir = $rrow[filename][0] . '/' . $rrow[filename][1] . '/' . $rrow[filename][2] . '/' . $rrow[filename][3] . '/' . $rrow[filename][4] . '/';
if ($encodeTrailer && $rrow['trailer_filename'] && !$_SESSION['userid']) {
$rrow['filename'] = $rrow['trailer_filename'];
}
if ($modsec_enabled) {
$defaultFile = getMediaLink($subdir . $rrow['filename']);
} else {
$defaultFile = $video_url . '/' . $subdir . $rrow['filename'];
$FileWebmpath = $video_path . '/' . $subdir . str_replace(".mp4",".webm",$rrow['filename']);
$FileFLVpath = $video_path . '/' . $subdir . str_replace(".mp4",".flv",$rrow['filename']);
}
}
if (file_exists($FileWebmpath)) {
$FileWebm = ($video_url . '/' . $subdir . str_replace(".mp4",".webm",$rrow['filename']));
} else {}
if (file_exists($FileFLVpath)) {
$FileFLV = ($video_url . '/' . $subdir . str_replace(".mp4",".flv",$rrow['filename']));
} else {}
?>
<? $subtitle = ($video_path . '/' . $subdir . $rrow['filename']) . ('-da.vtt');
if (file_exists($subtitle)) {
$subtitles = ($video_url . '/' . $subdir . $rrow['filename']) . ('-da.vtt');
} else {
}
?>
<div id="with-subtitles"
class="minimalist flowplayer play-button color-light"
preload="metadata"
data-swf="//<? echo $domain; ?>/includes/html5/flowplayer.swf"
data-key="<? echo $licenseKeyHTML5; ?>"
data-logo="<? echo $player_watermark_url; ?>"
data-splash="true"
data-embed="false"
data-fullscreen="true"
data-poster="<? echo getThumbUrl($rrow['orig_filename'],$rrow['filename'],$rrow['main_thumb'],true); ?>"
data-analytics="UA-31104891-3"
>
<video>
<source type="video/mp4" src="<? echo $defaultFile; ?>">
<source type="video/webm" src="<? echo $FileWebm; ?>">
<source type="video/flash" src="<? echo $FileFLV; ?>">
<track kind="subtitles" srclang="da" label="Dansk" src="<? echo $subtitles; ?>">
</video>
</div>
<?
}
}
//display video player Admin Interface
function displayPlayerHtml5adm($rrow, $width = 450, $height = 300, $skipAutoPlay = false) {
global $domain;
global $licenseKeyHTML5;
global $basehttp;
global $video_url;
global $player_streamer;
global $encodeTrailer;
global $modsec_enabled;
global $adultCentroPassword;
global $player_watermark_url;
if ($player_streamer == 'rtmp') {
unset($video_url);
}
if (strpos($width, '%') === false) {
$width = $width . 'px';
}
if (strpos($height, '%') === false) {
$height = $height . 'px';
}
if ($rrow['embed']) {
echo resizeEmbedded($rrow['embed'], $width, $height);
} else {
if ($rrow['hotlinked']) {
if (stripos($rrow['hotlinked'], 'adultcentro') !== false) {
$defaultFile = $basehttp . '/index.php' . urlencode('?controller=adultCentroGetLink&id=' . str_replace('adultcentro', '', $rrow['hotlinked']) . '&hash=' . md5($adultCentroPassword . str_replace('adultcentro', '', $rrow['hotlinked']) . $_SERVER['REMOTE_ADDR']));
} else {
$defaultFile = $rrow['hotlinked'];
}
} else {
$video_file = $rrow['filename'];
$subdir = $rrow[filename][0] . '/' . $rrow[filename][1] . '/' . $rrow[filename][2] . '/' . $rrow[filename][3] . '/' . $rrow[filename][4] . '/';
if ($encodeTrailer && $rrow['trailer_filename'] && !$_SESSION['userid']) {
$rrow['filename'] = $rrow['trailer_filename'];
}
if ($modsec_enabled) {
$defaultFile = getMediaLink($subdir . $rrow['filename']);
} else {
$defaultFile = $video_url . '/' . $subdir . $rrow['filename'];
}
}
?>
<link rel="stylesheet" type="text/css" href="//<? echo $domain; ?>/includes/html5/skin/minimalist.css">
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="//<? echo $domain; ?>/includes/html5/flowplayer.min.js"></script>
<div class="flowplayer play-button color-light"
style="max-width: 450px; max-hight: 300px;"
data-swf="//<? echo $domain; ?>/includes/html5/flowplayer.swf"
preload="metadata"
data-key="<? echo $licenseKeyHTML5; ?>"
data-splash="true"
data-fullscreen="true"
data-embed="false"
data-poster="<? echo getThumbUrl($rrow['orig_filename'],$rrow['filename'],$rrow['main_thumb'],true); ?>">
<video>
<source type="video/mp4" src="<? echo $defaultFile; ?>">
</video>
</div>
<?
}
}
?>
I would like it to replace any of the .flv .mp4 .webm etc. whit a fixed value of .webm and .flv ..... if file do exist. So a file check is mandatory.
I can't manipulate/add columns to db do to featured upgrades..
a few ex. on filename from db 54b1d96b89943.flv 5547e6f7b2694Politijagtmedover200km_t-[720p].mp4
Can anyone help me out here?
As i understood from your question. You can try this
$fileExtensions=array(original file extensions here);
$replacement=array(replacement extensions);
Then
if(file_exists($fileName)){ str_replace($fileExtensions, $replacement, $fileName);
}
while ( substr($filename,-1)!=".") ){
$filename = substr($filname,0,-1);
}
$filename = substr($filname,0,-1);
$newext=".flv";
$newfilename = $filename.$newext;

Loop through images not working

With this code, the ID is always 1. I want it to add +1 for each times it loops through the messages.
Like ex1, ex2 ex3 etc. etc.
I cant figure it out whats wrong. Could anyone help?
foreach ($message['attachment'] as $attachment)
{
if ($attachment['is_image'])
{
if ($attachment['thumbnail']['has_thumb'])
echo '<img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" border="0" class="opplastetbilde"/><br />';
else
$id = 1;
if ($id < 10) {
echo '<span class="zoom" id="ex' . $id . '"><img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" border="0" class="opplastetbilde"/></span><br />';
$id++;
}
}
echo '<img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" /> ' . $attachment['name'] . ' (', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br />';
}
move this before foreach or it is always reinitialize $id
$id = 1;
foreach ($message['attachment'] as $attachment)
{
Right now, you're setting $id = 1 each time you loop through the array
foreach ($message['attachment'] as $attachment) {
// ...
$id = 1;
// ...
}
In order to increment it properly, you need to place it before the loop
$id = 1;
foreach ($message['attachment'] as $attachment) {
// ...
}

Categories