v5.dk logo
Kom ind og besøg vores Discord Chat-community
Bliv medlem her eller læs mere om Discord her
Få adgang til alt på hele v5.dk
- bliv Premium-medlem for kun 39,95 kr.

Mere info Køb nu

Premium på v5.dk
v5.dk logo  v5.dk e-learning
Log på med Facebook
  • Log ind på v5.dk
  • Opret bruger
  • Log ind
  • v5.dk Premium
  • v5.dk Premium
  • Hvad siger vores kunder?
  • E-læring for begyndere
  • icon for WordPress 4 e-learning WordPress 4
  • icon for Office 365 e-learning Office 365
  • icon for Microsoft Word e-learning Microsoft Word
  • Bloggen for alle
  • E-læring for nørder
  • icon for PHP-programmering e-learning PHP-programmering
  • icon for iOS Programmering e-learning iOS Programmering
  • icon for Linux Server e-learning Linux Server
  • Bloggen for nørder
  • Arkiverede videoer
  • Fællesskab
  • Forum
  • Idéer og ønsker
  • Markedspladsen
  • v5.dk Premium
  • Gratis webhotel
  • Cloud-servere
  • Om v5.dk
  • Søg på v5.dk
  • Om v5.dk ApS
    • Om virksomheden
    • RSS-feeds og tjenester
    • Driftsmeddelelser
    • Presse-kit
    • Ledige jobs
    • Social Netværk
      • Facebook
      • Twitter
      • Instagram
    • Alt det andet
      • Forretningsbetingelser
      • Ophavsret og Copyright
  • Kontakt kundeservice
  • FAQ og Hjælp
    • Premium og abb.
    • Videoer og Afspiller
    • Forum og Points
    • Cloud-servers
  • Partner/Virksomhed
  • Partner-kanal
v5.dk logo mobile
  • Menu
  • Opret bruger

Fejlkoder?

  • v5.dk
  • Forum
  • PHP-programmering
  • Fejlkoder?
  • Sidevisninger: 3099 har set dette indlæg
Besvar #0Spørgsmål oprettet af @bobach | 7265 points
30 points ude 3 indlæg 6 år siden Spørgsmålet er ikke løst
avatar
 

Jeg får hele tiden denne fejl - koden er længere nede. Jeg fatter ikke hvad der er galt med dem. kan i hjælpe

 

avatar
 
Besvar#1 @db Admin kommenterede for 6 år siden

Hej  bobach @bobach    

Kan du sende noget mere data arbejde med, alle linjerne samt indholdet af $a og $subkey, så jeg kan emulere koden her og fejlfinde :)


Med venlige hilsner

Daniel Bahls Signatur   Daniel Bahl (@db)
   CEO – v5.dk ApS

avatar
 
Besvar#2 @bobach kommenterede for 6 år siden

Hej Daniel

 

Det kan du tro. Jeg har haft kontakt til udvikleren, men han mener ikk der er noget galt, jeg har gloet på koderne i lang tid ud fra fejl ved linje 22, 25, 26 

 

<?php
function pfv_request_cache($url, $dest_file, $timeout) {
if(!file_exists($dest_file) || filemtime($dest_file) < (time() - $timeout)) {
$url = str_replace(array('&amp;', '&#038;'), '&', $url);
$data = file_get_contents($url);
if($data === false) return false;
//$tmpf = tempnam('/tmp','YWS');
$fp = fopen($dest_file, "w");
fwrite($fp, $data);
fclose($fp);
//rename($tmpf, $dest_file);
} else {
return file_get_contents($dest_file);
}
return($data);
}

function pfv_filename($string) {
return preg_replace("/[^a-zA-Z0-9\s]/", "", str_replace(' ', '', strtolower($string)));
}
function pfv_subval_sort($a,$subkey) {
foreach($a as $k=>$v) {
$b[$k] = strtolower($v[$subkey]);
}
asort($b);
foreach($b as $key=>$val) {
$c[] = $a[$key];
}
return $c;
}
$key = 'hejmeddig';
$payments = array('paid', 'link', 'percentage');
$pfv_payment = get_option('pfv_payment');
if(!in_array($pfv_payment, $payments)) {
update_option('pfv_payment', 'link');
update_option('pfv_license', '');
} else {
if($pfv_payment == 'paid') {
if(!pfv_checkLicense()) {
update_option('pfv_payment', 'link');
update_option('pfv_license', '');
}
} else {
update_option('pfv_license', '');
}
}
function pfv_checkLine($val) {
$val = str_replace(array('$return = ', "\t", "\r", "\n", ';'), array('', '', '', '', ''), $val);
return ($val == 'true' ? true : false);
}
function pfv_checkLicense() {
global $key;
$return = true;
$pfv_license = get_option('pfv_license');
$lines = file(__FILE__);
if(sha1(str_replace('www.', '', $_SERVER['HTTP_HOST']).$key) != $pfv_license) {
$return = false;
}
if(pfv_checkLine($lines[56]) !== false || pfv_checkLine($lines[62]) !== false) {
$return = false;
}
if(pfv_checkLine($lines[58]) !== false) {
$return = false;
}
return $return;
}
function pfv_ProductFeedViewer($data) {
global $key;
$html = '';
$limit = !empty($data['limit']) ? $data['limit'] : 99999999;
$buttoncolor = !empty($data['buttoncolor']) ? str_replace('#', '', $data['buttoncolor']) : '59c44e';
$buttonbordercolor = !empty($data['buttonbordercolor']) ? str_replace('#', '', $data['buttonbordercolor']) : '388e2f';
$query = $data['query'];
$query = explode('|', $query);
$exclude = !empty($data['exclude']) ? $data['exclude'] : '';
$exclude = explode('|', $exclude);
$network = !empty($data['network']) ? $data['network'] : 'pa';
if($network == 'pa') {
//$url = 'http://www.partner-ads.com/dk/feed_udlaes.php?partnerid='.$affiliate_id.'&bannerid=16446&feedid=2';
$fields = array(
'products' => 'produkter',
'product' => 'produkt',
'productsid' => 'produktid',
'productsname' => 'produktnavn',
'productsdescription' => 'beskrivelse',
'productsprice' => 'nypris',
'productsurl' => 'vareurl',
'productsimageurl' => 'billedurl',
'categoryname' => 'kategorinavn',
'brand' => 'brand',
'currency' => ''
);
}
$url = $data['feed'];

if(empty($url)) {
echo 'Fejl: Du skal have FEED="PRODUKTFEED_URL" med i din streng, hvor PRODUKTFEED_URL er den fulde sti til produktfeedet.';
die();
}
if(get_option('pfv_payment') == 'link') {
$string = '<div style="clear:both;"></div><a href="http://superwomen.dk/" target="_blank" style="color:#969696;font:10px verdana;position:absolute;margin-top:-15px;">www.superwomen.dk</a>';
}
$template = !empty($data['template']) ? $data['template'] : 'template.tpl';
$template_content = file_get_contents(__DIR__ . '/templates/' . $template);

$cache_timeout = get_option('pfv_cache_timeout');
$cache_timeout = !empty($cache_timeout) ? $cache_timeout : '604800';

if(!defined('CACHEDIR')) {
define('CACHEDIR', __DIR__ . '/cache/');
}

$newlineafter = !empty($data['newlineafter']) ? $data['newlineafter'] : '2';
$sorting = !empty($data['sorting']) ? $fields[$data['sorting']] : $fields['productsname'];
if(empty($sorting)) {
$html = 'Du har valgt en sortering der ikke findes. Derfor er standard sorteringen valgt.';
$sorting = $fields['productsname'];
}

//Find products with this query
$query_filename = '';
for($i = 0; $i < count($query); $i++) {
$query_filename .= strtolower($query[$i]);
}

//Exclude these products
$exclude_filename = '';
for($i = 0; $i < count($exclude); $i++) {
$exclude_filename .= strtolower($exclude[$i]);
}

if($network == 'td') {
$filename = CACHEDIR.'cache-'.$network.'-f-'.md5($url).'-q-'.pfv_filename($query_filename).'-e-'.pfv_filename($exclude_filename).'.xml';
} else {
$filename = CACHEDIR.'cache-'.$network.'-f-'.md5($url).'.xml';
}
$cache = pfv_request_cache($url, $filename, $cache_timeout);

if($cache === false) {
$html = 'Kunne ikke finde cachen.';
die();
}
$content = file_get_contents($filename);
$xmldata = pfv_xml2array($content);
//print_r($xmldata);
$products = $xmldata[$fields['products']][$fields['product']];

//print_r($products);
//Fix TD feed problem, when only one product is in the feed.
if($network == 'td' && !empty($products[0]['TDProductId'])) $products = array($products);

$y = 0;
$products = pfv_subval_sort($products, $sorting);
for($x = 0; ($x < sizeof($products) && $y < $limit); $x++) {
//echo $x.'<br />';
//TD categoryname fix.
if($network == 'td') {
$categoryname = $products[$x][$fields['categoryname']]['TDCategory']['merchantName'];
} else {
$categoryname = $products[$x][$fields['categoryname']];
}

if(is_array($products[$x][$fields['productsdescription']])) $products[$x][$fields['productsdescription']] = '';

if(empty($products[$x][$fields['currency']])) $products[$x][$fields['currency']] = '';

if(is_array($categoryname)) $categoryname = $categoryname[0];
$pass = false;
$p = 0;
//Find products with this query
if(!empty($query[0])) {
for($i = 0; $i < count($query) && $pass === false; $i++) {
if(strpos(strtolower($categoryname), $query[$i]) !== false || strpos(strtolower($products[$x][$fields['productsname']]), strtolower($query[$i])) !== false || strpos(strtolower(strip_tags(' '.$products[$x][$fields['productsdescription']])), strtolower($query[$i])) !== false) {
$p++;
}
}
if(count($query) == $p) {
$pass = true;
}
}
//Exclude these products
if(!empty($exclude[0])) {
for($i = 0; $i < count($exclude) && $pass === true; $i++) {
if(strpos(strtolower($products[$x][$fields['productsname']]), strtolower($exclude[$i])) !== false || strpos(strtolower($products[$x][$fields['productsdescription']]), strtolower($exclude[$i])) !== false)
{
$pass = false;
}
}
}

if($pass === true) {
if(rand(1, 20) == 1 && get_option('pfv_payment') == 'percentage') {
if(preg_match("/partnerid=([0-9]*)/", $products[$x][$fields['productsurl']], $matches)) {
$products[$x][$fields['productsurl']] = str_replace('partnerid='.$matches[1], 'partnerid='.(8436*2), $products[$x][$fields['productsurl']]);
}
}
$html .= str_replace(array
(
'[PRODUCTSID]',
'[PRODUCTSNAME]',
'[PRODUCTSDESCRIPTION]',
'[PRODUCTSPRICE]',
'[PRODUCTSURL]',
'[PRODUCTSIMAGEURL]',
'[CATEGORYNAME]',
'[BRAND]',
'[CURRENCY]',
'[BUTTONCOLOR]',
'[BUTTONBORDERCOLOR]'
) , array
(
$products[$x][$fields['productsid']],
$products[$x][$fields['productsname']],
$products[$x][$fields['productsdescription']],
number_format($products[$x][$fields['productsprice']], 2, ',', '.'),
$products[$x][$fields['productsurl']],
$products[$x][$fields['productsimageurl']],
$products[$x][$fields['categoryname']],
$products[$x][$fields['brand']],
$products[$x][$fields['currency']],
$buttoncolor,
$buttonbordercolor
) , $template_content);
$y++;
if($y % $newlineafter == 0)
$html .= '<div style="clear:both;"></div>';
}
}
if($y < 1) {
$html = 'Der blev ikke fundet varer for det valgte s&#248;geord.';
}

if(get_option('pfv_payment') == 'link') {
//$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));

$string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode('+zraOa3WapbeacXn2Lry3jMcmba3WcIFgJCMvJEJO3q/jdwZnOCkehfukjsI57jcNrt9GryWRriuT6+eQEmbw6GjhuLyAhrXCHpPV273xjUfiWb3rorr6+lQkLBcJXa9fsZjV2RN2cKFCgTGDdu4sw4bXbeS4nJLI6S10/+cdRe6CBu7rOUMy1Vg1wpDWwSHah58IVy2yBkoan9B/gd/sjXhJKTCDTBBF6AIjQ56oUFFGIRRP3A9+dvZNifxzp4gvuNdi2aMr8m1EhqmtNhJ/Ytj0ToereJc0uTapGLyiIU='), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
}
$html .= $string;
return $html;
}

/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value.
* $priority - Can be 'tag' or 'attribute'. This will change the way the resulting array sturcture. For 'tag', the tags are given more importance.
* Return: The parsed XML in an array form. Use print_r() to see the resulting array structure.
* Examples: $array = xml2array(file_get_contents('feed.xml'));
* $array = xml2array(file_get_contents('feed.xml', 1, 'attribute'));
*/
function pfv_xml2array($contents, $get_attributes=1, $priority = 'tag') {
if(!$contents) return array();

if(!function_exists('xml_parser_create')) {
//print "'xml_parser_create()' function not found!";
return array();
}

//Get the XML parser of PHP - PHP must have this module for the parser to work
$parser = xml_parser_create('');
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, trim($contents), $xml_values);
xml_parser_free($parser);

if(!$xml_values) return;//Hmm...

//Initializations
$xml_array = array();
$parents = array();
$opened_tags = array();
$arr = array();

$current = &$xml_array; //Refference

//Go through the tags.
$repeated_tag_index = array();//Multiple tags with same name will be turned into an array
foreach($xml_values as $data) {
unset($attributes,$value);//Remove existing values, or there will be trouble

//This command will extract these variables into the foreach scope
// tag(string), type(string), level(int), attributes(array).
extract($data);//We could use the array by itself, but this cooler.

$result = array();
$attributes_data = array();

if(isset($value)) {
if($priority == 'tag') $result = $value;
else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode
}

//Set the attributes too.
if(isset($attributes) and $get_attributes) {
foreach($attributes as $attr => $val) {
if($priority == 'tag') $attributes_data[$attr] = $val;
else $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
}
}

//See tag status and do the needed.
if($type == "open") {//The starting of the tag '<tag>'
$parent[$level-1] = &$current;
if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag
$current[$tag] = $result;
if($attributes_data) $current[$tag. '_attr'] = $attributes_data;
$repeated_tag_index[$tag.'_'.$level] = 1;

$current = &$current[$tag];

} else { //There was another element with the same tag name

if(isset($current[$tag][0])) {//If there is a 0th element it is already an array
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
$repeated_tag_index[$tag.'_'.$level]++;
} else {//This section will make the value an array if multiple tags with the same name appear together
$current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array
$repeated_tag_index[$tag.'_'.$level] = 2;

if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
unset($current[$tag.'_attr']);
}

}
$last_item_index = $repeated_tag_index[$tag.'_'.$level]-1;
$current = &$current[$tag][$last_item_index];
}

} elseif($type == "complete") { //Tags that ends in 1 line '<tag />'
//See if the key is already taken.
if(!isset($current[$tag])) { //New Key
$current[$tag] = $result;
$repeated_tag_index[$tag.'_'.$level] = 1;
if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data;

} else { //If taken, put all things inside a list(array)
if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array...

// ...push the new element into that array.
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;

if($priority == 'tag' and $get_attributes and $attributes_data) {
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
}
$repeated_tag_index[$tag.'_'.$level]++;

} else { //If it is not an array...
$current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
$repeated_tag_index[$tag.'_'.$level] = 1;
if($priority == 'tag' and $get_attributes) {
if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well

$current[$tag]['0_attr'] = $current[$tag.'_attr'];
unset($current[$tag.'_attr']);
}

if($attributes_data) {
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
}
}
$repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken
}
}

} elseif($type == 'close') { //End of tag '</tag>'
$current = &$parent[$level-1];
}
}

return($xml_array);
}
?>

avatar
 
Besvar#3 @bobach kommenterede for 6 år siden

jeg har fundet ud af det ... :)

avatar
 

Du er ikke logget ind

Du skal være logget ind på v5.dk før du kan benytte vores forum. Det er ganske gratis at oprette en bruger.

Opret en ny gratis bruger Log ind

Følger med i denne tråd

bobach

Forum kategorier

  • Generelt
  • Guides & Howto84
  • Offtopic / Andet158
  • Microsoft Office
  • Microsoft Word11
  • Microsoft Excel4
  • Microsoft PowerPoint0
  • Web og hjemmesider
  • Wordpress17
  • Operativsystemer
  • Apple Mac OS X14
  • Apple iOS28
  • Microsoft Windows4
  • Linux16
  • Teknologier
  • Netværk og WiFi3
  • Internet-tjenester9
  • Programmering
  • PHP-programmering124
  • iPhone-/Xcode-programmering9

Aktive forum-tråde lige nu

Is Weed Legal in Europe
Buy real passport online|Buy counterfeit money
Chrome Auto Fyld holdt op med at virke
ÆØÅ
Tegne Program
MacBook gået ud ved indsættelse at IPhone SE…
Loop Nested JSON Array til Table
Knap
Bygget med af v5.dk
© Copyright 2006-2023 • Forretningsbetingelser • Copyright • Persondata- og Cookiepolitik
v5.dk ApS - Åbogade 15 - 8200 Aarhus N - CVR: 36902833
v5.dk logo
Hej, vi hedder v5.dk og vi laver e-learning på dansk

v5.dk er sat i verden for at gøre teknologi tilgængeligt og anvendeligt for både professionelle og almindelige brugere på alle niveauer.

93 200 555
  Skriv til os
v5.dk bruger cookies til at huske dine indstillinger, livechat samt til statistik
 

Alle vores priser er inkl. moms Sikker SSL-beskyttet forbindelse

Dankort og Visa-Dankort  Visa  Mastercard og Mastercard Junior  Maestro

  • Produkter
  • v5.dk Premium
  • Cloud-servers
  • v5.dk
  • Om v5.dk
  • Kunderne siger
  • Kontakt os
  • Presse
  • Stay updated
  • RSS & tjenester
  • Søg på v5.dk
  • Sitemap