Permalink
Browse files

Доработка билдера

Парсер
  • Loading branch information...
1 parent 49ca078 commit 7771a48ddf91f458138b5ec7f39e58d1eddb1dd5 ErgallM committed Nov 21, 2011
View
@@ -80,6 +80,50 @@
<div id="load-more" class="button">Load More</div>
</div>
</div>
+
+<div id="compare" class="compare">
+ <div class="block">
+ <h3 class="q4">
+ Орб Рудры
+ <span><i>+1</i> <button class="up"></button><button class="down"></button></span>
+ </h3>
+ <div class="type"><span>Тип</span>Орбы</div>
+ <div>[Обмен невозможен], [Невозможно положить на склад аккаунта], [Невозможно положить на склад легиона]</div>
+ <div>Можно использовать с 55-го уровня.</div>
+ </div>
+
+ <div class="block">
+ <div class="title">Медленное оружие, кол-во ударов: 1 (Стихия огня)</div>
+ <div class="skills"><span>Атака</span> 270 - 330</div>
+ <div class="skills"><span>Скор. атаки</span> 2.2</div>
+ <div class="skills"><span>Сила магии</span> 860</div>
+ <div class="skills"><span>Точн. магии</span> 391</div>
+ <div class="clear"></div>
+ </div>
+
+ <div class="block">
+ <div class="skills"><span>Макс. HP</span> 509</div>
+ <div class="skills"><span>Сила магии</span> 85</div>
+ <div class="skills"><span>М. крит.</span> 20</div>
+ <div class="skills"><span>Скор. магии</span> 20%</div>
+ <div class="skills"><span>Макс. MP</span>898</div>
+ <div class="clear"></div>
+ </div>
+
+ <div class="block">
+ <div class="title">Можно усилить магическими камнями 60-го уровня и ниже.</div>
+ <div class="manastone"></div>
+ <div class="manastone"></div>
+ <div class="manastone"></div>
+ <div class="manastone"></div>
+ <div class="manastone"></div>
+ <div class="clear"></div>
+ </div>
+
+ <div class="block">
+ Можно вставить божественный камень.
+ </div>
+</div>
<script language="javascript">
window.addEvent('domready', function() {
window.s = new SearchItems({
View
@@ -2,7 +2,7 @@
class Model_Item extends Zend_Db_Table
{
protected $_name = 'items';
- protected $_cols = array('id', 'name', 'lvl', 'type', 'slot', 'q', 'skills', 'manastoneLvl', 'manastoneCount', 'godstone', 'price', 'icon', 'image');
+ protected $_cols = array('id', 'name', 'lvl', 'type', 'slot', 'q', 'skills', 'manastoneLvl', 'manastoneCount', 'godstone', 'price', 'icon', 'image', 'links');
public function addItem($data)
{
@@ -19,6 +19,7 @@ public function addItem($data)
'price' => $this->filter($data['price']),
'icon' => $this->filter($data['icon']),
'image' => $this->filter($data['image']),
+ 'links' => $this->filter($data['links'])
);
$data['skills'] = serialize($data['skills']);
View
@@ -0,0 +1,169 @@
+<?php
+set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__DIR__) . '/library');
+
+require_once 'ZF.php';
+require_once 'Cli.php';
+require_once 'Dom/Query.php';
+
+Zend_Db_Table::setDefaultAdapter(new Zend_Db_Adapter_Pdo_Mysql(array(
+ 'host' => 'localhost',
+ 'username' => 'root',
+ 'password' => '25459198',
+ 'charset' => 'UTF8',
+ 'dbname' => 'aion_library'
+)));
+
+class Model_Noparserdata extends Zend_Db_Table
+{
+ protected $_name = 'noparserdata';
+ protected $_cols = array('id', 'ai', 'en', 'en_compare', 'en_js', 'ru', 'ru_compare', 'ru_js');
+
+ /** @var string */
+ protected $_folder = '/home/eaglemoor/AionParser/db';
+
+ protected $_selectors = array(
+ 'ai' => '.hbody>table',
+ 'en' => 'table.aion_tooltip_container',
+ 'en_2' => '.map-box-content-wrapper',
+ 'en_image' => '.infobox-table .map_tooltip_border img',
+ 'en_compare' => '*',
+ 'en_icon' => '/res/icons/40/{name}.png'
+ );
+
+ public function parserAI($id)
+ {
+ $file = @file_get_contents($this->_folder . "/ai/$id.html");
+ if (empty($file)) return '';
+
+ $q = new Zend_Dom_Query($file);
+ $data = $q->query($this->_selectors['ai']);
+ if ($data->count()) {
+ $dom = new DOMDocument();
+ $dom->appendChild($dom->importNode($data->current(), true));
+ return $dom->saveHTML();
+ } else {
+ return '';
+ }
+ }
+
+ public function parserItem($id, $lang = 'en')
+ {
+ $file = @file_get_contents($this->_folder . "/$lang/$id.html");
+ if (empty($file)) return '';
+
+ $q = new Zend_Dom_Query($file);
+ $data = $q->query($this->_selectors['en']);
+
+ $dom = new DOMDocument();
+
+ if ($data->count()) {
+ $dom->appendChild($dom->importNode($data->current(), true));
+ } else {
+ return '';
+ }
+
+ $data = $q->query($this->_selectors['en_2'], true);
+ if ($data->count()) $dom->appendChild($dom->importNode($data->current(), true));
+
+ $data = $q->query($this->_selectors['en_image'], true);
+ if ($data->count()) $dom->appendChild($dom->importNode($data->current(), true));
+
+ $data = $q->query('img');
+ foreach ($data as $image) {
+ /** @var \DOMElement $image */
+ if (0 === strpos($image->getAttribute('src'), '/res/icons/40/')) {
+ $dom->appendChild($dom->importNode($image, true));
+ break;
+ }
+ }
+
+ return $dom->saveHTML();
+ }
+
+ public function parserCompare($id, $lang = 'en')
+ {
+ $data = @file_get_contents($this->_folder . "/$lang/compare/$id.txt");
+ return (string) $data;
+ }
+
+ public function parserJs($id, $lang = 'en')
+ {
+ $data = @file_get_contents($this->_folder . "/$lang/js/$id.js");
+ $data = str_replace('aionInjector.addTooltip(', '', $data);
+ $data = str_replace('});', '}', $data);
+ return (string) $data;
+ }
+
+ public function noparserdataToDb($id = null)
+ {
+ if (null !== $id) {
+ $saveData = array(
+ 'id' => $id,
+ 'ai' => $this->parserAI($id),
+ 'en' => $this->parserItem($id),
+ 'en_compare' => $this->parserCompare($id),
+ 'en_js' => $this->parserJs($id),
+ 'ru' => $this->parserItem($id, 'ru'),
+ 'ru_compare' => $this->parserCompare($id, 'ru'),
+ 'ru_js' => $this->parserJs($id, 'ru')
+ );
+
+ $this->createRow($saveData)->save();
+ return true;
+ }
+
+ $idArray = array();
+
+ if ($handle = opendir($this->_folder . '/ai')) {
+ echo "Дескриптор каталога: $handle\n";
+
+ while (false !== ($file = readdir($handle))) {
+ if ('.' != $file && '..' != $file) {
+ $id = (int) str_replace('.html', '', $file);
+ if (!$id) continue;
+ $idArray[$id] = $id;
+ }
+ }
+
+ closedir($handle);
+ }
+
+ echo "Обнаружено " . sizeof($idArray) . " элементов.\nНачинаю парсинг...\n";
+ $i = 0;
+ foreach ($idArray as $id) {
+ $i++;
+ $saveData = array(
+ 'id' => $id,
+ 'ai' => $this->parserAI($id),
+ 'en' => $this->parserItem($id),
+ 'en_compare' => $this->parserCompare($id),
+ 'en_js' => $this->parserJs($id),
+ 'ru' => $this->parserItem($id, 'ru'),
+ 'ru_compare' => $this->parserCompare($id, 'ru'),
+ 'ru_js' => $this->parserJs($id, 'ru')
+ );
+
+ try {
+ $this->createRow($saveData)->save();
+ } catch (\Exception $e) {
+ if (false === strpos($e->getMessage(), 'Duplicate entry')) echo 'ERROR #' . $e->getCode() . ' ' . $e->getMessage() . PHP_EOL;
+ }
+
+ echo $id . ' - ' . sizeof($idArray) . ' / ' . (sizeof($idArray) - $i) . PHP_EOL;
+ }
+ echo "PARSER END";
+ }
+}
+
+class Model_Parser
+{
+ /** @var Zend_Db_Table */
+ protected $_db = null;
+
+ /** @var string */
+ protected $_folder = '/home/eaglemoor/AionParser/db';
+}
+
+$options = Cli::getParams(array('id' => null), $argc, $argv);
+$parser = new Model_Noparserdata();
+$parser->noparserdataToDb($options['id']);
View
@@ -16,6 +16,19 @@
#searchItems {position: absolute; margin-top: -430px; width: 500px; left: -200px;}
#posts { height:300px; overflow-y: auto; }
+#posts div {
+ height: 40px;
+ line-height: 40px;
+ border: 1px solid gray;
+ background: #14222A;
+ padding-left: 50px;
+ cursor: pointer;
+ font-size: 1.2em;
+}
+#posts div img {
+ float: left;
+ margin: 0px 5px;
+}
#addItem {margin: 0px 20px;}
#addItem > form > div {margin-bottom: 1em; padding-bottom: 1em; border-bottom: 1px solid #f5f5f5; width: 600px;}
@@ -57,3 +70,43 @@
.q2 {color: #4CCFFF !important;}
.q3 {color: #FFC103 !important;}
.q4 {color: #FF8033 !important;}
+
+.compare h3 {height: 40px; line-height: 40px; font-size: 1.286em;}
+.compare h3 button {border: none; cursor: pointer; height: 16px; width: 16px;}
+.compare h3 button.up {background: url('/images/up.png') center center no-repeat;}
+.compare h3 button.down {background: url('/images/down.png') center center no-repeat;}
+.compare h3 span {margin-left: 20px;}
+.compare h3 span i {display: inline-block; width: 25px; text-align: right;}
+
+
+.compare {
+ background: url('http://ru.aiondatabase.com/res/icons/40/icon_item_orb_e01.png') 5px 5px no-repeat;
+ width: 500px;
+ position: absolute;
+ top: 100px;
+ left: 50%;
+ z-index: 100;
+ margin-left: -250px;
+ border: 1px solid #666;
+ padding: 5px;
+ padding-left: 50px;
+ padding-right: 30px;
+}
+.compare .block {
+ border-bottom: 1px solid #666;
+ padding-bottom: 1em;
+ margin-bottom: 1em;
+}
+.compare .block:last-child {
+ border-bottom: none;
+ padding-bottom: 0px;
+}
+.compare .block .title {margin-bottom: 1em;}
+.compare .block .skills {width: 230px; padding-right: 20px; text-align: right; float: left;}
+.compare .block .skills span {float: left;}
+
+.compare .block .manastone {width: 230px; height: 40px; float: left; cursor: pointer; background: url('/images/manastone/hp-white.png') top left no-repeat; margin-bottom: 5px; margin-right: 20px;}
+.compare .block .manastone.white {background-image: url('/images/manastone/hp-white.png');}
+.compare .block .manastone.green {background-image: url('/images/manastone/hp-green.png');}
+.compare .block .type {text-align: right;}
+.compare .block .type span {float: left;}
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit 7771a48

Please sign in to comment.