cereal 1,524 Nearly a Senior Poster Featured Poster

@UI

Something similar and probably more sane exists, see https://bountify.co/

There you can see each solution, unless the parts decide to use private messages. It works like this:

  • the requester sets a bounty, the range goes from 1 to 100 USD (before it allowed up to 500 USD) and it will stay active for 7 days
  • the requester pays the bounty upfront, on this stage he also pays a small fee to the website
  • if users decide to reply they usually use gist.github.com or pastebin & co. to share their solutions
  • the requester can discuss with each participant to fix the solutions
  • if the requester is happy with one of the provided solutions he/she can assign the bounty to the author
  • at this point the winner can receive the bounty

An example: https://bountify.co/help-converting-a-flat-json-file-into-hierarchical-json-schema-to-use-with-d3-treemap

If the requester does not choose a winner, or the winner does not withdraw the prize, after seven days the bounty will go to charity. Right now there is only one available, last time I checked there where a couple more, I think there was EFF also.

They have been up for the last five years and receive 3-4 requests per week.

Most of the time bounties are very low but people answer because they want to compete or try to solve the requests. However, I think this does not fit Daniweb and in general, forums.

If you think your idea can work, then put it up and see what you get.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

which Windows version are you using? Version 7 and previous, for example, miss this procedure.

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you change excel sheet and make it importable into mysql tables?

Yes, it can be done. You can convert it to CSV and the use fgetcsv() and prepared statements. Search for PHPExcel or similar. If you use MariaDB, a MySQL fork, then you can use the ODBC connect engine to attach the excel file to a table and run a query to insert the rows into the destination table, see:

cereal 1,524 Nearly a Senior Poster Featured Poster

Harri seems to be a spammer (human?), a quick search revealed many posts with the same text:

cereal 1,524 Nearly a Senior Poster Featured Poster

Keep in mind also that a lack of vitamin B favors insomnia. As thyroid issues like hyperthyroidism.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hehe, it will be fun, don't worry ;D

gentlemedia commented: Not sure about the fun part. Necessary? Yes! Bur fun...? :) +7
cereal 1,524 Nearly a Senior Poster Featured Poster

Just an addition. To test the queries you can try mysqlslap: https://dev.mysql.com/doc/refman/5.7/en/mysqlslap.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

please share the code and explain where you have difficulties. Also write meaningful titles, just php does not help who wants to help or is searching a solution for your same issue.

cereal 1,524 Nearly a Senior Poster Featured Poster

// EDIT

In addition to rproffitt's: contents, in the MS knowledge board, are loaded through Javascript, file_get_contents() won't load them, you need a rendering engine (like browsers do) to run your scripts. So you need something like PhantomJS: http://phantomjs.org/

Few months ago I posted an usage example here:

Which generates a screenshot of the page. The discussion was about testing the existence of a page with an HEAD request, which MS drops, and on success perform a GET request.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

if you can edit the main php.ini file, change the option to on:

allow_url_fopen=on

then reload the phpinfo page to see if it applied. The location of the file is defined in the Configuration File (php.ini) Path of the phpinfo view. If you cannot edit the main php.ini, you can try to create a new php.ini file in the document root. And just add the options you want to change. The Loaded Configuration File field of the phpinfo view should show if the new file is loaded.

Note: some times, the configuration (of PHP or of the web server) does not allow to override the settings through custom php.ini files, so you may need to contact your hosting support to make changes.

For more info, see the HOST and PATH directives:

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

${APACHE_RUN_DIR} should be defined in /etc/apache2/envvars, now I don't have one to verify, but it should be something like:

export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
cereal 1,524 Nearly a Senior Poster Featured Poster

IMHO it's best printing the name on the usb case and let the client reuse the drive. Otherwise you have to change the firmware of the usb to act like a CD, see if this helps: https://superuser.com/a/822578

Stefce commented: yes i would do the same but its not for me its for furniture company +2
cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe this will be helpful for your research:

cereal 1,524 Nearly a Senior Poster Featured Poster

Okay, I do not dance. Never. But I can listen the music while squinching at my shadow :D However the YT link seems broken (I mean the video id, not the protocol).

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you are missing a comma between these two columns, in the update statement:

work_carry = '$work_carry' demage_found = '$demage_found'

Then edit_customer_detail is not set by the form which, however, is okay if this is set by a previous step and carried through GET.

cereal 1,524 Nearly a Senior Poster Featured Poster

I see why, to be honest I was reading the documentation for PDO and saw why you were using fpassthru():

PDO::PARAM_LOB tells PDO to map the data as a stream, so that you can manipulate it using the PHP Streams API.

However while testing I got:

PHP Warning:  fpassthru() expects parameter 1 to be resource, string given

And in fact a comment in the same page states the same issue:

cereal 1,524 Nearly a Senior Poster Featured Poster

Great, now change fpassthru($lob); to echo $lob; as fpassthru() is used with file pointers.

seularts commented: This was the answer after all :) +2
cereal 1,524 Nearly a Senior Poster Featured Poster

With the disabled attribute those inputs are not submitted by the browser, you can use readonly instead.

cereal 1,524 Nearly a Senior Poster Featured Poster

Just a note!

I was just curious to learn why anyone would bother using the long version if the short version can do the same job. file_get_contents() using a URL is not guaranteed to work in all situations, as it depends on a configuration setting to allow it to use HTTP (which is sometimes disabled for security reasons) ...

It happens because allow_url_fopen is set to false, in case curl is not available you can also use sockets or fsockopen() & co.

Also, file_get_contents() allows more complex requests, in fact, it can make POST requests, by using the resource context parameter. The same can be done by file(), readfile(), fopen() and in general by all functions that support streams, an example:

<?php

$url = "https://www.apple.com/";

// Resource context
$rc["http"]["method"] = "GET";
$rc["http"]["header"] = "Accept-language: en\r\n";
$rc["http"]["follow_location"] = 1; // 1 = yes, 0 = no
$rc["http"]["timeout"] = 10; // seconds

$context = stream_context_create($rc);

$fp = fopen($url, "r", FALSE, $context);

while( ! feof($fp))
    print fread($fp, 4096);

fclose($fp);
cereal 1,524 Nearly a Senior Poster Featured Poster

$name is defined? If not the loop will not run:

while($i < count($name))
{
    $stmt->execute([':user_id' => $user_id, ':name' => $name[$i], ':email' => $email[$i], ':role' => $role[$i]]);
    $i++;
}

Also, you could add debugDumpParams() to see what looks like the prepared statement:

while($i < count($name))
{
    $stmt->execute([':user_id' => $user_id, ':name' => $name[$i], ':email' => $email[$i], ':role' => $role[$i]]);
    print_r($stmt->debugDumpParams());
    die;
}

This will stop the execution after the first loop and will show the contents of the query. If it does not help paste the result here and also the code.

diafol commented: Big hyand for debugDumpParams +15
cereal 1,524 Nearly a Senior Poster Featured Poster

There is a missing $ in $email[$i] and $role[$i].

Then you are passing three arguments to the execute() method: one array and then email and role with a syntax that would probably send some warnings.

$this cannot be used in this context, use $stmt.

In the prepare() method, the syntax to define the placeholder is not correct, the format is :keyword, not : keyword, nor =: keyword and not even = : keyword. And it is missing the last column: role.

The query has also another issue, a bracket: (, I think here you were trying to mix the two available syntaxes for inserts in MySQL:

INSERT INTO table (column, column) VALUES('', '');
INSERT INTO table SET column = '', column = '';

The first is the standard, the second is a peculiarity of MySQL.

To recap:

$stmt = $pdo->prepare("INSERT INTO `contact` (`user_id`, `name`, `email`, `role`) VALUES (:user_id, :name, :email, :role)");

while($i < count($name))
{
    $stmt->execute([':user_id' => $user_id, ':name' => $name[$i], ':email' => $email[$i], ':role' => $role[$i]]);
    $i++;
}

However there is still an issue. In the form there are some checkbox, by default if none are selected, the checkboxes will not be set by the browser and so the POST array will miss them. So, if your forms has fields for two identities (Person1, Person2) and you select only Teacher for Person2, you will get role[0] => Teacher. Value, that according to the loop, will be associated to Person1, not to Person2, as expected.

To avoid this, you have …

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

what is the size of the array? There are few errors:

  1. a syntax error: you are missing a comma between user_id and dateTime;
  2. dateTime, it does not matter the case, is a reserved word, so use backticks.

Also you could move prepare() outside the loop and use placeholders:

$stmt = $dbh->prepare("INSERT INTO `worksheet` SET `user_id` = :user_id, `dateTime` = NOW(), `indicator` = :indicator");

And set an array into execute() to define the values of each loop:

$stmt->execute([':user_id' => $user_id, ':indicator' => $indicator[$i]]);

You should move the header() outside the loop, too, but after, otherwise you keep setting it at each iteration. Right after that set exit, to stop the execution and make the server redirect. To recap:

$stmt = $dbh->prepare("INSERT INTO `worksheet` SET `user_id` = :user_id, `dateTime` = NOW(), `indicator` = :indicator");

while($i < count($indicator))
{
    $this->execute([':user_id' => $user_id, ':indicator' => $indicator[$i]]);
    $i++;
}

header('Location: form-page2.php');
exit;

See if these changes, in particular the syntax error, makes a difference. Otherwise, as you defined the exception mode, set a try catch block to see if PDO sends an exception.

cereal 1,524 Nearly a Senior Poster Featured Poster

MySQL suggests LONGBLOB or LONGTEXT, however with 5.7.8 there is also the JSON data type:

I have used the blob type to save small JSON objects, it works fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

If you can use the latest version of MySQL, then you can use JSON_REPLACE:

JSON_REPLACE(data, '$.Employee_Number', '544')

See: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html

cereal 1,524 Nearly a Senior Poster Featured Poster

All my other scripts (mysqli and procedural) worked like this:
if($sql)
So, why didn't it tonight ?
Why it only worked with oop style ?
if(TRUE === $conn->query($sql))
Is it because most part of the script is oop ?

No, it happens because $sql is a string, you could either do:

$conn->query($sql);

Or procedural:

$sql = mysqli_query($conn, "INSERT QUERY HERE");

With the procedural then your IF statement would work fine:

if($sql)

as the result of the query is assigned to the $sql variable. In my example I just skipped the assignement to a new variable an ran the query directly in the statement. It's the same.

it is not actually dumping just the url I am visiting but more. Infact, it's logging other links on my visited page.
Is it because the browser called those links to load the images (even though I did not click them) ?

Yes, the proxy is rewriting all the urls, so the browser is going to request them through the proxy script, it's the same list that you get through the Network tab of the Developer Tools.

and one link twice ?

It happens because there is a redirect with status code 301 or 302, then it reloads the page with status code 200, so the script log its boths.

If you were in my position, how would you code it so the img or video links (that are residing on …

cereal 1,524 Nearly a Senior Poster Featured Poster

Those sites you are viewing do not host your http://localhost:80/proxy/test.php? links nor precede it but your proxy itself does it.
Now, as you can see the proxy is preceding "http://localhost:80/proxy/test.php?" in order to proxify your chosen url. But my idea is, instead of getting it to precede "http://localhost:80/proxy/test.php?", why don't we get it to precede "http://localhost:80/proxy/tracker.php?" instead.
Now, can you figure-out which part of the code to replace with what to get the script to start logging ?

Sorry, but tracker.php what should do? It's the same code of test.php? Then just rename the file. If it's different and you want to send people from script A (test.php) to script B (tracker.php), you just need a form whose action points to script B, but then what is the role of the proxy here? Once you are on the tracker script, the proxy won't work anymore as the execution is completed. If you want to mix the proxy with the tracker then rename test.php to tracker.php and include your tracking code inside this file.

I have already suggested where you can place the tracking code.

Also consider that you don't need a form to initialize the proxy script, just append a link to the file name with a ? and it will work fine. Anyway, see if you get other replies. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

@UI

in addition to Andris, the first 16 lines are useless, because it makes a request to google and it does not use it. Line 21 ($url) is not used by the following code, so curl sends a request to the homepage not to the search. Even by changing that, to run the query and set an additional fake user agent, it will hit against a robot check:

<!--
    To discuss automated access to Amazon data please contact api-services-support@amazon.com.
    For information about migrating to our APIs refer to our Marketplace APIs at https://developer.amazonservices.com/ref=rm_c_sv, or our Product Advertising API at https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html/ref=rm_c_ac for advertising use cases.
-->

or status code 503 from CloudFront. Why? Try running the link you want to access through the command line curl:

curl -s -D - https://www.amazon.com/s/field-keywords=movies+2017 -o /dev/null

You get:

HTTP/1.1 301 Moved Permanently
...
Location: https://www.amazon.com/movies-2017/s?ie=UTF8&page=1&rh=i%3Aaps%2Ck%3Amovies%2B2017

which means you have to add a curl option to follow redirects. Would now work? Yes, but it probably won't return results because this part of the pattern ._AC_US_160_.jpg, in the preg match expression, is not pointing to what is currently returned by Amazon results page. So, you can:

  • open the source page and verify what is in use and hard code the change
  • or modify the pattern to be more flexible to code changes

in your current code it returns what is in the scr and in srcset attributes, so you can get an extended list of links for each entry and you could apply another …

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

in practice you want to log the $url variable. Between line 202 and 246 the scripts initialize the variable, verifies if the url format is valid and finally it attemps to contact the server. Now you have to decide at which step you want to log, for example if you want separate logging for successful and failed requests do it after line 246, i.e. after this line:

$response = makeRequest($url);

and use the responseInfo index returned in the $response array to log the differences.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

read the notice and the warning:

Notice: Use of undefined constant RETURNTRANSFER - assumed 'RETURNTRANSFER' in C:\xampp\htdocs\test\curl.php on line 27

Warning: curl_setopt() expects parameter 2 to be integer, string given in C:\xampp\htdocs\test\curl.php on line 27

The notice tells you that RETURNTRANSFER is not defined. The PHP engine in this case makes an assumption: you probably meant to use it as a string, so it dress the constant with quotes and serve it to the code.

The warning is just curl_setopt() complaining because, by consequence of the PHP engine assumption, received a string, when it was expecting an integer. So, have you checked if, among curl constants, there is something like RETURNTRANSFER?

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you cannot do this with plain HTML. You need javascript: you could use AJAX to submit the two forms, but you are going to generate two separated requests, with two separated responses from the server(s). Which means the second could return before the first is completed. Or one could fail, due to timeout or other issues. To solve these scenarios you could use the Promise API:

In practice the requests are performed asynchronously, and each will generate a promise, i.e. an object that represents a successful response or a failure. This can be done also in server side, see:

Can you explain why you want to keep them separated?

diafol commented: Promises, promises :) These multiple-form submits never add up for me. +15
cereal 1,524 Nearly a Senior Poster Featured Poster

I am trying to change the whole 3 circles with one button press. Any clue how? Why only one circle that changes color?

The reason is the ID (unique identifier):

<div id="circle1"></div>
<div id="circle1"></div>
<div id="circle1"></div>

which must be unique in the page, you have three of them.

cereal 1,524 Nearly a Senior Poster Featured Poster

In Javascript, hyphenated CSS properties margin-top & co. are converted to lower camel case, so marginTop. Line 27 has this issue.

See: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

Those are definitions of the same function (hcf), the first line is defining a default in case the second argument is 0, in that case returns the first argument (a). Why? Because if you run mod 1 0 you get an exception:

*** Exception: divide by zero

In haskell there are partial and total functions, mod is partial, as it returns an error in case the argument is not a valid value. By defining the default for 0 you cover that error. See:

cereal 1,524 Nearly a Senior Poster Featured Poster
diafol commented: Indicative of this person's m.o. Ridiculous. +15
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

in this case the artisan command won't solve the issue, because it's PHP telling those functions are deprecated as PHP 7.1.0.

The Mcrypt library has been declared deprecated and will be moved to PECL with the release of PHP 7.2.0, this because it relies on libmcrypt which has not been developed or mantained since 2007, see:

To solve, update the code with an alternative library.

cereal 1,524 Nearly a Senior Poster Featured Poster

Agree, preg results are painful. The following should ship the same output with preg_match_all():

$results = array_column($matches[0], 1);

However, I suspect it will add some overhead.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can also use a regular expression (regex), in PHP you can use regex with preg_* functions:

preg_match_all('/5/', $numberedString, $matches, PREG_OFFSET_CAPTURE);

The first argument is the pattern to search, the slashes are delimiters; the second argument is the subject to search, your string; the third argument is the array that will hold the results; the last argument is a constant to show the position of each match in the researched subject.

So, if you print it, you get:

print_r($matches);

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [0] => 5
                    [1] => 4
                )

            [1] => Array
                (
                    [0] => 5
                    [1] => 14
                )

            [2] => Array
                (
                    [0] => 5
                    [1] => 24
                )

            [3] => Array
                (
                    [0] => 5
                    [1] => 34
                )

        )

)

About the docs: at the end of each function page, there is a list of other functions to consider as alternative. If you open php.net/strpos you get preg_match, which would return only $matches[0][0], from there you can reach preg_match_all. Once you get used, you just have to explore and test.

cereal 1,524 Nearly a Senior Poster Featured Poster

In the specific case of Twitter, there is an API that allows to search through the public tweets of a specific account:

You can check the libraries used to connect this service here and see how it is done:

If you want to check the contents of a static page and here I mean the contents generated on server side and loaded in plain HTML, you can use a library to analyze the DOM, like:

DOM libraries require valid documents, if these are malformed then the extraction can fail.

If, instead, the contents are loaded through Javascript, you need a browser engine and some javascript, see as example:

A part these, there are many other available solutions, like regular expressions or scripting with command line tools as awk or sed:

Also, if the goal is to extract data, don't limit your choices to PHP, there are excellent solutions written in other languages, see for example Scrapy:

Curious to see what the code would look like and php is capable of doing it in how many lines of code.

Hehe, I think you can try to extract the tweet through a DOM library (DOM Crawler should be easy to use), check the HTML source of the link you provided, load the page and see what you can …

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition: consider that a bind can be defined in the execute() method, so:

$stmt->execute([':id' => $id]);

You could change the queries to whitelist some expressions and add it as a variable, something like this should work and allow you to define multiple conditions:

$sql = "SELECT * FROM `names` WHERE %s";

if($int > 0)
{
    $condition = "`fname` = :fname";
    $data = [':fname' => 'klaus'];
}

else
{
    $condition = "`fname` IS NOT NULL";
    $data = NULL;
}

$stmt = $db->prepare(sprintf($sql, $condition));
$stmt->execute($data);

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hehe, sure you can!

If you want to solve it, instead, read the notice, it says Use of undefined constant session - assumed 'session', which means you probably wrote:

$autoload['libraries'] = array(session); # without quotes

Instead of:

$autoload['libraries'] = array('session'); # with quotes

By adding quotes the value is considered a string, which is what you need in this case.

cereal 1,524 Nearly a Senior Poster Featured Poster

Open application/config/autoload.php and set session inside:

$autoload['libraries'] = array('session');

You can do the same with other libraries or helpers that you will use constantly, like database or form.

More info: https://codeigniter.com/user_guide/general/autoloader.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

it is not clear where you are having difficutiles.

cereal 1,524 Nearly a Senior Poster Featured Poster

It, probably, happens because you are calling the session inside application/core/MY_Loader.php but you are loading it from the controller, which is executed after the MY_Loader. Have you tried to autoload the session?

cereal 1,524 Nearly a Senior Poster Featured Poster

Okay,

consider to use the identical operator === on line 20:

if ($this->form_validation->run() == FALSE)

The alpha_space_only() callback can fail when using accented characters like àèéìòùñ, so you may want to replace the regex pattern to:

preg_match('/^[\p{L} ]+$/ui', $str)

a part this your code seems fine.

But another error happen.

So, what is the error?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello KK,

from the screenshot is seems you are trying to load CI resources from outside the application folder. Is Contact.php a CI controller? Can you share it? Remember to remove address and password as the post is public.

cereal 1,524 Nearly a Senior Poster Featured Poster

Have you read this? http://php.net/manual/en/language.expressions.php
Basically a statement can be an expression. And:

The simplest yet most accurate way to define an expression is "anything that has a value"

About tokens: in PHP it can be, strictly, used to define some parts of the language or used widely by the interlocutor to refer to other concepts, see:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I don't want to add confusion, but I wonder if there is an open process pointing to an unlinked file in that directory. Try something like:

lsof -nP +L1 | grep '(deleted)' | grep -i ".club"

from a terminal, to see if it outputs results. To be honest, I ran a test on my system[2] and, while the file was still "existing" for the process, I was able to install Flarum through composer.

Reference:

  1. http://www.gnu.org/software/libc/manual/html_node/Deleting-Files.html
  2. http://www.linuxquestions.org/questions/linux-security-4/how-can-i-hide-a-file-from-ls-a-496229/

Anyway, instead of using composer on the server, you could install it on local and then use SFTP (Filezilla has the client too) to upload all the files to the server.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

In addition to previous suggestion: if the path is wrong or does not have write permissions Python would return:

sqlite3.OperationalError: unable to open database file

Instead you get:

sqlite3.OperationalError: no such table: Airports

Which can be generated if:

  1. the database file name is wrong due, for example, to the case: linux is case sensitive, Mac OS no (at least not by default)
  2. the database file or the parent directory is read-only, so you have to change the permissions
  3. the table does not exists

In the first case connect() will create the database file, but this obviously won't have the Airports table.

In the first case this:

for row in cur.execute('''SELECT "Hello"'''):
    print row

will run successfully, it will run successfully also if the file is read-only, but it will fail if there are permission issues with the parent directory. The error, however, will be related to the database file, not to the table.