Jump to content

quasiman

Members
  • Posts

    197
  • Joined

  • Last visited

Everything posted by quasiman

  1. That's a great effort, but you're assuming a lot by posting this much information. Hopefully it's helpful...
  2. Without any idea of your requirements or abilities, here's what looks like a good example: https://github.com/web-project-builder/expense-management-codeigniter-adminlte-php
  3. Yep, doesn't work. Glad we got that sorted out.... lol. Only support I can provide (without more details) is the console log error I'm seeing: VM15:1 Mixed Content: The page at 'https://social.searchika.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://social.searchika.com/requests.php?hash=dae40cb6316d320130e8&f=update_lastseen&_=1562702739775'. This request has been blocked; the content must be served over HTTPS.
  4. I have to agree with the comments above. They're a bit harsh, but really this is for your own good. You need to know what's going on - instead of just putting the ability to upload anything out there. Here's a few good places to start: http://www.w3schools.com/php/php_file_upload.asp http://www.tizag.com/phpT/fileupload.php http://webcheatsheet.com/php/file_upload.php
  5. This is a Joomla component, and so natively I can't use ON DUPLICATE, but I've thought about putting it into just standard SQL... I just wouldn't have the portability. I think I'm going to look into running this through a cron plugin, instead of at the user page views. Thanks!
  6. Hi all, I'm working on a project involving an orders set of APIs, and having trouble coming up with the best logic to handle this - with the smallest amount of overhead and client facing slowness. Here's the jist of what I'm looking at... There are 21 API methods to pull different types of orders, and each of them handle paging by requesting a number of records (10 - 500), and a page number. So I could say in my URI, "page-no=1&no-of-records=50", followed by "page-no=2&no-of-records=50", to get subsequent records. The API will return in each call the total records returned as well as the total records in their database. Now, I want to insert all of this into my database, and so that means something like 21 APIs * 3 SQL requests each = 63 sql queries (check it exists, if so update - else insert). This seems to me like way too much work for a client facing application. Any suggestions?
  7. I've been trying and trying, but can't seem to get how you're meaning... 1. I need $data to be an array of everything, so that I can iterate over it to get the $query array of records. I'm not sure how I can make $data a temporary variable to do that - can you explain further? 2. I've tried combining the two arrays together, but really that just iterates over each $api method, reassigning values all over them. I'm sure I'm not doing what you had intended, but this seems to work foreach ($api as $type => $value) { $data[$type] = $dispatcher->trigger('getData', array(&$value, $string)); } // Loop through results foreach ($data as $k=>$key) { if (is_array($key)) { foreach ($key as $val) { if (is_array($val)) { foreach ($val as $v) { if (is_array($v)) { $v['apimethod'] = $k; $query[] = $v; } } } } } }
  8. Sorry for the topic title if it's confusing, I wasn't sure what to call this. So, I'm calling an array of API request and pushing the responses all into one array - but I need to identify which API is which. I've assigned keys to the api array, but I'm not sure how to get them into the returned data. Here's what I have so far..... $api = array( "domains" => "api/domains/search.json", "websrvs" => "api/webservices/search.json", "snlinus" => "api/singledomainhosting/linux/us/search.json", "digcert" => "api/digitalcertificate/search.json"); foreach ($api as $type => $value) { // Joomla style trigger to get the API data $data[] = $dispatcher->trigger('getData', array(&$value, $string)); } // Loop through results foreach ($data as $key) { if (is_array($key)) { foreach ($key as $val) { if (is_array($val)) { foreach ($val as $v) { if (is_array($v)) { $query[] = $v; } } } } } } return $query;
  9. Nevermind, I figured it out.... I set the dataType to 'json', but then I didn't properly set the object.
  10. Hi, I'm trying to learn jquery ui (without much of a javascript background), and I think I'm pretty close to what I want.....but the error I'm seeing doesn't make much sense to me. Here's my code first: <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script> $(function() { var contactid = "<?php echo $_GET['contactid']; ?>"; $( "#dialog-confirm" ).dialog({ autoOpen: false, resizable: false, height:290, width:450, modal: true, buttons: { "Delete": function() { $.ajax({ type: "POST", url: 'delete-contact.php', data: {contactid: contactid}, dataType: 'json', context: $(this), cache: false, statusCode: { 404: function() { alert("page not found"); }, 200: function() { alert("200 success"); } } }).then( function(){ alert("$.ajax succeeded"); }, function(){ alert("$.ajax failed!"); } ); }, Cancel: function() { $( this ).dialog( "close" ); } } }); $( "#confirm-delete" ) .button() .click(function() { $( "#dialog-confirm" ).dialog( "open" ); }); }); </script> Now, you can see I have a few alerts in there, and I'm getting two to popup, first '$.ajax failed!', followed by '200 success'. I check Firebug and I can see the post successful (to a dummy file just echoing the $_POST), so I don't understand why I'm seeing the deferred.then() return an error. Any ideas for jquery newbie?
  11. I figured it out..... "In order to be able to directly modify array elements within the loop precede $value with &": http://php.net/manual/en/control-structures.foreach.php So all I had to do was: $services[] = getData('domains/search', $params); foreach ($services as &$service) { foreach ($service as &$s) { if (is_array($s)) { $s['key_name'] = "key value"; } } } print_r($services);
  12. Hi all, I feel like this is a dumb question, but I can't seem to get around it. I'm working with several arrays and pulling them together basically like this: $services[] = getData('....', $params); $services[] = getData('....', $params); $services[] = getData('....', $params); $services[] = getData('....', $params); $merge = call_user_func_array('array_merge', $services); Now, the getData function is pulling through info from an API and I want to add a little reference to each array to show where it came from. The array I'm getting back looks like this: Array ( [0] => Array ( [entity.entityid] => 44705207 [orders.endtime] => 1372226238 [orders.resellerlock] => false [orders.timestamp] => 2012-06-26 05:57:20.292531+00 [orders.creationdt] => 1340690238 ) [1] => Array ( [entity.entityid] => 44705207 [orders.endtime] => 1372226238 [orders.resellerlock] => false [orders.timestamp] => 2012-06-26 05:57:20.292531+00 [orders.creationdt] => 1340690238 ) ) I tried this: $services[][]['key_name'] = 'key_value';. But it just adds a new array set : Array ( [0] => Array ( [entity.entityid] => 44705207 [orders.endtime] => 1372226238 [orders.resellerlock] => false [orders.timestamp] => 2012-06-26 05:57:20.292531+00 [orders.creationdt] => 1340690238 ) [1] => Array ( [entity.entityid] => 44705207 [orders.endtime] => 1372226238 [orders.resellerlock] => false [orders.timestamp] => 2012-06-26 05:57:20.292531+00 [orders.creationdt] => 1340690238 ) [2] => Array ( [key_name] => key_value ) ) So how do I add a key / value to the arrays that are already there? $services[] = getData('....', $params); foreach ($services as $service) { if (is_array($service)) { foreach ($service as $key) { $key['key_name'] = "key_value"; } } } This didn't even show up in the results.... I'm lost.
  13. Oops...I just realized this is the wrong forum. Maybe a moderator can move it?
  14. Hi Everyone, To begin with, traditional basic PHP/MySql websites use stored usernames and passwords in their database for authentication, and create session values to grant user access, based on the username and a hash of the password. Now, the site I'm working on uses MySql for the session storage and brute force protection, but the username and password are not stored there. During the login process the username, password, and IP address are passed via cURL to an API, which responds with a temporary (about 5 minutes I think) token. My question is this. What's the best way to ensure the session is secure? I'm not storing the password locally, and obviously I can't keep it in session to revalidate at the API. Would it be secure "enough" if I simply store the token response in MySql? Maybe hash it together with the username, IP address, and browser agent? If I did that, at least with the next login the token would be different and a new hash created. Any ideas?
  15. Josparky, Did you set the password in the config.php file? $upload_dirs = array( "images" => array( "dir" =>"uploads/images/", "name" =>"Images folder", "password"=>"images", ), "docs" => array( "dir" =>"uploads/docs/", "name" =>"Docs", "password"=>"docs", ), "common" => array( "dir" =>"uploads/common/", "name" =>"Common files", "password"=>"common", ), );
  16. Does anyone here know ValidForm? I'm trying to use the (fairly new) validation rule matchwith for password confirmation, but it's acting like nothing is wrong when I type in different passwords. Here's what I've tried so far.... // First password field $objForm->addField("password1","Password", VFORM_PASSWORD, array( "required" => true ), array( "required" => "Please fill in a password" ) ); // Second password field $objForm->addField("password2","Repeat password", VFORM_PASSWORD, array( "required" => true, "matchwith" => $objForm->getValidField("password1")->getValue() ), array( "type" => "Your passwords don't match", "required" => "Please retype your password" ) ); There's no documentation yet on this validation, so I'm not sure how it should be implemented....
  17. Oh you're kidding!? Well ok, that explains it... thanks!
  18. Sorry about the topic title, I'm not really sure how else to simply explain this... Anyway, can someone explain why this doesn't work? I'm checking the type with '===' versus checking value with '=='. I could just use the two ==, but I want to know why... <?php function validate($value, $type) { switch ($type) { case "url": if (filter_var($value, FILTER_VALIDATE_URL) === TRUE) return TRUE; break; default: return FALSE; } } if (validate('http://gmail.com','url')) { echo 'true'; } else { echo 'false'; } ?>
  19. Nevermind, I got it... $(document).ready(function() { $(".country").change(function() { var dataString = 'id='+ $(this).val(); $.ajax ({ type: "POST", url: "state.php", data: dataString, cache: false, success: function(html) { $(".state").html(html); } }); }); $(".country").change(function() { // bind a change event: $(this).val(); }).change(); // and trigger a "change" event immediately });
  20. Alright, no response....still working on this. I've switched to jquery, but same results - I can't see how to autoselect the state when a country is preselected. See my new code below: jquery <script src="<? echo _TEMPLATE;?>/js/jquery-1.7.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $(".country").change(function() { var dataString = 'id='+ $(this).val(); $.ajax ({ type: "POST", url: "state.php", data: dataString, cache: false, success: function(html) { $(".state").html(html); } }); }); }); </script> fields: <tr> <td><strong>Country</strong></td> <td><select name="country" class="country"> <option selected="selected">--Select Country--</option> <?php $query = "SELECT `id`, `iso`, `country` FROM regions ORDER BY `country`"; $result = $mysqli->query($query) or die($mysqli->error . __LINE__); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<option value='" . $row['id'] . "' " . ($customer['country'] == $row['iso'] ? 'selected=\"selected\"' : '') . " >" . $row['country'] . "</option> \n"; } } ?> </select></td> </tr> state.php <?php include ('includes/functions.php'); if($_POST['id']) { $id=$_POST['id']; $query = "SELECT id,region_id,name FROM subregions WHERE region_id = '$id'"; $result = $mysqli->query($query) or die($mysqli->error . __LINE__); if ($result->num_rows > 0) { echo "<select name='state' >\n"; echo "<option value='0'>====Choose State ====</option>\n"; while ($row = $result->fetch_assoc()) { echo "<option value='" . $row['name'] . "' >" . $row['name'] . "</option> \n"; } } else { echo "<input name=\"state\" type=\"text\" name=\"other\" />"; } } ?>
  21. I have a pair of ajax country / state select boxes that I want to autopopulate from the users profile. The country is selected from a db query, but I can't figure out how to have it select the state too. On page load the countries are listed and the users country selected, but the state select doesn't recognize that it's already populated. Here's my code...any help would be appreciated: ajax <script type="text/javascript"> function Inint_AJAX() { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} try { return new XMLHttpRequest(); } catch(e) {} alert("XMLHttpRequest not supported"); return null; }; function dochange(src, val) { var req = Inint_AJAX(); req.onreadystatechange = function () { if (req.readyState==4) { if (req.status==200) { document.getElementById(src).innerHTML=req.responseText; } } }; req.open("GET", "country.php?data="+src+"&val="+val); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); req.send(null); } window.onload=dochange('country', -1); </script> fields: <tr> <td><strong>Country</strong></td> <td><span id="country"></span></td> </tr> <tr> <td><strong>State</strong></td> <td><span id="state"><input name="state" type="text" value="" /></span></td> </tr> country.php <?php include ('includes/functions.php'); $data = $_GET['data']; $val = $_GET['val']; if ($data == 'country') { echo "<select name='country' onchange=\"dochange('state', this.value)\">\n"; echo "<option value='0'>===Choose a country===</option>\n"; $query = "SELECT `id`, `iso`, `country` FROM regions ORDER BY `country`"; $result = $mysqli->query($query) or die($mysqli->error . __LINE__); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<option value='" . $row['id'] . "' " . ($customer['country'] == $row['iso'] ? 'selected=\"selected\"' : '') . " >" . $row['country'] . "</option> \n"; } } } else if ($data == 'state') { $query = "SELECT id,region_id,name FROM subregions WHERE region_id = '$val'"; $result = $mysqli->query($query) or die($mysqli->error . __LINE__); if ($result->num_rows > 0) { echo "<select name='state' >\n"; echo "<option value='0'>====Choose State ====</option>\n"; while ($row = $result->fetch_assoc()) { echo "<option value='" . $row['name'] . "' >" . $row['name'] . "</option> \n"; } } else { echo "<input name=\"state\" type=\"text\" name=\"other\" value='Other' \">"; } } echo "</select>\n"; ?>
  22. Hi, I'm building an array from two other arrays, and I want to loop through them for specific key/value pairs. The problem is that some of the pairs do not exist in every sub array, and so referencing them causes an unidentified offset error. So....here's what I'm doing so far. How can I (easily and with minimum if/else statements) check whether they exist prior to generating my array? <?php $category = 'linux_hosting_plan'; $name = 'Starter'; print_r(returnHostPlan($category, $name)); function returnHostPlan($category, $name) { $planDetails = getData('products/plan-details'); $customerPrice = getData('products/customer-price'); $plan = combineArray($planDetails['hosting'], $customerPrice['hosting']); foreach ($plan as $key => $value) { if ($value[0]['category'] == $category && $value[0]['plan_name'] == $name) { $array = array( 'key' => $key, 'plan_name' => $value[0]['plan_name'], 'dbspace' => $value[0]['dbspace'], 'status' => $value[0]['status'], 'webspace' => $value[0]['webspace'], 'no_of_mail_accounts' => $value[0]['no_of_mail_accounts'], 'bandwidth' => $value[0]['bandwidth'], 'hosting_location' => $value[0]['hosting_location'], 'noofdbs' => $value[0]['noofdbs'], '12' => $value[1]['add'][12], '36' => $value[1]['add'][36], '48' => $value[1]['add'][48] ); } } return $array; } ?> This creates: Notice: Undefined offset: 48 in /../../planDetails.php on line 35 Array ( [key] => 737167 [plan_name] => Ecommerce [dbspace] => 5120 [status] => Active [webspace] => 20480 [no_of_mail_accounts] => 100 [bandwidth] => 204800 [hosting_location] => us [noofdbs] => -1 [12] => 4.99 [24] => 3.99 [36] => 2.99 [48] => )
  23. Hi, Nice new forum! I'm writing a function that combines two arrays, and based on the params assigned returns a new array. The problem I'm having is making one of the parameters not required. This would return all results not filtered by the param, or if included would only return the filtered results. Here's where I am so far... <?php function showPlan($type, $cat, $name=null) { $planDetails = getData('products/plan-details'); $customerPrice = getData('products/customer-price'); $a1 = $planDetails[$type]; $a2 = $customerPrice[$type]; $a3 = combineArray($a1, $a2); //external function combining the two above arrays $array = array(); foreach ($a3 as $keys) { if ($keys[0]['category'] == $cat) { if(isset($name) && $keys[0]['plan_name'] == $name) { foreach ($keys[0] as $key => $value) { $array[$key] = $value; } foreach ($keys[1]['add'] as $key => $value) { $array[$key] = $value; } } } } return $array; } ?> Now, if I take out the line "if(isset($name) && $keys[0]['plan_name'] == $name)" and force the $name param, this function works fine. But I don't want to write two functions simply to return all results or only one result. Any help would be greatly appreciated!
  24. It was fine until I added the token Thanks for looking!
×
×
  • 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.