Guest User

Untitled

a guest
Mar 1st, 2017
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 23.16 KB | None | 0 0
  1. <?php
  2. /*
  3. =====================================================
  4.  DataLife Engine - Edit News on the SITE
  5. -----------------------------------------------------
  6.  http://bslab.uz/ - [email protected]  - ICQ: 284296
  7. -----------------------------------------------------
  8.  Copyright (c) 2010 Best Site Laboratory
  9. =====================================================
  10.  Данный код защищен авторскими правами
  11. =====================================================
  12.  Файл: editnews.php
  13. -----------------------------------------------------
  14.  Назначение: Редактирование новости посетителем
  15. =====================================================
  16. */
  17.  
  18. if( ! defined( 'DATALIFEENGINE' ) ) {
  19.     die( "Hacking attempt!" );
  20. }
  21.  
  22. $allow_addnews = true;
  23.  
  24. include_once ENGINE_DIR . '/classes/parse.class.php';
  25. $parse = new ParseFilter( Array (), Array (), 1, 1 );
  26.  
  27. if( $config['max_moderation'] and ! $user_group[$member_id['user_group']]['moderation'] ) {
  28.  
  29.     $stats_approve = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_post WHERE approve != '1'" );
  30.     $stats_approve = $stats_approve['count'];
  31.  
  32.     if( $stats_approve >= $config['max_moderation'] ) $allow_addnews = false;
  33.  
  34. }
  35.  
  36. if( $member_id['restricted'] and $member_id['restricted_days'] and $member_id['restricted_date'] < $_TIME ) {
  37.  
  38.     $member_id['restricted'] = 0;
  39.     $db->query( "UPDATE LOW_PRIORITY " . USERPREFIX . "_users SET restricted='0', restricted_days='0', restricted_date='' WHERE user_id='{$member_id['user_id']}'" );
  40.  
  41. }
  42.  
  43. if( $member_id['restricted'] == 1 or $member_id['restricted'] == 3 ) {
  44.  
  45.     if( $member_id['restricted_days'] ) {
  46.  
  47.         $lang['news_info_4'] = str_replace( '{date}', langdate( "j M Y H:i", $member_id['restricted_date'] ), $lang['news_info_4'] );
  48.         $lang['add_err_9'] = $lang['news_info_4'];
  49.  
  50.     } else {
  51.  
  52.         $lang['add_err_9'] = $lang['news_info_5'];
  53.  
  54.     }
  55.  
  56.     $allow_addnews = false;
  57.  
  58. }
  59.  
  60. if( ! $allow_addnews ) {
  61.  
  62.     msgbox( $lang['all_info'], $lang['add_err_9'] . "<br /><br /><a href=\"javascript:history.go(-1)\">$lang[all_prev]</a>" );
  63.  
  64. } else {
  65.  
  66.     if( isset( $_REQUEST['mod'] ) and $_REQUEST['mod'] == "addnews" and $is_logged and $user_group[$member_id['user_group']]['allow_adds'] ) {
  67.  
  68.         $stop = "";
  69.  
  70.         if( $config['sec_addnews'] ) {
  71.  
  72.             $id_key = $_POST[$_SESSION['id_key']];
  73.  
  74.             if( $id_key == "" or $id_key != $dle_login_hash ) $stop .= "<li>ANTISPAM: User ID not valid</li>";
  75.  
  76.             if (clean_url($_SERVER['HTTP_REFERER']) != clean_url($_SERVER['HTTP_HOST'])) $stop .= "<li>ANTISPAM: User ID not valid</li>";
  77.  
  78.         }
  79.  
  80.  
  81.         $allow_comm = intval( $_POST['allow_comm'] );
  82.  
  83.         if( $user_group[$member_id['user_group']]['allow_main'] ) $allow_main = intval( $_POST['allow_main'] );
  84.         else $allow_main = 0;
  85.  
  86.         $approve = intval( $_POST['approve'] );
  87.         $allow_rating = intval( $_POST['allow_rating'] );
  88.  
  89.         if( $user_group[$member_id['user_group']]['allow_fixed'] ) $news_fixed = intval( $_POST['news_fixed'] );
  90.         else $news_fixed = 0;
  91.  
  92.         if( ! count( $_REQUEST['catlist'] ) ) {
  93.             $catlist = array ();
  94.             $catlist[] = '0';
  95.         } else
  96.             $catlist = $_REQUEST['catlist'];
  97.         $category_list = $db->safesql( implode( ',', $catlist ) );
  98.  
  99.         if( ! $config['allow_add_tags'] ) $_POST['tags'] = "";
  100.         elseif( preg_match( "/[\||\'|\<|\>|\"|\!|\?|\$|\@|\/|\\\|\&\~\*\+]/", $_POST['tags'] ) ) $_POST['tags'] = "";
  101.         else $_POST['tags'] = $db->safesql( htmlspecialchars( strip_tags( stripslashes( trim( $_POST['tags'] ) ) ), ENT_QUOTES ) );
  102.  
  103.         if( ! $user_group[$member_id['user_group']]['moderation'] ) {
  104.             $approve = 0;
  105.             $allow_comm = 1;
  106.             $allow_main = 1;
  107.             $allow_rating = 1;
  108.             $news_fixed = 0;
  109.         }
  110.  
  111.         if( $approve ) $msg = $lang['add_ok_1_1'];
  112.         else $msg = $lang['add_ok_2_1'];
  113.  
  114.         $allow_list = explode( ',', $user_group[$member_id['user_group']]['cat_add'] );
  115.  
  116.         if( $user_group[$member_id['user_group']]['moderation'] ) {
  117.             foreach ( $catlist as $selected ) {
  118.                 if( $allow_list[0] != "all" and ! in_array( $selected, $allow_list ) and $member_id['user_group'] != "1" ) {
  119.                     $approve = 0;
  120.                     $msg = $lang['add_ok_3_1'];
  121.                 }
  122.             }
  123.         }
  124.  
  125.  
  126.         if ( !$user_group[$member_id['user_group']]['allow_html'] ) {
  127.  
  128.             $config['allow_site_wysiwyg'] = 0;
  129.             $_POST['short_story'] = strip_tags ($_POST['short_story']);
  130.             $_POST['full_story'] = strip_tags ($_POST['short_story']);
  131.  
  132.         }
  133.  
  134.         if( $config['allow_site_wysiwyg'] ) {
  135.  
  136.             $parse->allow_code = false;
  137.             $full_story = $db->safesql( $parse->BB_Parse( $parse->process( $_POST['short_story'] ) ) );
  138.             $short_story = $db->safesql( $parse->BB_Parse( $parse->process( $_POST['short_story'] ) ) );
  139.             $allow_br = 0;
  140.  
  141.         } else {
  142.  
  143.             $full_story = $db->safesql( $parse->BB_Parse( $parse->process( $_POST['short_story'] ), false ) );
  144.             $short_story = $db->safesql( $parse->BB_Parse( $parse->process( $_POST['short_story'] ), false ) );
  145.             $allow_br = 1;
  146.  
  147.         }
  148.  
  149.  
  150.         if( $parse->not_allowed_text ) {
  151.             $stop .= "<li>" . $lang['news_err_39'] . "</li>";
  152.         }
  153.  
  154.         $parse->ParseFilter();
  155.         $title = $db->safesql( $parse->process( trim( strip_tags ($_POST['title']) ) ) );
  156.         $alt_name = trim( $parse->process( stripslashes( $_POST['alt_name'] ) ) );
  157.  
  158.         $add_module = "yes";
  159.         $xfieldsaction = "init";
  160.         $category = $catlist;
  161.         include (ENGINE_DIR . '/inc/xfields1.php');
  162.  
  163.         $filecontents = array ();
  164.  
  165.         if( $config['safe_xfield'] ) {
  166.             $parse->ParseFilter();
  167.             $parse->safe_mode = true;
  168.         } else {
  169.             $parse = new ParseFilter( Array (), Array (), 1, 1 );
  170.         }
  171.  
  172.         if( ! empty( $postedxfields ) ) {
  173.             foreach ( $postedxfields as $xfielddataname => $xfielddatavalue ) {
  174.                 if( $xfielddatavalue == "" ) {
  175.                     continue;
  176.                 }
  177.                 $parse->allow_code = true;
  178.                 $xfielddatavalue = $db->safesql( $parse->BB_Parse( $parse->process( $xfielddatavalue ), false ) );
  179.  
  180.                 $xfielddataname = $db->safesql( $xfielddataname );
  181.  
  182.                 $xfielddataname = str_replace( "|", "&#124;", $xfielddataname );
  183.                 $xfielddataname = str_replace( "\r\n", "__NEWL__", $xfielddataname );
  184.                 $xfielddatavalue = str_replace( "|", "&#124;", $xfielddatavalue );
  185.                 $xfielddatavalue = str_replace( "\r\n", "__NEWL__", $xfielddatavalue );
  186.  
  187.                 $filecontents[] = "$xfielddataname|$xfielddatavalue";
  188.             }
  189.  
  190.             $filecontents = implode( "||", $filecontents );
  191.         } else
  192.             $filecontents = '';
  193.  
  194.         if( $alt_name == "" or ! $alt_name ) $alt_name = totranslit( stripslashes( $title ), true, false );
  195.         else $alt_name = totranslit( $alt_name, true, false );
  196.  
  197.         if( $title == "" or ! $title ) $stop .= $lang['add_err_1'];
  198.         if( strlen( $title ) > 200 ) $stop .= $lang['add_err_2'];
  199.         if( trim( $short_story ) == "" or ! $short_story ) $stop .= $lang['add_err_5'];
  200.  
  201.         if( $user_group[$member_id['user_group']]['news_sec_code']) {
  202.  
  203.             if ($config['allow_recaptcha']) {
  204.  
  205.                 require_once ENGINE_DIR . '/classes/recaptcha.php';
  206.                 $sec_code = 1;
  207.                 $sec_code_session = false;
  208.  
  209.                 if ($_POST["recaptcha_response_field"] AND $_POST["recaptcha_response_field"]) {
  210.  
  211.                     $resp = recaptcha_check_answer ($config['recaptcha_private_key'],
  212.                                                      $_SERVER["REMOTE_ADDR"],
  213.                                                      $_POST["recaptcha_challenge_field"],
  214.                                                      $_POST["recaptcha_response_field"]);
  215.  
  216.                         if (!$resp->is_valid) {
  217.  
  218.                             $stop .= "<li>" . $lang['news_err_30'] . "</li>";
  219.  
  220.                         }
  221.  
  222.                 } else $stop .= "<li>" . $lang['news_err_30'] . "</li>";
  223.  
  224.             } elseif( $_REQUEST['sec_code'] != $_SESSION['sec_code_session'] OR !$_SESSION['sec_code_session'] ) $stop .= "<li>" . $lang['news_err_30'] . "</li>";
  225.  
  226.  
  227.         }
  228.  
  229.         if( $stop ) {
  230.             $stop = "<ul>" . $stop . "</ul><a href=\"javascript:history.go(-1)\">$lang[all_prev]</a>";
  231.             msgbox( $lang['add_err_6'], $stop  );
  232.         }
  233.  
  234.         if( ! $stop ) {
  235.  
  236.             $_SESSION['sec_code_session'] = 0;
  237.             $id = (isset( $_REQUEST['id'] )) ? intval( $_REQUEST['id'] ) : 0;
  238.             $found = false;
  239.  
  240.             if( $id ) {
  241.                 $row = $db->super_query( "SELECT * FROM " . PREFIX . "_post where id = '$id' and approve = '0'" );
  242.                 if( $id == $row['id'] and ($member_id['name'] == $row['autor'] or $user_group[$member_id['user_group']]['allow_all_edit']) ) $found = true;
  243.                 else $found = false;
  244.             }
  245.  
  246.             $ndatesi = $db->super_query( "SELECT * FROM " . PREFIX . "_post where id = '$id'" );
  247.             $newsdate = $ndatesi['date'];
  248.             $newdate = strtotime( $_POST['newdate'] );
  249.             $allow_date = intval( $_POST['allow_date'] );
  250.             $allow_now = intval( $_POST['allow_now'] );
  251.  
  252.                 // Обработка даты и времени
  253.                 $added_time = time() + ($config['date_adjust'] * 60);
  254.  
  255.                 if( $allow_date != "1" and is_logged and $member_id['user_group'] < 3 ) {
  256.  
  257.                     if( $allow_now != "1" ) {
  258.  
  259.                         $thistime = date( "Y-m-d H:i:s", $newdate );
  260.  
  261.                     } else {
  262.  
  263.                         $thistime = date ('Y-m-d H:i:s', $added_time);
  264.  
  265.                     }
  266.  
  267.  
  268.                     $db->query( "UPDATE " . PREFIX . "_post set title='$title', date='$thistime', short_story='$short_story', full_story='$full_story', xfields='$filecontents', descr='{$metatags['description']}', keywords='{$metatags['keywords']}', category='$category_list', alt_name='$alt_name', allow_comm='$allow_comm', approve='$approve', allow_main='$allow_main', fixed='$news_fixed', allow_br='$allow_br', symbol='$catalog_url', tags='{$_POST['tags']}', metatitle='{$metatags['title']}' WHERE id='$id'" );
  269.                                                    
  270.                 } else {
  271.  
  272.                     $db->query( "UPDATE " . PREFIX . "_post set title='$title', short_story='$short_story', full_story='$full_story', xfields='$filecontents', category='$category_list', alt_name='$alt_name', allow_comm='$allow_comm', approve='$approve', allow_main='$allow_main', fixed='$news_fixed', allow_br='$allow_br', tags='" . $_POST['tags'] . "' WHERE id='$id'" );
  273.                 }
  274.  
  275.                 // Облако тегов
  276.                 if( $_POST['tags'] != $row['tags'] or $approve ) {
  277.                     $db->query( "DELETE FROM " . PREFIX . "_tags WHERE news_id = '{$row['id']}'" );
  278.  
  279.                     if( $_POST['tags'] != "" and $approve ) {
  280.  
  281.                         $tags = array ();
  282.  
  283.                         $_POST['tags'] = explode( ",", $_POST['tags'] );
  284.  
  285.                         foreach ( $_POST['tags'] as $value ) {
  286.  
  287.                             $tags[] = "('" . $row['id'] . "', '" . trim( $value ) . "')";
  288.                         }
  289.  
  290.                         $tags = implode( ", ", $tags );
  291.                         $db->query( "INSERT INTO " . PREFIX . "_tags (news_id, tag) VALUES " . $tags );
  292.  
  293.                     }
  294.                 }
  295.  
  296.  
  297.             if( $config['allow_alt_url'] == "yes" ) msgbox( $lang['add_ok_ok'], "{$msg} <a href=\"{$config['http_home_url']}\">$lang[all_prev]</a>" );
  298.             else msgbox( $lang['add_ok_ok'], "{$msg} <a href=\"{$config['http_home_url']}\">$lang[all_prev]</a>" );
  299.  
  300.             if( $approve ) clear_cache();
  301.  
  302.         }
  303.  
  304.     } elseif( $is_logged and $user_group[$member_id['user_group']]['allow_adds'] ) {
  305.  
  306.  
  307.  
  308.         $id = (isset( $_REQUEST['id'] )) ? intval( $_REQUEST['id'] ) : 0;
  309.         $found = false;
  310.  
  311.         if( $id ) {
  312.             $row = $db->super_query( "SELECT * FROM " . PREFIX . "_post where id = '$id' and approve = '0'" );
  313.             if( $id == $row['id'] and ($member_id['name'] == $row['autor'] or $user_group[$member_id['user_group']]['allow_all_edit']) ) $found = true;
  314.             else $found = false;
  315.         }
  316.  
  317.  
  318.     $id = intval( $_GET['id'] );
  319.     $row = $db->super_query( "SELECT * FROM " . PREFIX . "_post where id = '$id'" );
  320.  
  321.             $cat_list = explode( ',', $row['category'] );
  322.             // без категории
  323.             // $cat_list[0] - первая рубрика
  324.             if ($cat_list[0] == 0) {
  325.                 $tpl->load_template( 'editnews.tpl' );
  326.             } else {
  327.                 // желательно проверить есть ли такой шаблон с № иначе отдать дефолтный
  328.                 $tpl->load_template( 'editnews'.$cat_list[0].'.tpl' );
  329.             }
  330.            
  331.        
  332.         // вырезано с верху
  333.         $addtype = "addnews";
  334.  
  335.         if ( !$user_group[$member_id['user_group']]['allow_html'] ) {
  336.  
  337.             $config['allow_site_wysiwyg'] = 0;
  338.  
  339.         }
  340.  
  341.         if( $config['allow_site_wysiwyg'] ) {
  342.  
  343.             include_once ENGINE_DIR . '/editor/shortsite.php';
  344.             include_once ENGINE_DIR . '/editor/fullsite.php';
  345.             $bb_code = "";
  346.  
  347.         } else {
  348.                         $bb_editor = true;
  349.             include_once ENGINE_DIR . '/modules/bbcode.php';
  350.         }                
  351.        
  352.         if( !$config['allow_site_wysiwyg'] ) {
  353.  
  354.             $tpl->set( '[not-wysywyg]', '' );
  355.             $tpl->set( '[/not-wysywyg]', '' );
  356.  
  357.         } else
  358.             $tpl->set_block( "'\\[not-wysywyg\\].*?\\[/not-wysywyg\\]'si", '' );
  359.  
  360.         if( $config['allow_site_wysiwyg'] ) {
  361.  
  362.             $tpl->set( '{shortarea}', $shortarea );
  363.             $tpl->set( '{fullarea}', $fullarea );
  364.  
  365.         } else {
  366.             $tpl->set( '{shortarea}', '' );
  367.             $tpl->set( '{fullarea}', '' );
  368.         }
  369.         // конец вырезки
  370.            
  371.             $categories_list = CategoryNewsSelection( $cat_list, 0 );
  372.             $tpl->set( '{title}', $parse->decodeBBCodes( $row['title'], false ) );
  373.             $tpl->set( '{alt-name}', $row['alt_name'] );
  374.             $tpl->set( '{datenews11}', $row['date'] );
  375.  
  376.  
  377.             if( $config['allow_site_wysiwyg'] or $row['allow_br'] != '1' ) {
  378.                 $row['short_story'] = $parse->decodeBBCodes( $row['short_story'], TRUE, $config['allow_site_wysiwyg'] );
  379.                 $row['full_story'] = $parse->decodeBBCodes( $row['full_story'], TRUE, $config['allow_site_wysiwyg'] );
  380.             } else {
  381.                 $row['short_story'] = $parse->decodeBBCodes( $row['short_story'], false );
  382.                 $row['full_story'] = $parse->decodeBBCodes( $row['full_story'], false );
  383.             }
  384.  
  385.             $tpl->set( '{short-story}', $row['short_story'] );
  386.             $tpl->set( '{full-story}', $row['full_story'] );
  387.             $tpl->set( '{tags}', $row['tags'] );
  388.  
  389.  
  390.         $xfieldsaction = "categoryfilter";
  391.         include_once ENGINE_DIR . '/inc/xfields1.php';
  392.         if( $config['allow_multi_category'] ) {
  393.  
  394.             $cats = "<select name=\"catlist[]\" id=\"category\" onchange=\"onCategoryChange(this.value)\" style=\"width:316px;height:73px;\" multiple>";
  395.  
  396.         } else {
  397.  
  398.             $cats = "<select name=\"catlist[]\" id=\"category\" onchange=\"onCategoryChange(this.value)\">";
  399.         }
  400.  
  401.         $cats .= $categories_list;
  402.         $cats .= "</select>";
  403.  
  404.         $tpl->set( '{bbcode}', $bb_code );
  405.         $tpl->set( '{category}', $cats );
  406.  
  407.         if ($row['allow_comm'] == '1') $comm_chek = "checked=\"checked\"";
  408.         if ($row['approve'] == '1') $app_chek = "checked=\"checked\"";
  409.         if ($row['allow_main'] == '1') $main_chek = "checked=\"checked\"";
  410.         if ($row['allow_rate'] == '1') $rate_chek = "checked=\"checked\"";
  411.         if ($row['fixed'] == '1') $nfix_chek = "checked=\"checked\"";
  412.  
  413.         if( $user_group[$member_id['user_group']]['moderation'] ) {
  414.  
  415.             $admintag = "<input type=\"checkbox\" name=\"allow_comm\" id=\"allow_comm\" value=\"1\" ".$comm_chek." /><label for=\"allow_comm\">" . $lang['add_al_com'] . "</label>";
  416.  
  417.             if( $user_group[$member_id['user_group']]['allow_main'] ) $admintag .= "&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" name=\"allow_main\" id=\"allow_main\" value=\"1\" ".$main_chek." /><label for=\"allow_main\">" . $lang['add_al_m'] . "</label>";
  418.  
  419.             $admintag .= "<br /><input type=\"checkbox\" name=\"approve\" id=\"approve\" value=\"1\" ".$app_chek." /><label for=\"approve\"> {$lang['add_al_ap']}</label>";
  420.  
  421.             if( $user_group[$member_id['user_group']]['allow_fixed'] ) $admintag .= "<br /><input type=\"checkbox\" name=\"news_fixed\" id=\"news_fixed\" value=\"1\" $nfix_chek /><label for=\"news_fixed\"> {$lang['add_al_fix']}</label>";
  422.  
  423.             $tpl->set( '{admintag}', $admintag );
  424.  
  425.         } else
  426.             $tpl->set( '{admintag}', '' );
  427.  
  428.         if( $is_logged and $member_id['user_group'] < 3 ) {
  429.  
  430.             $tpl->set( '[urltag]', '' );
  431.             $tpl->set( '[/urltag]', '' );
  432.  
  433.         } else
  434.             $tpl->set_block( "'\\[urltag\\].*?\\[/urltag\\]'si", "" );
  435.  
  436.  
  437.         if( $is_logged and $member_id['user_group'] < 3 ) {
  438.  
  439.             $tpl->set( '[dateedadm]', '' );
  440.             $tpl->set( '[/dateedadm]', '' );
  441.  
  442.         } else
  443.             $tpl->set_block( "'\\[dateedadm\\].*?\\[/dateedadm\\]'si", "" );
  444.             $xfieldsaction = "list";
  445.             $xfieldsid = $row['xfields'];
  446.             $xfieldscat = $row['category'];
  447.             include (ENGINE_DIR . '/inc/xfields1.php');
  448.  
  449.  
  450.         $tpl->set( '{xfields}', $output );
  451. $tpl->set( '', $outputList );
  452.  
  453.  
  454.  
  455.         if( strpos( $tpl->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl->copy_template, "[xfgiven_" ) !== false ) {
  456.            
  457.             $xfieldsdata = xfieldsdataload( $row['xfields'] );
  458.            
  459.             foreach ( $xfields as $value ) {
  460.                 $preg_safe_name = preg_quote( $value[0], "'" );
  461.  
  462.                 if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
  463.                     $temp_array = explode( ",", $xfieldsdata[$value[0]] );
  464.                     $value3 = array();
  465.  
  466.                     foreach ($temp_array as $value2) {
  467.  
  468.                         $value2 = trim($value2);
  469.                         $value2 = str_replace("&#039;", "'", $value2);
  470.  
  471.                         if( $config['allow_alt_url'] ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" . urlencode( $value2 ) . "/\">" . $value2 . "</a>";
  472.                         else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&amp;xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
  473.                     }
  474.  
  475.                     $xfieldsdata[$value[0]] = implode(", ", $value3);
  476.  
  477.                     unset($temp_array);
  478.                     unset($value2);
  479.                     unset($value3);
  480.  
  481.                 }
  482.                
  483.                 if( empty( $xfieldsdata[$value[0]] ) ) {
  484.                     $tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  485.                     $tpl->copy_template = str_replace( "[xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
  486.                     $tpl->copy_template = str_replace( "[/xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
  487.                 } else {
  488.                     $tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  489.                     $tpl->copy_template = str_replace( "[xfgiven_{$value[0]}]", "", $tpl->copy_template );
  490.                     $tpl->copy_template = str_replace( "[/xfgiven_{$value[0]}]", "", $tpl->copy_template );
  491.                 }
  492.  
  493.                 $xfieldsdata[$value[0]] = $parse->decodeBBCodes( $xfieldsdata[$value[0]], false );
  494.  
  495.                 if ($config['allow_links'] AND $value[3] == "textarea" AND function_exists('replace_links')) $xfieldsdata[$value[0]] = replace_links ( $xfieldsdata[$value[0]], $replace_links['news'] );
  496.  
  497.                 $tpl->copy_template = str_replace( "[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]], $tpl->copy_template );
  498.  
  499.                 if ( preg_match( "#\\[xfvalue_{$preg_safe_name} limit=['\"](.+?)['\"]\\]#i", $tpl->copy_template, $matches ) ) {
  500.                     $count= intval($matches[1]);
  501.        
  502.                     $xfieldsdata[$value[0]] = str_replace( "</p><p>", " ", $xfieldsdata[$value[0]] );
  503.                     $xfieldsdata[$value[0]] = strip_tags( $xfieldsdata[$value[0]], "<br>" );
  504.                     $xfieldsdata[$value[0]] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $xfieldsdata[$value[0]] ) ) ) ));
  505.        
  506.                     if( $count AND dle_strlen( $xfieldsdata[$value[0]], $config['charset'] ) > $count ) {
  507.                            
  508.                         $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $count, $config['charset'] );
  509.                            
  510.                         if( ($temp_dmax = dle_strrpos( $xfieldsdata[$value[0]], ' ', $config['charset'] )) ) $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $temp_dmax, $config['charset'] );
  511.                        
  512.                     }
  513.        
  514.                     $tpl->set( $matches[0], $xfieldsdata[$value[0]] );
  515.        
  516.                 }
  517.             }
  518.         }
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.         if( $user_group[$member_id['user_group']]['news_sec_code'] ) {
  534.  
  535.             if ( $config['allow_recaptcha'] ) {
  536.  
  537.                 $tpl->set( '[recaptcha]', "" );
  538.                 $tpl->set( '[/recaptcha]', "" );
  539.  
  540.                 $tpl->set( '{recaptcha}', '
  541. <script language="javascript" type="text/javascript">
  542. <!--
  543.     var RecaptchaOptions = {
  544.        theme: \''.$config['recaptcha_theme'].'\',
  545.        lang: \''.$lang['wysiwyg_language'].'\'
  546.     };
  547.  
  548. //-->
  549. </script>
  550. <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k='.$config['recaptcha_public_key'].'"></script>' );
  551.  
  552.                 $tpl->set_block( "'\\[sec_code\\](.*?)\\[/sec_code\\]'si", "" );
  553.                 $tpl->set( '{reg_code}', "" );
  554.  
  555.             } else {
  556.  
  557.                 $tpl->set( '[sec_code]', "" );
  558.                 $tpl->set( '[/sec_code]', "" );
  559.                 $path = parse_url( $config['http_home_url'] );
  560.                 $tpl->set( '{sec_code}', "<span id=\"dle-captcha\"><img src=\"" . $path['path'] . "engine/modules/antibot.php\" alt=\"${lang['sec_image']}\" border=\"0\" alt=\"\" /><br /><a onclick=\"reload(); return false;\" href=\"#\">{$lang['reload_code']}</a></span>" );
  561.                 $tpl->set_block( "'\\[recaptcha\\](.*?)\\[/recaptcha\\]'si", "" );
  562.                 $tpl->set( '{recaptcha}', "" );
  563.             }
  564.  
  565.         } else {
  566.  
  567.             $tpl->set( '{sec_code}', "" );
  568.             $tpl->set( '{recaptcha}', "" );
  569.             $tpl->set_block( "'\\[recaptcha\\](.*?)\\[/recaptcha\\]'si", "" );
  570.             $tpl->set_block( "'\\[sec_code\\](.*?)\\[/sec_code\\]'si", "" );
  571.  
  572.         }
  573.  
  574.         $script = "
  575. <script language=\"javascript\" type=\"text/javascript\">
  576. <!--
  577. function preview(){";
  578.  
  579.         if( $config['allow_site_wysiwyg'] == "yes" ) {
  580.  
  581.             $script .= "document.getElementById('short_story').value = tinyMCE.get('short_story').getContent();
  582.     document.getElementById('full_story').value = tinyMCE.get('full_story').getContent();";
  583.  
  584.         }
  585.  
  586.         $script .= "if(document.entryform.short_story.value == '' || document.entryform.title.value == ''){ alert('$lang[add_err_7]'); }
  587.    else{
  588.        dd=window.open('','prv','height=400,width=750,resizable=0,scrollbars=1')
  589.        document.entryform.mod.value='preview';document.entryform.action='{$config['http_home_url']}engine/preview.php';document.entryform.target='prv'
  590.        document.entryform.submit();dd.focus()
  591.        setTimeout(\"document.entryform.mod.value='addnews';document.entryform.action='';document.entryform.target='_self'\",500)
  592.    }
  593. }";
  594.  
  595.         $script .= <<<HTML
  596.  
  597. function reload () {
  598.  
  599.     var rndval = new Date().getTime();
  600.  
  601.     document.getElementById('dle-captcha').innerHTML = '<img src="{$path['path']}engine/modules/antibot.php?rndval=' + rndval + '" border="0" width="120" height="50" alt="" /><br /><a onclick="reload(); return false;" href="#">{$lang['reload_code']}</a>';
  602.  
  603. };
  604.  
  605.     function CheckStatus(Form){
  606.         if(Form.allow_date.checked) {
  607.         Form.allow_now.disabled = true;
  608.         Form.allow_now.checked = false;
  609.         } else {
  610.         Form.allow_now.disabled = false;
  611.         }
  612.     }
  613. //-->
  614. </script>
  615. HTML;
  616.  
  617.         if( $config['allow_site_wysiwyg'] == "yes" ) $script .= "<form method=post name=\"entryform\" id=\"entryform\" onsubmit=\"document.getElementById('short_story').value = tinyMCE.get('short_story').getContent(); document.getElementById('full_story').value = tinyMCE.get('full_story').getContent(); if(document.entryform.title.value == '' || document.entryform.short_story.value == ''){alert('$lang[add_err_7]');return false}\" action=\"\">";
  618.         else $script .= "<form method=post name=\"entryform\" id=\"entryform\" onsubmit=\"if(document.entryform.title.value == '' || document.entryform.short_story.value == ''){alert('$lang[add_err_7]');return false}\" action=\"\">";
  619.  
  620.         if( $config['sec_addnews'] ) {
  621.  
  622.             $salt = "abchefghjkmnpqrstuvwxyz";
  623.             srand( ( double ) microtime() * 1000000 );
  624.             $random_key = "";
  625.  
  626.             for($i = 0; $i < 8; $i ++) {
  627.                 $random_key .= $salt{rand( 0, 23 )};
  628.             }
  629.  
  630.             @session_register( 'id_key' );
  631.             $_SESSION['id_key'] = $random_key;
  632.  
  633.             $random_key = "<input type=\"hidden\" name=\"{$random_key}\" value=\"{$dle_login_hash}\" />";
  634.  
  635.  
  636.  
  637.         } else
  638.             $random_key = "";
  639.  
  640.         $tpl->copy_template = $categoryfilter . $script . $tpl->copy_template . "<input type=\"hidden\" name=\"mod\" value=\"addnews\" />{$random_key}</form>";
  641.         $tpl->compile( 'content' );
  642.         $tpl->clear();
  643.  
  644.     } else
  645.         msgbox( $lang['all_info'], "$lang[add_err_8]<br /><a href=\"javascript:history.go(-1)\">$lang[all_prev]</a>" );
  646.  
  647. }
  648. ?>
Advertisement
Add Comment
Please, Sign In to add comment