HEX
Server: Apache
System: Linux 4485441ca2e2 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 11:03:07 UTC 2025 aarch64
User: (1000)
PHP: 8.2.24
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/ganryu_shop/action/Image.php
<?php

require_once dirname(__FILE__).'/Abstract.php';

class ganryu_shop_action_Image extends ganryu_shop_action_Abstract{

	function item_image(){
		$sz = $this->g('sz');
		$ar = preg_split('/\./', $sz, 3);
		if (count($ar) < 3){
			$this->image(null);
			return;
		}
		$itemid = $ar[0];
		$ss = $ar[1];
		$size = $ar[2];
		$itm = $this->loadModel('Item');
		
		if ($itemid == "temporary"){
			$itemid = 0;
		}
		else{
			$res = $itm->getItem($itemid);
			if (!$res){
				$this->image(null);
				return;
			}
			$itemdata = $res;
			
			$itemar = array();
			if ($itemdata['images']){
				$itemar = preg_split('/,/', $itemdata['images']);
			}
			
			if (!in_array($ss, $itemar)){
				$this->image(null);
				return;
			}
		}
		
		$res = $itm->getItemImage($ss, $size, true);
		if (!$res){
			$this->image(null);
			return;
		}
		$imgdata = $res;
		
		if (!$imgdata['data']){
			$this->image(null);
			return;
		}
		
		if ($itemid == 0){
			if (!$imgdata['expire_date']){
				$this->image(null);
				return;
			}
		}
		else{
			if ($imgdata['expire_date']){
				$this->image(null);
				return;
			}
		}
		
		$this->image($imgdata['data']);
	}
	
	function subitem_image(){
		$sz = $this->g('sz');
		$ar = preg_split('/\./', $sz, 3);
		if (count($ar) < 3){
			$this->image(null);
			return;
		}
		$cateid = $ar[0];
		$ss = $ar[1];
		$size = $ar[2];
		$itm = $this->loadModel('Item');
		
		if ($cateid == "temporary"){
			$cateid = 0;
		}
		else{
			$res = $itm->getItemCategory($cateid);
			if (!$res){
				$this->image(null);
				return;
			}
			$catedata = $res;
			
			if ($ss != $catedata['image']){
				$this->image(null);
				return;
			}
		}
		
		$res = $itm->getItemImage($ss, $size, true);
		if (!$res){
			$this->image(null);
			return;
		}
		$imgdata = $res;
		
		if (!$imgdata['data']){
			$this->image(null);
			return;
		}
		
		if ($cateid == 0){
			if (!$imgdata['expire_date']){
				$this->image(null);
				return;
			}
		}
		else{
			if ($imgdata['expire_date']){
				$this->image(null);
				return;
			}
		}
		
		$this->image($imgdata['data']);
	}
	

	
	function image($data){
		if (!$data || strlen($data) < 4){
			$data = file_get_contents(GANRYU_SHOP_ROOT.'/img/no_image.png');
		}
		if (preg_match('/^GIF/', $data)){
			header('Content-Type: image/gif');
		}
		else if (preg_match('/^\x89PNG/', $data)){
			header('Content-Type: image/png');
		}
		else{
			header('Content-Type: image/jpeg');
		}
		print $data;
	}

	
	function receipt(){
		$pid = $this->g('pid');
		
		$pur = $this->loadModel('Purchase');
		$itm = $this->loadModel('Item');
		$res = $pur->getPurchase($pid);
		if (!$res){
			$this->error();
			return;
		}
		$pdata = $res;
		
		$res = $pur->getPurchaseItem($pid);
		$itemlist = $res;
		
		for($i = 0; $i < count($itemlist); $i++){
			$res = $itm->getSubitem($itemlist[$i]['subitemid']);
			$subitem = $res;
			
			$res = $itm->getItem($subitem['itemid']);
			$item = $res;
			
			$itemlist[$i]['subitem'] = $subitem;
			$itemlist[$i]['item'] = $item;

			$itemlist[$i]['labels'] = $itm->getCategorySetupLabels($itemlist[$i]['itemid']);
			if ($itemlist[$i]['category1']){
				$itemlist[$i]['cate1'] = $itm->getItemCategory($itemlist[$i]['category1']);
			}
			if ($itemlist[$i]['category2']){
				$itemlist[$i]['cate2'] = $itm->getItemCategory($itemlist[$i]['category2']);
			}

		}
		
		$res = $pur->getPurchaseDeliv($pid);
		
		$addresslist = $res;
		
		$addr = $this->loadModel('Address');
		
		$maddr = null;
		if ($pdata['userid']){
			$res = $addr->getAddressMain($pdata['userid']);
			if ($res){
				$maddr = $res;
			}
		}
		if (!$maddr){
			$maddr = $addresslist[0];
		}
		
		$tmpldata = array('pdata'=>$pdata, 'itemlist'=>$itemlist, 'addresslist'=>$addresslist, 'mainaddr'=>$maddr);
		$this->attachTemplate('admin/purchase_receipt', $tmpldata);
		exit;
	}

}