decir/functions.php
changeset 11 5585ac341820
parent 7 37387f84fe25
equal deleted inserted replaced
10:36bc382ed459 11:5585ac341820
    33   
    33   
    34   $post_text = bbcode_inject_uid($post_text, $bbcode_uid);
    34   $post_text = bbcode_inject_uid($post_text, $bbcode_uid);
    35   $post_text = $db->escape($post_text);
    35   $post_text = $db->escape($post_text);
    36   
    36   
    37   $post_subject = $db->escape($post_subject);
    37   $post_subject = $db->escape($post_subject);
       
    38   if ( empty($post_subject) )
       
    39   {
       
    40     $q = $db->sql_query('SELECT topic_title FROM '.table_prefix.'decir_topics WHERE topic_id = ' . $topic_id . ';');
       
    41     if ( !$q )
       
    42       $db->_die('Decir functions.php in decir_submit_post()');
       
    43     if ( $db->numrows() < 1 )
       
    44       return false;
       
    45     list($post_subject) = $db->fetchrow_num();
       
    46     $post_subject = 'Re: ' . $db->escape($post_subject);
       
    47   }
    38   
    48   
    39   $q = $db->sql_query('INSERT INTO '.table_prefix."decir_posts(topic_id,poster_id,poster_name,post_subject,timestamp) VALUES($topic_id, $poster_id, '$poster_name', '$post_subject', $timestamp);");
    49   $q = $db->sql_query('INSERT INTO '.table_prefix."decir_posts(topic_id,poster_id,poster_name,post_subject,timestamp) VALUES($topic_id, $poster_id, '$poster_name', '$post_subject', $timestamp);");
    40   if ( !$q )
    50   if ( !$q )
    41     $db->_die('Decir functions.php in decir_submit_post()');
    51     $db->_die('Decir functions.php in decir_submit_post()');
    42   
    52   
   112   $grace = time() - ( 10 * 60 );
   122   $grace = time() - ( 10 * 60 );
   113   $q = $db->sql_query('UPDATE '.table_prefix."decir_posts SET post_subject='$post_subject', edit_count = edit_count + 1, edit_reason='$edit_reason', last_edited_by=$last_edited_by WHERE post_id=$post_id AND timestamp < $grace;");
   123   $q = $db->sql_query('UPDATE '.table_prefix."decir_posts SET post_subject='$post_subject', edit_count = edit_count + 1, edit_reason='$edit_reason', last_edited_by=$last_edited_by WHERE post_id=$post_id AND timestamp < $grace;");
   114   if ( !$q )
   124   if ( !$q )
   115     $db->_die('Decir functions.php in decir_edit_post()');
   125     $db->_die('Decir functions.php in decir_edit_post()');
   116 
   126 
   117   $q = $db->sql_query('UPDATE '.table_prefix."decir_posts_text SET post_text='$post_text' WHERE post_id=$post_id;");
   127   $q = $db->sql_query('UPDATE '.table_prefix."decir_posts_text SET post_text='$post_text',bbcode_uid='$bbcode_uid' WHERE post_id=$post_id;");
   118   if ( !$q )
   128   if ( !$q )
   119     $db->_die('Decir functions.php in decir_edit_post()');
   129     $db->_die('Decir functions.php in decir_edit_post()');
   120   
   130   
   121   return true;
   131   return true;
   122 }
   132 }