Перейти к контенту

[2.3.x]Защита админцентра: карта доступа


Arhar

Рекомендуемые сообщения

  • Ответы 92
  • Создана
  • Последний ответ

Лучшие авторы в этой теме

Лучшие авторы в этой теме

  • 2 недели спустя...
  • 2 недели спустя...
В инструкции написано :D А она по ссылке "скачать" в первом сообщении темы.
Ссылка на комментарий
Поделиться на других сайтах

  • 2 месяца спустя...

! C:\Documents and Settings\Администратор\Application Data\Opera\Opera\profile\cache4\temporary_download\zip_source.zip: CRC failed in source1.jpg. The file is corrupt

Это когда я пытаюсь извлечь картинку

Ссылка на комментарий
Поделиться на других сайтах

  • 2 недели спустя...

2Arhar

Появилась проблема. Во время установки мода админов было двое, мод работал исправно. Сейчас добавил третьего, пытаюсь скачать все карты, все вроде бы нормально - скачиваю архив, открываю его, в нем лежат 3 карточки, с первыми двумя все ок, а у третьей вес 0 байт, соответственно, пустой файл. В чем может быть дело?

Ссылка на комментарий
Поделиться на других сайтах

а, ну так надо при добавлении через инсталлятор скачивать

 

вообще я у себя сделал кнопку "добавить админов"

функция к ней

			case 'addsmartcards':
			$this->add_smart_cards();
			break;

	function add_smart_cards()
{
	require_once(ROOT_PATH."sources/zip.lib.php");
	$zip=new zipfile();
	$this->ipsclass->DB->simple_construct( array( 'select' => 'admin_id',
													'from' => 'admin_smartcards',
												));

	$this->ipsclass->DB->simple_exec();
	while($admin = $this->ipsclass->DB->fetch_row())
	{
		$admins[] = $admin['admin_id'];
	}

	$this->ipsclass->DB->simple_construct( array( 'select' => 'm.id as mid',
													'from' => 'members m LEFT JOIN '.SQL_PREFIX.'groups g on g.g_id=m.mgroup',
													'where' => 'g.g_access_cp = 1 or m.mgroup = '.$this->ipsclass->vars['admin_group']));

	$this->ipsclass->DB->simple_exec();
	while($newadmin = $this->ipsclass->DB->fetch_row())
	{
		if (!in_array($newadmin['mid'],$admins))
		{
			$newadmins[] = $newadmin['mid'];
		}
	}

	foreach ($newadmins as $id)
	{
		$object= ROOT_PATH."cache/".$this->ipsclass->vars['smartcards_directory']."/source".$id.".jpg";

		$start = imagecreate(210,65);

		imagecolorallocate($start, rand(0,255),rand(0,255),rand(0,255));

		for($i=0; $i<32; $i++)
		{
			for($j=0; $j<64; $j++)
			{		
				$points[$j] = rand($j,200);
				$ponits[$j+1] = rand(1,64);
			}
			imagefilledpolygon($start, $points, 32, imagecolorallocate($start, rand(0,255),rand(0,255),rand(0,255)));
		}			

		for($i=0; $i<32; $i++)
		{
			$this->imagelinethick($start,rand(1,209),rand(1,64),rand(1,209),rand(1,64),imagecolorallocate($start,rand(0,255),rand(0,255),rand(0,255)),rand(1,3));
			imagearc($start,rand(100,120),rand(25,35),rand(1,200),rand(1,64),rand(1,90),rand(180,360),imagecolorallocate($start,rand(0,255),rand(0,255),rand(0,255)));
		}
		$name = parse_url($this->ipsclass->vars['board_url']);
		imagestring($start,5,15,1,$name['host'],imagecolorallocate($start,rand(0,255),rand(0,255),rand(0,255)));
		imagefilledpolygon($start,array(15,48,(strlen($id) * 12),48,(strlen($id) * 12),60,15,60),4,imagecolorallocate($start, rand(0,255),rand(0,255),rand(0,255)));
		imagestring($start,5,15,48,$id,imagecolorallocate($start,rand(0,255),rand(0,255),rand(0,255)));

		imagejpeg($start,$object,100);
		$repeat = array();
		$image = imagecreatefromjpeg($object);
		for($i=1; $i<=32; $i++)
		{
			do
			{
				$x=rand(30,180);
				$y=rand(8,56);
				$rgb = imagecolorat($image,$x,$Y);
				$ch = $x.":".$y.":".$rgb;
			}
			while(in_array($rgb,$repeat));
			$repeat[$i] = $rgb;

			$check[$i] = $ch;
		}

		$smartvalue = array(
						'point1' => $check[1],
						'point2' => $check[2],
						'point3' => $check[3],
						'point4' => $check[4],
						'point5' => $check[5],
						'point6' => $check[6],
						'point7' => $check[7],
						'point8' => $check[8],
						'point9' => $check[9],
						'point10' => $check[10],
						'point11' => $check[11],
						'point12' => $check[12],
						'point13' => $check[13],
						'point14' => $check[14],
						'point15' => $check[15],
						'point16' => $check[16],
						'point17' => $check[17],
						'point18' => $check[18],
						'point19' => $check[19],
						'point20' => $check[20],
						'point21' => $check[21],
						'point22' => $check[22],
						'point23' => $check[23],
						'point24' => $check[24],
						'point25' => $check[25],
						'point26' => $check[26],
						'point27' => $check[27],
						'point28' => $check[28],
						'point29' => $check[29],
						'point30' => $check[30],
						'point31' => $check[31],
						'point32' => $check[32],
		);

		$smartvalue['admin_id'] = $id;
		$this->ipsclass->DB->do_insert('admin_smartcards', $smartvalue);	

		$fp=fopen(ROOT_PATH."cache/".$this->ipsclass->vars['smartcards_directory']."/source".$id.".jpg", "rb"); 
		$zip->addFile(fread($fp, filesize(ROOT_PATH."cache/".$this->ipsclass->vars['smartcards_directory']."/source".$id.".jpg")), "source".$id.".jpg", time()); 
		fclose($fp); 		
	}

	Header("Content-Type: application/octet-stream"); 
	Header("Content-disposition: attachment; filename=\"new_zip_source.zip\"");  
	echo($zip->file()); 		
	//print_r($newadmins);
	//exit;
}

 

плюс если у кого много админов, в инсталляторе использовать функцию

	function auto_run()
{
	if ($this->ipsclass->member['mgroup'] != $this->ipsclass->vars['admin_group'])
	{
		$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
		exit;
	}

	$a = intval($this->ipsclass->input['a']);

	if (! $this->ipsclass->input['a'] )
	$a = 0;


	//require_once(ROOT_PATH."sources/zip.lib.php");
	//$zip=new zipfile(); 

	$this->ipsclass->DB->simple_construct( array( 'select' => 'm.id as mid',
													'from' => 'members m LEFT JOIN '.SQL_PREFIX.'groups g on g.g_id=m.mgroup',
													'where' => 'g.g_access_cp = 1 or m.mgroup = '.$this->ipsclass->vars['admin_group']));

	$this->ipsclass->DB->simple_exec();
	while($admin = $this->ipsclass->DB->fetch_row())
	{
		$admins[] = $admin['mid'];
	}

	$c = count($admins);

			if ( $a == $c)
			{
			print "end.";
			exit;
			}

	//for ($this->a=0; $this->a<$c; $this->a++)
	//{
		$object= ROOT_PATH."cache/".$this->ipsclass->vars['smartcards_directory']."/source".$admins[$a].".jpg";

		$start = imagecreate(210,65);

		imagecolorallocate($start, rand(0,255),rand(0,255),rand(0,255));


		for($i=0; $i<32; $i++)
		{
			for($j=0; $j<64; $j++)
			{		
				$points[$j] = rand($j,200);
				$ponits[$j+1] = rand(1,64);
			}
			imagefilledpolygon($start, $points, 32, imagecolorallocate($start, rand(0,255),rand(0,255),rand(0,255)));
		}

		for($i=0; $i<32; $i++)
		{
			$this->imagelinethick($start,rand(1,209),rand(1,64),rand(1,209),rand(1,64),imagecolorallocate($start,rand(0,255),rand(0,255),rand(0,255)),rand(2,4));
			imagearc($start,rand(100,120),rand(25,35),rand(1,200),rand(1,64),rand(1,90),rand(180,360),imagecolorallocate($start,rand(0,255),rand(0,255),rand(0,255)));
		}

		$name = parse_url($this->ipsclass->vars['board_url']);
		imagestring($start,5,15,1,$name['host'],imagecolorallocate($start,rand(0,255),rand(0,255),rand(0,255)));
		imagefilledpolygon($start,array(15,48,(strlen($admins[$a]) * 12),48,(strlen($admins[$a]) * 12),60,15,60),4,imagecolorallocate($start, rand(0,255),rand(0,255),rand(0,255)));
		imagestring($start,5,15,48,$admins[$a],imagecolorallocate($start,rand(0,255),rand(0,255),rand(0,255)));


		imagejpeg($start,$object,100);

		$repeat = array();
		$image = imagecreatefromjpeg($object);
		for($i=1; $i<=32; $i++)
		{
			do
			{
				$x=rand(30,180);
				$y=rand(8,56);
				$rgb = imagecolorat($image,$x,$Y);
				$ch = $x.":".$y.":".$rgb;
			}
			while(in_array($rgb,$repeat));
			$repeat[$i] = $rgb;

			$check[$i] = $ch;
		}

		$smartvalue = array(
						'point1' => $check[1],
						'point2' => $check[2],
						'point3' => $check[3],
						'point4' => $check[4],
						'point5' => $check[5],
						'point6' => $check[6],
						'point7' => $check[7],
						'point8' => $check[8],
						'point9' => $check[9],
						'point10' => $check[10],
						'point11' => $check[11],
						'point12' => $check[12],
						'point13' => $check[13],
						'point14' => $check[14],
						'point15' => $check[15],
						'point16' => $check[16],
						'point17' => $check[17],
						'point18' => $check[18],
						'point19' => $check[19],
						'point20' => $check[20],
						'point21' => $check[21],
						'point22' => $check[22],
						'point23' => $check[23],
						'point24' => $check[24],
						'point25' => $check[25],
						'point26' => $check[26],
						'point27' => $check[27],
						'point28' => $check[28],
						'point29' => $check[29],
						'point30' => $check[30],
						'point31' => $check[31],
						'point32' => $check[32],
		);

		$this->ipsclass->DB->simple_construct( array( 'select' => 'id', 'from' => 'admin_smartcards' , 'where' => 'admin_id='.$admins[$a] ));

		$this->ipsclass->DB->simple_exec();

		$controldata = $this->ipsclass->DB->fetch_row();

		if (! $controldata['id'])
		{
			$smartvalue['admin_id'] = $admins[$a];
			$this->ipsclass->DB->do_insert('admin_smartcards', $smartvalue);	
		}
		else
		{		
			$this->ipsclass->DB->do_update('admin_smartcards', $smartvalue, 'admin_id='.$admins[$a]);	
		}

		//$fp=fopen(ROOT_PATH."cache/".$this->ipsclass->vars['smartcards_directory']."/source".$this->admins[$this->a].".jpg", "rb"); 
		//$zip->addFile(fread($fp, filesize(ROOT_PATH."cache/".$this->ipsclass->vars['smartcards_directory']."/source".$this->admins[$this->a].".jpg")), "source".$this->admins[$this->a].".jpg", time()); 
		//fclose($fp); 


		$a++;

		$this->ipsclass->print->redirect_screen( $admins[$a-1], "act=installsmartcards&a=".$a );

	//}

	//Header("Content-Type: application/octet-stream"); 
	//Header("Content-disposition: attachment; filename=\"zip_source.zip\"");  
	//echo($zip->file());

}

но только скачать придется по фтп

Ссылка на комментарий
Поделиться на других сайтах

  • 3 недели спустя...

А папка с картами, что в кеше лежит,в дальнейшем на хосте нужна? или можно снести?

И ещё, а можно как-то менять карту ОДЕЛЬНО одному админу? к примеру уперёли карточку(или подозрения есть такие), чтоб менять персональному ему а не всем.

Ссылка на комментарий
Поделиться на других сайтах

папку саму нельзя снести, чтобы не было недоразумений, а вот карты оттуда удалить можно

одному изначально нет, но можно написать код методом копипасте..

Ссылка на комментарий
Поделиться на других сайтах

  • 6 месяцев спустя...

Переехал на новый хостинг.

При заходе в админку пишет Move failed.

 

// upd: разобрался в чём трабла, вопрос снимается.

Изменено пользователем atlant1s
Ссылка на комментарий
Поделиться на других сайтах

  • 4 месяца спустя...
  • 1 месяц спустя...
  • 5 месяцев спустя...

×
×
  • Создать...

Важная информация

Находясь на нашем сайте, вы соглашаетесь на использование файлов cookie, а также с нашим положением о конфиденциальности Политика конфиденциальности и пользовательским соглашением Условия использования.