Advertisement
Guest User

Untitled

a guest
Oct 8th, 2016
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 43.85 KB | None | 0 0
  1. <?php
  2. /**
  3.  * MoonSerials
  4.  * =======================================================
  5.  * Автор:  kild
  6.  * =======================================================
  7.  * Файл:  moonserials.php
  8.  * -------------------------------------------------------
  9.  * Версия: 1.4.5
  10.  * =======================================================
  11.  */
  12.         if ( !defined('DATALIFEENGINE'))
  13.                 die("Go fuck yourself!");
  14.         include ( 'engine/data/moonserials_options.php' );
  15.         global $row;
  16.         $myConfig = array( 'cachePrefix' => $moonserials_options['cashe_prefix_dle'], 'cacheSuffix' => !empty( $cacheSuffix ) ? $cacheSuffix : false, 'id' => $row['id'], );
  17.         if ( $config['charset'] == 'windows-1251' )
  18.         {
  19.                 function encoding(& $data, $in, $to)
  20.                 {
  21.                         if ( is_array($data))
  22.                         {
  23.                                 foreach ( $data as $key => $value )
  24.                                 {
  25.                                         if ( is_array($data[$key]))
  26.                                         {
  27.                                                 encoding($data[$key], $in, $to);
  28.                                         }
  29.                                         else
  30.                                         {
  31.                                                 $data[$key] = iconv($in, $to, $value);
  32.                                         }
  33.                                 }
  34.                         }
  35.                         else
  36.                         {
  37.                                 $data = iconv($in, $to, $data);
  38.                         }
  39.                 }
  40.         }
  41.         if ( $moonserials_options['allow_module_on'] != 0 )
  42.         {
  43.                 $cacheName = md5(implode('_', $myConfig));
  44.                 $myModule = false;
  45.                 $allow_cache = ( $config['version_id'] >= '10.2' ) ? $config['allow_cache'] == '1' : $config['allow_cache'] == "yes";
  46.                 if ( !$allow_cache )
  47.                 {
  48.                         if ( $config['version_id'] >= '10.2' )
  49.                                 $config['allow_cache'] = '1';
  50.                         else
  51.                                 $config['allow_cache'] = "yes";
  52.                         $is_change = true;
  53.                 }
  54.                 $myModule = dle_cache($myConfig['cachePrefix'], $cacheName . $config['skin'], $myConfig['cacheSuffix']);
  55.                 if ( $myModule === false )
  56.                 {
  57.                         $post_id = $row['id'];
  58.                         $xfieldsdata = xfieldsdataload($row['xfields']);
  59.                         $xfields_n = $xfieldsdata;
  60.                         $kinopoisk_id = $xfieldsdata[$moonserials_options['field_kpid']];
  61.                         if ( $xfieldsdata[$moonserials_options['field_season']] AND $xfieldsdata[$moonserials_options['field_series']] AND $xfieldsdata[$moonserials_options['field_season']] !== $moonserials_options['if_series_ower'] )
  62.                         {
  63.                                 $str = strpos($xfieldsdata[$moonserials_options['field_season']], " ");
  64.                                 $seasonTemp = substr($xfieldsdata[$moonserials_options['field_season']], 0, $str);
  65.                                 $str = strpos($xfieldsdata[$moonserials_options['field_series']], " ");
  66.                                 $seriesTemp = substr($xfieldsdata[$moonserials_options['field_series']], 0, $str);
  67.                         }
  68.                         else
  69.                         {
  70.                                 $seasonTemp = false;
  71.                                 $seriesTemp = false;
  72.                         }
  73.                         if ( $moonserials_options['allow_module_new_series_max'] > 0 AND $moonserials_options['field_series-max'] AND !$xfieldsdata[$moonserials_options['field_series-max']] AND $xfieldsdata[$moonserials_options['field_season_iframe']] )
  74.                         {
  75.                                 $url = "http://api.kinopoisk.cf/tvshow/get?kinopoiskID=" . $kinopoisk_id;
  76.                                 $curlpost = curl_init($url);
  77.                                 curl_setopt($curlpost, CURLOPT_URL, $url);
  78.                                 curl_setopt($curlpost, CURLOPT_RETURNTRANSFER, 1);
  79.                                 curl_setopt($curlpost, CURLOPT_HEADER, 0);
  80.                                 curl_setopt($curlpost, CURLOPT_FOLLOWLOCATION, 1);
  81.                                 curl_setopt($curlpost, CURLOPT_ENCODING, "");
  82.                                 curl_setopt($curlpost, CURLOPT_CONNECTTIMEOUT, 120);
  83.                                 curl_setopt($curlpost, CURLOPT_TIMEOUT, 120);
  84.                                 curl_setopt($curlpost, CURLOPT_MAXREDIRS, 10);
  85.                                 $data = curl_exec($curlpost);
  86.                                 curl_close($curlpost);
  87.                                 if ( $data )
  88.                                 {
  89.                                         $data = json_decode($data, true);
  90.                                         $seriesMax = $data['episodesInSeason'][$xfieldsdata[$moonserials_options['field_season_iframe']]];
  91.                                 }
  92.                         }
  93.                         elseif ( $xfieldsdata[$moonserials_options['field_series-max']] AND $moonserials_options['allow_module_new_series_max'] > 0 AND $xfieldsdata[$moonserials_options['field_season_iframe']] )
  94.                                 $seriesMax = $xfieldsdata[$moonserials_options['field_series-max']];
  95.                         if ( $moonserials_options['allow_module_new'] )
  96.                         {
  97.                                 $tpl1 = new dle_template();
  98.                                 $tpl1->dir = TEMPLATE_DIR;
  99.                                 $tpl1->load_template('/moonserials/moonserials_iframe.tpl');
  100.                         }
  101.                         if ( $xfieldsdata[$moonserials_options['field_status_name']] == $moonserials_options['field_status'] )
  102.                         {
  103.                                 if ( $moonserials_options['allow_fields_spy'] )
  104.                                 {
  105.                                         $xfields_n[$moonserials_options['field_season']] = $moonserials_options['if_series_ower'];
  106.                                         if ( $xfieldsdata[$moonserials_options['field_series']] )
  107.                                                 unset( $xfields_n[$moonserials_options['field_series']] );
  108.                                         foreach ( $xfields_n as $key => & $value )
  109.                                                 $arr_field[] = $key . "|" . str_replace('|', '&#124;', $value);
  110.                                         $xfields_n = implode("||", $arr_field);
  111.                                         unset( $arr_field );
  112.                                         $xfields_n = $db->safesql($xfields_n);
  113.                                         $db->query("UPDATE " . PREFIX . "_post SET `xfields` = '$xfields_n' WHERE id = {$post_id}");
  114.                                 }
  115.                                 if ( $moonserials_options['allow_module_new'] )
  116.                                 {
  117.                                         $tpl1->set('[ower]', "");
  118.                                         $tpl1->set('[/ower]', "");
  119.                                         $tpl1->set_block("'\\[not-ower\\](.*?)\\[/not-ower\\]'si", "");
  120.                                 }
  121.                         }
  122.                         else
  123.                         {
  124.                                 if ( $moonserials_options['allow_module_new'] )
  125.                                 {
  126.                                         $tpl1->set_block("'\\[ower\\](.*?)\\[/ower\\]'si", "");
  127.                                         $tpl1->set_block("'\\[not-ower\\](.*?)\\[/not-ower\\]'si", "\\1");
  128.                                 }
  129.                         }
  130.                         if ( $curl = curl_init())
  131.                         {
  132.                                 curl_setopt($curl, CURLOPT_URL, 'http://moonwalk.cc/api/videos.json?kinopoisk_id=' . $kinopoisk_id . '&api_token=' . $moonserials_options['api_token'] . '');
  133.                                 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  134.                                 $out = curl_exec($curl);
  135.                                 $output_tr = json_decode($out, true);
  136.                                 curl_close($curl);
  137.                         }
  138.                         if ( $config['charset'] == 'windows-1251' )
  139.                         {
  140.                                 encoding($output_tr, "UTF-8", "WINDOWS-1251");
  141.                         }
  142.                         if ( !$output_tr or $output_tr['error'] == 'videos_not_found' )
  143.                         {
  144.                                 if ( $moonserials_options['allow_module_new'] )
  145.                                 {
  146.                                         if ( !$xfieldsdata[$moonserials_options['field_season_iframe']] )
  147.                                         {
  148.                                                 $tpl1->set('[error]', "");
  149.                                                 $tpl1->set('[/error]', "");
  150.                                                 $tpl1->set_block("'\\[not-error\\](.*?)\\[/not-error\\]'si", "");
  151.                                                 $tpl1->set_block("'\\[soon\\](.*?)\\[/soon\\]'si", "");
  152.                                                 $tpl1->set_block("'\\[not-soon\\](.*?)\\[/not-soon\\]'si", "\\1");
  153.                                         }
  154.                                         else
  155.                                         {
  156.                                                 $tpl1->set_block("'\\[error\\](.*?)\\[/error\\]'si", "");
  157.                                                 $tpl1->set_block("'\\[not-error\\](.*?)\\[/not-error\\]'si", "\\1");
  158.                                                 $tpl1->set('[soon]', "");
  159.                                                 $tpl1->set('[/soon]', "");
  160.                                                 $tpl1->set_block("'\\[not-soon\\](.*?)\\[/not-soon\\]'si", "");
  161.                                         }
  162.                                         $tpl1->set_block("'\\[studios\\](.*?)\\[/studios\\]'si", "");
  163.                                         $tpl1->set_block("'\\[not-studios\\](.*?)\\[/not-studios\\]'si", "\\1");
  164.                                 }
  165.                         }
  166.                         else
  167.                         {
  168.                                 if ( $moonserials_options['allow_module_new'] )
  169.                                 {
  170.                                         $tpl1->set_block("'\\[error\\](.*?)\\[/error\\]'si", "");
  171.                                         $tpl1->set_block("'\\[not-error\\](.*?)\\[/not-error\\]'si", "\\1");
  172.                                         $tpl1->set('{title}', $output_tr[0]['title_ru']);
  173.                                         if ( count($output_tr) == 1 )
  174.                                         {
  175.                                                 $tpl1->set_block("'\\[studios\\](.*?)\\[/studios\\]'si", "");
  176.                                                 $tpl1->set_block("'\\[not-studios\\](.*?)\\[/not-studios\\]'si", "\\1");
  177.                                         }
  178.                                         else
  179.                                         {
  180.                                                 $tpl1->set('[studios]', "");
  181.                                                 $tpl1->set('[/studios]', "");
  182.                                                 $tpl1->set_block("'\\[not-studios\\](.*?)\\[/not-studios\\]'si", "");
  183.                                         }
  184.                                         $tpl2 = new dle_template();
  185.                                         $tpl2->dir = TEMPLATE_DIR;
  186.                                         $tpl2->load_template('/moonserials/moonserials_iframe_title.tpl');
  187.                                         $tpl3 = new dle_template();
  188.                                         $tpl3->dir = TEMPLATE_DIR;
  189.                                         $tpl3->load_template('/moonserials/moonserials_iframe_content.tpl');
  190.                                 }
  191.                                 foreach ( ( array ) $output_tr as $kk => $vv )
  192.                                 {
  193.                                         $seasonfound = 0;
  194.                                         $seriesfound = 0;
  195.                                         if ( $curl = curl_init())
  196.                                         {
  197.                                                 curl_setopt($curl, CURLOPT_URL, 'http://moonwalk.cc/api/serial_episodes.json?kinopoisk_id=' . $kinopoisk_id . '&api_token=' . $moonserials_options['api_token'] . '&translator_id=' . $vv['translator_id'] . '');
  198.                                                 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  199.                                                 $out = curl_exec($curl);
  200.                                                 $output_sr = json_decode($out, true);
  201.                                                 curl_close($curl);
  202.                                         }
  203.                                         if ( $moonserials_options['disable_sub'] > 0 AND $vv['translator'] == 'Субтитры' )
  204.                                                 continue;
  205.                                         if ( $config['charset'] == 'windows-1251' )
  206.                                                 encoding($output_sr, "UTF-8", "WINDOWS-1251");
  207.                                         $title_ru = $vv['title_ru'];
  208.                                         if ( !$vv['translator'] )
  209.                                         {
  210.                                                 $vv['translator'] = 'Неизвестно';
  211.                                         }
  212.                                         elseif ( $vv['translator'] == 'двухголосый закадровый' )
  213.                                         {
  214.                                                 $vv['translator'] = 'Двухголосый';
  215.                                         }
  216.                                         elseif ( $vv['translator'] == 'многоголосый закадровый' )
  217.                                         {
  218.                                                 $vv['translator'] = 'Многоголосый';
  219.                                         }
  220.                                         elseif ( $vv['translator'] == 'одноголосый закадровый' )
  221.                                         {
  222.                                                 $vv['translator'] = 'Одноголосый';
  223.                                         }
  224.                                         if ( $moonserials_options['field_studios_sp'] AND $vv['translator'] !== "Неизвестно" )
  225.                                                 $studios_sp = !$studios_sp ? $vv['translator'] : $studios_sp . ", " . $vv['translator'];
  226.                                         foreach ( ( array ) $output_sr["season_episodes_count"] as $kkk => $vvv )
  227.                                         {
  228.                                                 if ( $xfieldsdata[$moonserials_options['field_season_iframe']] )
  229.                                                 {
  230.                                                         if ( $vvv["season_number"] == $xfieldsdata[$moonserials_options['field_season_iframe']] )
  231.                                                         {
  232.                                                                 $season = $vvv["season_number"];
  233.                                                                 $seriesA = $vvv["episodes"];
  234.                                                                 $seriesC = $vvv["episodes_count"];
  235.                                                         }
  236.                                                 }
  237.                                                 else
  238.                                                 {
  239.                                                         if ( $vvv["season_number"] > $season )
  240.                                                         {
  241.                                                                 $season = $vvv["season_number"];
  242.                                                                 $seriesA = $vvv["episodes"];
  243.                                                                 $seriesC = $vvv["episodes_count"];
  244.                                                         }
  245.                                                 }
  246.                                                 if ( $moonserials_options['allow_module_new'] )
  247.                                                 {
  248.                                                         if ( $xfieldsdata[$moonserials_options['field_season_iframe']] )
  249.                                                         {
  250.                                                                 if ( $vvv["season_number"] == $xfieldsdata[$moonserials_options['field_season_iframe']] )
  251.                                                                 {
  252.                                                                         $seasonfound = 1;
  253.                                                                         if ( $xfieldsdata[$moonserials_options['field_series_iframe']] )
  254.                                                                         {
  255.                                                                                 foreach ( ( array ) $vvv["episodes"] as $vvvvv )
  256.                                                                                 {
  257.                                                                                         if ( $vvvvv == $xfieldsdata[$moonserials_options['field_series_iframe']] )
  258.                                                                                         {
  259.                                                                                                 $seriesfound = 1;
  260.                                                                                                 break;
  261.                                                                                         }
  262.                                                                                 }
  263.                                                                         }
  264.                                                                 }
  265.                                                         }
  266.                                                 }
  267.                                                 foreach ( ( array ) $seriesA as $vvvv )
  268.                                                 {
  269.                                                         if ( $vvvv == 0 )
  270.                                                                 $seriesT = - 1;
  271.                                                 }
  272.                                                 if ( $seriesT == - 1 AND $seriesC == 1 )
  273.                                                         $series = $moonserials_options['if_pilot_series'];
  274.                                                 else
  275.                                                         $series = max($seriesA);
  276.                                         }
  277.                                         $tabs[] = array( 'translator' => $vv['translator'], 'iframe_url' => $vv['iframe_url'], 'season' => $season, 'series' => $series, 'seasonfound' => $seasonfound, 'seriesfound' => $seriesfound );
  278.                                         unset( $season );
  279.                                         unset( $series );
  280.                                         usleep(100000);
  281.                                 }
  282.                                 foreach ( ( array ) $tabs as $k => $v )
  283.                                 {
  284.                                         if ( $v['series'] == $moonserials_options['if_pilot_series'] )
  285.                                                 $v['series'] = 0;
  286.                                         if ( $v['translator'] == "Субтитры" )
  287.                                                 $v['series'] = $v['series'] - 0.5;
  288.                                         $se[$k] = $v['season'];
  289.                                         $ep[$k] = $v['series'];
  290.                                 }
  291.                                 array_multisort($se, SORT_NUMERIC, SORT_DESC, $ep, SORT_NUMERIC, SORT_DESC, $tabs);
  292.                                 if ( $moonserials_options['allow_module_new'] )
  293.                                 {
  294.                                         $tplstudios = false;
  295.                                         foreach ( ( array ) $tabs as $tabskey => $tabsvalue )
  296.                                         {
  297.                                                 if ( $xfieldsdata[$moonserials_options['field_season_iframe']] AND $xfieldsdata[$moonserials_options['field_series_iframe']] )
  298.                                                 {
  299.                                                         if ( $tabsvalue['seasonfound'] > 0 AND $tabsvalue['seriesfound'] > 0 )
  300.                                                         {
  301.                                                                 if ( !$tplstudios )
  302.                                                                         $tplstudios = $tabsvalue['translator'];
  303.                                                                 $tpl2->set('{ms-title}', $tabsvalue['translator']);
  304.                                                                 $tpl2->compile('tabs-title');
  305.                                                                 $ifrm = '' . $tabsvalue['iframe_url'] . '?season=' . $xfieldsdata[$moonserials_options['field_season_iframe']] . '&episode=' . $xfieldsdata[$moonserials_options['field_series_iframe']] . '&nocontrols=1';
  306.                                                                 $tpl3->set('{data-season}', $xfieldsdata[$moonserials_options['field_season_iframe']]);
  307.                                                                 $tpl3->set('{data-series}', $tabsvalue['series']);
  308.                                                                 $tpl3->set('{ms-content}', $ifrm);
  309.                                                                 $tpl3->compile('tabs-content');
  310.                                                         }
  311.                                                 }
  312.                                                 elseif ( $xfieldsdata[$moonserials_options['field_season_iframe']] AND !$xfieldsdata[$moonserials_options['field_series_iframe']] )
  313.                                                 {
  314.                                                         if ( $tabsvalue['seasonfound'] > 0 )
  315.                                                         {
  316.                                                                 if ( !$tplstudios )
  317.                                                                         $tplstudios = $tabsvalue['translator'];
  318.                                                                 $tpl2->set('{ms-title}', $tabsvalue['translator']);
  319.                                                                 $tpl2->compile('tabs-title');
  320.                                                                 $ifrm = '' . $tabsvalue['iframe_url'] . '?season=' . $xfieldsdata[$moonserials_options['field_season_iframe']] . '';
  321.                                                                 $tpl3->set('{data-season}', $xfieldsdata[$moonserials_options['field_season_iframe']]);
  322.                                                                 $tpl3->set('{data-series}', $tabsvalue['series']);
  323.                                                                 $tpl3->set('{ms-content}', $ifrm);
  324.                                                                 $tpl3->compile('tabs-content');
  325.                                                         }
  326.                                                 }
  327.                                                 elseif ( !$xfieldsdata[$moonserials_options['field_season_iframe']] AND !$xfieldsdata[$moonserials_options['field_series_iframe']] )
  328.                                                 {
  329.                                                         if ( !$tplstudios )
  330.                                                                 $tplstudios = $tabsvalue['translator'];
  331.                                                         $tpl2->set('{ms-title}', $tabsvalue['translator']);
  332.                                                         $tpl2->compile('tabs-title');
  333.                                                         $tpl3->set('{ms-content}', $tabsvalue['iframe_url']);
  334.                                                         $tpl3->compile('tabs-content');
  335.                                                 }
  336.                                         }
  337.                                         if ( !$tplstudios )
  338.                                                 $tplstudios = $tabs[0]['translator'];
  339.                                         $tpl1->set('{season}', $tabs[0]['season']);
  340.                                         $tpl1->set('{studios}', $tplstudios);
  341.                                         if ( $moonserials_options['add_series_one_tpl'] )
  342.                                                 $tpl1->set('{series}', $tabs[0]['series'] + 1);
  343.                                         else
  344.                                                 $tpl1->set('{series}', $tabs[0]['series']);
  345.                                 }
  346.                                 $season = $tabs[0]['season'];
  347.                                 $series = $tabs[0]['series'];
  348.                                 $studios = $tabs[0]['translator'];
  349.                                 if ( $moonserials_options['allow_module_new'] )
  350.                                 {
  351.                                         if ( $season < $xfieldsdata[$moonserials_options['field_season_iframe']] OR ( $xfieldsdata[$moonserials_options['field_season_iframe']] == $season AND $series < $xfieldsdata[$moonserials_options['field_series_iframe']] ))
  352.                                         {
  353.                                                 $tpl1->set('[soon]', "");
  354.                                                 $tpl1->set('[/soon]', "");
  355.                                                 $tpl1->set_block("'\\[not-soon\\](.*?)\\[/not-soon\\]'si", "");
  356.                                         }
  357.                                         else
  358.                                         {
  359.                                                 $tpl1->set_block("'\\[soon\\](.*?)\\[/soon\\]'si", "");
  360.                                                 $tpl1->set_block("'\\[not-soon\\](.*?)\\[/not-soon\\]'si", "\\1");
  361.                                         }
  362.                                 }
  363.                                 if ( $xfieldsdata[$moonserials_options['field_season_iframe']] )
  364.                                 {
  365.                                         $season = $xfieldsdata[$moonserials_options['field_season_iframe']];
  366.                                         if ( $moonserials_options['allow_module_new'] )
  367.                                                 $tpl1->set('{season}', $xfieldsdata[$moonserials_options['field_season_iframe']]);
  368.                                 }
  369.                                 if ( $xfieldsdata[$moonserials_options['field_series_iframe']] )
  370.                                 {
  371.                                         $series = $xfieldsdata[$moonserials_options['field_series_iframe']];
  372.                                         if ( $moonserials_options['allow_module_new'] )
  373.                                                 $tpl1->set('{series}', $xfieldsdata[$moonserials_options['field_series_iframe']]);
  374.                                 }
  375.                                 if ( $season AND !$seasonTemp AND $series AND !$seriesTemp AND $xfieldsdata[$moonserials_options['field_status_name']] !== $moonserials_options['field_status'] )
  376.                                         $notdateup = true;
  377.                                 else
  378.                                         $notdateup = false;
  379.                                 if ( ( ( $seasonTemp AND $seriesTemp ) AND ( ( int ) $season > ( int ) $seasonTemp OR ( int ) $series > ( int ) $seriesTemp ) AND $xfieldsdata[$moonserials_options['field_status_name']] !== $moonserials_options['field_status'] ) OR ( $season AND !$seasonTemp AND $series AND !$seriesTemp AND $xfieldsdata[$moonserials_options['field_status_name']] !== $moonserials_options['field_status'] ))
  380.                                 {
  381.                                         $season = $season . " сезон";
  382.                                         $series = $series . " серия";
  383.                                         if ( $moonserials_options['field_series_form'] == 'type1' OR $series == '1 серия' AND $moonserials_options['field_series_form'] )
  384.                                         {
  385.                                                 $series1 = ( $tabs[0]['series'] + 1 ) . " серия";
  386.                                                 $series0 = $tabs[0]['series'] . " серия";
  387.                                         }
  388.                                         elseif ( $moonserials_options['field_series_form'] == 'type2' )
  389.                                         {
  390.                                                 $series1 = "1-" . ( $tabs[0]['series'] + 1 ) . " серия";
  391.                                                 $series0 = "1-" . $tabs[0]['series'] . " серия";
  392.                                         }
  393.                                         elseif ( $moonserials_options['field_series_form'] == 'type3' )
  394.                                         {
  395.                                                 $series1 = $tabs[0]['series'] + 1;
  396.                                                 for ( $i = 1; $i <= $series1; $i++ )
  397.                                                 {
  398.                                                         $seriesSrt .= $i . ",";
  399.                                                 }
  400.                                                 $seriesSrt = substr($seriesSrt, 0, - 1);
  401.                                                 $series1 = $seriesSrt . " серия";
  402.                                                 unset( $seriesSrt );
  403.                                                 for ( $i = 1; $i <= $tabs[0]['series']; $i++ )
  404.                                                 {
  405.                                                         $seriesSrt .= $i . ",";
  406.                                                 }
  407.                                                 $seriesSrt = substr($seriesSrt, 0, - 1);
  408.                                                 $series0 = $seriesSrt . " серия";
  409.                                                 unset( $seriesSrt );
  410.                                         }
  411.                                         elseif ( $moonserials_options['field_series_form'] == 'type4' )
  412.                                         {
  413.                                                 $series1 = $tabs[0]['series'] + 1 . "," . ( $tabs[0]['series'] + 2 ) . "," . ( $tabs[0]['series'] + 3 ) . " серия";
  414.                                                 $series0 = $tabs[0]['series'] . "," . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . " серия";
  415.                                         }
  416.                                         elseif ( $moonserials_options['field_series_form'] == 'type5' )
  417.                                         {
  418.                                                 if ( $tabs[0]['series'] <= 5 )
  419.                                                 {
  420.                                                         $series1 = $tabs[0]['series'] + 1;
  421.                                                         for ( $i = 1; $i <= $series1; $i++ )
  422.                                                         {
  423.                                                                 $seriesSrt .= $i . ",";
  424.                                                         }
  425.                                                         $seriesSrt = substr($seriesSrt, 0, - 1);
  426.                                                         $series1 = $seriesSrt . " серия";
  427.                                                         unset( $seriesSrt );
  428.                                                         for ( $i = 1; $i <= $tabs[0]['series']; $i++ )
  429.                                                         {
  430.                                                                 $seriesSrt .= $i . ",";
  431.                                                         }
  432.                                                         $seriesSrt = substr($seriesSrt, 0, - 1);
  433.                                                         $series0 = $seriesSrt . " серия";
  434.                                                         unset( $seriesSrt );
  435.                                                 }
  436.                                                 else
  437.                                                 {
  438.                                                         $series1 = "1-" . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . "," . ( $tabs[0]['series'] + 3 ) . " серия";
  439.                                                         $series0 = "1-" . ( $tabs[0]['series'] ) . "," . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . " серия";
  440.                                                 }
  441.                                         }
  442.                                         if ( $moonserials_options['field_season_form'] == 'type1' OR $season == '1 сезон' )
  443.                                                 $season0 = $tabs[0]['season'] . " сезон";
  444.                                         elseif ( $moonserials_options['field_season_form'] == 'type2' )
  445.                                                 $season0 = "1-" . $tabs[0]['season'] . " сезон";
  446.                                         elseif ( $moonserials_options['field_season_form'] == 'type3' )
  447.                                         {
  448.                                                 for ( $i = 1; $i <= $tabs[0]['season']; $i++ )
  449.                                                 {
  450.                                                         $seasonSrt .= $i . ",";
  451.                                                 }
  452.                                                 $seasonSrt = substr($seasonSrt, 0, - 1);
  453.                                                 $season0 = $seasonSrt . " сезон";
  454.                                                 unset( $seasonSrt );
  455.                                         }
  456.                                         $xfields_n[$moonserials_options['field_season']] = $season;
  457.                                         if ( $moonserials_options['add_series_one'] > 0 )
  458.                                                 $xfields_n[$moonserials_options['field_series']] = ( $tabs[0]['series'] + 1 ) . ' серия';
  459.                                         else
  460.                                                 $xfields_n[$moonserials_options['field_series']] = $series;
  461.                                         if ( $studios AND $studios !== "Неизвестно" AND $moonserials_options['field_studios'] )
  462.                                                 $xfields_n[$moonserials_options['field_studios']] = $studios;
  463.                                         if ( !$xfieldsdata[$moonserials_options['field_title_ru']] AND $moonserials_options['field_title_ru'] AND $title_ru )
  464.                                                 $xfields_n[$moonserials_options['field_title_ru']] = $title_ru;
  465.                                         if ( $studios_sp AND $moonserials_options['field_studios_sp'] )
  466.                                                 $xfields_n[$moonserials_options['field_studios_sp']] = $studios_sp;
  467.                                         if ( $moonserials_options['season_mod'] )
  468.                                                 $xfields_n[$moonserials_options['season_mod']] = $season0;
  469.                                         if ( $moonserials_options['series_mod'] )
  470.                                         {
  471.                                                 if ( $moonserials_options['add_series_one'] )
  472.                                                         $xfields_n[$moonserials_options['series_mod']] = $series1;
  473.                                                 else
  474.                                                         $xfields_n[$moonserials_options['series_mod']] = $series0;
  475.                                         }
  476.                                         if ( !$xfieldsdata[$moonserials_options['field_series-max']] AND $seriesMax AND $moonserials_options['allow_module_new_series_max'] > 0 )
  477.                                                 $xfields_n[$moonserials_options['field_series-max']] = $seriesMax;
  478.                                         if ( $moonserials_options['allow_module_new_series_max'] > 0 AND $seriesMax == $tabs[0]['series'] AND $xfieldsdata[$moonserials_options['field_status_name']] !== $moonserials_options['field_status'] )
  479.                                                 $xfields_n[$moonserials_options['field_status_name']] = $moonserials_options['field_status'];
  480.                                         if ( $moonserials_options['allow_news_update'] AND !$notdateup )
  481.                                                 $myNewDate = ( $moonserials_options['allow_news_update'] != 0 ) ? ", `date` = '" . date('Y-m-d H:i:s') . "'" : false;
  482.                                         if ( $moonserials_options['allow_news_title_update'] )
  483.                                         {
  484.                                                 $ms_title_date = !empty( $moonserials_options['ms_title_date'] ) ? langdate($moonserials_options['ms_title_date']) : false;
  485.                                                 $ms_title_preffix = !empty( $moonserials_options['ms_title_preffix'] ) ? $db->safesql(trim(strip_tags(stripslashes($moonserials_options['ms_title_preffix'])))) . " " : false;
  486.                                                 $ms_title_year = !empty( $moonserials_options['ms_title_year'] ) ? trim(strip_tags(stripslashes($xfieldsdata[$moonserials_options['ms_title_year']]))) . " " : false;
  487.                                                 $ms_title_t1 = !empty( $moonserials_options['ms_title_t1'] ) ? $db->safesql(trim(strip_tags(stripslashes($moonserials_options['ms_title_t1'])))) . " " : false;
  488.                                                 $ms_title_t2 = !empty( $moonserials_options['ms_title_t2'] ) ? $db->safesql(trim(strip_tags(stripslashes($moonserials_options['ms_title_t2'])))) . " " : false;
  489.                                                 $ms_title_field = !empty( $moonserials_options['ms_title_field'] ) ? $db->safesql(trim(strip_tags(stripslashes($xfieldsdata[$moonserials_options['ms_title_field']])))) . " " : false;
  490.                                                 if ( $moonserials_options['ms_title_season'] )
  491.                                                 {
  492.                                                         if ( $moonserials_options['ms_title_season_one'] AND $season == "1 сезон" )
  493.                                                                 $ms_title_season = false;
  494.                                                         else
  495.                                                         {
  496.                                                                 if ( $moonserials_options['title_season_form'] == 'type1' OR $season == '1 сезон' )
  497.                                                                         $ms_title_season = $tabs[0]['season'] . " сезон";
  498.                                                                 elseif ( $moonserials_options['title_season_form'] == 'type2' )
  499.                                                                         $ms_title_season = "1-" . $tabs[0]['season'] . " сезон";
  500.                                                                 elseif ( $moonserials_options['title_season_form'] == 'type3' )
  501.                                                                 {
  502.                                                                         for ( $i = 1; $i <= $tabs[0]['season']; $i++ )
  503.                                                                         {
  504.                                                                                 $seasonSrt .= $i . ",";
  505.                                                                         }
  506.                                                                         $seasonSrt = substr($seasonSrt, 0, - 1);
  507.                                                                         $ms_title_season = $seasonSrt . " сезон";
  508.                                                                         unset( $seasonSrt );
  509.                                                                 }
  510.                                                         }
  511.                                                 }
  512.                                                 if ( $moonserials_options['ms_title_series'] )
  513.                                                 {
  514.                                                         if ( $moonserials_options['title_series_form'] == 'type1' OR $series == '1 серия' AND $moonserials_options['title_series_form'] )
  515.                                                         {
  516.                                                                 $ms_title_series1 = ( $tabs[0]['series'] + 1 ) . " серия";
  517.                                                                 $ms_title_series0 = $tabs[0]['series'] . " серия";
  518.                                                         }
  519.                                                         elseif ( $moonserials_options['title_series_form'] == 'type2' )
  520.                                                         {
  521.                                                                 $ms_title_series1 = "1-" . ( $tabs[0]['series'] + 1 ) . " серия";
  522.                                                                 $ms_title_series0 = "1-" . $tabs[0]['series'] . " серия";
  523.                                                         }
  524.                                                         elseif ( $moonserials_options['title_series_form'] == 'type3' )
  525.                                                         {
  526.                                                                 $ms_title_series1 = $tabs[0]['series'] + 1;
  527.                                                                 for ( $i = 1; $i <= $ms_title_series1; $i++ )
  528.                                                                 {
  529.                                                                         $seriesSrt .= $i . ",";
  530.                                                                 }
  531.                                                                 $seriesSrt = substr($seriesSrt, 0, - 1);
  532.                                                                 $ms_title_series1 = $seriesSrt . " серия";
  533.                                                                 unset( $seriesSrt );
  534.                                                                 for ( $i = 1; $i <= $tabs[0]['series']; $i++ )
  535.                                                                 {
  536.                                                                         $seriesSrt .= $i . ",";
  537.                                                                 }
  538.                                                                 $seriesSrt = substr($seriesSrt, 0, - 1);
  539.                                                                 $ms_title_series0 = $seriesSrt . " серия";
  540.                                                                 unset( $seriesSrt );
  541.                                                         }
  542.                                                         elseif ( $moonserials_options['title_series_form'] == 'type4' )
  543.                                                         {
  544.                                                                 $ms_title_series1 = $tabs[0]['series'] + 1 . "," . ( $tabs[0]['series'] + 2 ) . "," . ( $tabs[0]['series'] + 3 ) . " серия";
  545.                                                                 $ms_title_series0 = $tabs[0]['series'] . "," . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . " серия";
  546.                                                         }
  547.                                                         elseif ( $moonserials_options['title_series_form'] == 'type5' )
  548.                                                         {
  549.                                                                 if ( $tabs[0]['series'] <= 5 )
  550.                                                                 {
  551.                                                                         $ms_title_series1 = $tabs[0]['series'] + 1;
  552.                                                                         for ( $i = 1; $i <= $ms_title_series1; $i++ )
  553.                                                                         {
  554.                                                                                 $seriesSrt .= $i . ",";
  555.                                                                         }
  556.                                                                         $seriesSrt = substr($seriesSrt, 0, - 1);
  557.                                                                         $ms_title_series1 = $seriesSrt . " серия";
  558.                                                                         unset( $seriesSrt );
  559.                                                                         for ( $i = 1; $i <= $tabs[0]['series']; $i++ )
  560.                                                                         {
  561.                                                                                 $seriesSrt .= $i . ",";
  562.                                                                         }
  563.                                                                         $seriesSrt = substr($seriesSrt, 0, - 1);
  564.                                                                         $ms_title_series0 = $seriesSrt . " серия";
  565.                                                                         unset( $seriesSrt );
  566.                                                                 }
  567.                                                                 else
  568.                                                                 {
  569.                                                                         $ms_title_series1 = "1-" . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . "," . ( $tabs[0]['series'] + 3 ) . " серия";
  570.                                                                         $ms_title_series0 = "1-" . ( $tabs[0]['series'] ) . "," . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . " серия";
  571.                                                                 }
  572.                                                         }
  573.                                                         if ( $moonserials_options['ms_title_series_add'] > 0 )
  574.                                                                 $ms_title_series = $ms_title_series1;
  575.                                                         else
  576.                                                                 $ms_title_series = $ms_title_series0;
  577.                                                 }
  578.                                                 if ( $ms_title_series )
  579.                                                         $ms_title_season = $ms_title_season . " ";
  580.                                                 $myModule_title = $ms_title_season . $ms_title_series . " ";
  581.                                                 $ms_title_up = $ms_title_preffix . $title_ru . " " . $ms_title_year . $ms_title_t1 . $myModule_title . $ms_title_t2 . $ms_title_field . $ms_title_date;
  582.                                                 if ( substr($ms_title_up, - 1) == " " )
  583.                                                         $ms_title_up = substr($ms_title_up, 0, - 1);
  584.                                                 $ms_title_up = ", `metatitle`='" . $ms_title_up . "'";
  585.                                         }
  586.                                         if ( $moonserials_options['allow_news_cpu_update'] )
  587.                                         {
  588.                                                 $ms_cpu_date = !empty( $moonserials_options['ms_cpu_date'] ) ? totranslit(langdate($moonserials_options['ms_cpu_date'])) : false;
  589.                                                 $ms_cpu_preffix = !empty( $moonserials_options['ms_cpu_preffix'] ) ? totranslit($moonserials_options['ms_cpu_preffix']) . '-' : false;
  590.                                                 $ms_cpu_year = !empty( $moonserials_options['ms_cpu_year'] ) ? totranslit($xfieldsdata[$moonserials_options['ms_cpu_year']]) . '-' : false;
  591.                                                 $ms_cpu_t1 = !empty( $moonserials_options['ms_cpu_t1'] ) ? totranslit($moonserials_options['ms_cpu_t1']) . '-' : false;
  592.                                                 $ms_cpu_t2 = !empty( $moonserials_options['ms_cpu_t2'] ) ? totranslit($moonserials_options['ms_cpu_t2']) . '-' : false;
  593.                                                 $ms_cpu_field = !empty( $moonserials_options['ms_cpu_field'] ) ? totranslit($xfieldsdata[$moonserials_options['ms_cpu_field']]) . "_" : false;
  594.                                                 $title_ru_cpu = totranslit($title_ru) . '-';
  595.                                                 if ( $moonserials_options['ms_cpu_season'] )
  596.                                                 {
  597.                                                         if ( $moonserials_options['ms_cpu_season_one'] AND $season == "1 сезон" )
  598.                                                                 $ms_cpu_season = false;
  599.                                                         else
  600.                                                         {
  601.                                                                 if ( $moonserials_options['cpu_season_form'] == 'type1' OR $season == '1 сезон' )
  602.                                                                         $ms_cpu_season = $tabs[0]['season'] . " сезон";
  603.                                                                 elseif ( $moonserials_options['cpu_season_form'] == 'type2' )
  604.                                                                         $ms_cpu_season = "1-" . $tabs[0]['season'] . " сезон";
  605.                                                                 elseif ( $moonserials_options['cpu_season_form'] == 'type3' )
  606.                                                                 {
  607.                                                                         for ( $i = 1; $i <= $tabs[0]['season']; $i++ )
  608.                                                                         {
  609.                                                                                 $seasonSrt .= $i . ",";
  610.                                                                         }
  611.                                                                         $seasonSrt = substr($seasonSrt, 0, - 1);
  612.                                                                         $ms_cpu_season = $seasonSrt . " сезон";
  613.                                                                         unset( $seasonSrt );
  614.                                                                 }
  615.                                                         }
  616.                                                 }
  617.                                                 if ( $moonserials_options['ms_cpu_series'] )
  618.                                                 {
  619.                                                         if ( $moonserials_options['cpu_series_form'] == 'type1' OR $series == '1 серия' AND $moonserials_options['cpu_series_form'] )
  620.                                                         {
  621.                                                                 $ms_cpu_series1 = ( $tabs[0]['series'] + 1 ) . " серия";
  622.                                                                 $ms_cpu_series0 = $tabs[0]['series'] . " серия";
  623.                                                         }
  624.                                                         elseif ( $moonserials_options['cpu_series_form'] == 'type2' )
  625.                                                         {
  626.                                                                 $ms_cpu_series1 = "1-" . ( $tabs[0]['series'] + 1 ) . " серия";
  627.                                                                 $ms_cpu_series0 = "1-" . $tabs[0]['series'] . " серия";
  628.                                                         }
  629.                                                         elseif ( $moonserials_options['cpu_series_form'] == 'type3' )
  630.                                                         {
  631.                                                                 $ms_cpu_series1 = $tabs[0]['series'] + 1;
  632.                                                                 for ( $i = 1; $i <= $ms_cpu_series1; $i++ )
  633.                                                                 {
  634.                                                                         $seriesSrt .= $i . ",";
  635.                                                                 }
  636.                                                                 $seriesSrt = substr($seriesSrt, 0, - 1);
  637.                                                                 $ms_cpu_series1 = $seriesSrt . " серия";
  638.                                                                 unset( $seriesSrt );
  639.                                                                 for ( $i = 1; $i <= $tabs[0]['series']; $i++ )
  640.                                                                 {
  641.                                                                         $seriesSrt .= $i . ",";
  642.                                                                 }
  643.                                                                 $seriesSrt = substr($seriesSrt, 0, - 1);
  644.                                                                 $ms_cpu_series0 = $seriesSrt . " серия";
  645.                                                                 unset( $seriesSrt );
  646.                                                         }
  647.                                                         elseif ( $moonserials_options['cpu_series_form'] == 'type4' )
  648.                                                         {
  649.                                                                 $ms_cpu_series1 = $tabs[0]['series'] + 1 . "," . ( $tabs[0]['series'] + 2 ) . "," . ( $tabs[0]['series'] + 3 ) . " серия";
  650.                                                                 $ms_cpu_series0 = $tabs[0]['series'] . "," . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . " серия";
  651.                                                         }
  652.                                                         elseif ( $moonserials_options['cpu_series_form'] == 'type5' )
  653.                                                         {
  654.                                                                 if ( $tabs[0]['series'] <= 5 )
  655.                                                                 {
  656.                                                                         $ms_cpu_series1 = $tabs[0]['series'] + 1;
  657.                                                                         for ( $i = 1; $i <= $ms_cpu_series1; $i++ )
  658.                                                                         {
  659.                                                                                 $seriesSrt .= $i . ",";
  660.                                                                         }
  661.                                                                         $seriesSrt = substr($seriesSrt, 0, - 1);
  662.                                                                         $ms_cpu_series1 = $seriesSrt . " серия";
  663.                                                                         unset( $seriesSrt );
  664.                                                                         for ( $i = 1; $i <= $tabs[0]['series']; $i++ )
  665.                                                                         {
  666.                                                                                 $seriesSrt .= $i . ",";
  667.                                                                         }
  668.                                                                         $seriesSrt = substr($seriesSrt, 0, - 1);
  669.                                                                         $ms_cpu_series0 = $seriesSrt . " серия";
  670.                                                                         unset( $seriesSrt );
  671.                                                                 }
  672.                                                                 else
  673.                                                                 {
  674.                                                                         $ms_cpu_series1 = "1-" . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . "," . ( $tabs[0]['series'] + 3 ) . " серия";
  675.                                                                         $ms_cpu_series0 = "1-" . ( $tabs[0]['series'] ) . "," . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . " серия";
  676.                                                                 }
  677.                                                         }
  678.                                                         if ( $moonserials_options['ms_cpu_series_add'] > 0 )
  679.                                                                 $ms_cpu_series = $ms_cpu_series1;
  680.                                                         else
  681.                                                                 $ms_cpu_series = $ms_cpu_series0;
  682.                                                 }
  683.                                                 if ( $ms_cpu_series )
  684.                                                         $ms_cpu_season = $ms_cpu_season . " ";
  685.                                                 $myModule_cpu = $ms_cpu_season . $ms_cpu_series;
  686.                                                 $myModule_cpu = str_replace(",", "-", $myModule_cpu);
  687.                                                 $myModule_cpu = totranslit($myModule_cpu);
  688.                                                 $myModule_cpu = $myModule_cpu . '-';
  689.                                                 $ms_cpu_up = $ms_cpu_preffix . $title_ru_cpu . $ms_cpu_year . $ms_cpu_t1 . $myModule_cpu . $ms_cpu_t2 . $ms_cpu_field . $ms_cpu_date;
  690.                                                 if ( substr($ms_cpu_up, - 1) == "-" )
  691.                                                         $ms_cpu_up = substr($ms_cpu_up, 0, - 1);
  692.                                                 $ms_cpu_up = ", `alt_name`='" . $ms_cpu_up . "'";
  693.                                         }
  694.                                         if ( $moonserials_options['allow_news_title2_update'] )
  695.                                         {
  696.                                                 $ms_title2_date = !empty( $moonserials_options['ms_title2_date'] ) ? langdate($moonserials_options['ms_title2_date']) . " " : false;
  697.                                                 $ms_title2_preffix = !empty( $moonserials_options['ms_title2_preffix'] ) ? $db->safesql(trim(strip_tags(stripslashes($moonserials_options['ms_title2_preffix'])))) . " " : false;
  698.                                                 $ms_title2_year = !empty( $moonserials_options['ms_title2_year'] ) ? trim(strip_tags(stripslashes($xfieldsdata[$moonserials_options['ms_title2_year']]))) . " " : false;
  699.                                                 $ms_title2_t1 = !empty( $moonserials_options['ms_title2_t1'] ) ? $db->safesql(trim(strip_tags(stripslashes($moonserials_options['ms_title2_t1'])))) . " " : false;
  700.                                                 $ms_title2_t2 = !empty( $moonserials_options['ms_title2_t2'] ) ? $db->safesql(trim(strip_tags(stripslashes($moonserials_options['ms_title2_t2'])))) . " " : false;
  701.                                                 $ms_title2_field = !empty( $moonserials_options['ms_title2_field'] ) ? $db->safesql(trim(strip_tags(stripslashes($xfieldsdata[$moonserials_options['ms_title2_field']])))) . " " : false;
  702.                                                 if ( $moonserials_options['ms_title2_season'] )
  703.                                                 {
  704.                                                         if ( $moonserials_options['ms_title2_season_one'] AND $season == "1 сезон" )
  705.                                                                 $ms_title2_season = false;
  706.                                                         else
  707.                                                         {
  708.                                                                 if ( $moonserials_options['title2_season_form'] == 'type1' OR $season == '1 сезон' )
  709.                                                                         $ms_title2_season = $tabs[0]['season'] . " сезон";
  710.                                                                 elseif ( $moonserials_options['title2_season_form'] == 'type2' )
  711.                                                                         $ms_title2_season = "1-" . $tabs[0]['season'] . " сезон";
  712.                                                                 elseif ( $moonserials_options['title2_season_form'] == 'type3' )
  713.                                                                 {
  714.                                                                         for ( $i = 1; $i <= $tabs[0]['season']; $i++ )
  715.                                                                         {
  716.                                                                                 $seasonSrt .= $i . ",";
  717.                                                                         }
  718.                                                                         $seasonSrt = substr($seasonSrt, 0, - 1);
  719.                                                                         $ms_title2_season = $seasonSrt . " сезон";
  720.                                                                         unset( $seasonSrt );
  721.                                                                 }
  722.                                                         }
  723.                                                 }
  724.                                                 if ( $moonserials_options['ms_title2_series'] )
  725.                                                 {
  726.                                                         if ( $moonserials_options['title2_series_form'] == 'type1' OR $series == '1 серия' AND $moonserials_options['title2_series_form'] )
  727.                                                         {
  728.                                                                 $ms_title2_series1 = ( $tabs[0]['series'] + 1 ) . " серия";
  729.                                                                 $ms_title2_series0 = $tabs[0]['series'] . " серия";
  730.                                                         }
  731.                                                         elseif ( $moonserials_options['title2_series_form'] == 'type2' )
  732.                                                         {
  733.                                                                 $ms_title2_series1 = "1-" . ( $tabs[0]['series'] + 1 ) . " серия";
  734.                                                                 $ms_title2_series0 = "1-" . $tabs[0]['series'] . " серия";
  735.                                                         }
  736.                                                         elseif ( $moonserials_options['title2_series_form'] == 'type3' )
  737.                                                         {
  738.                                                                 $ms_title2_series1 = $tabs[0]['series'] + 1;
  739.                                                                 for ( $i = 1; $i <= $ms_title2_series1; $i++ )
  740.                                                                 {
  741.                                                                         $seriesSrt .= $i . ",";
  742.                                                                 }
  743.                                                                 $seriesSrt = substr($seriesSrt, 0, - 1);
  744.                                                                 $ms_title2_series1 = $seriesSrt . " серия";
  745.                                                                 unset( $seriesSrt );
  746.                                                                 for ( $i = 1; $i <= $tabs[0]['series']; $i++ )
  747.                                                                 {
  748.                                                                         $seriesSrt .= $i . ",";
  749.                                                                 }
  750.                                                                 $seriesSrt = substr($seriesSrt, 0, - 1);
  751.                                                                 $ms_title2_series0 = $seriesSrt . " серия";
  752.                                                                 unset( $seriesSrt );
  753.                                                         }
  754.                                                         elseif ( $moonserials_options['title2_series_form'] == 'type4' )
  755.                                                         {
  756.                                                                 $ms_title2_series1 = $tabs[0]['series'] + 1 . "," . ( $tabs[0]['series'] + 2 ) . "," . ( $tabs[0]['series'] + 3 ) . " серия";
  757.                                                                 $ms_title2_series0 = $tabs[0]['series'] . "," . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . " серия";
  758.                                                         }
  759.                                                         elseif ( $moonserials_options['title2_series_form'] == 'type5' )
  760.                                                         {
  761.                                                                 if ( $tabs[0]['series'] <= 5 )
  762.                                                                 {
  763.                                                                         $ms_title2_series1 = $tabs[0]['series'] + 1;
  764.                                                                         for ( $i = 1; $i <= $ms_title2_series1; $i++ )
  765.                                                                         {
  766.                                                                                 $seriesSrt .= $i . ",";
  767.                                                                         }
  768.                                                                         $seriesSrt = substr($seriesSrt, 0, - 1);
  769.                                                                         $ms_title2_series1 = $seriesSrt . " серия";
  770.                                                                         unset( $seriesSrt );
  771.                                                                         for ( $i = 1; $i <= $tabs[0]['series']; $i++ )
  772.                                                                         {
  773.                                                                                 $seriesSrt .= $i . ",";
  774.                                                                         }
  775.                                                                         $seriesSrt = substr($seriesSrt, 0, - 1);
  776.                                                                         $ms_title2_series0 = $seriesSrt . " серия";
  777.                                                                         unset( $seriesSrt );
  778.                                                                 }
  779.                                                                 else
  780.                                                                 {
  781.                                                                         $ms_title2_series1 = "1-" . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . "," . ( $tabs[0]['series'] + 3 ) . " серия";
  782.                                                                         $ms_title2_series0 = "1-" . ( $tabs[0]['series'] ) . "," . ( $tabs[0]['series'] + 1 ) . "," . ( $tabs[0]['series'] + 2 ) . " серия";
  783.                                                                 }
  784.                                                         }
  785.                                                         if ( $moonserials_options['ms_title2_series_add'] > 0 )
  786.                                                                 $ms_title2_series = $ms_title2_series1;
  787.                                                         else
  788.                                                                 $ms_title2_series = $ms_title2_series0;
  789.                                                 }
  790.                                                 if ( $ms_title2_series )
  791.                                                         $ms_title2_season = $ms_title2_season . " ";
  792.                                                 $myModule_title2 = $ms_title2_season . $ms_title2_series . " ";
  793.                                                 $ms_title2_up = $ms_title2_preffix . $title_ru . " " . $ms_title2_year . $ms_title2_t1 . $myModule_title2 . $ms_title2_t2 . $ms_title2_field . $ms_title2_date;
  794.                                                 if ( substr($ms_title2_up, - 1) == " " )
  795.                                                         $ms_title2_up = substr($ms_title2_up, 0, - 1);
  796.                                                 $ms_title2_up = ", `title`='" . $ms_title2_up . "'";
  797.                                         }
  798.                                         foreach ( $xfields_n as $key => & $value )
  799.                                                 $arr_field[] = $key . "|" . str_replace('|', '&#124;', $value);
  800.                                         $xfields_n = implode("||", $arr_field);
  801.                                         unset( $arr_field );
  802.                                         $xfields_n = $db->safesql($xfields_n);
  803.                                         $db->query("UPDATE " . PREFIX . "_post SET `xfields` = '$xfields_n' {$myNewDate} {$ms_title_up} {$ms_title2_up} {$ms_cpu_up} WHERE id = {$post_id}");
  804.                                         if ( $moonserials_options['sendpm'] AND !$xfieldsdata[$moonserials_options['field_season_iframe']] )
  805.                                         {
  806.                                                 $user_id = '1';
  807.                                                 $user_id = ( int ) $user_id;
  808.                                                 $now = time();
  809.                                                 $subject = 'Вышла ' . $series . ' сериала ' . $title_ru . '';
  810.                                                 $subject = $db->safesql($subject);
  811.                                                 $from = 'MoonSerials';
  812.                                                 $from = $db->safesql($from);
  813.                                                 $text = '<h3>Вышла ' . $series . ' сериала ' . $title_ru . '</h3>';
  814.                                                 $text .= '<p><b>Теперь можно:</b></p>';
  815.                                                 $text .= '<ul><li><a href="' . $config['http_home_url'] . 'index.php?newsid=' . $post_id . '" target="_blank">Открыть новость на сайте</a></li>';
  816.                                                 $text .= '<li><a href="' . $config['admin_path'] . '?mod=editnews&action=editnews&id=' . $post_id . '" target="_blank">Редактировать в админпанели</a></li>';
  817.                                                 $text .= '<li><a href="' . $config['admin_path'] . '?mod=addnews&action=addnews" target="_blank">Добавить новую новость в админпанели</a></li></ul>';
  818.                                                 $text = $db->safesql($text);
  819.                                                 $db->query("INSERT into " . PREFIX . "_pm (subj, text, user, user_from, date, pm_read, folder) VALUES ('$subject', '$text', '$user_id', '$from', '$now', '0', 'inbox')");
  820.                                                 $db->query("UPDATE " . USERPREFIX . "_users set pm_unread = pm_unread + 1, pm_all = pm_all+1  where user_id = '$user_id'");
  821.                                         }
  822.                                 }
  823.                         }
  824.                         if ( $moonserials_options['allow_module_new'] )
  825.                         {
  826.                                 $tpl1->set("{tabs-title}", $tpl2->result['tabs-title']);
  827.                                 unset( $tpl2 );
  828.                                 $tpl1->set("{tabs-content}", $tpl3->result['tabs-content']);
  829.                                 unset( $tpl3 );
  830.                                 $tpl1->compile('myModule');
  831.                                 $myModule = $tpl1->result['myModule'];
  832.                         }
  833.                         elseif ( $xfieldsdata[$moonserials_options['field_status_name']] !== $moonserials_options['field_status'] )
  834.                         {
  835.                                 if ( $moonserials_options['allow_module_new_season'] AND $moonserials_options['allow_module_new_series'] )
  836.                                         $myModule = $tabs[0]['season'] . " сезон " . $tabs[0]['series'] . " серия";
  837.                                 elseif ( $moonserials_options['allow_module_new_season'] AND !$moonserials_options['allow_module_new_series'] )
  838.                                         $myModule = $tabs[0]['season'] . " сезон";
  839.                                 elseif ( !$moonserials_options['allow_module_new_season'] AND $moonserials_options['allow_module_new_series'] )
  840.                                         $myModule = $tabs[0]['series'] . " серия";
  841.                         }
  842.                         else
  843.                                 $myModule = $moonserials_options['if_series_ower'];
  844.                         create_cache($myConfig['cachePrefix'], $myModule, $cacheName . $config['skin'], $myConfig['cacheSuffix']);
  845.                         if ( $is_change )
  846.                                 $config['allow_cache'] = false;
  847.                         if ( $moonserials_options['allow_module_new'] )
  848.                                 $tpl1->clear();
  849.                 }
  850.                 echo $myModule;
  851.         }
  852. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement