Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. Even lighter, not sure what the notify value is, don't see that in your code. if($parsed_json->active == true){ echo $notify; }
  2. I do give you some credit, to think this all out and create it all in a day, top of that to share it. Good for you.
  3. So modules without the cms. I'm all for making it simple and using imagination, others had those same ideas and they evolved into frameworks or CMS. Maybe one day we will all be reading about someone not liking FREE-FROM-CMS, hey you never know. CMS has the purpose to make non developers create websites fast and easy while also giving experienced coders a good platform to start making it custom. Frameworks make new or even experienced coders keep consistency. Why code everything from scratch when is proven working ones available, some work on a tight time schedule. If are a developer for a living is essential to know a multitude of such things or turning down work. Most have their specific uses, can't say one is bad or the other is good, depends on the person.
  4. I'd say so, lots of work to show a random image on a page with 2 buttons. To copy and host them is like image theft. loading a huge image isn't fun for many, I would hotlink from imgurl If I was to do such a project: simple image scraper using curl and php, most likely using dom and domxpath set a cron job to run the script scrape hyperlinks/alternately image tags and (match imgurl pattern if just want those, extract just the codes and normalize links the same for all imgurl) store full href links to expand upon this a day to other sites set a unique index on the url to prevent duplicates If the site scraping has adequate data just use their titles and or descriptions, otherwise go to the image source pages and obtain that data. In this case imgurl has all the opengraph meta data. I would hotlink from imgurl, cache smaller thumbnails and do a gallery in pagination or some lazy loader jquery or js/ajax If cached image exists load that...otherwise scale the image down or merely use css for a max width or height as a thumbnail. The frontend would be a mobile css design and more on the page than just a gallery.
  5. If you do a var_dump() on $status will see is bool(false) false true/false values in json surrounded quotes is a string otherwise is a boolean can check it something like this if($parsed_json->active == true){ $status = "true"; }else{ $status = "false"; } Or this: $status = ($parsed_json->active) ? 'true' : 'false'; var_dump() would now be string(5) "false"
  6. Thank you very much for the advancement and the kind words.
  7. Use their api, rip the url from that using preg_match
  8. Minimal response for a minimal question. $sql = "UPDATE table_name SET score='score+".$score."' WHERE user='".$user."'"; If you need whole numbers can use ROUND()
  9. Was there ever a spam filter for the posts here? It seems like I see a lot of spam since the last server crashes. I'm sure something can be added to the forum. Minimum 1 approved post before including a url in a post? Blocking the common bad words?
  10. This is the "Website Critique" and not "Looking to take people from this site and make them admins and mods on your own"
  11. Everything else besides the 4 there now? I'm going by the title of "Freedom-From-CMS", a well constructed CMS has a lot into it. What you have are more like snippets to add additionally. Is piles of sites that show code snippets.
  12. relative is no leading slash absolute will have a leading slash You don't want to use a relative path, an absolute path of the current directory is what you need If this script isn't running from the same directory it wouldn't be able to find it, so try adding the directory path You can use set_include_path() Some OS are slightly different. In php scripts I add this to locate the directory name and it's separator $full_path = dirname(__FILE__) . DIRECTORY_SEPARATOR."/projects/test.php";
  13. Explain a little more what you want to accomplish, a snippet of the file and expected results. Do you want to check to see if the word exists in a line of the file? For the record it's probably better to use a database for this, searching large text files is not friendly and a resource hog.
  14. Do you have any code at all? Are you using their api or trying to get it directly from your tweets page? If the page is public can use curl or file_get_contents to obtain the raw html. If you need to securely log in need to use curl and also send your name and password. Once you have text holding the url can use preg_match() or preg_match_all() using some regex patterns for urls Methods to scrape the page not using the api simplehtmldom can work Here is an example using DOM and DOMXPath This captures all links on the page and used preg_match to find the shortened ones they used in tweets. You can expand on this or change to your specific needs. It's possible to scrape just specific sections like div,span,class and so on but I kept this simple only looking for a tags within the body tag. <?php $target = "https://twitter.com/hashtag/GameofThrones"; $html = @file_get_contents($target); if (!$html) { die("Unable to connect to that url"); } $hrefs = array(); $url_array = array(); $short_links = array(); $dom = new DOMDocument(); @$dom->loadHTML($html); $xpath = new DOMXPath($dom); $hrefs = $xpath->query('/html/body//a'); for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $link = $href->getAttribute('href'); if (!preg_match("~(\/\/|twitter\.com|\/\/t\.co)~i", $link)) { $link = "https://twitter.com" . $link; } $title = trim($href->getAttribute('title')); if ($title == '') { $title = trim($href->plaintext); } if ($title == '') { $title = trim($href->nodeValue); } if ($title == '') { $title = $link; } if ($link != '' && $title != '') { //all links $url_array[] = array( "href" => $link, "title" => $title ); //only shortened links in posts if (preg_match("~(\/\/t\.co)~i", $link)) { $short_links[] = array( "href" => $link, "title" => $title ); } } } $hrefs = array(); //all links if(!empty($url_array)){ $url_array = array_map("unserialize", array_unique(array_map("serialize", $url_array))); echo "<pre>"; print_r($url_array); echo "</pre>"; } //only shortened links if(!empty($short_links)){ $short_links = array_map("unserialize", array_unique(array_map("serialize", $short_links))); echo "<pre>"; print_r($short_links); echo "</pre>"; } ?> Results from all links too long to post here. Results from shortened links: Array ( [0] => Array ( [href] => http://t.co/DYNv3xCKZ2 [title] => http://ow.ly/MMeAJ ) [1] => Array ( [href] => http://t.co/E5o56STr1S [title] => pic.twitter.com/E5o56STr1S ) [2] => Array ( [href] => http://t.co/Ozfx1MUjkw [title] => http://huff.to/1E1mKzN ) [3] => Array ( [href] => http://t.co/uNKOLtlvn3 [title] => pic.twitter.com/uNKOLtlvn3 ) [4] => Array ( [href] => http://t.co/6J1fjdAEWO [title] => pic.twitter.com/6J1fjdAEWO ) [5] => Array ( [href] => http://t.co/PvYozVNzlW [title] => http://hypb.st/yMVvB ) [6] => Array ( [href] => http://t.co/Qob84GCHkK [title] => pic.twitter.com/Qob84GCHkK ) [7] => Array ( [href] => http://t.co/oujTU8fi0G [title] => http://bit.ly/1HbKTv6 ) [8] => Array ( [href] => http://t.co/1666f9Isdr [title] => pic.twitter.com/1666f9Isdr ) [9] => Array ( [href] => http://t.co/z16DX5wpwH [title] => http://read.bi/1K0CM5w ) [10] => Array ( [href] => http://t.co/nEdiO9RET9 [title] => pic.twitter.com/nEdiO9RET9 ) [11] => Array ( [href] => http://t.co/4lab9UEohK [title] => http://tmto.es/LsEAu ) [12] => Array ( [href] => http://t.co/tZoKeesROW [title] => http://go.ign.com/VpUdD4c ) [13] => Array ( [href] => http://t.co/uhDQPVCyZa [title] => pic.twitter.com/uhDQPVCyZa ) [14] => Array ( [href] => http://t.co/4UCXMAFU9z [title] => http://rol.st/1IsC6oZ ) [15] => Array ( [href] => http://t.co/1w00G18Fl4 [title] => pic.twitter.com/1w00G18Fl4 ) [16] => Array ( [href] => http://t.co/8H672kaNPY [title] => http://ow.ly/MMeP9 ) [17] => Array ( [href] => http://t.co/hp9UwlY9VZ [title] => pic.twitter.com/hp9UwlY9VZ ) [18] => Array ( [href] => http://t.co/iTotXTT5IV [title] => pic.twitter.com/iTotXTT5IV ) [19] => Array ( [href] => http://t.co/FPaiw4b3TG [title] => pic.twitter.com/FPaiw4b3TG ) [20] => Array ( [href] => http://t.co/my1VXGW2C7 [title] => http://thebea.st/1PB5oka ) [21] => Array ( [href] => http://t.co/w5fQVOGj14 [title] => pic.twitter.com/w5fQVOGj14 ) [22] => Array ( [href] => http://t.co/tCD3AWXR3N [title] => http://ANGRYGOTFAN.COM ) [24] => Array ( [href] => http://t.co/xC5Lz63b9y [title] => pic.twitter.com/xC5Lz63b9y ) [25] => Array ( [href] => http://t.co/I8p5uFjgF7 [title] => pic.twitter.com/I8p5uFjgF7 ) )
  15. I was curious why you are trying to echo them wrapped double quotes and commas Make it an array in the loop $sql = 'SELECT video_code FROM yt_videos WHERE yt_video_item_id="'.$vidid.'" ORDER BY RAND() LIMIT 10'; $result=mysqli_query($db_conx,$sql); $video_codes = array(); // Associative array while ( $row = mysqli_fetch_assoc($result)){ $video_codes[] = $row['video_code']; echo $row['video_code']."<br />"; } if(!empty($video_codes)){ print_r($video_codes); echo '"' . join('","', $video_codes) . '"'; }
  16. Can make a cron job to run scripts a timely manner to either check something or perform a task, can also include or write code right into your scripts some actions to take upon certain conditions, even exec a shell script. Since you have cpanel https://documentation.cpanel.net/display/ALD/Cron+Jobs
  17. Option 1: In the database create a unique index using a unique constraint to prevent duplicates Since people could have the same name in the same city and also state...most likely have to do all four. This will prevent a new registration for someone with the same values. It's common for people with the same names in the same area. Using more information could lessen the chances, date of birth,nickname,password comes to mind. ALTER TABLE TableName ADD CONSTRAINT allUnique UNIQUE(FirstName, LastName, City, State); Option 2: In some circumstances can set the primary as a unique and then use INSERT IGNORE, even including ON DUPLICATE KEY UPDATE Option 3: Redirect the user elsewhere with either header() or a meta refresh <meta http-equiv="refresh" content="0;URL='http://site.com/'" /> Option 4: Perform a query to check if all 4 values from your form returns at least one result, only if they don't exist do the insert. Option 5: Another method is to set a unique token in a session, then check for it, if exists then was a resubmit. Option 6: More extreme is to use jquery or javascript and disable the submit button after submission.
  18. The one you selected be fine. Besides my 2 dedicated at my home I also have a vps with who knows who, is paid for for 6 years. They keep selling the company to other people, originally my friend owned it and I paid $6 a month in advance. Have rented the biggest dedicated server with limestone networks zero issues for 3 years and awesome support, usa based. Could not have one nude image there, they were strict. I have a search engine and websites index so needed to move on. I've rented my own and also managed other peoples servers pretty much every popular hosting out there, most really suck and are overpriced. You don't want ovh for some reason but I found these servers a lot better priced than anyone out there. For sure would have enough speed,cpu,memory and storage to do many things. https://www.ovh.com/us/dedicated-servers/enterprise/ It will all depend what your site is actually doing, if shared hosting can't do it are forced to go dedicated. I set up a client with the VPS Classic 4 there not long ago and worked well. I wouldn't even consider having a server less than these specs. For 22 bucks a month can't beat it. https://www.ovh.com/us/vps/vps-classic.xml
  19. if($_GET){ GET always exists as an empty array You didn't post your current code so will summarize what to do if(isset($_GET['FirstName']) && trim($_GET['FirstName']) !=''){ $FirstName = trim($_GET['FirstName']); } if(isset($_GET['LastName']) && trim($_GET['LastName']) !=''){ $lastName = trim($_GET['LastName']); } if(isset($_GET['City']) && trim($_GET['City']) !=''){ $City = trim($_GET['City']); } if(isset($_GET['State']) && trim($_GET['State']) !=''){ $state = trim($_GET['State']); } //checking to see if all the variables exist, also can do isset() for each if($FirstName && $lastName && $City && $state){ //then do connection,escape variables and insert } alternately can add your own errors $errors = array(); if(isset($_GET['FirstName']) && trim($_GET['FirstName']) !=''){ $FirstName = trim($_GET['FirstName']); }else{ $errors['firstname'] = "first name missing"; } if(isset($_GET['LastName']) && trim($_GET['LastName']) !=''){ $lastName = trim($_GET['LastName']); }else{ $errors['lastname'] = "last name missing"; } if(isset($_GET['City']) && trim($_GET['City']) !=''){ $City = trim($_GET['City']); }else{ $errors['city'] = "city missing"; } if(isset($_GET['State']) && trim($_GET['State']) !=''){ $state = trim($_GET['State']); }else{ $errors['state'] = "state missing"; } //checking to see if all the variables exist, also can do isset() for each if(empty($errors)){ //then do connection,escape variables and insert }else{ foreach($errors as $error){ echo $error."<br />"; } }
  20. In php using delay or sleep would hang the page until entire script completed. Possible in javascript and why said to use a lazy loader with jquery or combination javascript and ajax
  21. Sure they can be limiting the amount of requests, could act like a ddos attack and take their server down. I certainly feel it is. First of all why are you doing 60+ api requests a single page load. Lower the amount per page and create yourself a pagination to get the next set of results their api Think about what you are doing, a person has to wait a long time and load piles of information they may never even look at. Not to mention your server has to do this each user visiting every page. You can cache the api results and then show your local data if exists first...otherwise connect to api for fresh data In circumstances like this where the api service has limits ,slow or even down times.....I cache the json responses Other possible ways would be to use a lazy loader with jquery/ajax loading content as a person scrolls the page. Ever see sites with more...more...more... Is others that click a button for more Yet is others that load as you scroll down the page. I will give yet another solution, don't use their api and instead use their feeds. Looks like they show 34 at a time. Create a feed parser to display latest data or make a feed aggregator. Keep hitting the feeds in a timely manner and store the data a database Now you can show as many as desire without going overboard and not have these issues.
  22. Right click on the link and "copy link location" or "copy link address" I can see the full url in the address bar firefox or chrome.
  23. First thing you need to do is load this information into a database. I would save the excel as a csv file (tab delimited is probably less prone for errors in parsing) and use load data infile into mysql Make a form with dropdown selects with departure and arrival locations. The POST information from the form would be dynamic values for a select query pdo or mysqli for the database connection It's important to use prepared statements or escaped user input if(isset($_POST)){ if(isset($_POST['departure']){ $departure = strtolower(trim($_POST['departure'])); } if(isset($_POST['arrival']){ $arrival = strtolower(trim($_POST['arrival'])); } if($departure && $arrival){ //mysql connection credentials $sql_host = "localhost"; // MySQL Host $sql_user = "user_name"; // MySql UserName $sql_pass = "user_password"; // MySql Password $sql_db = "my_database"; // MySql Database $sql_table = "my_table";// MySql Table //mysql connection $con=mysqli_connect($sql_host, $sql_user, $sq_pass, $sql_db); if (mysqli_connect_errno()) { die("Connection failed: ".mysqli_error($con)); } //escape the variables if using mysqli, will do it in select statement $query = "SELECT * FROM `$sql_table` WHERE `departure`='".mysqli_real_escape_string ($con,$departure)."' AND `arrival`='".mysqli_real_escape_string ($con,$arrival)."'"; //perform a mysql query $result = mysqli_query($con, $query); //if results returned display the data, else show was no data if(mysqli_num_rows($result) > 0){ while($row = mysqli_fetch_array($result)) { //show the data echo $row['departure'] . "<br />"; echo $row['arrival'] . "<br />"; } } else { echo "No results found"; } //close the connection mysqli_close($con); } You could also do a single dropdown and display any departing or arriving a certain location. $query = "SELECT * FROM `$sql_table` WHERE `departure`='".mysqli_real_escape_string ($con,$location)."' OR `arrival`='".mysqli_real_escape_string ($con,$location)."'";
×
×
  • 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.