Skip to content

Commit

Permalink
Merge pull request #258 from tarasfrompir/master
Browse files Browse the repository at this point in the history
Увеличено количества загружаемых файлов - необходимо для медиарендерера
  • Loading branch information
T-REX-XP committed Aug 28, 2018
2 parents b6a52ac + f0c6851 commit c28e852
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
20 changes: 19 additions & 1 deletion modules/ssdp_finder/ssdp_finder.class.php
Expand Up @@ -474,6 +474,15 @@ function loadDrivers($device_type){
file_put_contents(ROOT.'/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type.'/Remote.php', $current);
};

for ($i = 1; $i <= 10; $i++) {
if (!file_exists(ROOT.'/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type.'/Remote'.$i.'.php')) {
$current = file_get_contents('https://raw.githubusercontent.com/tarasfrompir/SSDPDrivers/master/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type.'/Remote'.$i.'.php');
if (!$current) {
break;
};
file_put_contents(ROOT.'/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type.'/Remote'.$i.'.php', $current);
};
};
return true;
}

Expand Down Expand Up @@ -640,8 +649,15 @@ function deleteDrivers($device_type){
};
if (file_exists(ROOT.'/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type.'/Remote.php')) {
unlink(ROOT.'/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type.'/Remote.php');
rmdir(ROOT.'/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type);
};
for ($i = 1; $i <= 10; $i++) {
if (!file_exists(ROOT.'/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type.'/Remote'.$i.'.php')) {
break;
};
unlink(ROOT.'/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type.'/Remote'.$i.'.php');
};
// удаляем директорию для текущего устройства
rmdir(ROOT.'/modules/ssdp_finder/upnp/vendor/jalder/upnp/src/'.$device_type);
// удаляем structure in addons для устройства
if (file_exists(ROOT.'/modules/devices/addons/SSDPFinder_'.$device_type.'_structure.php')) {
unlink(ROOT.'/modules/devices/addons/SSDPFinder_'.$device_type.'_structure.php');
Expand Down Expand Up @@ -845,6 +861,8 @@ function uninstall() {
//delete ssdp_finder module
parent::uninstall();
}


/**
* dbInstall
*
Expand Down
35 changes: 32 additions & 3 deletions modules/ssdp_finder/ssdp_install_module.inc.php
Expand Up @@ -13,8 +13,38 @@
// если нету то устанавливаем модуль по названию которое находится в переменной $namemodule
include_once (DIR_MODULES.'market/market.class.php');
$mkt=new market();
}

$result = $mkt->marketRequest();
$data=json_decode($result, TRUE);
foreach ( $data['PLUGINS'] as $plug_number ) {
if ( $plug_number['TITLE'] == $namemodule ){
$url= $plug_number['REPOSITORY_URL'];
$name = $plug_number['MODULE_NAME'];
break;
};
};
//загружаем модуль в папку сайвресторе
if (!is_dir(ROOT.'cms/saverestore')) {
@umask(0);
@mkdir(ROOT.'cms/saverestore', 0777);
}

$filename=ROOT.'cms/saverestore/'.$name.'.tgz';
@unlink(ROOT.'cms/saverestore/'.$name.'.tgz');
@unlink(ROOT.'cms/saverestore/'.$name.'.tar');
$f = fopen($filename, 'wb');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FILE, $f);
$incoming = curl_exec($ch);
curl_close($ch);
@fclose($f);

////////////////////////////////////////////////////////////
}

// добавление устройства в таблицу ssdp_devices
$table_name='ssdp_devices';
Expand Down Expand Up @@ -76,4 +106,3 @@
$out['OK']=1;
// после сохранения устройства переходим на основную страницу
$this->redirect("?");

0 comments on commit c28e852

Please sign in to comment.