Jump to content

imgrooot

Members
  • Posts

    383
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by imgrooot

  1. So no redirect at all.

     

    You're probably on port 80 or else it would be obvious to you (you would have had to type out the colon and port number). Are you sure the

    RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com
    is correct?

     

    And I know you said the .htaccess was working, but if it isn't there's still a very reasonable explanation for how it seems to be. So back to the basic test: if you put random garbage in the file does the site still work? Please try it for real.

     

     

    I am using the same Rewrite on another site and it works fine. But not on this new site.

     

    I did do a basic test by following their example @ https://docs.bolt.cm/3.3/howto/making-sure-htaccess-works

    I do get an internal error when I input "Test." on the first line of .htaccess. So it is working.

  2. Forget about the secure thing for a minute.

    So you go to "http://mysite.com" and the address bar says "http://mysite.com"? No www and no https?

     

    Then unless there was something lost when you changed the .htaccess to use "mysite.com", I'm not seeing it.

     

    If I go to "http://mysite.com", it'll redirect me to ""mysite.com"". And if I go to "www.mysite.com", it'll show me  "www.mysite.com".

  3. To be clear,

    The HTTPS URL shows "https://" and has the secure thing, while the HTTP URL shows "https://" but no secure thing? It should show something there, good or bad.

     

    Correct. If i type in my domain like this "mysite.com", "www.mysite.com", or "http://mysite.com"; it won't show the secure thing. But If i type it like this "https://mysite.com", it will show the secure thing.

  4. Are you sure the .htaccess is even being read by Apache? What happens if you put random garbage in the file?

     

    Yes it is being read. Here's my full .htaccess file.

    #AuthName "Secure Area"
    
    #AuthType Basic
    
    #AuthUserFile  /home/mysite/public_html/protected/.htpasswd
    
    #require valid-user
    
    
    
    RewriteEngine On
    
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com
    RewriteRule ^(.*)$ https://mysite.com/$1 [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{REQUEST_FILENAME}.php -f
    
    RewriteRule ^(.*)$ $1.php [L]
    
    
    
    # 480 weeks
    
    <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    
    Header set Cache-Control "max-age=290304000, public"
    
    </FilesMatch>
    
    
    
    # 2 DAYS
    
    <FilesMatch "\.(xml|txt)$">
    
    Header set Cache-Control "max-age=172800, public, must-revalidate"
    
    </FilesMatch>
    
    
    
    # 2 HOURS
    
    <FilesMatch "\.(html|htm)$">
    
    Header set Cache-Control "max-age=7200, must-revalidate"
    
    </FilesMatch>
    
    
    
    <ifModule mod_gzip.c>
    
      mod_gzip_on Yes
    
      mod_gzip_dechunk Yes
    
      mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
    
      mod_gzip_item_include handler ^cgi-script$
    
      mod_gzip_item_include mime ^text/.*
    
      mod_gzip_item_include mime ^application/x-javascript.*
    
      mod_gzip_item_exclude mime ^image/.*
    
      mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    
    </ifModule>
    
    
    
    <IfModule mod_deflate.c>
    
      # Compress HTML, CSS, JavaScript, Text, XML and fonts
    
      AddOutputFilterByType DEFLATE application/javascript
    
      AddOutputFilterByType DEFLATE application/rss+xml
    
      AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    
      AddOutputFilterByType DEFLATE application/x-font
    
      AddOutputFilterByType DEFLATE application/x-font-opentype
    
      AddOutputFilterByType DEFLATE application/x-font-otf
    
      AddOutputFilterByType DEFLATE application/x-font-truetype
    
      AddOutputFilterByType DEFLATE application/x-font-ttf
    
      AddOutputFilterByType DEFLATE application/x-javascript
    
      AddOutputFilterByType DEFLATE application/xhtml+xml
    
      AddOutputFilterByType DEFLATE application/xml
    
      AddOutputFilterByType DEFLATE font/opentype
    
      AddOutputFilterByType DEFLATE font/otf
    
      AddOutputFilterByType DEFLATE font/ttf
    
      AddOutputFilterByType DEFLATE image/svg+xml
    
      AddOutputFilterByType DEFLATE image/x-icon
    
      AddOutputFilterByType DEFLATE text/css
    
      AddOutputFilterByType DEFLATE text/html
    
      AddOutputFilterByType DEFLATE text/javascript
    
      AddOutputFilterByType DEFLATE text/plain
    
      AddOutputFilterByType DEFLATE text/xml
    
    
    
      # Remove browser bugs (only needed for really old browsers)
    
      BrowserMatch ^Mozilla/4 gzip-only-text/html
    
      BrowserMatch ^Mozilla/4\.0[678] no-gzip
    
      BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    
      Header append Vary User-Agent
    
    </IfModule>
    
  5. I have a domain where I installed a SSL certificate. It works if I type in the domain like this "https://mysite.com". But if i go to the domain with www or without www, the SSL secure certificate won't show in the top bar. The site loads up fine. 

     

    Here is my .htaccess code. Am I doing something wrong?

    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com
    RewriteRule ^(.*)$ https://mysite.com/$1 [R=301,L]
    
  6. Sepodati is correct. But to your specific question:

     

     

    echo $global_trans_id['inputs'][0]['address'];
    
    As already pointed out, the sample data you provided shows that both the 'inputs' and 'outputs' keys are array (note: [ ] ).

     

    Each array has apparently a variable number of elements in the array. So if you wanted to see all the addresses:

     

    foreach ($global_trans_id['inputs'] as $value) {
        
        echo "Address:  {$value['address']} <br>";
    } 
    

    Awesome. That's that i needed. Thanks.

  7. I am trying to using this API.   https://www.blocktrail.com/api/docs

     

     

    I can retrieve the first layer value using this.

    $global_trans_id        = $client->transaction($post_transid);
    $api_transaction_id	= $global_trans_id['hash'];
    echo $api_transaction_id;

    As you see "hash" is the first layer below. But what if I want to retrieve the second layer such as a value from "Inputs" or "Outputs" like "$global_trans_id['address'];". How would that look?

    {
        "hash": "c326105f7fbfa4e8fe971569ef8858f47ee7e4aa5e8e7c458be8002be3d86aad",
        "first_seen_at": "2014-03-11T08:27:57+0000",
        "last_seen_at": "2014-03-11T08:27:57+0000",
        "block_height": 290000,
        "block_time": "2014-03-11T08:27:57+0000",
        "block_hash": "0000000000000000fa0b2badd05db0178623ebf8dd081fe7eb874c26e27d0b3b",
        "confirmations": 31130,
        "is_coinbase": false,
        "estimated_value": 70000000,
        "total_input_value": 70070000,
        "total_output_value": 70030000,
        "total_fee": 40000,
        "estimated_change": 30000,
        "estimated_change_address": "19M1EraiuAvZp8ZV7QJHH2LVkYm8ECufCJ",
        "high_priority": false,
        "enough_fee": true,
        "contains_dust": false,
        "inputs": [
            {
                "index": 0,
                "output_hash": "d283ab6edd394b8a69d6943ea3a29a679d92176b112b1f69ffb9b70cf27dec5a",
                "output_index": 2769,
                "value": 2730000,
                "address": "19M1EraiuAvZp8ZV7QJHH2LVkYm8ECufCJ",
                "type": "pubkeyhash",
                "multisig": null,
                "script_signature": "0x49 0x3046022100bb3d102afd0d57be618aeaa7432bc038dea928bec0af6b8cba37c7ec85701e3d022100c467073956b385f08fbfbc2e130d8f76deb7c5436ba245afca4678200b127c2001 0x21 0x02aa6584518e528be497be65fba84913b7d0cb55158f4e7922298923286a7f6156"
            },
            {
                "index": 1,
                "output_hash": "b350de75f9c27b457fa6cefb7072af8aa94de53ccedff4ec06ce885d63645e1d",
                "output_index": 2764,
                "value": 2740000,
                "address": "19M1EraiuAvZp8ZV7QJHH2LVkYm8ECufCJ",
                "type": "pubkeyhash",
                "multisig": null,
                "script_signature": "0x48 0x3045022059c6cc77c0a7c3a3a1ab0678690178750f2b5e442dc6f9331835be4cdb087cc00221008fca79860ab8f15acba61522b4f8482909cadfdf79dca7790efabf71c7c12d3701 0x21 0x02aa6584518e528be497be65fba84913b7d0cb55158f4e7922298923286a7f6156"
            },
            {
                "index": 2,
                "output_hash": "fa3f040de013ddbe4a5746c89d32de2cac147845682e7d26119fd686a57e0b65",
                "output_index": 2549,
                "value": 2930000,
                "address": "19M1EraiuAvZp8ZV7QJHH2LVkYm8ECufCJ",
                "type": "pubkeyhash",
                "multisig": null,
                "script_signature": "0x47 0x304402207266d8c69d2c28e4050a90f48209768554e1470999a2259b000fd3c096edc39f02207b7f6a6b7ca7952249a1a1f3064e6a3f573fcd6700084e2fe71ce8f3d3f2be8301 0x21 0x02aa6584518e528be497be65fba84913b7d0cb55158f4e7922298923286a7f6156"
            },
            { /* ... */ }
        ],
        "outputs": [
            {
                "index": 0,
                "value": 70000000,
                "address": "1JSywyhFSvCC4NGALvKoyX5xng86QaigAN",
                "type": "pubkeyhash",
                "multisig": null,
                "script": "DUP HASH160 0x14 0xbf641337e3ab4eaae788a72bafedb965749882b2 EQUALVERIFY CHECKSIG",
                "script_hex": "76a914bf641337e3ab4eaae788a72bafedb965749882b288ac",
                "spent_hash": "71acf863d37d9d18524607e3dd68128b91ddc43dfe32f620ec124ceff3bb3295",
                "spent_index": 34
            },
            {
                "index": 1,
                "value": 30000,
                "address": "19M1EraiuAvZp8ZV7QJHH2LVkYm8ECufCJ",
                "type": "pubkeyhash",
                "multisig": null,
                "script": "DUP HASH160 0x14 0x5b8986608535c96923769138ad5be236a091b791 EQUALVERIFY CHECKSIG",
                "script_hex": "76a9145b8986608535c96923769138ad5be236a091b79188ac",
                "spent_hash": "400f77fff18e24d1a770c0e1ca85434ca5e4cd0f6e1489e5849256cc71f9ec0a",
                "spent_index": 2
            },
            { /* ... */ }
        ]
    }
    
  8. Say I have this records table.

    RECORDS TABLE
    
    record_id    |    sponsor_id    |    user_id    |    plan_id
    ------------------------------------------------------------------------------
    1                 user5              user6               5  // I am this user.     
    2                 user3              user5               3 
    3                 user3              user4               4
    4                 user2              user3               4
    5                 user2              user2               2
    6                 user0              user1               5    
    

    I am "user6" and my sponsor is "user5".  What I want to do is find the same "plan_id" from my sponsors, no matter how far up I have to do.  

     

    For eg. My current plan id is "5". My sponsor is "user5". If I look for "user5" in the user_id column, I would find that he only has plan "3" id. So I go to his sponsor, which is "user3" and find him in the user_id column. That user's plan id is "4" so it does not match my plan id either. I repeat the same process by going to his sponsor and his sponsor and so on until I find the plan id that matches me.  So for this table example, that would be "user1". 

     

    I only want to retrieve the first result that matches my plan id.  How do I go on about coding this function? 

     

    Normally I can do these queries to go up limited amount. But I am looking for a more proper function that lets me search my sponsors unlimited times.

    $find_plan_id = $db->prepare("SELECT sponsor_id, plan_id FROM records WHERE user_id = :user_id");
    $find_plan_id->bindParam(':user_id', $user_id);
    $find_plan_id->execute();
    $result_find_plan_id = $find_plan_id->fetchAll(PDO::FETCH_ASSOC);
    if(count($result_plan_id) > 0) {
      foreach($result_plan_id as $row) {
        $get_sponsor_id_1 =	$row['sponsor_id'];
        $get_plan_id_1    =	$row['plan_id'];
      }
      if($get_plan_id_1 == $my_plan_id) {
      
        echo 'Plan id matches.';
        
      } else {
      
        $find_plan_id_2 = $db->prepare("SELECT sponsor_id, plan_id FROM records WHERE user_id = :user_id");
        $find_plan_id_2->bindParam(':user_id', $get_sponsor_id_1);
        $find_plan_id_2->execute();
        $result_plan_id_2 = $find_plan_id_2->fetchAll(PDO::FETCH_ASSOC);
        if(count($result_plan_id_2) > 0) {
          foreach($result_plan_id_2 as $row) {
            $get_sponsor_id_2 =	$row['sponsor_id'];
            $get_plan_id_2    =	$row['plan_id'];
          }
          if($get_plan_id_2 == $my_plan_id) {
          
            echo 'Plan id matches.';
            
          } else {
            // repeat the process
          }
        }
        
      }
    }
    
  9. Imgroot:

     

    This is how you get yourself in trouble:

     

    $date = 2017-08-10 00:06:10;
    
    There is no such thing. That line of code would trigger a syntax error. There is no intrinsic data type for a date in php. What you can do is use any of many different date/time string formats. My recommendation is that you always use a format that also encodes the timezone, as the foundation for supporting localized time for your visitors. Additionally best practice for most servers is that they are setup using UTC as the timezone, so you need to be able to adjust any datetime values you receive or output.

     

    There is highly functional DateTime class you can use, and I highly recommend. It is very capable of accepting a string and setting up the object. I took this code literally out of the manual:

     

     

    $dateStr = '2017-08-10 00:06:10';
    
    try {
        $date = new DateTime($dateStr);
    } catch (Exception $e) {
        echo $e->getMessage();
        exit(1);
    }
    
    echo $date->format('Y-m-d');
    
    If there is some problem with your input it will throw an exception. You can also use the DateTime through its procedural interface if you prefer.

     

     

    Got it. I will keep that in mind. Thanks.

  10. What do YOU think is empty? Where is the data coming from and why would it be empty?

     

    empty() to PHP is generally used for empty strings from form elements, but there are a lot more things considered "empty" in PHP:

     

    There's also isnull() or isset(), depending on whether you mean one of them as "empty". Or just the plain old != '' for matching an empty string.

     

    The date is coming from MySQL database. I just like to know what the best way to check if that date is empty.

  11. Dude. The syntax error isn't in line 12, it's in one of the lines before that. If you want help with a syntax problem, then we need to actually see the exact code, not an “and so on” placeholder. Is this really so hard to understand?

     

    Anyway, apparently you've repaired your secret code now. The new error is an interal library exception. Read the source code to understand why it's happening.

     

    The error says invalid credentials, I assume it means my API key.  I double checked it and it's the correct key.

     

    I am testing it on a test.php page with this code .

    require_once 'composer/vendor/autoload.php';
    
    use \Blocktrail\SDK\BlocktrailSDK;
    $client = new BlocktrailSDK("0012a34a76bf10cf01c53d0c6059fc84a22f8e9d", "22250773dfde8f4ed0a0252a299549e9c024b132", "BTC", true /* testnet */);
    
    $address = $client->address('1NcXPMRaanz43b1kokpPuYDdk6GGDvxT2T');
    $latestBlock = $client->blockLatest();
    
    var_dump($address['balance'], $latestBlock['hash']);
    
    

    And this is the error i receive.

    Fatal error: Uncaught Blocktrail\SDK\Connection\Exceptions\ObjectNotFound: The object you've tried to access does not exist. in C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php:336 Stack trace: #0 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php(306): Blocktrail\SDK\Connection\RestClient->responseHandler(Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php(173): Blocktrail\SDK\Connection\RestClient->request('GET', 'address/1NcXPMR...', NULL, NULL, NULL, NULL, NULL) #2 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\BlocktrailSDK.php(162): Blocktrail\SDK\Connection\RestClient->get('address/1NcXPMR...') #3 C:\xampp\htdocs\gift\test.php(7): Blocktrail\SDK\BlocktrailSDK->address('1NcXPMRaanz43b1...') #4 {main} thrown in C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php on line 336
    
  12. I actually did tried this on a test page outside of the normal site and it gives me this error. I'm pretty sure I installed it correctly using composer. 

    Fatal error: Uncaught Blocktrail\SDK\Connection\Exceptions\ObjectNotFound: The object you've tried to access does not exist. in C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php:336 Stack trace: #0 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php(306): Blocktrail\SDK\Connection\RestClient->responseHandler(Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php(173): Blocktrail\SDK\Connection\RestClient->request('GET', 'address/1NcXPMR...', NULL, NULL, NULL, NULL, NULL) #2 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\BlocktrailSDK.php(162): Blocktrail\SDK\Connection\RestClient->get('address/1NcXPMR...') #3 C:\xampp\htdocs\gift\test.php(28): Blocktrail\SDK\BlocktrailSDK->address('1NcXPMRaanz43b1...') #4 {main} thrown in C:\xampp\htdocs\site\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php on line 336
    
  13. I am using this API https://github.com/blocktrail/blocktrail-sdk-php.

     

    I am suppose to add this to top of my directory where I want to initialize the API. 

    require 'vendor/autoload.php';
    use Blocktrail\SDK\BlocktrailSDK;
    

    But the second line gives me an error.

    use Blocktrail\SDK\BlocktrailSDK;
    
    Parse error: syntax error, unexpected 'use' (T_USE) in C:\xampp\htdocs\site\templates\header.php on line 12
    

    Is the "use" a correct syntax for php? Why is it giving me an error?

  14. I have a query below where I want to search a table to find the top row with 1 or 2 empty positions. But it never returns the correct "referral_id". If I remove the "ref_user_1" and "ref_user_2" conditions from the query, then of course it will return the correct referral id. But those conditions are important for me to have. Is having "AND" and "OR" conditions in the same query against the rules? If so what's the solution for this problem?

    $find_sponsor = $db->prepare("SELECT * FROM referrals WHERE referred_by = :referred_by AND ref_user_1 = :ref_user_1 OR ref_user_2 = :ref_user_2 ORDER BY referral_id ASC LIMIT 1");
    $find_sponsor->bindValue(':referred_by', 2);
    $find_sponsor->bindValue(':ref_user_1', 0);
    $find_sponsor->bindValue(':ref_user_2', 0);
    $find_sponsor->execute();
    $result_sponsor = $find_sponsor->fetchAll(PDO::FETCH_ASSOC);
    if(count($result_sponsor) > 0) {
      foreach($result_sponsor as $row) {
        $get_referral_id   = $row['referral_id'];
        $get_ref_1         = $row['ref_user_1'];
        $get_ref_2         = $row['ref_user_2'];
      }
      echo $get_referral_id;
      // this always returns the wrong referral id
    }
    // Table
    referral_id referred_by ref_user_1 ref_user_2
    1           2           20         21
    2           2           23         24
    3           2           25         0
    4           2           0          0

    As per my table above, what would my new query look like if I want to retrieve #3 as my referral id?

     

     

     

     

     

  15. You've been here long enough to understand the difference between SQL and PHP. Thread moved.

     

    The solution you've acknowledged also contradicts your problem description. You said you want the latest record, now you're selecting the row(s) with the biggest amount. I also see no reason why the amount should be unique, so that won't even work.

     

    The last record WILL have the biggest amount. 

     

    Anyways, I have solved this issue.

  16. Say I have a records table with multiple records. There could be multiple records with the same name but different amounts.

     

    For Eg. Looking at the table below, the results should retrieve newest record-1 and record-2 because their amount is equals to or greater than 5.00. Record-3 is not selected because it falls below 3.00. 

    record_id     record_name     record_amount
    1             record-1        4.00
    2             record-1        3.00
    3             record-2        2.00
    4             record-1        5.00
    5             record-2        6.00
    6             record-3        3.00
    $get_records = $db->prepare("SELECT record_id, record_name FROM records WHERE record_amount >= :record_amount ORDER BY record_id DESC");
    $get_records->bindValue(':record_amount', 5.00);
    $get_records->execute();
    $result_records = $get_records->fetchAll(PDO::FETCH_ASSOC);
    if(count($result_records) > 0) {
      foreach($result_records as row) {
        $record_id 	  = $row['record_id'];
        $record_name  = $row['record_name'];
      
        echo $record_name;
      }
    }
    

    Currently the query above outputs ALL the rows that matches the >=. What I want to do is select only ONE row of each unique record name that matches the criteria. And that row is typically the last row that was inserted. So the output would be like only these two.  How do I do that?

    4             record-1        5.00
    5             record-2        6.00
    
    
  17. I had a little side project a few years ago downloading achievement data from the world of warcraft api to run some statistics on it. If I remember correctly my table linking characters to achievements and their completion dates got to about 8 million rows before mysql started to struggle with it. Adding partitioning let me get up to 12 million rows with mysql still handling it like a champ. This was on a fairly small VPS as well (20GB disk, 2GB RAM iirc). Ultimately I stopped around the 12 million mark not because mysql was struggling but because my VPS just didn't have enough disk space for the data and I didn't want to invest more money into it.

     

    Moral of the story is you probably shouldn't worry about how many rows you may be adding to a table. Focus on a proper database design and worry about the performance if you actually have a problem.

     

    Good to know. Thanks for the info. I will keep it in mind.

×
×
  • 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.