vinsb
Members-
Posts
38 -
Joined
-
Last visited
-
Days Won
1
Everything posted by vinsb
-
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
-
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'?
-
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...?
-
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?
-
I just installed Laravel on my local and will start the user guide. Thank's!
-
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..
-
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!
-
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 {
-
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!
-
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..
-
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!
-
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.
-
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>
-
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>"; }
-
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
-
Thank you again. I'm trying to implement http_build_query() in my code but no success. Here is how I try and I guess is not ok since doesn't work. if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button 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>"; //pages if ($lastpage < 7 + ($adjacents * 2)) { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?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=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?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=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?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=\"$targetpage?page=$counter\">$counter</a>"; } } } if ($page < $counter - 1) { ---> $_GET['page'] = $page + 1; ---> $pagination .= http_build_query($_GET, '', '&'); $pagination.= "<a href=\"$targetpage?page=$next\">next </a>"; } else $pagination.= "<span class=\"disabled\">next </span>"; $pagination.= "</div>\n"; } I've added this lines ( '--->' in front of them)
-
Thank you for the replay. So with WHERE clause in other query the problem is partially resolved. It show the proper number of pages in pagination but when I click next and go on second page show again whole data from db. This is the piece of code which I didn't post first time if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\"> previous</a>"; else $pagination.= "<span class=\"disabled\"> previous</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?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=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?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=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?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=\"$targetpage?page=$counter\">$counter</a>"; } } } if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\">next </a>"; else $pagination.= "<span class=\"disabled\">next </span>"; $pagination.= "</div>\n"; }
-
Hello, I have one search form and when I search something the result is whole records from the database not only the search term. Any help is appreciated. I will post only the part where is calculating the rows from db but if need I will post whole pagination script. $searchTerm = trim($_POST['term']); $adjacents = 3; $sql1 = mysql_query("SELECT * FROM images ORDER BY id ASC"); $nr = mysql_num_rows($sql1); $limit = 6; $targetpage = "search.php"; $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; else $start = 0; if ($page == 0) $page = 1; $prev = $page - 1; // $prev = $page - 1 $next = $page + 1; // $next = $page + 1 $lastpage = ceil($nr/$limit); //lastpage = total pages / items per page. $lpm1 = $lastpage - 1; $pagination = ""; .... .... // pagination ... ... // while loop for the results $sql = "SELECT id, name, caption FROM images WHERE caption LIKE '%".$searchTerm."%' ORDER BY id DESC LIMIT $start, $limit"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $output.= "<div class=\"container_image\">"; $output.= "<a href=\"/pic-".$row['id'].".html\"><img src=\"/upload/".$row['name']."\" width=\"210\" height=\"150\"/></a>"; $output.= "</div>"; }
-
Seems good tut but have one question how exactly I can make like in the link wich I show. When is clicked category only then to show sub-category not all at once. Is it possible with php or I need to use other technique? Now I have full list of categories and sub/sub-sub-category.
-
Hello, New to php&mysql here and need a little help. I want to make category list with sub-categories and sub-sub-categories. The goal is when I load website I will see full list with master(root)categories . Then when I click some categories should load sub-category and if I click on sub-category should load sub-sub-category. Something like this: Computers -> Motherboards -> Model 1 -> Model 2 -> etc. Monitors -> Model 1 -> Model 2 As you can see max level of sub-category will be 2+root. Here is the perfect example what I want to do http://3docean.net/category I don't understand(know) also how exactly will look my database table? How to store categories and sub-categories. I don't want someone to write full code etc as I want to learn it but will be great if you guys can show me some good tutorial how to make it mostly database structure. Thank you in advance! p.s. Sorry for my English!
-
Hello, So I'm trying to take take description of content when I share it but can't figure out how. I have this: $currid = $line[0]; if (isset($_GET['id'])) { do { $currid = $line[0]; if ($currid == $_GET['id']) break; $previd = $currid; $line = mysqli_fetch_array($result, MYSQL_BOTH); } while ($line); } if ($line) { echo "<h1>".$line['caption']."</h1><br />"; ///rest of code And trying with this but content is empty. If I $_GET['id'] is ok and I get ID in content. <meta property="og:description" content="<?php echo $_GET[$line['content']];?>" /> Can anyone help me with this?
-
I've tried also on href links this but doesn't work also.. show empty page and without css in .htaccess RewriteRule ^category/(.*) pic.php?cat_id=$1&id=$2 [L,QSA] and in pic.php <a href="category/'.$cat_id.'/'.$line[0].'">Next </a>
-
Hi, first I'm sorry if I posting this in wrong forum. So I've tried to make my url a little bit more 'user friendly' with .htaccess. For example this URL's http://localhost/index.php?currentpage=1 http://localhost/page.php?pn=1 http://localhost/gifs.php?id=1 http://localhost/pic.php?cat_id=1&id=5 My .htaccess content is: Options +FollowSymlinks RewriteEngine on RewriteRule ^currentpage/([^/]*)$ /index.php?currentpage=$1 [L] RewriteRule ^pn/([^/]*)$ /page.php?pn=$1 [L] RewriteRule ^id/([^/]*)$ /gifs.php?id=$1 [L] RewriteRule ^category-([^/]*)/([^/]*)$ /pic.php?cat_id=$1&id=$2 [L] ErrorDocument 404 http://localhost/404.php But it doesn't work...
-
Thank you a lot!
-
Thank you for your explanation. I know that my code is ... mess. I will try to make it right and better. p.s. The link that you gave me isn't work. It's empty page.