Файл: public_html/admin/home.php
Строк: 290
<?php
error_reporting(E_ALL);
session_start();
include 'config.php';
echo dbconn();
include_once('pagination.class.php');
if (!isset($_SESSION['autoblg'])) {
header( 'Location: index.php' ) ;
}
if (isset($_GET['res'])) {
unset($_SESSION['autoblg']);
header( 'Location: index.php' ) ;
}
if (isset($_GET['del'])) {
$del = $_GET['del'];
mysql_query("Delete from feeds where id ='$del'");
$message = 'RSS feed successfully deleted';
}
if (isset($_POST['feedlink'])) {
$feedlink = $_POST['feedlink'];
$feedtitle = $_POST['feedtitle'];
$feedcat = $_POST['feedcat'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "".$feedlink."");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
if (simplexml_load_string($output)) {
mysql_query("INSERT INTO feeds (link, category, title) VALUES('$feedlink', '$feedcat', '$feedtitle')");
  $message = 'RSS feed successfully added';
} else {
  $message = 'RSS FEED IS NOT VALID, PLEASE DOUBLE CHECK THE LINK AND TRY AGAIN';
}
}
if (isset($_POST['efeedid'])) {
$efeedlink = $_POST['efeedlink'];
$efeedtitle = $_POST['efeedtitle'];
$efeedid = $_POST['efeedid'];
$efeedcat = $_POST['efeedcat'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "".$efeedlink."");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
if (simplexml_load_string($output)) {
mysql_query("UPDATE feeds set title='$efeedtitle', category='$efeedcat', link='$efeedlink' WHERE id='$efeedid'");
$message = 'RSS feed successfully updated';
} else {
  $message = 'RSS FEED IS NOT VALID, PLEASE DOUBLE CHECK THE LINK AND TRY AGAIN';
}
}
?>
<!DOCTYPE html>
<html class="no-js">
    
    <head>
        <title>АвтоБлог Администраторская</title>
        <!-- Bootstrap -->
        <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
        <link href="vendors/easypiechart/jquery.easy-pie-chart.css" rel="stylesheet" media="screen">
        <link href="assets/styles.css" rel="stylesheet" media="screen">
         <link href="assets/demo_table.css" rel="stylesheet" media="screen">
         <link href="assets/jquery.dataTables.css" rel="stylesheet" media="screen">
         
        
        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <script src="vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
        <style>
            div.pagination {
        padding: 3px;
        margin: 3px;
        text-align:center;
        font-family:Tahoma,Helvetica,sans-serif;
        font-size:.85em;
    }
    
    div.pagination a {
        border: 1px solid #ccdbe4;
        margin-right:3px;
        padding:2px 8px;
        background-position:bottom;
        text-decoration: none;
        color: #0061de;        
    }
    div.pagination a:hover, div.pagination a:active {
        border: 1px solid #2b55af;
        background-image:none;
        background-color:#3666d4;
        color: #fff;
    }
    div.pagination span.current {
        margin-right:3px;
        padding:2px 6px;
        
        font-weight: bold;
        color: #000;
    }
    div.pagination span.disabled {
        display:none;
    }
    div.pagination a.next{
        border:2px solid #ccdbe4;
        margin:0 0 0 10px;
    }
    div.pagination a.next:hover{
        border:2px solid #2b55af;
    }
    div.pagination a.prev{
        border:2px solid #ccdbe4;
        margin:0 10px 0 0;
    }
    div.pagination a.prev:hover{
        border:2px solid #2b55af;
    }
        </style>
    </head>
    
    <body>
        <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container-fluid">
                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                    </a>
                     <a class="brand" href="home.php">АвтоБлог Администраторская</a>
                    <div class="nav-collapse collapse">
                        <ul class="nav pull-right">
                            <li class="dropdown">
                                <a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-user"></i> Админ <i class="caret"></i>
                                </a>
                                <ul class="dropdown-menu">
                                    
                                    <li>
                                        <a tabindex="-1" href="?res">Выход</a>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                      
                    </div>
                    <!--/.nav-collapse -->
                </div>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">         
                <div class="span3" id="sidebar">
                    <ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
                        <li class="active">
                            <a href="home.php"><i class="icon-chevron-right"></i> Управление парсингом</a>
                        </li>
                        <li>
                            <a href="manage-articles.php"><i class="icon-chevron-right"></i> Управление записями</a>
                        </li>
                         <li>
                            <a href="manage-categories.php"><i class="icon-chevron-right"></i> Управление категориями</a>
                        </li>
                         <li>
                            <a href="manage-ads.php"><i class="icon-chevron-right"></i> Реклама</a>
                        </li>
                    </ul>
                </div>
                
                <!--/span-->
                <div class="span9" id="content">
                 <?php if (isset($message)) {
                 echo '<div class="alert">
  <button type="button" class="close" data-dismiss="alert">×</button>
  '.$message.'
</div>';
                 }?>
                    <div class="row-fluid">
                      <div class="span5"> 
<form method="POST" class="form-search">
  <input type="text" name="searchfeeds" class="input-medium search-query" value="<?php if (isset($_POST["searchfeeds"])) { echo $_POST["searchfeeds"];   } ?>">
  <button type="submit" class="btn">Поиск фидов</button>
</form>
                      </div>
         <div class="span2">   <a href="#addfeed" class="btn btn-success btn-small pull-right" data-toggle="modal" type="button">Add New Feed</a>      </div>
             <div class="span2">  <a style="margin-bottom:20px" href="cron-all.php" class="btn btn-small pull-right" type="button">Update All Feeds</a> </div>
                    </div>
<div class="row-fluid">            
<?php
$rss_sql=mysql_query("Select * from feeds");
$rss_count=mysql_num_rows($rss_sql);
if($rss_count==0)
{
?>                      
                     <div class="alert">
  <strong>There are no feeds to display yet! You can add one <a href="#addfeed" role="button" class="btn" data-toggle="modal">HERE</a></strong>
</div>
<?php } else { ?>
<table class="table table-bordered" id="example">
              <thead>
                <tr>
                  <th>Описание</th>
                  <th>Feed</th>
                  <th>Категория</th>
                  <th>Последнее обновление</th>
                  <th>Инструменты</th>
                </tr>
              </thead>
              <tbody>
<?php 
$items = 20;
    $page = 1;
    
    if(isset($_GET['page']) and is_numeric($_GET['page']) and $page = $_GET['page'])
            $limit = " LIMIT ".(($page-1)*$items).",$items";
        else
            $limit = " LIMIT $items";
 if (isset($_POST["searchfeeds"])) {    
$feedsearch = $_POST["searchfeeds"];
$sqlStr = "SELECT * FROM feeds WHERE title LIKE '%$feedsearch%'";
$sqlStrAux = "SELECT count(*) as total FROM feeds WHERE title LIKE '%$feedsearch%'";
} else { 
    $sqlStr = "SELECT * FROM feeds";
    $sqlStrAux = "SELECT count(*) as total FROM feeds";
}
    $aux = Mysql_Fetch_Assoc(mysql_query($sqlStrAux));
    $query = mysql_query($sqlStr.$limit);
    if($aux['total']>0){
            $p = new pagination;
            $p->Items($aux['total']);
            $p->limit($items);
            $p->currentPage($page);
            $p->calculate();
            $p->changeClass("pagination");
            
            while($rowfeeds = mysql_fetch_assoc($query)){
            $idd = $rowfeeds["id"];
?>
     
     <tr>
                  <td><?php echo $rowfeeds["title"] ?></td>
                  <td><?php echo $rowfeeds["link"] ?></td>
                  <td><?php echo $rowfeeds["category"] ?></td>
                  <?php
                  if ($rowfeeds["lastupdate"] == '0') {
                  echo  '<td>Not Yet Updated <a href="cron-single.php?id='.$rowfeeds["id"].'" class="btn btn-small btn-info" type="button">Update Now</a></td>  ';
                  } else {
                  echo  '<td><abbr class="timeago" title="'.$rowfeeds["lastupdate"].'">'.$rowfeeds["lastupdate"].'</abbr> <a href="cron-single.php?id='.$rowfeeds["id"].'" class="btn btn-small btn-info" type="button">Update Now</a></td>';
                  }
                  ?>
                  <td style="width:15%"><a href="#edit-<?php echo $rowfeeds["id"] ?>" class="btn btn-small btn-primary" data-toggle="modal" type="button">Edit</a> <a href="?del=<?php echo $rowfeeds["id"] ?>" class="btn btn-small btn-danger" onclick="javascript:return confirm('Are you sure you want to delete this?')" type="button">Delete</a></td>             
               </tr>
<div id="edit-<?php echo $rowfeeds["id"] ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
    <h3 id="myModalLabel">Edit Feed</h3>
  </div>
 <div class="modal-body">
    <form method="POST">
    <fieldset>
    <label>Feed Title</label>
    <input style="display:none" type="text" name="efeedid" value="<?php echo $rowfeeds["id"] ?>">
    <input type="text" name="efeedtitle" value="<?php echo $rowfeeds["title"] ?>">
    </fieldset>
    <fieldset>
    <label>Feed категория</label>
<select name="efeedcat">
<?php $currentcat = mysql_result(mysql_query("SELECT category FROM feeds WHERE id = '$idd'"), 0); ?>
<option value="<?php echo $currentcat ?>"><?php echo $currentcat ?></option>
<?php
$resultecat = mysql_query("SELECT * FROM cats"); 
while($rowecat = mysql_fetch_array( $resultecat )) { ?>
  <option value="<?php echo $rowecat["cat"] ?>"><?php echo $rowecat["cat"] ?></option>
<?php } ?>
</select>
    </fieldset>
  <fieldset>
    <label>ссылка</label>
    <input type="text" name="efeedlink" value="<?php echo $rowfeeds["link"] ?>">
    <span class="help-block">Ссылка должна быть рабочей</span>
  </fieldset>
 <fieldset>
  </div>
  <div class="modal-footer">
    <button class="btn btn-primary" type="submit">Редактировать</button>
    </form>
  </div>
</div>   
     
<?php } ?>
 </tbody>
 </table>
 
<?php    
$p->show();            
} else {
echo"There are no feeds to display";
}
?>
<?php } ?>
</div>
    
    
 <div id="addfeed" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
    <h3 id="myModalLabel">Добавить новую ленту</h3>
  </div>
  <div class="modal-body">
    <form method="POST">
    <fieldset>
    <label>RSS описание</label>
    <input type="text" name="feedtitle" placeholder="">
    </fieldset>
        <fieldset>
    <label>RSS категория</label>
<select name="feedcat">
<?php
$resultecat = mysql_query("SELECT * FROM cats ORDER BY cat"); 
while($rowecat = mysql_fetch_array( $resultecat )) { ?>
  <option value="<?php echo $rowecat["cat"] ?>"><?php echo $rowecat["cat"] ?></option>
<?php } ?>
</select>
    </fieldset>
  <fieldset>
    <label>Rss ссылка</label>
    <input type="text" name="feedlink" placeholder="">
    <span class="help-block">Ссылка RSS должна быть правильной</span>
  </fieldset>
 <fieldset>
  </div>
  <div class="modal-footer">
    <button class="btn btn-primary" type="submit">Добавить rss ленту</button>
 </fieldset>    
    </form>
  </div>
</div>                 
                  
                   
                   
                </div>
            </div>
            <hr>
            <footer>
                <p>© <a href="/">05q.ru</a></p>
            </footer>
        </div>
        <!--/.fluid-container-->
        <script src="vendors/jquery-1.9.1.min.js"></script>
        <script src="bootstrap/js/bootstrap.min.js"></script>
        <script src="assets/jquery.timeago.js"></script>
        <script src="assets/scripts.js"></script>
        <script>
        jQuery(document).ready(function() {
  jQuery("abbr.timeago").timeago();
});
        </script>
    </body>
</html>