Guests can add news

Download plugins, language packs and stuff.

Postby eberswine » Wed Jul 28, 2010 6:18 pm

This is what I have so far... it is sort of working.. but how do I select the right folder for the actual image??

Code: Select all
<?php
//Installation:
//Open inc/show.news.php and change this:
//$output = str_replace('{author}', $user_name[$row['author']], $output);
//to this:
//$output = str_replace('{author}', (isset($user_name[$row['author']]) ? $user_name[$row['author']] : $row['author']) , $output);

//Config maximum unapproved
$max_unapproved = 50;
///////////////////////////
//Config XFields
$show_xfields = false;
///////////////////////////
//Config categories
$config_categories = '1,2,3';
///////////////////////////
//Config captcha
$use_captcha = false; //true or false
$path_to_captcha = './plugins/captcha/';
//Config bbcode
$bbcode = true;

if($use_captcha){
   @include $path_to_captcha.'php-captcha.inc.php';
}

?>
<link rel="stylesheet" type="text/css" href="skins/default.css">
<script type="text/javascript">
function check_fields(){
   if (document.guest.short_story.value == ""){
     document.guest.short_story.focus();
     alert ("The short story can't be blank.");
     return false;
   }
   return true;
}

function insertext(open, close, area){

   if(area=="short"){msgfield = document.guest.short_story}
   else if(area=="full"){msgfield = document.guest.full_story}

   // IE support
   if (document.selection && document.selection.createRange){
      msgfield.focus();
      sel = document.selection.createRange();
      sel.text = open + sel.text + close;
      msgfield.focus();
   }

   // Moz support
   else if (msgfield.selectionStart || msgfield.selectionStart == "0"){
      var startPos = msgfield.selectionStart;
      var endPos = msgfield.selectionEnd;

      msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length);
      msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
      msgfield.focus();
   }

   // Fallback support for other browsers
   else {
      msgfield.value += open + close;
      msgfield.focus();
   }

   return;
}
</script>
<?
include 'head.php';

if($_POST['dosend'] == "yes"){

   $unapproved = count($sql->select(array('table' => 'news', 'where' => array('hidden = 1'))));
   if($unapproved > $max_unapproved) echo "Sorry, we have enough unapproved stories.";
   if ($use_captcha and !PhpCaptcha::Validate($_POST['code'])) {
      echo("<div style=\"text-align: center;\">Please enter the numbers from the image.<br /><a href=\"javascript:history.go(-1)\">go back</a></div>");
   }
   else{

     $added_time = (time() + $config_date_adjust * 60);

     if (!$title){
       $title = substr($short_story, 0, 10).'...';
     }

     $id = $sql->last_insert_id('news', '', 'id') + 1;

     if ($cat){
       foreach ($cat as $k => $v){
         $category_tmp[] = $k;
       }
       $category = join(',', $category_tmp);
     }
    
     $mod == 'addnews';
      
     $sql->insert(array(
     'table'    => 'news',
     'values' => array(
         'date'      => $added_time,
         'author'   => ($_POST['name'] ? $_POST['name'] : 'guest'),
         'title'       => replace_news('add', $title),
         'short'       => strlen(replace_news('add', $short_story)),
         'full'      => strlen(replace_news('add', $full_story)),
         'avatar'   => $avatar,
         'category' => $category,
         'url'      => namespace2(totranslit($title)),
         'hidden'   => true
         )
     ));

     $sql->insert(array(
     'table'    => 'story',
     'values' => array(
         'post_id' => $id,
         'short'      => replace_news('add', $short_story),
         'full'      => replace_news('add', $full_story)
         )
     ));
      
     if($show_xfields){
       call_xfields_Save();
     }
     mail("josh@runsleepdesign.com", "New guest news", "There's a new guest news", "From:noreply@runsleepdesign.com");
     echo "Thank you for submitting your story.<br />";
     echo "The admin will publish it after approval.";
   }
}

else{
?>
<form action="" name="guest" method="post" onsubmit="return check_fields()">
<table>
<tr><td>Author:</td><td><input size="20" type="text" name="name"></td></tr>
<tr><td>Title:</td><td><input size="60" type="text" name="title"></td></tr>
<?
     echo '<tr><td>Category:</td><td>'.get_categories($config_categories).'</td></tr>';
?>
<tr><td>Short story:</td><td><?=$bbcode ? insertTag('short') : ''; ?><textarea name="short_story"></textarea></td></tr>
<!--Browse for image-->
<tr><td>Add a picture:</td><td><input name="avatar" type="file" class="text_calendar" value="" size="32" /></td></tr>
<!--Browse for image-->

<?
if($show_xfields){
   echo "<tr><td>XFields:</td><td>";
   echo admins_xfields();
   echo "</td></tr>";
}
if($use_captcha){
?>
<tr><td>Enter this code in the field below.<br /><img src="<?=$path_to_captcha; ?>/captcha.php?width=144" width="144" alt="Security Image"/><br /><input type="text" size="10" name="code" maxlength="6" />
<?
}
?>
<tr><td align="center" colspan="2"><input type="submit" value="Submit story"></td></tr>
<input type="hidden" name="dosend" value="yes">
</table>
</form>
<?
}

function get_categories($selection){
global $sql;

$category = '<select name="category">';

foreach($single_cats = explode(",", $selection) as $id){

   foreach ($sql->select(array('table' => 'categories', 'where' => array("id = $id"))) as $row){
     $category .= '<option value="'.$id.'">'.$row['name'].'</option>';
   }
}

$category .= '</select>';

return $category;
}

function namespace2($str){
global $sql;

   foreach ($sql->select(array('table' => 'news')) as $row){
      if (@preg_match("/$str([0-9]+)?/i", $row['url'])){
         $result[] = $row['id'];
      }
   }

   $count = count($result);

   $count++;


return totranslit($str.(($count and $count != 1) ? ' '.$count : ''));
}

?>
User avatar
eberswine
 
Posts: 289
Joined: Thu Apr 26, 2007 7:23 pm

Re: Guests can add news

Postby nolikewise » Sat Apr 16, 2011 6:19 pm

When i include guest.php like this...

Code: Select all
<?php
     echo '<div id="ajaxnews">';   
if ($do == 'register')
{
   echo regForm('default');
} elseif ($category == 'genel'){
   include $cutepath.'/genel.php';
} elseif ($category == 'kpss-dersler'){
   include $cutepath.'/kpss-dersler.php';
} elseif ($category == 'genel-ingilizce'){
   include $cutepath.'/genel-ingilizce.php';
} elseif ($category == 'sbs-dersleri'){
   include $cutepath.'/sbs-dersler.php';
} elseif ($category == 'siirler'){
   include $cutepath.'/siirler.php';

} elseif($do == 'chat')
{
      include $cutepath.'/chat.php';
}
elseif($do == 'add-post')
{
      include $cutepath.'/guest.php';
}
else {
         $number         = 12;
         $category      = '12, 31, 35,42 ,43, 52';
         $template      = 'fero';
         include $cutepath.'/show_news.php';
}

echo '</div>';
?>





it gives an error of ....

Code: Select all
Fatal error: Cannot redeclare comments_to_approve() (previously declared in /var/www/vhosts/okuogren.com/httpdocs/plugins/approve-comments.php:15) in /var/www/vhosts/okuogren.com/httpdocs/plugins/approve-comments.php on line 28


also gives error with shotTitle, latestcomments and etc.

You can check heree... http://www.okuogren.com/guest.php it works like that but i couldnt include it in the content section (middle of the page).

I am okay with captcha problem... it workss..

why is that?
nolikewise
 
Posts: 177
Joined: Mon Dec 17, 2007 8:47 am
Location: Turkiye

Re: Guests can add news

Postby Hawk » Sat Apr 23, 2011 11:04 am

It is something regareding the plugin "comments to approve". Did you try to disable it and see if you are getting the same error again?
User avatar
Hawk
 
Posts: 279
Joined: Tue Aug 29, 2006 9:00 pm

Re: Guests can add news

Postby jannypan » Sun May 08, 2011 4:26 am

The other important thing is it dose not mail the news posts to admin. while it is too necessary to recieve an email from guest posters when the item posted.
jannypan
 
Posts: 3
Joined: Sun May 08, 2011 4:23 am

Previous

Return to Additional Downloads



Who is online

Users browsing this forum: No registered users and 0 guests

cron