Jump to content

vinsb

Members
  • Posts

    38
  • Joined

  • Last visited

  • Days Won

    1

vinsb last won the day on November 8 2014

vinsb had the most liked content!

vinsb's Achievements

Member

Member (2/5)

1

Reputation

  1. Hi there, I want to make script which will execute via crontab every Sunday at 0:01h and will stop at 23:59h. My goal is to put(show) some tekst on the site. The problem is how to put this tekst in the site? I mean I know how to configure Cron Jobs but how to include the tekst in index.php for example? crontab will be. 1 0 * * 0 /usr/bin/php Start.php 59 23 * * 0 /usr/bin/php Stop.php
  2. Yes, I'm using it now. So I need to work with ffmpeg for the gif. That's ok. Just one more question - So as I see I must download first the video and then make the gif .. then save the video link in database and somehow connect the gif to that video.. Honestly, I'm not that advanced and I don't see how this will hapen. If I upload/save video/link only on the site is ok.. I will make this. But every registered user can upload video.. In this case I will need to store the video and make gif .. It will be something like ffmpeg + ffmpeg -i video_origine.avi gif_anime.gif But can I put the link to the video instead of 'video_origine.avi'?
  3. Now I store youtube link in database and play the video from the link. I think this will be the problem and I can't use it with html5 video player...?
  4. Hello, How can I make gif from video while uploading it or after uploaded? Is there any tutorial.. I've been searched but didn't found anything. The reason I want this is because when I upload video then I will show few thumbnails of the video on the page. Then when user hover the video will play short gif from the video 2-5 seconds and when the user click on video will play the video.. Hope you get what I mean.. I don't know how to explain it better. Just point me somewhere to read or watch about this.. Thank's in advanced! p.s. Sorry for my English! EDIT: Here is the exaplme.. when you hover over the video an hold your mouse there it will play some gif http://gifsoup.com/faq.php Is it possible this?
  5. I just installed Laravel on my local and will start the user guide. Thank's!
  6. Oh, I didn't know this.. Any suggest for new framework then. Is Laravel good? According to this article Laravel is on first place..http://www.sitepoint.com/best-php-frameworks-2014/ Laravel Phalcon Symfony2 I want to learn some but I think I'm lost..
  7. Hello, Can you guys point me to something where I can follow some tutorial or something and learning CI? I've already made tons of 'Cars' models... 'Dogs' .. 'Cats'.. etc but I really need some project where I can follow steps to creat and learn while I create. p.s. I think I post this thread in right place but please correct me if is wrong. Thank's!
  8. I will try to go directly to PDO and OOP. In fact I have upload form for images/gifs/videos .. and it's with prepared statements. $query = "INSERT INTO images (caption, name, size, type, file_path, alt, img_category) VALUES (?,?,?,?,?,?,?)"; $conn = $db->prepare($query); if ($conn == TRUE) { $conn->bind_param("ssissss",$caption, $myFile, $fileSize, $fileType, $path, $alt, $category); if (!$conn->execute()) { echo 'error insert'; } else {
  9. I want and I must change one day to PDO. But I think I must first learn php&mysql and then switch to PDO or I can go directly to PDO. As I said I'm not totaly beginner I have some background. Anyway will do it sooner or later. Thank you guys again for your help!
  10. Thank you for your replay. I must confess I'm kinda new in php&mysql at all.. not complete beginner but still learning. I have writen few codes in mysqli_* but never in PDO that's why I think PDO is harder for newbie. Also OOP at all..
  11. Yes, it"s better now. Doesn't show any massages or something. Just reloading the page. I will convert this to mysli_* because I know nothing from PDO yet. Thank's for your help!
  12. Now that's working perfectly. Just last question because I'm not very familiar with sql injections and etc. Is it secure enought this code? Also what can I make if someone enter something like "' OR 1=1 #" to show some message for error because if I search for this is load whole images from database without pagination.. and they are ~5000 images so far. It's loading them on the page and this slowing the entire site. Is this ok for major sql injections? if (strstr($queryString,"<") || strstr($queryString,">") || strstr($queryString,"(") || strstr($queryString,")") || strstr($queryString,"..") || strstr($queryString,"%") || strstr($queryString,"*") || strstr($queryString,"+") || strstr($queryString,"!") || strstr($queryString,"@") || preg_match('/union.*select/i', $queryString) || preg_match('/exec/i', $queryString) || preg_match('/declare/i', $queryString) || preg_match('/drop/i', $queryString) ) { $filename = '/logs/sql_injection_log_'.date('Y-m-d').'.txt'; $fh = fopen($filename, 'a'); fwrite($fh, $data); fclose($fh); // Send an email to the administrator $message = 'SqlInjectionAlarm function '.wordwrap($data, 70); $headers = 'From: site' . "\r\n" . 'Reply-To: '.$email. "\r\n" . 'X-Mailer: PHP/' . phpversion(); // Send mail('', 'Possible Hack Attempt', $message, $headers); header('Location: http://www.google.com'); exit();} edit: Also if I enter in search bar this: <script>alert('Some JavaScript code')</script> I get this massages You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Some JavaScript code')</script>%' ORDER BY id DESC LIMIT 0, 6' at line 1 I think I must hide this somehow.
  13. With method="get" on my form doens't search at all. Just reloading the entire page.. <form action="../search.php" class="search-wrapper cf" method="get"> <input type="text" placeholder="Search here..." required="" name="term"> <button type="submit">Search</button> </form> Also I called the pagination later in my html <div id="main"> <div id="column_left"> <?php echo $output; ?> <div style=" margin-left:100px; margin-top: 5px; height: 30px; width: 400px;"><?php echo paginate($total_rows, $pp, $page, $display_links); ?></div> </div> <?php include 'include/right.php'; ?> <?php include 'include/footer.php'; ?><br/> </div>
  14. Great tool!! Working like above. When I click on Next link I get 240 pages instead 2 Here is what your tool produce to me. I've just put my while loop // Makes a CONSTANT to use in the paginate function that defines the page the name to be placed in the pagination links href. define ("body_id", basename($_SERVER['SCRIPT_NAME'], ".php")); // Sets the page number for pagination if(!isset($_GET['page']) || (int)$_GET['page'] < 0) {$page = 1;} else {$page = (int)$_GET['page'];} // This is the number of items displayed per page. $pp = 12; // This is number of links to display before ... and then the last number of pages available. $display_links = 4; // Sets up the start value for pagination queries function startValue($page, $pp) { return ($page > 0) ? ($page * $pp) - $pp: 0; } // Standard Next and Previous setup for pagination // $pp tells it how many items per page // $cp is the $_GET['page'] for the current page. // $p_type allows you to specify additional $_GET items for the page you are using. // $lpp allows you to specify the number of links to show before it starts to split them up. // Define your own class called current-page to destinguish what page you are on in the links. function paginate($rc, $pp, $cp, $lpp = NULL, $p_type = NULL) { $html=''; if($p_type !== NULL) { $page_type = '&'.$p_type; } else{$page_type='';} if ($rc > $pp) { $html .= '<div class="pagination">'; $prev = $cp - 1; $next = $cp + 1; $page_count = ceil($rc / $pp); // Total number of pages needed to paginate. $linkspp = ($lpp !== NULL) ? $lpp : 10; // Number of links to show in between the first and last page numbers if the number of pages exceeds the $linkspp. $median = floor($linkspp / 2); // Number of links to display on either side of the current page. $multiplier1 = ceil($linkspp / 2); $multiplier2 = $linkspp - 1; // Starting page number to display. $start_count = (($cp - $median) <=1) ? 1 : $cp - $median; // Checks if the we have correct number of page links being displayed. $start_count = (($cp + $median) >= $page_count) ? $start_count - (($cp + $median) - $page_count) : $start_count; // Checks if we are at the end of the page numbering. $start_count = (($start_count + $multiplier1) >= $page_count) ? $page_count - $multiplier2 : $start_count; //Checks if the starting page number is greater than the page count. $start_count = ($linkspp > $page_count) ? $linkspp = $page_count : $start_count; // Checks if the page count is equal to the number of pages being displayed. $start_count = ($linkspp == $page_count) ? 1: $start_count; for($t=0; $t<$linkspp; $t++) { $page_links[$start_count] = $start_count; $start_count++; } if($cp == $page_count) {$page_links[$page_count] = $page_count;} if ($cp > 1) {$html .= '<a href="'.body_id.'.php?page='.$prev.$page_type.'">Prev</a> ';} if(!in_array(1, $page_links)) {$html .= '<a href="'.body_id.'.php?page=1'.$page_type.'">1</a> ... ';} foreach($page_links as $key => $val) { if($key > $page_count){} else { if ($cp!=$val || $cp == 1) {$html .= '<a href="'.body_id.'.php?page='.$val.$page_type.'">'.$val.'</a> ';} else {$html .= '<span class="current-page"><a href="'.body_id.'.php?page='.$val.$page_type.'">'.$val.'</a></span> ';} } } if(array_key_exists("$page_count", $page_links) === FALSE) {$html .= '... <a href="'.body_id.'.php?page='.$page_count.$page_type.'">'.$page_count.'</a> ';} if ($cp < $page_count) {$html .= ' <a href="'.body_id.'.php?page='.$next.$page_type.'">Next</a>';} $html .= '<br/><br/></div>'; } else {} return $html; } $start = startValue($page, $pp); $searchTerm = trim($_POST['term']); $get = mysql_query("SELECT SQL_CALC_FOUND_ROWS id, name, caption FROM images WHERE caption LIKE '%".$searchTerm."%' ORDER BY id DESC LIMIT $start, $pp") or die(mysql_error()); $result_count = mysql_query("SELECT FOUND_ROWS();"); $rowResult = mysql_fetch_array($result_count); $total_rows = $rowResult[0]; $output = ''; while($rows = mysql_fetch_assoc($get)){ //$results[] = $rows; $output.= "<div class=\"container_image\">"; $output.= "<a href=\"/pic-".$rows['id'].".html\"><img src=\"/upload/".$rows['name']."\" width=\"210\" height=\"150\"/></a>"; $output.= "</div>"; }
  15. Ok, I've changed them to if ($page > 1) { $_GET['page'] = 1; $pagination = http_build_query($_GET, '', '&'); $prevlink = "<a href='?$pagination' title='First page'>«</a>"; $_GET['page'] = $page - 1; $pagination = http_build_query($_GET, '', '&'); $prevlink .= " <a href='?$pagination' title='Previous page'>‹</a>"; } else $pagination.= "<span class=\"disabled\"> previous</span>"; if ($lastpage < 7 + ($adjacents * 2)) { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"?page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) { if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"?page=$lastpage\">$lastpage</a>"; } elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"?page=1\">1</a>"; $pagination.= "<a href=\"?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"?page=$lastpage\">$lastpage</a>"; } else { $pagination.= "<a href=\"?page=1\">1</a>"; $pagination.= "<a href=\"?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"?page=$counter\">$counter</a>"; } } } if ($page < $counter - 1) { $_GET['page'] = $page + 1; $pagination .= http_build_query($_GET, '', '&'); $pagination.= "<a href=\"?page=$next\">next </a>"; } else $pagination.= "<span class=\"disabled\">next </span>"; And I receive this
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.