Esempio n. 1
0
	/**
	 * Выводит результат работы компонента
	 */
	public function output()
	{
		Component::print_headers();

		$this->objects->call("handler_bind");
		$this->objects->call("handler_output");
	}
Esempio n. 2
0
	/**
	 * Отправляет данные картинку капчи на сервер
	 */
	public function output()
	{
		$captcha = $this->Common->gen_password(CAPTCHA_LENGTH, false);
		$captcha = strtoupper($captcha);

		$_SESSION['captcha'] = $captcha;

		$width		= 15 + CAPTCHA_LENGTH * self::SymbolWidth + 15;

		$image		= imagecreatetruecolor($width, self::ImageHeight);
		$backcolor	= imagecolorallocate($image, 0xFF, 0xFF, 0xFF);

		imagefill($image, 0, 0, $backcolor);

		for ($i = 0; $i < self::PointsCount; $i++)
		{
			$color = imagecolorallocate($image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
			imagesetpixel($image, mt_rand(0, $width), mt_rand(0, self::ImageHeight), $color);
		}

		for ($i = 0; $i < CAPTCHA_LENGTH; $i++)
		{
			$color = imagecolorallocate($image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
			imagettftext($image, self::FontSize, mt_rand(-15, 15), 15 + $i * self::SymbolWidth, 35, $color, CAPTCHA_FONT_LOCATION, $captcha[$i]);
		}

		Component::print_headers("image/png", false);

		imagepng($image);
		imagedestroy($image);

		exit;
	}
Esempio n. 3
0
	private function send_empty()
	{
		Component::print_headers();

		echo json_encode(array('aaData' => array()));
		exit;
	}
Esempio n. 4
0
	public function on_add_item()
	{
		Component::print_headers("text/xml");

		$fields = array('order_id'		=> array('filter' => FILTER_VALIDATE_INT),
				'code'			=> array('filter' => FILTER_VALIDATE_INT),
				'size'			=> array('require' => false, 'filter' => FILTER_VALIDATE_FLOAT),
				'count'			=> array('filter' => FILTER_VALIDATE_INT),
				'name'			=> array(),
				'price'			=> array('filter' => FILTER_VALIDATE_INT),
				'initial_price'		=> array('filter' => FILTER_VALIDATE_FLOAT),
				'status_manager'	=> array()

		    );
		$fields = $this->EasyForms->fields($fields);
		if ($fields === false)
		{
			$this->XML->send_error("Не верно заполнены поля");
			exit;
		}
		if ($fields['size'] < 0 || $fields['size'] > 100)
		{
			$this->XML->send_error("Не верно заполнено поле размер");
			exit;
		}
		if ($fields['count'] <= 0 || $fields['count'] > 100)
		{
			$this->XML->send_error("Не верно заполнено поле кол-во");
			exit;
		}
		if ($fields['price'] <= 0 || $fields['price'] > 1000000)
		{
			$this->XML->send_error("Не верно заполна цена продажи");
			exit;
		}
		if ($fields['initial_price'] <= 0 || $fields['initial_price'] > 1000000)
		{
			$this->XML->send_error("Не верно заполнена цена отгрузки");
			exit;
		}

		$new_id = $this->Orders->add_order_items($fields['order_id'], array($fields));
		$fields['id'] = $new_id[0];

		$this->Orders->update_price($fields['order_id'], $fields['price']  * $fields['count']);

		$template = $this->Templates->get("");

		$order_item = $template->order_item;
		if ($order_item === false)
			$this->Log->error("Can't find 'order_item' param");

		$fields[$fields['status_manager']] = true;
		$fields['status_manager'] = $this->get_manager_status($fields['status_manager']);
		$order_item->bind_params($fields);
		$fields['status_manager'] = "ignored";

		$xml = $this->XML->start_answer();
		$xml->addChild("item", (string) $order_item);
		$this->XML->send_xml($xml);
	}
Esempio n. 5
0
	/**
	 * Устанавливает страницу для отображения
	 * @param $page_name String: Имя страницы
	 */
	public function set_page($page_name)
	{
		$this->set($page_name);

		$this->header = false;
		$this->footer = false;

		if (empty($this->template))
			return;

		$template = $this->get("/".$this->template);

		$content_type = $template->get_param("Pages::Content-type");
		if ($content_type !== false)
			Component::print_headers((string) $content_type);

		if (isset($template->params['Pages::Header']))
		{
			$this->header = $template->params['Pages::Header'];
			unset($template->params['Pages::Header']);
		}

		if (isset($template->params['Pages::Footer']))
		{
			$this->footer = $template->params['Pages::Footer'];
			unset($template->params['Pages::Footer']);
		}

		$this->assign_params($template);
	}
Esempio n. 6
0
	public function on_set_count()
	{
		Component::print_headers();
		$fields = array(
			'id'		=> array(),
			'count'		=> array(),
			'size'		=> array(),
			'product_id'	=> array()
		);

		$fields = $this->EasyForms->fields($fields, array('flags' => FILTER_VALIDATE_INT));
		if ($fields === false)
			exit;

		$order = $this->Orders->get($fields['id']);
		if ($order === false)
			exit;

		$order['products'] = unserialize($order['products']);
		if (!isset($orders['products'][$fields['product_id']][$fields['size']]))
			exit;

		$order['products'][$fields['product_id']][$fields['size']] = $fields['count'];

		$summary = $this->Basket->summary($order['products']);
		$summary = $summary['buy'];
		$this->Orders->update($fields['id'], array('products' =>  serialize($order['products']), 'price' => $summary['price']));

		echo $this->format_list_products($order['products']);
		exit;
	}
Esempio n. 7
0
	/**
	 * Отображает данные экспорта страниц
	 */
	public function on_export_submit()
	{
		$fields = array(
			'names'		=> array('array' => true),
			'compress'	=> array('require' => false),
			'trim'		=> array('require' => false),
		);

		$fields = $this->EasyForms->fields($fields);
		if (!$fields)
			$this->Log->error("No page names specified");

		if (empty($fields['compress']))
			$fields['compress'] = "none";

		$fields['trim'] = intval($fields['trim']);

		$export = array();

		if (!empty($fields['names']))
		{
			$result = $this->Pages->get_all($fields['names']);

			while (($row = $result->fetch()))
			{
				if ($fields['trim'] != 0)
				{
					$pieces = explode("/", $row['name']);
					$pieces = array_slice($pieces, $fields['trim']);

					$row['name'] = implode("/", $pieces);
				}

				$data = $this->Common->copy_fields($row, array("name", "params", "content"));
				$this->Common->remove_empty($data);

				array_push($export, $data);
			}
		}

		$export = serialize($export);
		$export = $this->Compress->compress($export, $fields['compress']);

		header("Content-Length: ".strlen($export));
		header("Content-Disposition: attachment; filename=\"export.itw\"");
		header("Content-Transfer-Encoding: binary");

		Component::print_headers("application/octet-stream", false);

		echo $export;
		exit;
	}
Esempio n. 8
0
	/**
	 * Получение всех категорий
	 */
	public function on_get_categories()
	{
		Component::print_headers();
		$template = $this->Templates->get("");

		$category_item = $template->category_item;
		if ($category_item === false)
			$this->Log->error("Can't find 'category_item' param");

		$categories = $this->News->get_categories();
		echo $this->Lists->make($category_item, $categories);
		exit;
	}
Esempio n. 9
0
	/**
	 * Отправляет данные инкапсулированными в XML-объект
	 * @param $element String: Данные для передачи
	 */
	public function send_as_xml($element)
	{
		$buffer = ob_get_clean();

		$xml = $this->start_answer();
		$xml->addChild($element, $buffer);

		Component::print_headers("text/xml");

		echo $xml->asXML();
		exit;
	}