Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Curl issue

  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post Curl issue

    Hello

    I want login with my username and password to my Joomla admin account with cURL. The code seem to be fine but still couldn't login and I ignore the reason, I create a working account for test :

    Url to admin authentication page : http://www.fsr.servhome.org/administrator/?admin

    Username : demo

    Password : demo/

    Here the php file script.php :


    PHP Code:
    <?php
    $fields
    ['task'] = 'login';
    $fields['option'] = 'com_login';
    $fields['username'] = 'demo';
    $fields['passwd'] = 'demo/';
    $urlLogin 'http://www.fsr.servhome.org/administrator/?admin';
    $useragent 'Mozilla/5.0';
    $referer $urlLogin;
    $urlLogout 'http://www.fsr.servhome.org/administrator/index.php?option=com_login&task=logout';

    $ch curl_init();
    curl_setopt($chCURLOPT_URL$urlLogin);
    curl_setopt($chCURLOPT_POST1);
    curl_setopt($chCURLOPT_POSTFIELDS$fields);
    curl_setopt($chCURLOPT_USERAGENT$useragent);
    curl_setopt($chCURLOPT_REFERER$referer);
    curl_setopt($chCURLOPT_COOKIESESSION1);
    curl_setopt ($curlCURLOPT_COOKIEJAR'cookie.txt');
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    $result curl_exec($ch);

    curl_setopt($chCURLOPT_URL$urlLogout);
    curl_setopt($chCURLOPT_COOKIESESSION1);
    curl_setopt($chCURLOPT_COOKIEFILE'cookie.txt');
    curl_setopt($chCURLOPT_USERAGENT$useragent);
    curl_setopt($chCURLOPT_REFERER$urlLogout);
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    $result curl_exec($ch);
    curl_close($ch);
    ?>
    Think You

  • #2
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post

    Hi

    I couldn't find help, seem the issue is very difficult and unique. I post the code of the login form which located in http://www.fsr.servhome.org/administ.../mod_login.php. Please help me I didn't find any answer and I am working to run my first cron for more than a week and I still not able to authenticate.

    PHP Code:
    <?php

    // no direct access
    defined'_JEXEC' ) or die( 'Restricted access' );

    jimport('joomla.language.helper');
    //$browserLang = JLanguageHelper::detectLanguage();
    // forced to default
    $browserLang null;
    $lang =& JFactory::getLanguage();

    $languages = array();
    $languages JLanguageHelper::createLanguageList($browserLang );
    array_unshift$languagesJHTML::_('select.option',  ''JText::_'Default' ) ) );
    $langs JHTML::_('select.genericlist',   $languages'lang'' class="inputbox"''value''text'$browserLang );
    ?>
    <?php 
    if(JPluginHelper::isEnabled('authentication''openid')) :
            
    $lang->load'plg_authentication_openid'JPATH_ADMINISTRATOR );
            
    $langScript =     'var JLanguage = {};'.
                            
    ' JLanguage.WHAT_IS_OPENID = \''.JText::_'WHAT_IS_OPENID' ).'\';'.
                            
    ' JLanguage.LOGIN_WITH_OPENID = \''.JText::_'LOGIN_WITH_OPENID' ).'\';'.
                            
    ' JLanguage.NORMAL_LOGIN = \''.JText::_'NORMAL_LOGIN' ).'\';'.
                            
    ' var modlogin = 1;';
            
    $document = &JFactory::getDocument();
            
    $document->addScriptDeclaration$langScript );
            
    JHTML::_('script''openid.js');
    endif; 
    ?>
    <form action="<?php echo JRoute::_'index.php'true$params->get('usesecure')); ?>" method="post" name="login" id="form-login" style="clear: both;">
        <p id="form-login-username">
            <label for="modlgn_username"><?php echo JText::_('Username'); ?></label>
            <input name="username" id="modlgn_username" type="text" class="inputbox" size="15" />
        </p>

        <p id="form-login-password">
            <label for="modlgn_passwd"><?php echo JText::_('Password'); ?></label>
            <input name="passwd" id="modlgn_passwd" type="password" class="inputbox" size="15" />
        </p>
        <?php
        
    if($error JError::getError(true)) {
            echo 
    '<p id="login-error-message">';
            echo 
    $error->get('message');
            echo 
    '<p>';
        }
        
    ?>
        <p id="form-login-lang" style="clear: both;">
            <label for="lang"><?php echo JText::_('Language'); ?></label>
            <?php echo $langs?>
        </p>
        <div class="button_holder">
        <div class="button1">
            <div class="next">
                <a onclick="login.submit();">
                    <?php echo JText::_'Login' ); ?></a>

            </div>
        </div>
        </div>
        <div class="clr"></div>
        <input type="submit" style="border: 0; padding: 0; margin: 0; width: 0px; height: 0px;" value="<?php echo JText::_'Login' ); ?>" />
        <input type="hidden" name="option" value="com_login" />
        <input type="hidden" name="task" value="login" />
        <?php echo JHTML::_'form.token' ); ?>
    </form>
    ?>
    Think You.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •