Example #1
1
	public function _home() {
		global $config, $cache;

		if (!_button()) {
			$sql = 'SELECT ub, name
				FROM _artists
				ORDER BY name';
			return _rowset_style($sql, 'artists');
		}

		$name = request_var('name', '');

		$sql = 'SELECT *
			FROM _artists
			WHERE name = ?';
		if (!$a_data = sql_fieldrow(sql_filter($sql, $name))) {
			fatal_error();
		}

		$sql = 'SELECT m.user_id, m.user_email
			FROM _artists_auth a, _members m
			WHERE a.ub = ?
				AND a.user_id = m.user_id';
		$result = sql_rowset(sql_filter($sql, $a_data['ub']));

		$mods = w();
		foreach ($result as $row) {
			$mods[] = $row['user_id'];
		}

		if (count($mods)) {
			foreach ($mods as $i => $each) {
				$sql = 'SELECT COUNT(user_id) AS total
					FROM _artists_auth
					WHERE user_id = ?';
				$total = sql_field(sql_filter($sql, $each), 'total', 0);

				if ($total > 1) {
					unset($mods[$i]);
				}
			}
		}

		if (count($mods)) {
			$sql = 'UPDATE _members SET user_auth_control = 0
				WHERE user_id IN (??)';
			$d_sql[] = sql_filter($sql, _implode(',', $mods));
		}

		$ary_sql = array(
			'DELETE FROM _artists WHERE ub = ?',
			'DELETE FROM _artists_auth WHERE ub = ?',
			'DELETE FROM _artists_fav WHERE ub = ?',
			'DELETE FROM _artists_images WHERE ub = ?',
			'DELETE FROM _artists_log WHERE ub = ?',
			'DELETE FROM _artists_lyrics WHERE ub = ?',
			'DELETE FROM _artists_posts WHERE post_ub = ?',
			'DELETE FROM _artists_stats WHERE ub = ?',
			'DELETE FROM _artists_viewers WHERE ub = ?',
			'DELETE FROM _artists_voters WHERE ub = ?',
			'DELETE FROM _artists_votes WHERE ub = ?',
			'DELETE FROM _forum_topics WHERE topic_ub = ?',
			'DELETE FROM _dl WHERE ub = ?'
		);
		$d_sql = sql_filter($ary_sql, $a_data['ub']);

		$sql = 'SELECT topic_id
			FROM _forum_topics
			WHERE topic_ub = ?';
		if ($topics = sql_rowset(sql_filter($sql, $a_data['ub']), false, 'topic_id')) {
			$d_sql[] = sql_filter('DELETE FROM _forum_posts
				WHERE topic_id IN (??)', _implode(',', $topics));
		}

		$sql = 'SELECT id
			FROM _dl
			WHERE ub = ?';
		if ($downloads = sql_rowset(sql_filter($sql, $a_data['ub']), false, 'id')) {
			$ary_sql = array(
				'DELETE FROM _dl_fav WHERE dl_id IN (??)',
				'DELETE FROM _dl_posts WHERE download_id IN (??)',
				'DELETE FROM _dl_vote WHERE ud IN (??)',
				'DELETE FROM _dl_voters WHERE ud IN (??)'
			);
			$d_sql = array_merge($d_sql, sql_filter($ary_sql, _implode(',', $downloads)));
		}

		if (!_rm($config['artists_path'] . $a_data['ub'])) {
			_pre('Error al eliminar directorio de artista.', true);
		}

		sql_query($d_sql);

		// Cache
		$cache->delete('ub_list a_last_images');

		redirect(s_link('a'));
	}
Example #2
0
function kfm_rm($files, $no_dir = 0)
{
    include_once KFM_BASE_PATH . 'includes/files.php';
    return _rm($files, $no_dir);
}
Example #3
0
	public function _home() {
		global $config, $user, $cache, $upload;

		if (_button()) {
			$event_id = request_var('event_id', 0);

			$filepath_1 = $config['events_path'] . 'tmp/';
			$filepath_2 = $config['events_path'] . 'gallery/';
			$filepath_3 = $filepath_1 . $event_id . '/';
			$filepath_4 = $filepath_3 . 'thumbnails/';

			$f = $upload->process($filepath_1, 'add_zip', 'zip');
			if (!sizeof($upload->error) && $f !== false) {
				@set_time_limit(0);

				foreach ($f as $row) {
					$zip_folder = unzip($filepath_1 . $row['filename'], $filepath_3, true);
					_rm($filepath_1 . $row['filename']);
				}

				if (!empty($zip_folder)) {
					$zip_folder = substr($zip_folder, 0, -1);

					$fp = @opendir($filepath_3 . $zip_folder);
					while ($file = @readdir($fp)) {
						if (!is_level($file)) {
							$ftp->ftp_rename($ftp->dfolder() . 'data/tmp/' . $event_id . '/' . $zip_folder . '/' . $file, $ftp->dfolder() . 'data/tmp/' . $event_id . '/' . $file);
							//@rename($filepath_3 . $zip_folder . '/' . $file, $filepath_3 . $file);
						}
					}
					@closedir($fp);

					_rm($filepath_3 . $zip_folder);
				}

				if (!@file_exists($filepath_4)) {
					a_mkdir($ftp->dfolder() . 'data/tmp/' . $event_id, 'thumbnails');
				}

				$footer_data = '';
				$filerow_list = w();
				$count_images = $img = $event_pre = 0;

				$check_is = w();
				if (@file_exists($filepath_2 . $event_id)) {
					$fp = @opendir($filepath_2 . $event_id);
					while ($filerow = @readdir($fp)) {
						if (preg_match('#(\d+)\.(jpg)#is', $filerow)) {
							$dis = getimagesize($filepath_2 . $event_id . $filerow);
							$disd = intval(_decode('4e6a4177'));
							if (($dis[0] > $dis[1] && $dis[0] < $disd) || ($dis[1] > $dis[0] && $dis[1] < $disd)) {
								$check_is[] = $filerow;
								continue;
							}

							$event_pre++;
						}
					}
					@closedir($fp);

					if (count($check_is)) {
						echo lang('dis_invalid');

						foreach ($check_is as $row) {
							echo $row . '<br />';
						}
						exit;
					}

					$img = $event_pre;
				}

				$filerow_list = array_dir($filepath_3);
				array_multisort($filerow_list, SORT_ASC, SORT_NUMERIC);

				foreach ($filerow_list as $filerow) {
					if (preg_match('#(\d+)\.(jpg)#is', $filerow))
					{
						$row = $upload->_row($filepath_3, $filerow);
						if (!@copy($filepath_3 . $filerow, $row['filepath'])) {
							continue;
						}

						$img++;
						$xa = $upload->resize($row, $filepath_3, $filepath_3, $img, array(600, 450), false, true, true, 'w2');
						if ($xa === false) {
							continue;
						}
						$xb = $upload->resize($row, $filepath_3, $filepath_4, $img, array(100, 75), false, false);

						$insert = array(
							'event_id' => (int) $event_id,
							'image' => (int) $img,
							'width' => (int) $xa['width'],
							'height' => (int) $xa['height'],
							'allow_dl' => 1
						);
						sql_insert('events_images', $insert);

						$count_images++;
					} elseif (preg_match('#(info)\.(txt)#is', $filerow)) {
						$footer_data = $filerow;
					}
				}

				if (!empty($footer_data) && @file_exists($filepath_3 . $footer_data)) {
					$footer_info = @file($filepath_3 . $footer_data);
					foreach ($footer_info as $linerow) {
						$part = explode(':', $linerow);
						$part = array_map('trim', $part);

						$numbs = explode('-', $part[0]);
						$numbs[1] = (isset($numbs[1])) ? $numbs[1] : $numbs[0];

						for ($i = ($numbs[0] + $event_pre), $end = ($numbs[1] + $event_pre + 1); $i < $end; $i++) {
							$sql = 'UPDATE _events_images SET image_footer = ?
								WHERE event_id = ?
									AND image = ?';
							sql_query(sql_filter($sql, htmlencode($part[1]), $event_id, $i));
						}
					}

					_rm($filepath_3 . $footer_data);
				}

				$sql = 'SELECT *
					FROM _events_colab
					WHERE colab_event = ?
						AND colab_uid = ?';
				if (!$row = sql_fieldrow(sql_filter($sql, $event_ud, $user->d('user_id')))) {
					$sql_insert = array(
						'colab_event' => $event_id,
						'colab_uid' => $user->d('user_id')
					);
					sql_insert('events_colab', $sql_insert);
				}

				$sql = 'UPDATE _events SET images = images + ??
					WHERE id = ?';
				sql_query(sql_filter($sql, $count_images, $event_id));

				$ftp->ftp_rename($ftp->dfolder() . 'data/tmp/' . $event_id . '/', $ftp->dfolder() . 'data/events/gallery/' . $event_id . '/');
				//@rename($filepath_3, $filepath_2 . $event_id);
				$ftp->ftp_quit();

				redirect(s_link('events', $event_id));
			}

			_style('error', array(
				'MESSAGE' => parse_error($upload->error))
			);
		}

		$sql = 'SELECT *
			FROM _events
			WHERE date < ??
			ORDER BY date DESC';
		$result = sql_rowset(sql_filter($sql, (time() + 86400)));

		foreach ($result as $row) {
			_style('event_list', array(
				'EVENT_ID' => $row['id'],
				'EVENT_TITLE' => (($row['images']) ? '* ' : '') . $row['title'],
				'EVENT_DATE' => $user->format_date($row['date']))
			);
		}

		return;
	}
Example #4
0
	private function remove() {
		global $config;

		$s_images = request_var('ls_images', array(0));
		if (sizeof($s_images)) {
			$common_path = $config['artists_path'] . $this->object['ub'] . '/';
			$path = array(
				$common_path . 'x1/',
				$common_path . 'gallery/',
				$common_path . 'thumbnails/',
			);

			$sql = 'SELECT *
				FROM _artists_images
				WHERE ub = ?
					AND image IN (??)
				ORDER BY image';
			$result = sql_rowset(sql_filter($sql, $this->object['ub'], implode(',', $s_images)));

			$affected = w();
			foreach ($result as $row) {
				foreach ($path as $path_row) {
					$filepath = $path_row . $row['image'] . '.jpg';
					_rm($filepath);
				}
				$affected[] = $row['image'];
			}

			if (count($affected)) {
				$sql = 'DELETE FROM _artists_images
					WHERE ub = ?
						AND image IN (??)';
				sql_query(sql_filter($sql, $this->object['ub'], implode(',', $affected)));

				$sql = 'UPDATE _artists SET images = images - ??
					WHERE ub = ?';
				sql_query(sql_filter($sql, sql_affectedrows(), $this->object['ub']));
			}
		}

		return redirect(s_link('acp', array('artist_gallery', 'a' => $this->object['subdomain'])));
	}
Example #5
0
	private function remove() {
		global $config, $cache;

		$remove = request_var('s_downloads', array(0));

		if (!count($remove)) {
			return;
		}

		$sql = 'SELECT *
			FROM _dl
			WHERE id IN (??)
				AND ub = ?';
		if ($result = sql_rowset(sql_filter($sql, _implode(',', $remove), $this->object['ub']))) {
			foreach ($result as $row) {
				$path = artist_root($this->object['ub'] . ' media ' . $row['id'] . '.mp3');

				_rm($path);

				$sql = 'DELETE FROM _dl
					WHERE id = ?';
				sql_query(sql_filter($sql, $row['id']));

				$cache->delete('downloads_list');
			}

			redirect(s_link('acp', array('artist_media', 'a' => $this->object['subdomain'])));
		}

		return;
	}
Example #6
0
	public function resize(&$row, $folder_a, $folder_b, $filename, $measure, $do_scale = true, $watermark = true, $remove = false, $watermark_file = false) {
		global $config;

		$t = (object) array(
			'filename' => $filename . '.' . $row->extension,
			'source' => $folder_a . $row->filename
		);

		if (!@is_readable($t->source)) {
			$row->error = 'not_readable';
			return false;
		}

		$t->destination = $folder_b . $t->filename;

		foreach ($t as $tk => $tv) {
			$row->$tk = $tv;
		}

		// Get source image data
		$dim = @getimagesize($t->source);

		if ($dim[0] < 1 && $dim[1] < 1) {
			$row->error = 'bad_size';
			return false;
		}

		if ($dim[0] < $measure[0] && $dim[1] < $measure[1]) {
			$measure[0] = $dim[0];
			$measure[1] = $dim[1];
		}

		$row->width = $dim[0];
		$row->height = $dim[1];
		$row->mwidth = $measure[0];
		$row->mheight = $measure[1];

		$mode = ($do_scale === true) ? 'c' : 'v';
		$scale = $this->scale($mode, $row);

		$row->width = $scale->width;
		$row->height = $scale->height;

		switch ($dim[2]) {
			case IMG_JPG:
				$image_f = 'imagecreatefromjpeg';
				$image_g = 'imagejpeg';
				$image_t = 'jpg';
				break;
			case IMG_GIF:
				$image_f = 'imagecreatefromgif';
				$image_g = 'imagegif';
				$image_t = 'gif';
				break;
			case IMG_PNG:
				$image_f = 'imagecreatefrompng';
				$image_g = 'imagepng';
				$image_t = 'png';
				break;
		}

		if (!$generated = $image_f($t->source)) {
			return false;
		}

		imagealphablending($generated, true);
		$thumb = imagecreatetruecolor($row->width, $row->height);
		imagecopyresampled($thumb, $generated, 0, 0, 0, 0, $row->width, $row->height, $dim[0], $dim[1]);

		// Watermark
		if ($watermark) {
			if ($watermark_file === false) {
				$watermark_file = $config['watermark'];
			}

			if (!empty($watermark_file)) {
				$wm = imagecreatefrompng($watermark_file);
				$wm_w = imagesx($wm);
				$wm_h = imagesy($wm);

				if ($watermark_file == 'w') {
					$dest_x = $row->width - $wm_w - 5;
					$dest_y = $row->height - $wm_h - 5;

					imagecopymerge($thumb, $wm, $dest_x, $dest_y, 0, 0, $wm_w, $wm_h, 100);
					imagedestroy($wm);
				} else {
					$dest_x = round(($row->width / 2) - ($wm_w / 2));
					$dest_y = round(($row->height / 2) - ($wm_h / 2));

					$thumb = $this->alpha_overlay($thumb, $wm, $wm_w, $wm_h, $dest_x, $dest_y, 100);
				}
			}
		}

		if ($type == IMG_JPG) {
			$created = @$image_g($thumb, $t->destination, 85);
		} else {
			$created = @$image_g($thumb, $t->destination);
		}

		if (!$created || !file_exists($t->destination)) {
			$row->error = 'not_created';
			return false;
		}

		_chmod($t->destination, $config['mask']);
		imagedestroy($thumb);
		imagedestroy($image);

		if ($remove && file_exists($t->source)) {
			_rm($t->source);
		}

		return $row;
	}
Example #7
0
function _rm($path) {
	if (empty($path)) {
		return false;
	}

	if (!@file_exists($path)) {
		return false;
	}

	if (is_dir($path)) {
		$fp = @opendir($path);
		while ($file = @readdir($fp)) {
			if ($file == '.' || $file == '..') continue;

			_rm($path . '/' . $file);
		}
		@closedir($fp);

		if (!@rmdir($path)) {
			return false;
		}
	} else {
		if (!@unlink($path)) {
			return false;
		}
	}

	return true;
}
Example #8
0
	public function delete($list) {
		if (!$this->use) {
			return;
		}

		foreach (w($list) as $var) {
			$cache_filename = ROOT . 'cache/' . $var . '.php';
			if (file_exists($cache_filename)) {
				_rm($cache_filename);
			}
		}

		return;
	}