Jump to content

megglz

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Everything posted by megglz

  1. I have the following array which builds a concatenation of the items in tree-like form. $arrayT = array(); $arrayT[0] = "a"; $arrayT[1] = "b"; $arrayT[2] = "c"; $arrayT[3] = "d"; $arrayT[4] = "e"; $arrayT[5] = "f"; $arrayT[6] = "g"; $arrayT[7] = "h"; $arrayT = buildTree($arrayT); print_r($arrayT); function buildTree($array) { $arrayTree = $array; $start = 0; $end = count($arrayTree); $i = 0; while ($start != $end - 1) { if ($i % 2 == 1) { $arrayTree[count($arrayTree) - 1].=$arrayTree[$start + $i]; } else $arrayTree[] .= $arrayTree[$start + $i]; $i++; if (($start + $i) == $end) { $i = 0; $start = $end; $end = count($arrayTree); } } return $arrayTree; } Example output is I would like the values to be hashed using sha1. e.g value at [8] ab would be the hash of [0]a and [1] b, value [12]abcd would be the hash of the values at [8]ab and [9]cd. I modified it myself in the next code snippet but I still don't feel it's doing what it's meant function buildTree($array) { $arrayTree = $array; $start = 0; $end = count($arrayTree); $i = 0; while ($start != $end - 1) { if ($i % 2 == 1) { $arrayTree[count($arrayTree) - 1].=$arrayTree[$start + $i]; sha1($arrayTree[count($arrayTree)-1].=$arrayTree[$start + $i]); } else $arrayTree[] .= sha1($arrayTree[$start + $i]); $i++; if (($start + $i) == $end) { $i = 0; $start = $end; $end = count($arrayTree); } } return $arrayTree; } $val1 = sha1($arrayT[0]); $val2 = sha1($arrayT[1]); $val3 = sha1($val1.$val2); $val4 = sha1("ab"); echo "VAL1 ".$val1; echo "<br/>"; echo "VAL2 ".$val2; echo "<br/>"; echo "VAL3 ".$val3; echo "<br/>"; echo "VAL4 ".$val4; Anyone any ideas? Thankyou.
  2. Thanks! I realised this yesterday after posting but forgot to come back and edit Thank you.
  3. I am including my test.php for other to run. I have a very large array of concatenated hash values. I have another array that contains the first 8 hash values of the other array. I have a function to locate them in the larger array. Depending on their index value I then choose the index of the value before or behind them for adding to something else later. This 'computeWalk' method works for small arrays but for larger arrays I notice duplicates or errors with larger ones. For example. The first array returns: Array ( [0] => 1 [1] => 18 [2] => 18 [3] => 35 [4] => 33 [5] => 33 ) The values for i's to get each of these values are I = 0 I = 19 I = 29 I = 34 I = 37 I = 39 Walking through the method by hand, 0%2 = 0 So the first element of the array will be 1. CORRECT. 19%2 = 1 So the next element will be 18. CORRECT. 29%2 = 1 The next element should be 28. It returns 18. 34%2 = 0 The next element will be 35. Correct. 37%2 = 1 The next element should be 36. It returns 33. 39%2 = 1 The next element should be 38. It returns 33. I am not sure why it's doing the above. I also tried array_search and it computed it the same way. Would appreciate any help. <?php $arrayTree = array(); $arrayTree[0] = "9d027b1c4068d81287c9170f4b291387f8327eb7"; $arrayTree[1] = "4c8fabdc24c2d8205db916a22e9459195833a272"; $arrayTree[2] = "209526afab9e85b54e1832a820a7f578b7760af0"; $arrayTree[3] = "59d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayTree[4] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9d"; $arrayTree[5] = "b207bea6c4833d90f6ee4e694ffb148c046b0eb3"; $arrayTree[6] = "6d72a84b3aefbd3766078ed17a19aebb0c4ae026"; $arrayTree[7] = "b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[8] = "d934f53af9bee26f35df7206dc06211778996986"; $arrayTree[9] = "de2ecd02fd017b0311dbfe589b5faa7954ced196"; $arrayTree[10] = "7d9752d09d3097fac748b6767472f9b69a65ed2e"; $arrayTree[11] = "62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayTree[12] = "d727b5b8ffaeadbac75123801c270fd65f19251c"; $arrayTree[13] = "e39a9141fd9ce9426e88f30b6f245fdbb8f887a5"; $arrayTree[14] = "85fe053baa7ccf469c440a7dd98381228a0c52c3"; $arrayTree[15] = "6199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[16] = "af594de7d539519445013b7c87f02edbf3c44653"; $arrayTree[17] = "b6eb6dab75d092f4be345925ccbf87ff1e17fc31"; $arrayTree[18] = "2163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[19] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272"; $arrayTree[20] = "209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayTree[21] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb3"; $arrayTree[22] = "6d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[23] = "d934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced196"; $arrayTree[24] = "7d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayTree[25] = "d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a5"; $arrayTree[26] = "85fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[27] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc31"; $arrayTree[28] = "2163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[29] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayTree[30] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[31] = "d934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayTree[32] = "d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[33] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[34] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[35] = "d934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[36] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[37] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232ad934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[38] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[39] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232ad934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911deaf594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[40] = "54u58rfhfheyrr4gfdtfvgw36tr36"; $arrayTree[41] = "54u58rfhfheyrr4gfdtfvgw36tr369d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232ad934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911deaf594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayDocs = array(); $arrayDocs[0] = "9d027b1c4068d81287c9170f4b291387f8327eb7"; $arrayDocs[1] = "4c8fabdc24c2d8205db916a22e9459195833a272"; $arrayDocs[2] = "209526afab9e85b54e1832a820a7f578b7760af0"; $arrayDocs[3] = "59d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayDocs[4] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9d"; $arrayDocs[5] = "b207bea6c4833d90f6ee4e694ffb148c046b0eb3"; $arrayDocs[6] = "6d72a84b3aefbd3766078ed17a19aebb0c4ae026"; $arrayDocs[7] = "b00207b8944520ea3817334615a7cdbf8214232a"; $arrayDocs[8] = "d934f53af9bee26f35df7206dc06211778996986"; $arrayDocs[9] = "de2ecd02fd017b0311dbfe589b5faa7954ced196"; $arrayDocs[10] = "7d9752d09d3097fac748b6767472f9b69a65ed2e"; $arrayDocs[11] = "62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayDocs[12] = "d727b5b8ffaeadbac75123801c270fd65f19251c"; $arrayDocs[13] = "e39a9141fd9ce9426e88f30b6f245fdbb8f887a5"; $arrayDocs[14] = "85fe053baa7ccf469c440a7dd98381228a0c52c3"; $arrayDocs[15] = "6199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayDocs[16] = "af594de7d539519445013b7c87f02edbf3c44653"; $arrayDocs[17] = "b6eb6dab75d092f4be345925ccbf87ff1e17fc31"; $arrayDocs[18] = "2163ca6b0a608242712af82a81599f1f95c26dee"; foreach($arrayDocs as $doc) { $bitIndex = computeWalk($arrayTree, $doc); echo "<br/>"; print_r($bitIndex); echo "<br/>"; } function computeWalk($array, $needle) { $result = array(); for ($i = 0; $i < count($array) - 1; $i++) { if (false !== strpos($array[$i], $needle)) { echo " I = ".$i; if ($i % 2 == 0) { $result[] = getItemIndex($array[$i + 1], $array); } else { $result[] = getItemIndex($array[$i - 1], $array); } } } return $result; } function getItemIndex($item, $array) { $myPosition=-1; for ($i = 0; $i<count($array)-1; $i++) { if($array[$i]==$item) { $myPosition = $i; break; } } return $myPosition; } ?>
  4. I am using TCPDF & FPDI together to create and merge PDF's. I create a PDF with a link embedded in html and then merge it with another PDF. After merging, the link is only clickable if I pass in the link as // Set some content to print $html = <<<EOD <A HREF="http://www.helloworld.com">http://www.helloworld.com</A> EOD; $pdf->writeHTML($html, true, 0, true, 0); It is no longer clickable if I pass in the link as $html = <<<EOD <A HREF="http://www.helloworld.com">Visit Link</A> EOD; $pdf->writeHTML($html, true, 0, true, 0); I would like to pass it in the above way as the actual link I'm using is very long/tedious looking. Can anyone help here?
  5. I have a bunch of pdf's and I want to extract text from the last page of every pdf. I have a function to count the number of pages in each pdf. Does anyone know of a way that I could extract file from a specified file and page number. example: getData('example.pdf', 54);
  6. i also have this problem
  7. Please help. I am running xampp for windows - it contains apache, ssl, php, mysql. I am unable to generate a key/cert via php even though everything is apparently set up and running correctly. I ran a script and it said the following cert.php <?php $configargs = array( 'config' => '../apache/bin/openssl.cnf', 'digest_alg' => 'md5', 'x509_extensions' => 'v3_ca', 'req_extensions' => 'v3_req', 'private_key_bits' => 666, 'private_key_type' => OPENSSL_KEYTYPE_RSA, 'encrypt_key' => false, ); $dn = array( "countryName" => "IE", "stateOrProvinceName" => "cork", "localityName" => "cork", "organizationName" => "org", "organizationalUnitName" => "Organizational Unit Name", "commonName" => "example.com", "emailAddress" => "Email Address" ); // Generate a new private (and public) key pair $privkey = openssl_pkey_new($configargs); // Generate a certificate signing request $csr = openssl_csr_new($dn, $privkey); // You will usually want to create a self-signed certificate at this // point until your CA fulfills your request. // This creates a self-signed cert that is valid for 365 days $sscert = openssl_csr_sign($csr, null, $privkey, 365); // Now you will want to preserve your private key, CSR and self-signed // cert so that they can be installed into your web server, mail server // or mail client (depending on the intended use of the certificate). // This example shows how to get those things into variables, but you // can also store them directly into files. // Typically, you will send the CSR on to your CA who will then issue // you with the "real" certificate. openssl_csr_export($csr, $csrout) and var_dump($csrout); openssl_x509_export($sscert, $certout) and var_dump($certout); openssl_pkey_export($privkey, $pkeyout, "mypassword") and var_dump($pkeyout); // Show any errors that occurred here while (($e = openssl_error_string()) !== false) { echo $e . "\n"; } ?>
×
×
  • 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.