Example #1
0
 public function add_land($user)
 {
     $id_booster = Database::join('game_booster', 'gb.id_game_set = gs.id')->get_field('game_set', 'gb.id', 'gs.id_game = ?', $this->get_id());
     $insert = $this->generate_lands($id_booster, $user);
     Database::bulk_insert('game_booster_card', $insert, true);
 }
Example #2
0
<?
die;
include '../inc.common.php';

$pools = Database::get_vector('art_pool', 'id, art');

foreach ($pools as $id => $arts) {

	$arts = explode('|', $arts);
	$arts = array_filter($arts);
	$arts = array_reverse($arts);

	$insert = array();
	$order = 0;
	foreach ($arts as $art) {
		$insert[] = array(
			'art_id' => $art,
			'pool_id' => $id,
			'order' => $order++,
		);
	}

	Database::bulk_insert('art_in_pool', $insert, true);
}

Example #3
0
  	function morphyphp ($words) {
		if (empty($this->morphy_ru) || empty($this->morphy_en)) {
			$this->init_morphy();
		}

		$return = array();
		if (empty($words) || $this->error) {
			return $return;
		}

		foreach ($words as $key => $word) {
			if (preg_match('/[А-ЯЁ]/u',$word)) {

				$converted = iconv('utf-8', $this->encoding, $word);

				try {
					$collection = $this->morphy_ru->findWord($converted);
					if ($collection === false) {
						$return[$key] = $word;
					} else {
						foreach($collection as $paradigm) {
							$return[$key] = iconv($this->encoding, 'utf-8', $paradigm[0]->getWord());
						}
					}
				} catch(phpMorphy_Exception $e) {
					$this->error = true;
					return $return;
				}
			}
		}

		foreach ($words as $key => $word) {
			if (!empty($return[$key])) {
				continue;
			}

			if (ctype_alnum($word{0})) {
				$converted = iconv('utf-8', $this->encoding, $word);
				try {
					$collection = $this->morphy_en->findWord($converted);
					if ($collection === false) {
						$return[$key] = $word;
					} else {
						foreach($collection as $paradigm) {
							$return[$key] = iconv($this->encoding, 'utf-8', $paradigm[0]->getWord());
						}
					}
				} catch(phpMorphy_Exception $e) {
					$this->error = true;
					return $return;
				}
			}
		}

		foreach ($words as $key => $word) {
			if (!empty($return[$key])) {
				continue;
			}
			$return[$key] = $word;
		}

		$insert = array();
		foreach ($words as $key => $word) {
			$insert[] = array($word, $return[$key]);
		}
		Database::bulk_insert('morphy_cache', $insert, array('word', 'cache'));

		ksort($return);
		return $return;
	}
Example #4
0
 protected function parse_dir($directory)
 {
     $handle = dir($directory);
     $insert = array();
     while ($entry = $handle->read()) {
         if ($entry[0] == ".") {
             continue;
         }
         $filename = $entry;
         $entry = $directory . $entry;
         if (is_dir($entry)) {
             $this->parse_dir($entry . SL);
         } elseif (in_array(mime_content_type($entry), self::$imagetypes)) {
             $this->count++;
             $sort = str_repeat("0", 5 - strlen($this->count)) . $this->count;
             $insert[] = array('pack_art', $this->id, $entry, $sort, $filename, 0);
         }
     }
     $handle->close();
     Database::bulk_insert('misc', $insert);
 }