Jump to content

Wikipedia:Reference desk/Archives/Computing/2017 August 26

From Wikipedia, the free encyclopedia
Computing desk
< August 25 << Jul | August | Sep >> August 27 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


August 26

[edit]

How to modify Quadodo login script(v3.1.11) and database to reset password after login without any mailing or other method for resetting password securely by multiple users without mailing with PHP MySQLi/PDO

[edit]

How to implement this functionality in a web app wrapped in Quadodo login system or any alternative open source login system

 =>  Change/reset password should not be by mailing.However, if a user forgets the admin will be notified and the admin will reset the password to welcome and then with welcome password the user will reset to password of his choice.

I also want the system to be secure and restrict single simultaneous session per user. How should I modify the user table and the PHP source code, specially password changing script which appears to be nonfunctional, and disable any mail functionality?

Unfortunately the "Quadodo" login system does not appear to be enterprise grade/production quality. Web reviews are saying that the code repeatedly senselessly uses sha1() and md5().

Should I use bcrypt and password salting what will be the database schema like the one seen in culttt.com or "p2p.wrox.com"?

Where can I find such source code "php/mysqli/pdo" source code in Github or any book /site.45.120.16.220 (talk) 09:50, 26 August 2017 (UTC)[reply]

Convert python to PHP

[edit]

Can someone help me convert this python code to PHP?

n,x=input().split()
n=int(n)
l=lambda s:"".join(s)+"\n"
h=lambda s:s.replace(*"! ")*~-n+s.replace(*"!_")
print(l(" "+"_ "[c in"14"]*n+" "for c in x)+h(l("| "[c in"1237"]+n*"! "[c in"017"]+"| "[c in"56"]for c in x))+h(l(" |"[c in"0268"]+n*"! "[c in"1479"]+"| "[c=="2"]for c in x)))

Thanks! 82.43.219.147 (talk) 10:00, 26 August 2017 (UTC)[reply]

For anyone curious, this is a minified version of an ASCII-art seven-segment display formatter. --Tardis (talk) 20:31, 26 August 2017 (UTC)[reply]
There is no direct translation between Python and PHP. Many of the functions in Python are simply not the way PHP works and much of the way PHP works is simply not how it works in Python. The following gets to the same result using a very similar logic. I could have written the functions l and h, but it wouldn't have simplified things at all.
list($n,$x) = explode(' ',trim(fgets(STDIN))); // Split input on a space
$x = str_split($x); // Convert x to a character array
// No need to convert n to an int as PHP will doesn't care what the type is
foreach($x as $c) // PHP needs this to be a loop, you can't tack it on at the end
  print ' '.str_repeat(strpos(' 14',$c) ? ' ' : '_', $n).' '; // Repeat _ n times if c is not in 14
// Why the space before 14? It is a kludge fix to keep a '0' index being considered false
print "\n";
for($i=0; $i<$n-1; ++$i) // This is ugly because PHP doesn't let you say "do the previous stuff $n times"
{
  foreach($x as $c) // Same logic as above using strpos and str_repeat
    print (strpos(' 1237',$c) ? ' ' : '|').str_repeat(' ', $n).(strpos(' 56',$c) ? ' ' : '|');
  print "\n";
}
// Now, just keep repeating the previous logic for the rest of the lines of output
foreach($x as $c)
  print (strpos(' 1237',$c) ? ' ' : '|').str_repeat(strpos(' 017',$c) ? ' ' : '_', $n).(strpos(' 56',$c) ? ' ' : '|');
print "\n";
for($i=0; $i<$n-1; $i++)
{
    foreach($x as $c)
        print (strpos(' 134579',$c) ? ' ' : '|').str_repeat(' ', $n).(strpos(' 2',$c) ? ' ' : '|');
    print "\n";
}
foreach($x as $c)
    print (strpos(' 134579',$c) ? ' ' : '|').str_repeat(strpos(' 147',$c) ? ' ' : '_', $n).(strpos(' 2',$c) ? ' ' : '|');
print "\n";
That all can, obviously, be minimized. You can remove whitespace and other things to make it far less readable. If I was to write this from scratch, I wouldn't do it this way because this doesn't get at the strengths of PHP. It is more of a bad translation from Python to PHP. 209.149.113.5 (talk) 18:24, 28 August 2017 (UTC)[reply]

Does Microsoft Excel have an "hours:minutes" format for values?

[edit]

I have Excel 2016. Does Microsoft Excel have an "hours:minutes" format for values? So, for example, I might say: On Monday, I worked 07:53 hours/minutes; on Tuesday, I worked 05:48 hours/minutes; and so forth. And the Excel spread sheet can do mathematical calculations upon those values. The only thing I can seem to find is a "time" format. For example, the time now is 1:36 PM. Or, the time now is 13:36 military time. But, that's not what I want. I want "hours:minutes". Also, I don't want to have to do equivalent calculations myself. For example, I don't want to have to calculate that 00:30 minutes equals 0.5 hours, and then use the 0.5 hours to calculate totals. I want something that will display (and calculate) that -- from my above example -- 07:53 hours/minutes on Monday plus 05:48 hours/minutes on Tuesday equals 13:41 hours/minutes in total. Thanks. Joseph A. Spadaro (talk) 20:38, 26 August 2017 (UTC)[reply]

[h]:mm Phil Holmes (talk) 09:37, 27 August 2017 (UTC)[reply]
Thanks. Joseph A. Spadaro (talk) 16:41, 27 August 2017 (UTC)[reply]

DVI-D to VGA conversion

[edit]

I have a VGA-D converter but I'm not sure whether it works. I've found another online which looks very different and I've heard from someone else that they have some active circuitry in them which suggests that the style I've bought could never work and is basically fake. Is that correct?

The small style which I have

The larger style which presumably has more going on inside

--145.255.246.8 (talk) 21:09, 26 August 2017 (UTC)[reply]
I think the smaller one is DVI-I to VGA. [1] "DVI-I has a separate bunch of pins that carry a VGA signal. A DVI-I to VGA adapter plug just wires the VGA socket on the adapter to these pins. DVI-D does not have these VGA connections (they may not even be physically present) so there is no VGA signal for the adapter to pick up. Therefore you need a digital to analogue converter unit to adapt a DVI-D output to VGA." [2] Note that this picture shows that those 4 little pins on the side are absent. (((The Quixotic Potato))) (talk) 21:26, 26 August 2017 (UTC)[reply]
No, it's DVI-D, not DVI-I. I would have given a link but Wikipedia has blacklisted the website so I can't. https://www.ali express.com/item/15-Pin-VGA-Female-to-DVI-D-Male-Adapter-Converter-LCD/32816075448.html I've broken the link to bypass the blockade. --145.255.246.8 (talk) 11:49, 29 August 2017 (UTC)[reply]
That's a fairly weird device. The price means it's definitely not active. Maybe there is some weird device with DVI-D output port which supports VGA but uses some weird pinout. I don't think 15 wires is enough even for single link DVI-D so you can't use it (and another adapter) to put a DVI-D signal through a VGA cabling unless I'm mistaken and in any case you'd probably want the adapter to be the reverse (male VGA, female DVI-D). (Ideally you want 18 plus ground but maybe 17 or even 16 is enough.) Maybe it's simply useless and doesn't work with anything. If you look at the reviews, no one seems to actually say it works. Some people say they got refunded for various reasons. Some people say they received a product as per the photo (but what for?). Some people even seem to blame themselves for compabitility issues. At least one received a DVI-I adapter instead. Yet others seems to recognise it doesn't work and can never work. It would be interesting if someone actually took one apart and checked how it was wired if at all. Nil Einne (talk) 12:43, 30 August 2017 (UTC)[reply]
Thinking about it, I guess you could use it and another adapter to put a VGA signal through DVI-D (single or dual link) cabling, rather than what I was initially thinking of and mentioned above namely a DVI signal through a VGA cabling. And it's even the right direction for that I suspect (I presume most room cabling would have two female ports). This seems a lot less useful since while I can imagine some other rooms etc may have VGA cabling and this cabling may good enough to support a DVI-D signal were it not for the fact there aren't enough wires. Whereas it seems a lot less likely there will be a room or whatever with DVI-D cabling and you want to put VGA through it. But I guess there could be some cases where it will arise. Nil Einne (talk) 12:43, 30 August 2017 (UTC)[reply]
Edited both posts above to fix info on adapter directions. Nil Einne (talk) 12:43, 30 August 2017 (UTC)[reply]
Yes DVI-I to VGA converters are very common and not fake. They have worked well for the majority of use cases for 16+ years since most desktop GPUs still supported at least one or actually after 2004? two VGA outputs regardless of how many direct VGA outputs they had although I think recently some may have come back down to only supporting one again. Note that a well made GPU should probably have a DVI-D keyed output port if it's not DVI-I so it should not be possible to plug a DVI-I adapter in to it. However it's possible if the device has multiple DVI outputs it may have multiple DVI-I outputs so you can choose which one to plug it into, but the number which can support DVI-I simultaneously areis more limited. I.E. All the DVI-I ports can function as DVI-I so are correctly keyed, but not all at the same time. Nil Einne (talk) 05:28, 27 August 2017 (UTC) edit: 14:38, 27 August 2017 (UTC)[reply]
@Nil Einne: ???? (((The Quixotic Potato))) (talk) 11:36, 27 August 2017 (UTC)[reply]
Sorry for the confusion, reworded. Nil Einne (talk) 14:38, 27 August 2017 (UTC)[reply]
Thank you. (((The Quixotic Potato))) (talk) 14:47, 27 August 2017 (UTC)[reply]
Please explain what you mean when you say you're not sure if it works. You plugged it in and got what ? A black screen ? StuRat (talk) 22:00, 26 August 2017 (UTC)[reply]
"Check signal cable" or whatever. 145.255.246.8 (talk) 11:51, 29 August 2017 (UTC)[reply]