Jump to content

lefreak

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by lefreak

  1. Hi Guys, I would like to implement a loading spinner when a button is clicked and a function is called to run a script in the background, just not sure how to do it. If possible I would like to keep it a simple css spinner if possible. My code looks like <div class="col-md-12 text-center" id="sync"> <button type="button" class="btn btn-primary" onclick="loadDoc()">Click here to synchronise</br>live stock quantities</button> </div> </div> </div> <script> function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("sync").innerHTML = this.responseText; } }; xhttp.open("GET", "sync.php", true); xhttp.send(); } </script> I would like to use the following css to load the spinner and hide the button if possible <div class="loader">Loading...</div> and the css .loader, .loader:after { border-radius: 50%; width: 10em; height: 10em; } .loader { margin: 60px auto; font-size: 10px; position: relative; text-indent: -9999em; border-top: 1.1em solid rgba(128,128,255, 0.2); border-right: 1.1em solid rgba(128,128,255, 0.2); border-bottom: 1.1em solid rgba(128,128,255, 0.2); border-left: 1.1em solid #8080ff; -webkit-transform: translateZ(0); -ms-transform: translateZ(0); transform: translateZ(0); -webkit-animation: load8 1.1s infinite linear; animation: load8 1.1s infinite linear; } @-webkit-keyframes load8 { 0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } } @keyframes load8 { 0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } } Any help would be appreciated.
  2. ok for anyone still following this topic I was on the completely wrong side of the tracks lol I changed the function completely to this and now it works as expected by removing the url in the array and leaving only the filename behind. function clear_string_from_characters( $string ) { $search = array( 'http://www.mysite.co.uk/store/images/', ); $replace = ''; return str_replace( $search, $replace, $string ); }
  3. I am trying to remove the tld from the url and leave only the filename
  4. I think I have narrowed it down to the clean urls function which is not just removing the url from the string but the entire string including the filename. I dont fully understand the contents of the preg_match. Eg. http://my-site.com/gifts/images/my-image.jpg I require the function to remove http://my-site.com/gifts/images/ and leave only the filename help would be appreciated as its got me stumped 😖 function containsTLD($string) { preg_match( "/(AC($|\/)|\.AD($|\/)|\.AE($|\/)|\.AERO($|\/)|\.AF($|\/)|\.AG($|\/)|\.AI($|\/)|\.AL($|\/)|\.AM($|\/)|\.AN($|\/)|\.AO($|\/)|\.AQ($|\/)|\.AR($|\/)|\.ARPA($|\/)|\.AS($|\/)|\.ASIA($|\/)|\.AT($|\/)|\.AU($|\/)|\.AW($|\/)|\.AX($|\/)|\.AZ($|\/)|\.BA($|\/)|\.BB($|\/)|\.BD($|\/)|\.BE($|\/)|\.BF($|\/)|\.BG($|\/)|\.BH($|\/)|\.BI($|\/)|\.BIZ($|\/)|\.BJ($|\/)|\.BM($|\/)|\.BN($|\/)|\.BO($|\/)|\.BR($|\/)|\.BS($|\/)|\.BT($|\/)|\.BV($|\/)|\.BW($|\/)|\.BY($|\/)|\.BZ($|\/)|\.CA($|\/)|\.CAT($|\/)|\.CC($|\/)|\.CD($|\/)|\.CF($|\/)|\.CG($|\/)|\.CH($|\/)|\.CI($|\/)|\.CK($|\/)|\.CL($|\/)|\.CM($|\/)|\.CN($|\/)|\.CO($|\/)|\.COM($|\/)|\.COOP($|\/)|\.CR($|\/)|\.CU($|\/)|\.CV($|\/)|\.CX($|\/)|\.CY($|\/)|\.CZ($|\/)|\.DE($|\/)|\.DJ($|\/)|\.DK($|\/)|\.DM($|\/)|\.DO($|\/)|\.DZ($|\/)|\.EC($|\/)|\.EDU($|\/)|\.EE($|\/)|\.EG($|\/)|\.ER($|\/)|\.ES($|\/)|\.ET($|\/)|\.EU($|\/)|\.FI($|\/)|\.FJ($|\/)|\.FK($|\/)|\.FM($|\/)|\.FO($|\/)|\.FR($|\/)|\.GA($|\/)|\.GB($|\/)|\.GD($|\/)|\.GE($|\/)|\.GF($|\/)|\.GG($|\/)|\.GH($|\/)|\.GI($|\/)|\.GL($|\/)|\.GM($|\/)|\.GN($|\/)|\.GOV($|\/)|\.GP($|\/)|\.GQ($|\/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|\/)|\.PR($|\/)|\.PRO($|\/)|\.PS($|\/)|\.PT($|\/)|\.PW($|\/)|\.PY($|\/)|\.QA($|\/)|\.RE($|\/)|\.RO($|\/)|\.RS($|\/)|\.RU($|\/)|\.RW($|\/)|\.SA($|\/)|\.SB($|\/)|\.SC($|\/)|\.SD($|\/)|\.SE($|\/)|\.SG($|\/)|\.SH($|\/)|\.SI($|\/)|\.SJ($|\/)|\.SK($|\/)|\.SL($|\/)|\.SM($|\/)|\.SN($|\/)|\.SO($|\/)|\.SR($|\/)|\.ST($|\/)|\.SU($|\/)|\.SV($|\/)|\.SY($|\/)|\.SZ($|\/)|\.TC($|\/)|\.TD($|\/)|\.TEL($|\/)|\.TF($|\/)|\.TG($|\/)|\.TH($|\/)|\.TJ($|\/)|\.TK($|\/)|\.TL($|\/)|\.TM($|\/)|\.TN($|\/)|\.TO($|\/)|\.TP($|\/)|\.TR($|\/)|\.TRAVEL($|\/)|\.TT($|\/)|\.TV($|\/)|\.TW($|\/)|\.TZ($|\/)|\.UA($|\/)|\.UG($|\/)|\.UK($|\/)|\.US($|\/)|\.UY($|\/)|\.UZ($|\/)|\.VA($|\/)|\.VC($|\/)|\.VE($|\/)|\.VG($|\/)|\.VI($|\/)|\.VN($|\/)|\.VU($|\/)|\.WF($|\/)|\.WS($|\/)|\.XN--0ZWM56D($|\/)|\.XN--11B5BS3A9AJ6G($|\/)|\.XN--80AKHBYKNJ4F($|\/)|\.XN--9T4B11YI5A($|\/)|\.XN--DEBA0AD($|\/)|\.XN--G6W251D($|\/)|\.XN--HGBK6AJ7F53BBA($|\/)|\.XN--HLCJ6AYA9ESC7A($|\/)|\.XN--JXALPDLP($|\/)|\.XN--KGBECHTV($|\/)|\.XN--ZCKZAH($|\/)|\.YE($|\/)|\.YT($|\/)|\.YU($|\/)|\.ZA($|\/)|\.ZM($|\/)|\.ZW)/i", $string, $M); $has_tld = (count($M) > 0) ? true : false; return $has_tld; } function clean($url) { $U = explode(' ',$url); $W =array(); foreach ($U as $k => $u) { if (stristr($u,".")) { //only preg_match if there is a dot if (containsTLD($u) === true) { unset($U[$k]); return clean( implode(' ',$U)); } } } return implode(' ',$U); }
  5. Sorry to bump but can anyone offer any help? Thanks
  6. Can anyone help with this problem as I have tried various things which either killed the script or did not work. Thanks
  7. thank you for the easy to understand help I am now not receiving any errors and the script is running however it is only retrieving 1 image and saving it in the folder as .jpg with out the name which is causing the script to report the image already exists. I added a function to clean the url from the image name before saving so not sure if that is what is causing the problem. <?php /* settings */ //folder for images saving $saveDir = "c:/wamp64/www/script/images/"; //database connection // Turn off all error reporting //error_reporting(0); $conn = mysqli_connect('localhost', 'root', '', 'tbl_temp_products'); function containsTLD($string) { preg_match( "/(AC($|\/)|\.AD($|\/)|\.AE($|\/)|\.AERO($|\/)|\.AF($|\/)|\.AG($|\/)|\.AI($|\/)|\.AL($|\/)|\.AM($|\/)|\.AN($|\/)|\.AO($|\/)|\.AQ($|\/)|\.AR($|\/)|\.ARPA($|\/)|\.AS($|\/)|\.ASIA($|\/)|\.AT($|\/)|\.AU($|\/)|\.AW($|\/)|\.AX($|\/)|\.AZ($|\/)|\.BA($|\/)|\.BB($|\/)|\.BD($|\/)|\.BE($|\/)|\.BF($|\/)|\.BG($|\/)|\.BH($|\/)|\.BI($|\/)|\.BIZ($|\/)|\.BJ($|\/)|\.BM($|\/)|\.BN($|\/)|\.BO($|\/)|\.BR($|\/)|\.BS($|\/)|\.BT($|\/)|\.BV($|\/)|\.BW($|\/)|\.BY($|\/)|\.BZ($|\/)|\.CA($|\/)|\.CAT($|\/)|\.CC($|\/)|\.CD($|\/)|\.CF($|\/)|\.CG($|\/)|\.CH($|\/)|\.CI($|\/)|\.CK($|\/)|\.CL($|\/)|\.CM($|\/)|\.CN($|\/)|\.CO($|\/)|\.COM($|\/)|\.COOP($|\/)|\.CR($|\/)|\.CU($|\/)|\.CV($|\/)|\.CX($|\/)|\.CY($|\/)|\.CZ($|\/)|\.DE($|\/)|\.DJ($|\/)|\.DK($|\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6G($|\/)|\.XN--80AKHBYKNJ4F($|\/)|\.XN--9T4B11YI5A($|\/)|\.XN--DEBA0AD($|\/)|\.XN--G6W251D($|\/)|\.XN--HGBK6AJ7F53BBA($|\/)|\.XN--HLCJ6AYA9ESC7A($|\/)|\.XN--JXALPDLP($|\/)|\.XN--KGBECHTV($|\/)|\.XN--ZCKZAH($|\/)|\.YE($|\/)|\.YT($|\/)|\.YU($|\/)|\.ZA($|\/)|\.ZM($|\/)|\.ZW)/i", $string, $M); $has_tld = (count($M) > 0) ? true : false; return $has_tld; } function clean($url) { $U = explode(' ',$url); $W =array(); foreach ($U as $k => $u) { if (stristr($u,".")) { //only preg_match if there is a dot if (containsTLD($u) === true) { unset($U[$k]); return clean( implode(' ',$U)); } } } return implode(' ',$U); } //start and end table row to prevent timeout or hard server work $start = '1'; $end = '200'; /* end of settings */ //query for fetching the image urls $sql = 'SELECT image_url FROM tbl_temp_products ORDER BY id DESC LIMIT ' . $start . ',' . $end . ''; $res = $conn->query($sql); $count = 0; //this is for count the total row fetched $notify = ''; //this is for seeing result or errors while ($row = $res->fetch_assoc()) { $url = $row['image_url']; $dest = $saveDir . clean($row['image_url']) . '.jpg'; if (!file_exists($dest)) { //prevent file overwriting if (copy($url, $dest)) { $notify.= 'image saved: '. $row['image_url']; $count++; } else { $notify.= 'ERROR saving image: '. $row['image_url'] . '<br/>'; } } else { $notify.= 'image already exists: '. $row['image_url'] . '<br/>'; } } //output result echo 'TOTAL IMAGE SAVED: ' .$count .'\n'; echo $notify; ?>
  8. no need to be sorry, every little helps thank you do you mean ) or } this is the code now as it stands while ($row = $res->fetch_assoc()) { $url = $row(['image_url']); $dest = $saveDir . clean($row(['image_url'])) . '.jpg'; if (!file_exists($dest)) { //prevent file overwriting if (copy($url, $dest)) { $notify.= 'image saved: '. $row(['image_url']); $count++; } else { $notify.= 'ERROR saving image: '. $row(['image_url']); } } else { $notify.= 'image already exists: '. $row(['image_url']); } }
  9. thank you for helping previously Barand. I am now receiving this error which is this line $url = $row(['image_url']);
  10. I did think of that but still throws the error
  11. Thanks Barand, total rookie miss lol Also getting this error now which is the second }else{ if (!file_exists($dest)){ //prevent file overwriting if (copy($url, $dest)){ $notify.= 'image saved: '. $row(['image_url']); $count++; }else{ $notify.= 'ERROR saving image: '. $row(['image_url']); }else{ $notify.= 'image already exists: '. $row(['image_url']); } }
  12. Hi Guys, I have an issue with the following script which is throwing this error I just can not see the error, can anyone help (not even sure the script is going to work) <?php /* settings */ //folder for images saving $saveDir = "c:\wamp64\www\script\images\"; //database connection // Turn off all error reporting error_reporting(0); $conn = mysqli_connect('localhost', 'root', '', 'tbl_temp_products'); //start and end table row to prevent timeout or hard server work $start = '1'; $end = '200'; /* end of settings */ //query for fetching the image urls $sql = 'SELECT image_url FROM tbl_temp_products ORDER BY id DESC LIMIT ' . $start . ',' . $end . ''; $res = $conn->query($sql); $count = 0; //this is for count the total row fetched $notify = ''; //this is for seeing result or errors while ($row = $res->fetch_assoc()) { $url = $row(['image_url']); $dest = $saveDir . clean($row(['image_url'])) . '.jpg'; if (!file_exists($dest)){ //prevent file overwriting if (copy($url, $dest)){ $notify.= 'image saved: '. $row(['image_url']); $count++; }else{ $notify.= 'ERROR saving image: '. $row(['image_url']); }else{ $notify.= 'image already exists: '. $row(['image_url']); } } //output result echo 'TOTAL IMAGE SAVED: ' .$count .'\n'; echo $notify; ?>
  13. I am no expert and just looking for help and guidance in updating the script to work error free
  14. I have made a bit of progress since last nights issues but inevitably other issues have sprang up lol I have googled my little heart out trying to resolve this one with no luck function sql_fetchrow($query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } if($query_id) { $intQueryId = (integer) $query_id; $this->row[$intQueryId] = mysqli_fetch_array($query_id); // 212 return $this->row[$intQueryId]; // 213 } else { return false; } } the offending line $intQueryId = (integer) $query_id; I would say apart from the last few errors the script is now working and importing products and images into the database successfully.
  15. I will make it easier and post the entire file rather than snippets so you can see if(!defined("SQL_LAYER")) { define("SQL_LAYER","mysql"); class sql_db { var $db_connect_id; var $query_result; var $row = array(); var $rowset = array(); var $num_queries = 0; // // Constructor // function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true) { $this->persistency = $persistency; $this->user = $sqluser; $this->password = $sqlpassword; $this->server = $sqlserver; $this->dbname = $database; if($this->persistency) { $this->db_connect_id = mysql_pconnect($this->server, $this->user, $this->password); } else { $this->db_connect_id = mysqli_connect($this->server, $this->user, $this->password); } if($this->db_connect_id) { if($database != "") { $this->dbname = $database; $dbselect = mysqli_select_db($this->db_connect_id, $this->dbname); if(!$dbselect) { @mysql_close($this->db_connect_id); $this->db_connect_id = $dbselect; } } return $this->db_connect_id; } else { return false; } } // // Other base methods // function sql_close() { if($this->db_connect_id) { if($this->query_result) { mysql_free_result($this->query_result); } $result = mysql_close($this->db_connect_id); return $result; } else { return false; } } // // Base query method // function sql_query($query = "", $transaction = FALSE) { // Remove any pre-existing queries unset($this->query_result); if($query != "") { $this->num_queries++; //echo "[DEBUG] $query<br>"; $this->query_result = mysqli_query($this->db_connect_id, $query); } if($this->query_result) { unset($this->row[$this->query_result]); unset($this->rowset[$this->query_result]); return $this->query_result; } else { return ( $transaction == 'END_TRANSACTION' ) ? true : false; } } // // Other query methods // function sql_num_rows($query_id = 0) { return $this->sql_numrows($query_id); } function sql_numrows($query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } if($query_id) { $result = mysql_num_rows($query_id); return $result; } else { return false; } } function sql_affectedrows() { if($this->db_connect_id) { $result = mysql_affected_rows($this->db_connect_id); return $result; } else { return false; } } function sql_numfields($query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } if($query_id) { $result = mysql_num_fields($query_id); return $result; } else { return false; } } function sql_fieldname($offset, $query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } if($query_id) { $result = mysql_field_name($query_id, $offset); return $result; } else { return false; } } function sql_fieldtype($offset, $query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } if($query_id) { $result = mysql_field_type($query_id, $offset); return $result; } else { return false; } } function sql_fetchrow($query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } if($query_id) { $intQueryId = (integer) $query_id; $this->row[$intQueryId] = mysqli_fetch_array($query_id); // 212 return $this->row[$intQueryId]; // 213 } else { return false; } } function sql_fetchrowset($query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } if($query_id) { unset($this->rowset[$query_id]); unset($this->row[$query_id]); while($this->rowset[$query_id] = mysql_fetch_array($query_id)) { $result[] = $this->rowset[$query_id]; } return $result; } else { return false; } } function sql_fetchfield($field, $rownum = -1, $query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } if($query_id) { if($rownum > -1) { $result = mysql_result($query_id, $rownum, $field); } else { if(empty($this->row[$query_id]) && empty($this->rowset[$query_id])) { if($this->sql_fetchrow()) { $result = $this->row[$query_id][$field]; } } else { if($this->rowset[$query_id]) { $result = $this->rowset[$query_id][$field]; } else if($this->row[$query_id]) { $result = $this->row[$query_id][$field]; } } } return $result; } else { return false; } } function sql_rowseek($rownum, $query_id = 0){ if(!$query_id) { $query_id = $this->query_result; } if($query_id) { $result = mysql_data_seek($query_id, $rownum); return $result; } else { return false; } } function sql_nextid(){ if($this->db_connect_id) { $result = mysqli_insert_id($this->db_connect_id); return $result; } else { return false; } } function sql_freeresult($query_id = 0){ if(!$query_id) { $query_id = $this->query_result; } if ( $query_id ) { unset($this->row[$query_id]); unset($this->rowset[$query_id]); @mysql_free_result($query_id); return true; } else { return false; } } function sql_error($query_id = 0) { $result["message"] = mysqli_error($this->db_connect_id); $result["code"] = mysqli_errno($this->db_connect_id); return $result; } function sql_escape($query) { return mysqli_real_escape_string($this->db_connect_id, $query); } } // class sql_db } // if ... define
  16. sorry I should have said that this is a completely different function, the full function reads function sql_query($query = "", $transaction = FALSE) { // Remove any pre-existing queries unset($this->query_result); if($query != "") { $this->num_queries++; //echo "[DEBUG] $query<br>"; $this->query_result = mysqli_query($this->db_connect_id, $query); } if($this->query_result) { unset($this->row[$this->query_result]); unset($this->rowset[$this->query_result]); return $this->query_result; } else { return ( $transaction == 'END_TRANSACTION' ) ? true : false; } }
  17. well sort of, I now get this error which consists of unset($this->row[$this->query_result]); unset($this->rowset[$this->query_result]);
  18. ok I think this is correct, well the error has gone anyway $dbselect = mysqli_select_db($this->db_connect_id, $this->dbname); the next error that is being thrown is this and the line of code is $this->query_result = mysql_query($query, $this->db_connect_id); would I be right in thinking this is the correction $this->query_result = mysqli_query($this->db_connect_id, $query); Thanks Mark
  19. Thank yo for your fast response, the problem is I have already read that page and its about as clear as mud to me lol
  20. Hi Guys, First time poster on this forum and from what I can see so far I am going to find this site invaluable I was thumbing through some old folders today and came across a script I had made for me about 6 years ago now back in the old oscommerce 2.2 days. The script or should I say scripts imported thousands of products from an xml file and also did various other update functions etc. Now I thought to myself I wonder if it will work with the latest version incarnation and guess what 'no it does not' lol Anyhoo the first problem is to update the mysql to mysqli commands as it is throwing this error the code segment that throws the error is this function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true) { $this->persistency = $persistency; $this->user = $sqluser; $this->password = $sqlpassword; $this->server = $sqlserver; $this->dbname = $database; if($this->persistency) { $this->db_connect_id = mysql_pconnect($this->server, $this->user, $this->password); } else { $this->db_connect_id = mysqli_connect($this->server, $this->user, $this->password); } if($this->db_connect_id) { if($database != "") { $this->dbname = $database; $dbselect = mysqli_select_db($this->dbname); if(!$dbselect) { @mysql_close($this->db_connect_id); $this->db_connect_id = $dbselect; } } return $this->db_connect_id; } else { return false; } } line 62 is this line $dbselect = mysqli_select_db($this->dbname); Now originally the mysqli were mysql so I tried updating but with lack of know how I am struggling. Any help in showing me the way would be really appreciated. Thanks Mark
×
×
  • 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.