A Plugin that I use on my website use Chart.js
I try to start Y-Axis at a defined value.
Here's a picture of what I have now :
Line Chart
the javascript code :
(function() {
Chart.types.Line.extend({
name:'UncontinuousLine',
defaults:{scaleBeginAtZero:false},
initialize:function(data) {
Chart.types.Line.prototype.initialize.apply(this,arguments);
},
draw:function() {
Chart.types.Line.prototype.draw.apply(this,arguments);
var ctx=this.chart.ctx;
this.datasets.forEach(function(ds) {
ctx.strokeStyle=ds.strokeColor;
var prevPt={value:2.49};
ds.points.forEach(function(curPt) {
if(parseInt(curPt.value)<=0) {
curPt.value=prevPt.value;
}
if(parseInt(curPt.value)>0&&parseInt(prevPt.value)>0) {
ctx.beginPath();
ctx.moveTo(prevPt.x,prevPt.y);
ctx.lineTo(curPt.x,curPt.y);
ctx.stroke();
}
prevPt=curPt;
});
});
}
});})();
and the php code :
private function _create_uncontinuousline_chart( $data, $opt ){
if ( empty( $data ) ){
return '';
}
$id = self::_get_canvas_id( $this->count );
$sets = self::_parse_data( $data, 3 );
$cd = self::_resort_sets( $sets, true );
$this->js[] = 'new Chart(' . "jQuery('#$id').get(0).getContext('2d')" . ')
.UncontinuousLine(' . AimyChartsContentPluginHelper::phpva_json_encode( $cd ) . ','
. '{' . 'animation: ' . ( $opt[ 'animate' ] ? 'true' : 'false' ) . ','
. 'multiTooltipTemplate: ' . '"<%= value %> (<%= datasetLabel %>)"'
. ',responsive: ' . ( $opt[ 'responsive' ] ? 'true' : 'false' )
. ',datasetStrokeWidth:0.01' . '}' . ');';
return self::_get_canvas( 'UncontinuousLine', $this->count, $opt );
}
I've tried many things but impossible to start my y-axis at 1 for example...
Does someone know how i can do that ?
In your options, use this:
scaleBeginAtZero : false,
scaleOverride: true,
scaleStartValue: 1,
Try this for your php code:
private function _create_uncontinuousline_chart( $data, $opt ){
if ( empty( $data ) ){
return '';
}
$id = self::_get_canvas_id( $this->count );
$sets = self::_parse_data( $data, 3 );
$cd = self::_resort_sets( $sets, true );
$this->js[] = 'new Chart(' . "jQuery('#$id').get(0).getContext('2d')" . ')
.UncontinuousLine(' . AimyChartsContentPluginHelper::phpva_json_encode( $cd ) . ','
. '{' . 'animation: ' . ( $opt[ 'animate' ] ? 'true' : 'false' )
. ',multiTooltipTemplate: ' . '"<%= value %> (<%= datasetLabel %>)"'
. ',responsive: ' . ( $opt[ 'responsive' ] ? 'true' : 'false' )
. ',datasetStrokeWidth:0.01'
. ',scaleBeginAtZero : false'
. ',scaleOverride: true'
. ',scaleStartValue: 1'
. '}' . ');';
return self::_get_canvas( 'UncontinuousLine', $this->count, $opt );
Related
I had the hooks below that's working perfectly to change the Products variations select to radio buttons while creating variations using custom attributes.
I added new products variations using the Global Attributes but it seems that the hook is not compatible with it.
am looking for a way to make it compatible with both since I already have 200 products using the custom attributes and want to start using global attributes for the new products.
function variation_radio_buttons($html, $args)
{
$args = wp_parse_args(apply_filters('woocommerce_dropdown_variation_attribute_options_args', $args) , array(
'options' => false,
'attribute' => false,
'product' => false,
'selected' => false,
'name' => '',
'id' => '',
'class' => '',
'show_option_none' => __('Choose an option', 'woocommerce') ,
));
if (false === $args['selected'] && $args['attribute'] && $args['product'] instanceof WC_Product)
{
$selected_key = 'attribute_' . sanitize_title($args['attribute']);
$args['selected'] = isset($_REQUEST[$selected_key]) ? wc_clean(wp_unslash($_REQUEST[$selected_key])) : $args['product']->get_variation_default_attribute($args['attribute']);
}
$options = $args['options'];
$product = $args['product'];
$attribute = $args['attribute'];
$name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title($attribute);
$id = $args['id'] ? $args['id'] : sanitize_title($attribute);
$class = $args['class'];
$show_option_none = (bool)$args['show_option_none'];
$show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __('Choose an option', 'woocommerce');
$label = wc_attribute_label($args['attribute'], $args['product']);
if (empty($options) && !empty($product) && !empty($attribute))
{
$attributes = $product->get_variation_attributes();
$options = $attributes[$attribute];
}
$html = '<select id="' . esc_attr($id) . '" class="d-none ' . esc_attr($class) . '" name="' . esc_attr($name) . '" data-attribute_name="attribute_' . esc_attr(sanitize_title($attribute)) . '" data-show_option_none="' . ($show_option_none ? 'yes' : 'no') . '">';
$html .= '<option value="">' . esc_html($show_option_none_text) . '</option>';
if (!empty($options))
{
if ($product && taxonomy_exists($attribute))
{
// Get terms if this is a taxonomy - ordered. We need the names too.
$terms = wc_get_product_terms($product->get_id() , $attribute, array(
'fields' => 'all'
));
foreach ($terms as $term)
{
if (in_array($term->slug, $options))
{
$html .= '<option value="' . esc_attr($term->slug) . '" ' . selected(sanitize_title($args['selected']) , $term->slug, false) . '>' . esc_html(apply_filters('woocommerce_variation_option_name', $term->name)) . '</option>';
}
}
}
else
{
foreach ($options as $option)
{
// This handles < 2.4.0 bw compatibility where text attributes were not sanitized.
//$selected = sanitize_title( $args['selected'] ) === $args['selected'] ? selected( $args['selected'], sanitize_title( $option ), false ) : selected( $args['selected'], $option, false );
//if (sanitize_title($option) == $current){
//$selected = 'selected';
//}
$selected = '';
$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html(apply_filters('woocommerce_variation_option_name', $option)) . '</option>';
}
}
}
$html .= '</select>';
$radios = '<div class="radio-group">';
if (!empty($options))
{
if ($product && taxonomy_exists($attribute))
{
$terms = wc_get_product_terms($product->get_id() , $attribute, array(
'fields' => 'all',
));
foreach ($terms as $term)
{
if (in_array($term->slug, $options, true))
{
$radios .= '<input id="' . strtolower($option) . '" type="radio" name="' . esc_attr($name) . '" value="' . esc_attr($term->slug) . '" onClick="jQuery("#' . esc_attr($name) . '").val(' . esc_attr($term->slug) . ').trigger("change");" ' . checked(sanitize_title($args['selected']) , $term->slug, false) . '><label for="' . esc_attr($term->slug) . '">' . esc_html(apply_filters('woocommerce_variation_option_name', $term->name)) . '</label>';
}
}
}
else
{
foreach ($options as $option)
{
// $checked = sanitize_title($args['selected']) === $args['selected'] ? checked($args['selected'], sanitize_title($option), false) : checked($args['selected'], $option, false);
//if (sanitize_title($option) == $current){
//$checked = 'checked="checked"';
//}
$checked = '';
$radios .= '<input id="' . strtolower(sanitize_title($option)) . '" type="radio" name="' . esc_attr($name) . '" value="' . esc_attr($option) . '" id="' . sanitize_title($option) . '" onClick="changeTrigger(\'#' . strtolower($attribute) . '\',\'' . esc_attr($option) . '\',\'' . esc_attr($label) . '\');" ' . $checked . '><label for="' . sanitize_title($option) . '">' . esc_html(apply_filters('woocommerce_variation_option_name', $option)) . '</label>';
$allAttribute[] = strtolower($attribute);
}
}
}
$radios .= '</div>';
return $html . $radios;
}
add_filter('woocommerce_dropdown_variation_attribute_options_html', 'variation_radio_buttons', 20, 2);
function variation_check($active, $variation)
{
if (!$variation->is_in_stock() && !$variation->backorders_allowed())
{
return false;
}
return $active;
}
add_filter('woocommerce_variation_is_active', 'variation_check', 10, 2);
if (!function_exists('shop_attributes_in_loop'))
{
function shop_attributes_in_loop()
{
global $product;
//Getting product attributes
$product_attributes = $product->get_attributes();
if (!empty($product_attributes))
{
//Getting product attributes slugs
$product_attribute_slugs = array_keys($product_attributes);
?>
<script>
function resetAttr(c,d){
var attr = c;
jQuery('input[name=attribute_'+c+']').attr('disabled',false);
jQuery('input[name=attribute_'+c+']').attr('checked',false);
jQuery('#' + c + '-selected').html('');
jQuery('#' + c + '-section').removeClass('d-none');
jQuery('#' + c + ' option[value=""]').prop('selected', true);
if(d){
jQuery('#' + c).trigger('change');
}
<?php
foreach ($product_attribute_slugs as $product_attribute_slug)
{
$attribute_name = str_replace('pa_', '', $product_attribute_slug); // Removing "pa_" from attribute slug
//echo 'jQuery(\'#'.$attribute_name.'\').trigger(\'change\');';
?>
var allvalues = [];
jQuery('select#<?php echo $attribute_name; ?>').find('option').each(function() {
if(jQuery('select#<?php echo $attribute_name; ?>').val() == ""){
if(jQuery(this).attr('disabled', false)){
var theValue = jQuery(this).val();
allvalues.push(theValue);
}
}
});
jQuery('input[name="attribute_<?php echo $attribute_name; ?>"]').each(function () {
var theRadio = jQuery(this).val();
var check = allvalues.includes(theRadio);
if(check == false){
jQuery(this).attr('disabled', true);
}else{
jQuery(this).attr('disabled', false);
}
});
<?php
}
?>
}
function changeTrigger(a,b,c){
a = a.replace(/\s+/g, "-");
jQuery(a + ' option[value="' + b + '"]').prop('selected', true);
jQuery(a + '-selected').html('<div class="selected-variable"><span>'+c.replace(/#/, "").toUpperCase()+': '+b+' </span><a class="var-del" onClick="resetAttr(\''+a.replace(/#/, "")+'\',true)"><div class="close-x"></div></a></div>');
jQuery(a + '-section').addClass('d-none');
jQuery('input[name=attribute_'+a.replace(/#/, "")+']').attr('disabled',true);
jQuery(a).trigger('change');
<?php
foreach ($product_attribute_slugs as $product_attribute_slug)
{
$attribute_name = str_replace('pa_', '', $product_attribute_slug); // Removing "pa_" from attribute slug
//echo 'jQuery(\'#'.$attribute_name.'\').trigger(\'change\');';
?>
var allvalues = [];
jQuery('select#<?php echo $attribute_name; ?>').find('option').each(function() {
if(jQuery('select#<?php echo $attribute_name; ?>').val() == ""){
resetAttr('<?php echo $attribute_name; ?>',false);
/*jQuery('input[name=attribute_<?php echo $attribute_name; ?>]').attr('checked',false);*/
if(jQuery(this).attr('disabled', false)){
var theValue = jQuery(this).val();
allvalues.push(theValue);
}
}
});
jQuery('input[name="attribute_<?php echo $attribute_name; ?>"]').each(function () {
var theRadio = jQuery(this).val();
var check = allvalues.includes(theRadio);
if(check == false){
jQuery(this).attr('disabled', true);
}else{
//jQuery(this).attr('disabled', false);
}
});
<?php
}
echo "}</script>";
}
}
}
add_action('woocommerce_before_add_to_cart_button', 'shop_attributes_in_loop');
I want to get set if statement of no. of count of array from database. I already have a if statement checking the count but I am unable to use it in my file.
Help me replicate the count if statement here. I want to wrap pro_type and is_pro in if statement of no. of counts similar in reaferandearn page .
My function where I need if count statement :
users.php file
public function update_valid_refer_point($id){
global $db;
$user_balance = $db->where('id',$id)
->getOne('users',array('balance'));
$_POST['pro_type'] =4;
$_POST['is_pro'] =1;
$bal =$user_balance['balance']+500;
$updated = $db->where('id', $id)
->update('users', array('pro_type' => 4,'is_pro' => 1,'balance' => $bal));
return TRUE;
}
The file where I have similar if count statement but I have no idea how to use it above :
referandearn.php
if(count($data['refferal_data']['data']) > 0){
<?php
}>
referandearn controller :
Class Referearn extends Theme {
public static function LoadreffralUsers() {
global $_AJAX, $_CONTROLLERS;
$data = '';
$ajax_class = realpath($_CONTROLLERS . 'aj.php');
$ajax_class_file = realpath($_AJAX . 'loadmore.php');
if (file_exists($ajax_class_file)) {
require_once $ajax_class;
require_once $ajax_class_file;
$_POST['page'] = 1;
$loadmore = new Loadmore();
$refferal_users = $loadmore->refferal_users();
parent::$data['refferal_data'] = $refferal_users;
/*if (isset($refferal_users['html'])) {
$data = $refferal_users['html'];
}*/
}
return $data;
}
}
And loadmore referusers function :
function refferal_users() {
global $db, $_BASEPATH, $_DS,$_excludes;
if (self::ActiveUser() == NULL) {
return array(
'status' => 403,
'message' => __('Forbidden')
);
}
$error = '';
$page = 0;
$perpage = 7;
$html = '';
$html_imgs = '';
$template = '';
if (isset($_POST) && !empty($_POST)) {
if (isset($_POST[ 'page' ]) && (!is_numeric($_POST[ 'page' ]) || empty($_POST[ 'page' ]))) {
$error = '<p>• ' . __('no page number found.') . '</p>';
} else {
$page = (int) Secure($_POST[ 'page' ]) - 1;
}
}
if ($error == '') {
$limit = $perpage;
$offset = $page * $perpage;
//$query = GetRefferalUserQuery(self::ActiveUser()->id, $limit, $offset);
//exit;
//$refferal_users = $db->rawQuery($query);
$sql = 'SELECT U.id,U.online,U.lastseen,U.username,U.avater,U.country,U.first_name,U.last_name,U.location,U.birthday,U.language,U.relationship,U.height,U.body,U.smoke,U.ethnicity,U.pets,U.gender, RU.refferalDate, RU.refferalCode FROM users U INNER JOIN refferalusers RU ON RU.refferalBy = U.id ';
$sql .= ' WHERE RU.refferalTo = '.self::ActiveUser()->id.' AND ( ';
$sql .= ' U.verified = "1" AND U.privacy_show_profile_random_users = "1" ';
// to exclude blocked users
$notin = ' AND U.id NOT IN (SELECT block_userid FROM blocks WHERE user_id = '.self::ActiveUser()->id.') ';
// to exclude liked and disliked users users
$notin .= ' AND U.id NOT IN (SELECT like_userid FROM likes WHERE ( user_id = '.self::ActiveUser()->id.' OR like_userid = '.self::ActiveUser()->id.' ) ) ';
$sql .= ' ) ';
$sql .= ' ORDER BY U.id DESC LIMIT '.$limit.' OFFSET '.$offset.';';
$random_users = $db->objectBuilder()->rawQuery($sql);
$theme_path = $_BASEPATH . 'themes' . $_DS . self::Config()->theme . $_DS;
//$template = $theme_path . 'partails' . $_DS . 'find-matches' . $_DS . 'random_users.php';
//$template1 = $theme_path . 'partails' . $_DS . 'find-matches' . $_DS . 'matches_imgs.php';
if (file_exists($template)) {
foreach ($random_users as $random_user) {
if($random_user->id!=(int)auth()->id){
ob_start();
require($template);
$html .= ob_get_contents();
ob_end_clean();
}
}
}
return array(
'status' => 200,
'page' => $page + 2,
'html' => $html,
'data' => $random_users
);
} else {
return array(
'status' => 400,
'message' => $error
);
}
}
** Original Navbar**
*This is the structure of my actual navbar which includes a hamburger menu dropdown in mobile size. This doesn't work anymore when I try to make my own custom theme in Wordpress. Somehow the css works partly but the function does not use my JavaScript.
I tried a walker menu (see below) but it still does not work. *
<nav class="navbar">
<div class="container">
<h1 class="logo"> <?php the_title(); ?> </h1>
<div class="hamburger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
<ul class="nav">
<li>Home</li>
<li>About</li>
<li>Location</li>
</ul>
</div>
</nav>
Here my funcions.php
function demo1_menus(){
$locations= array(
'primary' => 'Desktop primary top navbar',
'footer' => 'Footer Menu items'
);
register_nav_menus($locations);
}
add_action('init', 'demo1_menus');
Here my header.php
<?php
wp_nav_menu(
array(
'menu' => 'primary',
'container' => '',
'theme_location' => 'primary',
'items_wrap' => '<ul id="" class="nav">%3$s</ul>',
'walker' => new Demo1_Walker_Nav_Primary()
)
);
?>
Here the walker
Can someone tell me why its not working or provide me another solution to my problem please*
<?php
class Demo1_Walker_Nav_Primary extends Walker_Nav_Menu{
function start_lvl( $output, $depth ){
$indent = str_repeat("\t", $depth );
$submenu =($depth > 0) ? 'sub-menu' : '';
$output .= "\n$indent<ul class=\"nav$submenu depth_$depth\">\n";
}
function start_el( &$output, $item, $depth=0, $args = array(), $id=0 ){
$indent = ( $depth) ? str_repeat( "\t", $depth ) : '';
$li_attributes = '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = ($args->has_children) ? 'nav' : '';
$classes[] = ($item->current || $item->current_item_anchestor) ? 'active': '';
$classes[] = 'menu-item-' . $item->ID;
if($depth && $args->has_children){
$classes[] = 'nav li';
}
$class_names = join(' ',apply_filter('nav_menu_css_class', array_filter($classes ), $item, $args) );
$class_names = ' class="' . esc_attr($class_names) . '"';
$id =apply_filter('nav_menu_item_id', 'menu-item-'.$item->ID, $item, $args);
$id = strlen($id) ? 'id="' . esc_attr($id) . '"' : '';
$output .= $indent . '<li' . $id . $value . $class_names . '>';
// Link attributes.
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$attributes .= ' class="nav' . ( $depth > 0 ? 'line1' : 'line2' ) . '"';
// Build HTML output and pass through the proper filter.
$item_output = sprintf( '%1$s<a%2$s>%3$s%4$s%5$s</a>%6$s',
$args->before,
$attributes,
$args->link_before,
apply_filters( 'the_title', $item->title, $item->ID ),
$args->link_after,
$args->after
);
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
function end_el( &$output, $item, $depth = 0, $args = array() ) {
$output .= "</li>\n";
}
}
}
?>
I would like to make use of Simple HTML DOM parser to search for mail-adresses in the content of a html-site and replace them.
The replacement contains a span element and a little bit JS (this should obfuscate the addresses.
At the moment this works as follows:
$pattern =
"/(?:[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")#(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/";
preg_match_all( $pattern, $content, $matches );
foreach ( $matches[ 0 ] as $email ) {
$content = $this->searchDOM(
$content,
$email,
$this->hide_email($email)
);
}
This is the searchDOM-method:
private function searchDOM( $content, $search, $replace, $excludedParents = [] )
{
$dom = HtmlDomParser::str_get_html(
$content,
true,
true,
DEFAULT_TARGET_CHARSET,
false,
DEFAULT_BR_TEXT,
DEFAULT_SPAN_TEXT
);
foreach ( $dom->find( 'text' ) as $element ) {
if ( !in_array( $element->parent()->tag, $excludedParents ) ) {
$element->innertext = preg_replace(
'/(?<!\w)' . preg_quote( $search, "/" ) . '(?!\w)/i',
$replace,
$element->innertext
);
}
}
return $dom->save();
}
and this is the hide_email-method:
function hide_email( $email )
{
$character_set = '+-.0123456789#ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
$key = str_shuffle( $character_set );
$cipher_text = '';
$id = 'e' . rand( 1, 999999999 );
for ( $i = 0; $i < strlen( $email ); $i += 1 )
$cipher_text .= $key[ strpos( $character_set, $email[ $i ] ) ];
$script = 'var a="' . $key . '";var b=a.split("").sort().join("");var c="' . $cipher_text . '";var d="";';
$script .= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
$script .= 'document.getElementById("' . $id . '").innerHTML=""+d+""';
$script = "eval(\"" . str_replace( [ "\\", '"' ], [ "\\\\", '\"' ], $script ) . "\")";
$script = '<script type="text/javascript">/*<![CDATA[*/' . $script . '/*]]>*/</script>';
return '<span id="' . $id . '">[javascript protected email address]</span>' . $script;
}
Well - this is not working as expected, because the rendered page shows only "[javascript protected email address]". If I have a look at the source, the a-tag is missing.
I have to upload the code
this code for Datalife engine. How do I make the file size limit ~5Mb. And where to put the code? Sorry I'm bad speaking English. Thanks for help.
$allowed_extensions = array ("gif", "jpg", "png", "jpe", "jpeg" );
if ((isset($_FILES['post_add']) && $_FILES['post_add']!='')) {
$file_prefix = time() + rand( 1, 100 );
$file_prefix .= "_";
define( 'FOLDER_PREFIX', date( "Y-m" ) );
if( ! is_dir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX ) ) {
#mkdir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX, 0777 );
#chmod( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX, 0777 );
#mkdir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/thumbs", 0777 );
#chmod( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/thumbs", 0777 );
}
$config_path_image_upload = ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/";
$current_image = 'post_add';
$image = $_FILES[$current_image]['tmp_name'];
$image_name = $_FILES[$current_image]['name'];
$image_size = $_FILES[$current_image]['size'];
$error_code = $_FILES[$current_image]['error'];
$img_name_arr = explode( ".", $image_name );
$type = totranslit( end( $img_name_arr ) );
if( $image_name != "" ) {
$curr_key = key( $img_name_arr );
unset( $img_name_arr[$curr_key] );
$image_name = totranslit( implode( ".", $img_name_arr ) ) . "." . $type;
}
if ( in_array( strtolower( $type ), $allowed_extensions) ) {
#move_uploaded_file( $image, $config_path_image_upload . $file_prefix . $image_name );
if( #file_exists( $config_path_image_upload . $file_prefix . $image_name ) ) {
#chmod( $config_path_image_upload . $file_prefix . $image_name, 0666 );
$row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_images where author = '{$member_id[name]}' AND news_id = '$idpost'" );
if( ! $row['count'] ) {
$added_time = time() + ($config['date_adjust'] * 60);
$inserts = FOLDER_PREFIX . "/" . $file_prefix . $image_name;
$db->query( "INSERT INTO " . PREFIX . "_images (images, author, news_id, date) values ('$inserts', '{$member_id[name]}', '$idpost', '$added_time')" );
} else {
$row = $db->super_query( "SELECT images FROM " . PREFIX . "_images where author = '{$member_id[name]}' AND news_id = '$idpost'" );
if( $row['images'] == "" ) $listimages = array ();
else $listimages = explode( "|||", $row['images'] );
foreach ( $listimages as $dataimages ) {
if( $dataimages == FOLDER_PREFIX . "/" . $file_prefix . $image_name ) $error_image = "stop";
}
if( $error_image != "stop" ) {
$listimages[] = FOLDER_PREFIX . "/" . $file_prefix . $image_name;
$row['images'] = implode( "|||", $listimages );
$db->query( "UPDATE " . PREFIX . "_images set images='{$row['images']}' where author = '{$member_id[name]}' AND news_id = '$idpost'" );
}
}
include_once ENGINE_DIR . '/classes/thumb.class.php';
$tumb_ok = false;
$_POST['make_thumb'] = true;
$_POST['make_watermark'] = $config['allow_watermark'];
if( isset( $_POST['make_thumb'] ) ) {
$thumb = new thumbnail( $config_path_image_upload . $file_prefix . $image_name );
if( $thumb->size_auto( $config['max_image'], $_POST['t_seite'] ) ) {
$thumb->jpeg_quality( $config['jpeg_quality'] );
if( $config['allow_watermark'] == "yes" and $_POST['make_watermark'] == "yes" ) $thumb->insert_watermark( $config['max_watermark'] );
$thumb->save( $config_path_image_upload . "thumbs/" . $file_prefix . $image_name );
}
if( #file_exists( $config_path_image_upload . "thumbs/" . $file_prefix . $image_name ) ) $tumb_ok = true;
#chmod( $config_path_image_upload . "thumbs/" . $file_prefix . $image_name, 0666 );
}
$config['max_up_side'] = intval( $config['max_up_side'] );
if( ($config['allow_watermark'] == "yes" and $_POST['make_watermark'] == "yes") or $config['max_up_side'] ) {
$thumb = new thumbnail( $config_path_image_upload . $file_prefix . $image_name );
$thumb->jpeg_quality( $config['jpeg_quality'] );
if( $config['max_up_side'] ) $thumb->size_auto( $config['max_up_side'] );
if( $config['allow_watermark'] == "yes" and $_POST['make_watermark'] == "yes" ) $thumb->insert_watermark( $config['max_watermark'] );
$thumb->save( $config_path_image_upload . $file_prefix . $image_name );
}
$short_story = preg_replace('/^<br \/>(.*?)(<br \/>)*?$/is', '$1', $short_story);
if ( $tumb_ok ) $short_story = "<!--TBegin--><a href=\"{$config['http_home_url']}uploads/posts/".FOLDER_PREFIX."/{$file_prefix}{$image_name}\" onclick=\"return hs.expand(this)\" ><img align=\"left\" src=\"{$config['http_home_url']}uploads/posts/".FOLDER_PREFIX."/thumbs/{$file_prefix}{$image_name}\" alt='$title' title='$title' /></a><!--TEnd-->".$short_story;
else $short_story = "<img src=\"{$config['http_home_url']}uploads/posts/".FOLDER_PREFIX."/{$file_prefix}{$image_name}\" align=\"left\" alt='$title' title='$title' />".$short_story;
$full_story = "<img src=\"{$config['http_home_url']}uploads/posts/".FOLDER_PREFIX."/{$file_prefix}{$image_name}\" align=\"center\" alt='$title' title='$title' />".$full_story;
$short_story = addslashes($short_story);
$full_story = addslashes($full_story);
$db->query( "UPDATE " . PREFIX . "_post SET short_story='$short_story', full_story='$full_story' where id = '$idpost'" );
}
}
}
I wrote to google translate
why do you want to play around with your code while you can set it in admin cp? the option can be set in system settings for both files and images, the new version of DLE settings are moved to Usergroup Manager