Jump to content

jaxdevil

Members
  • Posts

    268
  • Joined

  • Last visited

About jaxdevil

  • Birthday 10/03/1976

Contact Methods

  • AIM
    newclearscott
  • Website URL
    http://www.jaxdevil.com
  • Yahoo
    newclearscott

Profile Information

  • Gender
    Male
  • Location
    South Beach, Miami, FL, USA

jaxdevil's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. I've been trying to come at this problem from multiple angles and can't seem to figure it out. I have my update statement and it updates the other fields but not the field that is set as a decimal(20,5) type. I have tried formatting the number to be 5 decimal places, padded left with zeros so it is 20 characters long with 5 decimals, but it will not update. I can copy the query into phpmyadmin and run the update statement and it works fine, but in php it will update every field that is modified within the exact same query but not the decimal(20,5) field. Any ideas how to get around this issue? Thanks in advance to anyone who can help here.
  2. Never mind... got it... SELECT DISTINCT(`pc`.`pid`) AS `dpid`, `c`.`category_path` AS `category_path`, `c`.`parent` AS `cid`, `pa`.`name` AS `pa_name`, `pa`.`options_con` AS `pa_options_con`, `pa2`.`name` AS `pa2_name`, `pa2`.`options_con` AS `pa2_options_con` FROM `catalog` AS `c`, `products` AS `p`, `products` AS `p2`, `products_categories` AS `pc`, `brand_names` AS `bn`, `products_attributes` AS `pa`, `products_attributes` AS `pa2` WHERE `c`.`cid`=`pc`.`cid` AND `p`.`pid`=`pc`.`pid` AND `pc`.`bid`=`bn`.`id` AND `bn`.`brand_name`='begreen' AND `c`.`level`='3' AND `c`.`url_default` LIKE 'ca%' AND `p`.`pid`=`pa`.`pid` AND `pa2`.`pid`=`p`.`pid` AND (`pa`.`name`='Ink Type' AND ((`pa`.`options_con` LIKE '%|Other|%')) OR (`pa2`.`name`='Point Type' AND (`pa2`.`options_con` LIKE '%|0.7mm|%'))) ORDER BY `c`.`category_path` ASC That was a pain.. grrrr
  3. Tried revising it with this: SELECT`pc`.`pid` AS `dpid`, `c`.`category_path` AS `category_path`, `c`.`parent` AS `cid`, `pa`.`options_con` AS `pa_options_con`, `pa2`.`options_con` AS `pa2_options_con` FROM `catalog` AS `c`, `products` AS `p`, `products` AS `p2`, `products_categories` AS `pc`, `brand_names` AS `bn`, `products_attributes` AS `pa`, `products_attributes` AS `pa2` WHERE `c`.`cid`=`pc`.`cid` AND `p`.`pid`=`pc`.`pid` AND `pc`.`bid`=`bn`.`id` AND `bn`.`brand_name`='begreen' AND `c`.`level`='3' AND `c`.`url_default` LIKE 'ca%' AND `p`.`pid`=`pa`.`pid` AND `p2`.`pid`=`pa2`.`pid` AND `p`.`pid`=`p2`.`pid` AND (`pa`.`name`='Ink Type' AND (`pa`.`options_con` LIKE '%|Green|%')) AND (`pa2`.`name`='Point Type' AND (`pa2`.`options_con` LIKE '%|0.7mm|%')) ORDER BY `c`.`category_path` ASC Since the products_attributes table contains both the pid (product ID) a name (the name of option type) and also the different options concatenated with a pipe "|" to separate them for searches. So i figured limiting those two to looking for the ones that are of the Ink Color or Tip Type that match the selected options the user sent as variables it would work, NOT. I'm suckin today. Someone with a big brain lend a lesser mind a hand
  4. Ok, I am trying to find all the results in a table that match specific variables (obviously) but there is a table that contains both ink types and tip types, and I am trying to locate those that match the ink type and color types selected. I have tried numerous queries with the same zero result, even though I know those brands have those ink and color types available. Here is my query: SELECT DISTINCT(`pc`.`pid`) AS `dpid`, `c`.`category_path` AS `category_path`, `c`.`parent` AS `cid` FROM `catalog` AS `c`, `products` AS `p`, `products_categories` AS `pc`, `brand_names` AS `bn`, `products_attributes` AS `pa`, `products` AS `p2`, `products_attributes` AS `pa`, `products_attributes` AS `pa2` WHERE `c`.`cid`=`pc`.`cid` AND `p`.`pid`=`pc`.`pid` AND `pc`.`bid`=`bn`.`id` AND `bn`.`brand_name`='begreen' AND `c`.`level`='3' AND `c`.`url_default` LIKE 'ca%' AND `p`.`pid`=`pa`.`pid` AND `p2`.`pid`=`pa2`.`pid` AND (`pa`.`options_con` LIKE '%|Green|%') AND (`pa2`.`options_con` LIKE '%|0.7mm|%') ORDER BY `c`.`category_path` ASC Any help will be greatly appreciated.
  5. Just FYI. I have learned the hard way that you will need to pay for Google API access to use this for any real number of queries. If you are going to use it for a couple words and a couple sites you will probably be fine. But anything more than 100 queries in a day will lock your IP (the IP of the machine the scripts reside on) for the rest of the day. Also, if you want to use Yahoo instead of Google change the $url ="" variable to this: $url = "http://search.yahoo.com/search?n=100&ei=UTF-8&va_vt=any&vo_vt=any&ve_vt=any&vp_vt=any&vf=all&vm=p&fl=0&fr=yfp-t-435&p=".$word."&vs=".$domain; Yahoo has the same type of limitation though they use a free (or so it appears) API (called BOSS) Thanks, SK
  6. I found an issue which could affect some people. I know it did mine. If you are searching for strings and not words (i.e. "black dog" and not just "black" or "dog") the search will fail, so I added in the following code just under the $url = "" variable setting within the wordLocator.class.php $url = str_replace(" ", "%20", $url); I updated the ZIP and RAR files on my site, and I am uploading a new ZIP file. If you plan to use strings and not just single words then either download this new set of scripts in the file attached, download using the links on my server, or copy the new wordLocator.class.php from the below code: wordLocator.class.php <?php /* * wordLocator: Locate links in specific domains containing specific key words * (C) 2011 Scott Alan Kline, http://scottalankline.me/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * See http://www.gnu.org/copyleft/lesser.html * */ /* * Example usage: * Include this class on a seperate php page and create an array of words to search for and an array of domains to search through. * Then call this function like this: wordLocator($words, $domains) with the $words variable being your search words and * the $domains being the domains you want to search through. * The output will be an array of all the full URL's of the pages containing those words. * This script can be used for locating blacklisted words on your domains without needing to search one domain at a time or * even one word at a time. The output can be displayed but could be a huge output so it would be best to input the data into a MySQL * table that you can go through using a seperate script. */ function wordLocator($words, $domains) { foreach($domains as $key => $domain) { foreach($words as $key2 => $word) { $url = "http://www.google.com/search?sclient=psy-ab&hl=en&source=hp&q=".$word."+site:".$domain."&pbx=1&oq=".$word."+site:".$domain."&aq=f&aqi=&aql=&gs_sm=e&gs_upl=663384l665689l3l667034l3l3l0l0l0l0l186l511l0.3l3l0&biw=1360&bih=494&cad=cbv&sei=mhoHT6CJNeHe0QH8urmkAg#sclient=psy-ab&hl=en&source=hp&q=".$word."+site:".$domain."&pbx=1&oq=".$word."+site:".$domain."&aq=f&aqi=&aql=&gs_sm=s&gs_upl=0l0l0l185738l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=78028554459641b2&biw=1360&bih=494"; $url = str_replace(" ", "%20", $url); $input = @file_get_contents($url) or die("Could not access file: $url"); $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; if(preg_match_all("/$regexp/siU", $input, $matches)) { $domaintld = str_replace(".com", "", $domain); $pattern = "#^https?://([a-z0-9-]+\.)*".$domaintld."\.com(/.*)?$#"; foreach($matches as $matche) { foreach($matche as $match) { if(preg_match($pattern, $match)) { $urlArray[] = $match; } else { $urlArrayX[] = $match; } // if pregmatch pattern match } // end of foreach matche as match } // end of foreach matches as matche } // end of if pregmatchall } // end of foreach words as key2 to word } //end of foreach domains as key to domain $urlArray = array_unique($urlArray); return $urlArray; } // end of wordLocator function ?> 17279_.zip
  7. OK, I was able to figure this out using a second regexp to basically filter the results. I compiled this all into a compact function/class and am sharing it for anyone else who wants to utilize the same functionality. Here are the files RAR'd: http://scottalankline.me/scripts/speyeder.rar and ZIP'd: http://scottalankline.me/scripts/speyeder.zip I am copying the code for the 2 files below also. The reason I built this (which could be useful for someone else) is site compliance. If you have to verify that you're sits do not contain specific words to comply with your hosting or credit card processor requirements and have a LOT of sites and either forums or lots of individual copywriters/contributors then this would be handy for you. You can enter all of your domains into the $domains array and then all of the blacklisted words in the $words array and the script will search through Google for all of your sites pages that contain those terms and place them in an array. You can then view it on the screen, although I wouldn't recommend it. The results could be quite voluminous if you have a lot of terms to search for our a lot of domains, or both, then it could crash your browser or bog your computer down. The best way - the way I will utilize - will be to loop through the array and insert the results into a database table. I/You can then run through those entries using a separate script to check the links to confirm if the words still are on the pages (Google's indexing might not have been done since you removed the words previously) and then remove the entries that the words are not still on the pages which would leave a table of links for the pages you do need to fix. How you work through them will vary for each person, obviously. But hopefully this script comes in handy for someone else and not just myself. Here are the two scripts and their file names: speyeder.php <?php include('wordLocator.class.php'); //Create an array of the words we will be searching for $words = array('its', 'the', 'end', 'of', 'the', 'world', 'as', 'we', 'know', 'it'); //Create an array of the domains to search through in google $domains = array('example.com', 'anothersite.com', 'andanotherone.com'); //Lets output the results we obtained. echo "<pre>"; print_r(wordLocator($words, $domains)); echo "</pre>"; ?> wordLocator.class.php <?php /* * wordLocator: Locate links in specific domains containing specific key words * (C) 2011 Scott Alan Kline, http://scottalankline.me/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * See http://www.gnu.org/copyleft/lesser.html * */ /* * Example usage: * Include this class on a seperate php page and create an array of words to search for and an array of domains to search through. * Then call this function like this: wordLocator($words, $domains) with the $words variable being your search words and * the $domains being the domains you want to search through. * The output will be an array of all the full URL's of the pages containing those words. * This script can be used for locating blacklisted words on your domains without needing to search one domain at a time or * even one word at a time. The output can be displayed but could be a huge output so it would be best to input the data into a MySQL * table that you can go through using a seperate script. */ function wordLocator($words, $domains) { foreach($domains as $key => $domain) { foreach($words as $key2 => $word) { $url = "http://www.google.com/search?sclient=psy-ab&hl=en&source=hp&q=".$word."+site:".$domain."&pbx=1&oq=".$word."+site:".$domain."&aq=f&aqi=&aql=&gs_sm=e&gs_upl=663384l665689l3l667034l3l3l0l0l0l0l186l511l0.3l3l0&biw=1360&bih=494&cad=cbv&sei=mhoHT6CJNeHe0QH8urmkAg#sclient=psy-ab&hl=en&source=hp&q=".$word."+site:".$domain."&pbx=1&oq=".$word."+site:".$domain."&aq=f&aqi=&aql=&gs_sm=s&gs_upl=0l0l0l185738l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=78028554459641b2&biw=1360&bih=494"; $input = @file_get_contents($url) or die("Could not access file: $url"); $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; if(preg_match_all("/$regexp/siU", $input, $matches)) { $domaintld = str_replace(".com", "", $domain); $pattern = "#^https?://([a-z0-9-]+\.)*".$domaintld."\.com(/.*)?$#"; foreach($matches as $matche) { foreach($matche as $match) { if(preg_match($pattern, $match)) { $urlArray[] = $match; } else { $urlArrayX[] = $match; } // if pregmatch pattern match } // end of foreach matche as match } // end of foreach matches as matche } // end of if pregmatchall } // end of foreach words as key2 to word } //end of foreach domains as key to domain $urlArray = array_unique($urlArray); return $urlArray; } // end of wordLocator function ?> 17278_.zip
  8. Hello everyone! Its been over a year since I have been on here but I need some help with a regex and regex is definitely my weak spot. I am crawling search results looking for specific results where the link belongs to a specific domain. As it is my script crawls the pages, scrapes them, places them (all the <a href=""></a> hyperlinks). The problem is there are a ton of hyperlinks on the search results page that are not the actual results links, like the links to loggin to your account, or for google plus, or for news.google.com, etc. So I want to modify the regex in the preg_match_all that is matching the hyperlinks and grabbing them to ONLY grab hyperlinks that contain the domain that was targeted. So I have the variable $domain which contains the domain name I need to match in the a href so how can I include that in the following regex code to ONLY grab the links that have that domain name in the hyperlink? $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; if(preg_match_all("/$regexp/siU", $input, $matches)) { echo "<pre>"; print_r($matches); echo "</pre>"; } // end of if pregmatchall As I said before, regex is definitely my weak point. I know I should spend a weekend doing noting but regex practicing to master it myself, but for now is there someone who is a regex master who can lend me a hand? I read the topic on this specific board about asking for regex help so I will expand on that below, but hopefully you have what you need from above to help me with this. Thank you in advance guys, SK So you got a problem with regex? Great, here's some guidelines on asking: 1. Describe your problem or background that is important to it. A) See above. 2. Give sample data (the input data, the haystack...etc..) A) Also see above 3. Give the expected output/matches from your sample data. What I should end up with is arrays of hyperlinks that only contain the domain name in the $domain variable (for example lets say $domain = example.com - So only links like http://example.com/page.php or http://www.example.com/page.html etc should be contained within the arrays) 4. Give the actual output that you have if you've attempted something already. A) Well, I echoed out everything (all of the variables) for debugging purposes - I will be turning them off - but you can see the output here (not the actual script but a copy of it in a public directory) http://specialcreative.com/php/spider.php 5. Provide code if necessary, if your problem concerns it. A) See Above. 6. We assume its a php regex related as this is phpfreaks, but you still need to specifiy (if not obvious) if you are talking about POSIX (ereg) or PCRE (preg) flavor. A) Its definitely in PHP - always 7. Be patient/grateful and don't demand things. Regex questions may take longer than expected to be answered, they're tougher sometimes. A) Tell me about it. I believe it, if it was easy I would have mastered it myself by now, its the calculus of the coding world in my opinion.
  9. That was it. I have been without a day off for too long, its always something small that takes up the bulk of time to figure out. I marked this as solved, if you want a couple of months of free hosting (for PFMaBiSmAd only) message me on here and I will hook you up. You saved me some time this evening thats for certain! Thanks again, SK
  10. I have a problem, its very strange. When my script tries to write back the values I have it does all of them but the datetime string I compile to insert back to the table. It simply does not update the datetime field with this data, and when I switch the value from being updated into the datetime field and instead inserted into a varchar field, it does update, but every time it updates only with the character 0 (zero). Below is my code. Anyone know a reason why a script would write a number 0 (zero) to a table instead of the value you select? I can manually update the table in phpmyadmin with the data, but through the script it just inserts a number zero. Its a very short script below. BTW, I had it echo the variable that it is inserting and it echos as it should, as "2009-11-05 11:59:59", which is perfectly formatted for a datetime field, but in any evnet it should still not insert as a numeral 0 (zero) in a plain varchar field. Any help is GREATLY appreciated! If someone wants it I will give you a month or two of free hosting on my servers, you can use it to host your site or just use it as off-site testing space. It is filled with all the add-ons (imagemagick ,suhosin, imagick, magicwand, zend, everything) I REALLY need to figure this problem out! Thanks in advance guys, SK <?php //move to grab all the entries of events that do not have a day of the weekday listed $query = "SELECT * FROM mst_events WHERE `weekday`=''"; $result = mysql_query($query); $n=0; while ($aEvent = mysql_fetch_array($result)){ $aEventt[$n]['id'] = $aEvent['id']; $aEventt[$n]['month'] = $aEvent['month']; $aEventt[$n]['day'] = $aEvent['day']; $aEventt[$n]['year'] = $aEvent['year']; $n++; } //now determine the weekday for the given month, day, and year combination foreach($aEventt as $key => $value) { $aEventt[$key]['weekday'] = date("l", mktime(0, 0, 0, $aEventt[$key]['month'], $aEventt[$key]['day'], $aEventt[$key]['year'])); } // now compile a datetime format fro mysql and insert the weekday and the datetime stamp into the table for each line item we just retrieved the values for (all the ones without weekdays listed yet) foreach($aEventt as $keye => $valuee) { $day = str_pad($aEventt[$keye]['day'], 2, "0", STR_PAD_LEFT); $month = str_pad($aEventt[$keye]['month'], 2, "0", STR_PAD_LEFT); $year = $aEventt[$keye]['year']; $datenotime = $year."-".$month."-".$day." 11:59:59"; mysql_query("UPDATE mst_events SET `weekday`='".$aEventt[$keye]['weekday']."' AND `datetime`='$datenotime' WHERE id='".$aEventt[$keye]['id']."'") or die(mysql_error()); } ?>
  11. That was sort of it, I did not have mod_speling module active in apache on the external web host, and it is active in wamp. The urls it is pulling were all in lower case and the diretcory is a clone of the files on the local files server, so they were a mix of capital and lowercase characters. Added mod_speling and it works perfect now Thanks!
  12. I am having a strange problem. On my local wamp installation this below code works, and on my web host it does not. The bottom code ($files1) works on my web host but not on my wamp. So where it works on one system it doesn't work on the other, and where it doesn't work on one system it does work on the other. Its very odd. I turned error reporting on and receive this message: for each iteration of the foreach statement where it runs a new scandir and chdir for each path that is stored in the database table. And on the bottom code I get that error, but only on the last test code ($file1) where it is looking for the folder in the same directory it is in, the main code works like a charm on my local host, it grabs the folder paths, changes directory to them, and scans the contents, adding them to the array. I put my code right below, and under that a copy of the output on my remote host, and then a copy of the output on my local wamp install. <?php // Mysql connection string session_start(); require('bouncer/inner_security_check.php'); // Pull seperator passed from last page. If no seperator then we are on the first page so the seperator is 0 (this will pull rows 1-100 for 100, and for 100 it will pull 101-200, etc.) $seperator_num = $_GET['seperator_num']; if ($seperator_num='') { $seperator_num='0'; } $offset = 1; $rowsPerPage = '100'; // Now we are going to access the folders_table and put each folders full path one at a time into an array $query = "SELECT `folder_path` FROM `master_templates` LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error:'.mysql_error()); $my_count = mysql_num_rows($query); while($row = mysql_fetch_array($result)){ $folders[] = $row['folder_path']; } print_r($folders); // Now we are going to iterate through these array values (the folder paths) and scan directory on them. Adding an array to the array using their entry as the arrays id. foreach($folders as $key => $value) { $full_path = $value; $marker = strrpos( $value, '/' ) ; $value2 = substr( $value, 0, $marker ) ; $value = substr( $value, $marker ) ; $directory = $_SERVER['DOCUMENT_ROOT'].$value2; $folder = preg_replace('/\//', '', $value); echo "Directory: ".$directory; chdir($directory); $folder_data[$full_path] = scandir($folder); } print_r($folder_data); echo "<br>"; $files1 = scandir("cronjobs"); print_r($files1); ?> Link to the 'view source' contents of the web server install of the above, including ERRORS ALL on. (this is the one that doesn't work). Also includes a link to a html version of my phpinfo page http://temp-server.info/folder_paths.txt http://temp-server.info/phpinfo.php.htm Link to the 'view source' contents of the local WAMP install of the above, including ERRORS ALL on (this one is working how I want). Also includes an html generation of my local wamp phpinfo page. http://temp-server.info/folder_paths_local_wamp.txt http://temp-server.info/phpinfo_local_wamp.php.htm Anyone have an idea or see what I am missing?
  13. I figured it out. The problem was with escapeshellarg on $db_name , it places single quotes around the variable so it was screwing up the execution of the page. I also switched the last three $result to their own functions, and used file_get_contents() for them instead of CURL. I only used curl on the first one. I don't think those were working in CURL because of the ampersands they contained. It works perfect now. I plugged this into the aMember signup page so when a user signs up a new database is created for them and when they loggin they are using their own database, it also uplaods the structure and default data to their new database. Problem solved!
  14. I have a code snippet which is supposed to create a database, add a user to MySQL, and add that user to the new database with all privileges. I am copying it below. It is creating the new database, but not creating the user or adding it to the database. Can anyone tell what I am doing wrong on there? Oh yeah, the final $result I added is to a page that is a seperate query altogether that inserts the tables and data, but that is run last so I don't think that is affecting the user creation. Here is the code (I changed the username, password, and URL to dummy data): ############################################################### # cPanel Database Creator 1.2 ############################################################### # Visit http://www.zubrag.com/scripts/ for updates ############################################################### // cPanel username (you use to login to cPanel) $cpanel_user = "username"; // cPanel password (you use to login to cPanel) $cpanel_password = "xxxxxx"; // cPanel domain (example: mysite.com) $cpanel_host = "somedomain.com"; // cPanel theme/skin, usually "x" // Check http://www.zubrag.com/articles/determine-cpanel-skin.php // to know it for sure $cpanel_skin = "x"; // Script will add user to database if these values are not empty // User wil have ALL permissions $db_name = $u['login']; $db_username = $u['login']; $db_userpass = 'xxxxxx'; // Update this only if you are experienced user or if script does not work // Path to cURL on your server. Usually /usr/bin/curl $curl_path = "/usr/local/bin/curl"; ////////////////////////////////////// /* Code below should not be changed */ ////////////////////////////////////// function execCommand($command) { global $curl_path; if (!empty($curl_path)) { return exec("$curl_path '$command'"); } else { return file_get_contents($command); } } // escape db name $db_name = escapeshellarg($db_name); // will return empty string on success, error message on error $result .= execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/x/sql/adddb.html?db=$db_name"); // create user $result .= execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/x/sql/adduser.html?user=$db_username&pass=$db_userpass"); // assign user to database $result .= execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/x/sql/addusertodb.html?user=$cpanel_user_$db_username&db=$cpanel_user_$db_name&ALL=ALL"); // insert tables and data $result .= execCommand("http://$cpanel_host/members/dbstructure.php?acct=$db_name");
  15. Thanks! Using your suggesttion I was able to locate the issue. On this line: preg_match_all( "/\<SPAN.*?>(.*?)\<\/SPAN\>.*?\<A.*?\>(.*?)\<BR\>/is", $byname[0], $moviedata ); The $byname should be double arrayed like this: preg_match_all( "/\<SPAN.*?>(.*?)\<\/SPAN\>.*?\<A.*?\>(.*?)\<BR\>/is", $byname[0][0], $moviedata ); That fixed it! Thanks, SK
×
×
  • 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.