I use joomla 2.5.27 and community builder 2.0.2.
I use cb rank plugin for community builder
I get error
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'AND confirmed = 1 AND approved = 1' at line 1 SQL=SELECT
COUNT(id) FROM r2yze_comprofiler WHERE cb_points > AND confirmed
= 1 AND approved = 1
How to fix this error
PHP Code
// Calculate rank
if ( $ordertype == "low" ) {
$_CB_database->setQuery( "SELECT COUNT(`id`) FROM #__comprofiler WHERE `$fieldname` < $userfield AND `confirmed` = 1 AND `approved` = 1" );
}
else {
$_CB_database->setQuery( "SELECT COUNT(`id`) FROM #__comprofiler WHERE `$fieldname` > $userfield AND `confirmed` = 1 AND `approved` = 1" );
}
$value = $_CB_database->loadResult() + 1;
full PHP code
<?php
/**
* Joomla Community Builder Rank Field Type Plugin: plug_cbrankfield
* #version $Id$
* #package plug_cbrankfield
* #subpackage cb.rankfield.php
* #author Joe Palmer
* #copyright (C) 2009 www.softforge.co.uk
* #license Limited http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2
* #final 1.0
*/
/** ensure this file is being included by a parent file */
if ( ! ( defined( '_VALID_CB' ) || defined( '_JEXEC' ) || defined( '_VALID_MOS' ) ) ) { die( 'Direct Access to this location is not allowed.' ); }
global $_PLUGINS;
$_PLUGINS->loadPluginGroup( 'user', array( (int) 1 ) );
$_PLUGINS->registerUserFieldTypes( array( 'rankfield' => 'CBfield_rank' ) );
$_PLUGINS->registerUserFieldParams();
class CBfield_rank extends CBfield_counter {
/**
* Returns a field in specified format
*
* #param moscomprofilerFields $field
* #param moscomprofilerUser $user
* #param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
* #param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
* #param int $list_compare_types IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
* #return mixed
*/
function getField( &$field, &$user, $output, $reason, $list_compare_types ) {
global $_CB_framework, $ueConfig, $_CB_database;
$oReturn = null;
$fieldname = $field->params->get( 'fieldOrderName', 'hits' );
$ordertype = $field->params->get( 'fieldOrderType', 'high' );
$userfield = $user->$fieldname;
// Calculate rank
if ( $ordertype == "low" ) {
$_CB_database->setQuery( "SELECT COUNT(`id`) FROM #__comprofiler WHERE `$fieldname` < $userfield AND `confirmed` = 1 AND `approved` = 1" );
}
else {
$_CB_database->setQuery( "SELECT COUNT(`id`) FROM #__comprofiler WHERE `$fieldname` > $userfield AND `confirmed` = 1 AND `approved` = 1" );
}
$value = $_CB_database->loadResult() + 1;
switch ( $output ) {
case 'html':
case 'rss':
$oReturn = $value;
break;
case 'htmledit':
// $oReturn = parent::getField( $field, $user, $output, $reason, $list_compare_types );
$oReturn = null; //TBD for now no searches...not optimal in SQL anyway.
break;
case 'json':
case 'php':
case 'xml':
case 'csvheader':
case 'fieldslist':
case 'csv':
default:
$oReturn = $this->_formatFieldOutputIntBoolFloat( $field->name, $value, $output );
break;
}
return $oReturn;
}
}//end of rank field
?>
Try this.
// Calculate rank
if ( $ordertype == "low" ) {
$_CB_database->setQuery( "SELECT COUNT(`id`) FROM #__comprofiler WHERE ".$fieldname." < '".$userfield."' AND `confirmed` = 1 AND `approved` = 1" );
}
else {
$_CB_database->setQuery( "SELECT COUNT(`id`) FROM #__comprofiler WHERE ".$fieldname." > '".$userfield."' AND `confirmed` = 1 AND `approved` = 1" );
}
$value = $_CB_database->loadResult() + 1;
Related
How to remove owing side from inversed MTO relation side without cascade option? , how to update the inversed side of relation without cascade option?
Error is that if i change address(OTM) of the room (MTO), room remains in the previous address, although i remove it .
if( $this->addrOTM_b_ -> getRoomMTO_b_1() -> contains($this) ) {
$this->addrOTM_b_ -> getRoomMTO_b_1() -> remove($this);
}
If i check the address of the room - it is correct new address.
But if i check the rooms in the address, they are wrong, because exists rooms which have been removed.
Maybe there is an order how i shall flush entities? Or an order how i shall remove rooms from addresses? Or maybe it is not possible to make at level of entity, and i shall make this at level of Controller action?
This post has a coment that it is not possible:Doctrine: can't removeElement from inverse side of the relation
This is just an illustration about bidirectional MTO relation,
Normally it is difficult to transfer room to another address, unless it is a boat/tent/van.
p.s.
I know that it is not good to flush inside the foreach loop,
but i can not clear entity manager, because i will use entities in the second loop.
Anyway these loops are litte, thre are only 5 addresses and 20 rooms.
//Controller action, kind of fixture
//FIRST ROUND seeting random address for each room
foreach ( $roomEntArr as $roomEnt ) {
$addrCnt = count($addrEntArr)-1;
$i = rand(0, $addrCnt);
$addrEnt = $addrEntArr[$i];
$roomEnt->setAddrOTM_b_($addrEnt);
$this->em->persist($roomEnt);
$this->em->persist($addrEnt);
$this->em->flush();
}
$addrRoomArr1 = [];
foreach ( $addrEntArr as $ent1 ) {
$addrId = $ent1->getId();
$roomEnts = $ent1->getRoomMTO_b_1(); $roomStr="";
if( !empty($roomEnts) ) {
foreach ($roomEnts as $addr) { $roomStr .= $addr->getId().','; }
}
$addrRoomArr1[$addrId] = $roomStr;
} //foreach ( $ent1arr as $ent1 ) {
$roomAddrArr1 = [];
if( $dir==='b' ) {
foreach ( $roomEntArr as $ent2 ) {
$roomId = $ent2->getId();
$addr = $ent2->getAddrOTM_b_(); $addrStr="";
if($addr !== null) { $addrStr = $addr->getId().','; }
$roomAddrArr1[$roomId] = $addrStr;
} //foreach ( $ent1arr as $ent1 ) {
} //if( $dir==='b' ) {
//SECOND ROUND seeting random address for each room
foreach ( $roomEntArr as $roomEnt ) {
$addrCnt = count($addrEntArr)-1;
$i = rand(0, $addrCnt);
$addrEnt = $addrEntArr[$i];
$roomEnt->setAddrOTM_b_($addrEnt);
$this->em->persist($roomEnt);
$this->em->persist($addrEnt);
$this->em->flush();
}
$addrRoomArr1 = [];
foreach ( $addrEntArr as $ent1 ) {
$addrId = $ent1->getId();
$roomEnts = $ent1->getRoomMTO_b_1(); $roomStr="";
if( !empty($roomEnts) ) {
foreach ($roomEnts as $addr) { $roomStr .= $addr->getId().','; }
}
$addrRoomArr1[$addrId] = $roomStr;
} //foreach ( $ent1arr as $ent1 ) {
$roomAddrArr1 = [];
if( $dir==='b' ) {
foreach ( $roomEntArr as $ent2 ) {
$roomId = $ent2->getId();
$addr = $ent2->getAddrOTM_b_(); $addrStr="";
if($addr !== null) { $addrStr = $addr->getId().','; }
$roomAddrArr1[$roomId] = $addrStr;
} //foreach ( $ent1arr as $ent1 ) {
} //if( $dir==='b' ) {
//Room entity
<?php
namespace DctrBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Mapping\Index;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\ManyToMany;
use DctrBundle\Entity\AddrOTM_b_;
/**
/**
* #Table(name="t_roomMTO_b_1")
* #Entity( repositoryClass="DctrBundle\Repository\RoomMTO_b_1Repository" )
*/
class RoomMTO_b_1 {
/**
* #var integer
*
* #Column(name="id", type="integer" )
* #Id
* #GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ManyToOne(targetEntity="DctrBundle\Entity\AddrOTM_b_", inversedBy="roomMTO_b_1" )
* #JoinColumn(name="addr_id", referencedColumnName="id")
*/
private $addrOTM_b_;
public function __construct() {
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get AddrOTM_b_
*
* #return DctrBundle\Entity\AddrOTM_b_
*/
public function getAddrOTM_b_()
{
return $this->addrOTM_b_;
}
/**
* Get AddrOTM_b_
*
* #return DctrBundle\Entity\AddrOTM_b_
*/
public function setAddrOTM_b_( $addrOTM_b_ )
{
if ( $addrOTM_b_ !== null ) {
//if current address is not null, and if it is not the same
//1) remove the room from the previous address if it exists
//2) set new address to this room ( automatically removes the oldAddress from the room)
if ( $this->addrOTM_b_ !== null ) {
if( $addrOTM_b_->getId() != $this->addrOTM_b_->getId() ) {
// first you have to remove this room from previous address - this part does not work, according docs : Changes made only to the inverse side of an association are ignored. Make sure to update both sides of a bidirectional association (or at least the owning side, from Doctrine’s point of view). http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/unitofwork-associations.html
if( $this->addrOTM_b_ -> getRoomMTO_b_1() -> contains($this) ) {
$this->addrOTM_b_ -> getRoomMTO_b_1() -> remove($this);
}
// then you can set the room to the new address
$this->addrOTM_b_ = $addrOTM_b_;
} // if( $addrOTM_b_->getId() != $this->addrOTM_b_->getId ) {
} // if ( $this->addrOTM_b_ !== null ) {
else {
//if current address is null, just set the address
$this->addrOTM_b_ = $addrOTM_b_;
}
//3) add room to the new address
if ( !$addrOTM_b_->hasRoomMTO_b_1($this) ) {
//$addrMTM_b_1->getRoomMTM_b_()->removeElement($this);
$addrOTM_b_->addRoomMTO_b_1($this);
}
return $this;
} // if ( $addrOTM_b_ !== null ) {
else {
if ( $this->addrOTM_b_ !== null ) {
$idold = $this->addrOTM_b_->getId();
//remove this room from previous address
if( $this->addrOTM_b_ -> getRoomMTO_b_1() -> contains($this) ) {
$this->addrOTM_b_ ->getRoomMTO_b_1()->remove($this);
}
$this->addrOTM_b_ = null;
} // if ( $this->addrOTM_b_ !== null ) {
return true;
} // else of if ( $addrOTM_b_ !== null ) {
} //public function setAddrOTM_b_( $addrOTM_b_ )
/**
* #param DctrBundle\Entity\RoomMTO_b_1 $AddrOTM_b_
* #return bool
*/
public function hasAddrOTM_b_($addrOTM_b_)
{
if( ($addrOTM_b_!==null) && ($this->addrOTM_b_!== null) ) {
return ( $addrOTM_b_->getId() == $this->getAddrOTM_b_()->getId() );
}
else {
return false;
}
}
/**
* Return Entity as string
*
* #return string String representation of this class
*/
public function __toString()
{
return strval($this->id);
}
} // class RoomMTO_b_1 {
//Address entity
<?php
namespace DctrBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Mapping\Index;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\ManyToMany;
use DctrBundle\Entity\RoomMTO_b_1;
/**
/**
* #Table(name="t_addrOTM_b_")
* #Entity( repositoryClass="DctrBundle\Repository\AddrOTM_b_Repository" )
*/
class AddrOTM_b_ {
/**
* #var integer
*
* #Column(name="id", type="integer" )
* #Id
* #GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #OneToMany(targetEntity="DctrBundle\Entity\RoomMTO_b_1", mappedBy="addrOTM_b_" )
*/
private $roomMTO_b_1;
public function __construct() {
$this->roomMTO_b_1 = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get RoomMTO_b_1
*
* #return DctrBundle\Entity\RoomMTO_b_1
*/
public function getRoomMTO_b_1()
{
return $this->roomMTO_b_1;
}
/**
* Remove RoomMTO_b_1
*
* #param DctrBundle\Entity\AddrOTM_b_ $RoomMTO_b_1
*/
public function removeRoomMTO_b_1 (\DctrBundle\Entity\RoomMTO_b_1 $roomMTO_b_1)
{
if( $roomMTO_b_1->getAddrOTM_b_()->getId() == $this->id ) {
$roomMTO_b_1->setAddrOTM_b_(null);
} //
if ( $this->hasRoomMTO_b_1($roomMTO_b_1) ) {
$this->roomMTO_b_1->removeElement($roomMTO_b_1);
} // else if ( !$this->hasRoomMTO_b_1($roomMTO_b_1) )
} //remove
/**
* Add RoomMTO_b_1
*
* #param DctrBundle\Entity\AddrOTM_b_ $RoomMTO_b_1
*
* #return RoomMTO_b_1
*/
public function addRoomMTO_b_1(\DctrBundle\Entity\RoomMTO_b_1 $roomMTO_b_1)
{
if(!$roomMTO_b_1 instanceof \DctrBundle\Entity\RoomMTO_b_1) {
throw new \InvalidArgumentException('$roomMTO_b_1 must be null or instance of DctrBundle\Entity\RoomMTO_b_1');
}
else if ( !$this->hasRoomMTO_b_1($roomMTO_b_1) ) {
$this->roomMTO_b_1->add($roomMTO_b_1);
//echo "<br> 150,addRoomMTO_b_1 setting room to address in ".__FILE__;
if ( !$roomMTO_b_1->hasAddrOTM_b_($this) ) {
$roomMTO_b_1->setAddrOTM_b_($this);
}
} // else if ( !$this->hasRoomMTO_b_1($RoomMTO_b_1) ) {
return $this;
} //
/**
* #param DctrBundle\Entity\AddrOTM_b_ $RoomMTO_b_1
* #return bool
*/
public function hasRoomMTO_b_1($roomMTO_b_1)
{
return $this->getRoomMTO_b_1()->contains($roomMTO_b_1);
}
/**
* Return Entity as string
*
* #return string String representation of this class
*/
public function __toString()
{
return strval($this->id);
}
} //class AddrOTM_b_ {
The reason was wrong syntax, WRONG - remove, RIGHT - removeElement
WRONG in room entity setAddrOTM_b_($addr) :
if( $this->addrOTM_b_ -> getRoomMTO_b_1() -> contains($this) ) {
$this->addrOTM_b_ -> getRoomMTO_b_1() -> remove($this);
}
RIGHT in room entity setAddrOTM_b_($addr):
if( $this->addrOTM_b_ -> getRoomMTO_b_1() -> contains($this) ) {
$this->addrOTM_b_ -> getRoomMTO_b_1() -> removeElement($this);
}
I am totally new here, I will try to explain. On each data table header we have show entries, were we have options something like 10,20,30... This is normally displayed in select options, Insted i want it to be in List in ul li.
You need to modify jquery.dataTables.js file, refer below code which create menu item for length:- (Please note, this is code from jquery.dataTables.js file and you need to modify according to convert select option dropdown to ul li list)
/* This can be overruled by not using the _MENU_ var/macro in the language variable */
var sName = 'name="'+oSettings.sTableId+'_length"';
var sStdMenu = '<select size="1" '+sName+'>';
var i, iLen;
var aLengthMenu = oSettings.aLengthMenu;
if ( aLengthMenu.length == 2 && typeof aLengthMenu[0] === 'object' &&
typeof aLengthMenu[1] === 'object' )
{
for ( i=0, iLen=aLengthMenu[0].length ; i<iLen ; i++ )
{
sStdMenu += '<option value="'+aLengthMenu[0][i]+'">'+aLengthMenu[1][i]+'</option>';
}
}
else
{
for ( i=0, iLen=aLengthMenu.length ; i<iLen ; i++ )
{
sStdMenu += '<option value="'+aLengthMenu[i]+'">'+aLengthMenu[i]+'</option>';
}
}
sStdMenu += '</select>';
var nLength = document.createElement( 'div' );
if ( !oSettings.aanFeatures.l )
{
nLength.id = oSettings.sTableId+'_length';
}
nLength.className = oSettings.oClasses.sLength;
nLength.innerHTML = '<label>'+oSettings.oLanguage.sLengthMenu.replace( '_MENU_', sStdMenu )+'</label>';
/*
* Set the length to the current display length - thanks to Andrea Pavlovic for this fix,
* and Stefan Skopnik for fixing the fix!
*/
$('select option[value="'+oSettings._iDisplayLength+'"]', nLength).attr("selected", true);
$('select', nLength).bind( 'change.DT', function(e) {
var iVal = $(this).val();
/* Update all other length options for the new display */
var n = oSettings.aanFeatures.l;
for ( i=0, iLen=n.length ; i<iLen ; i++ )
{
if ( n[i] != this.parentNode )
{
$('select', n[i]).val( iVal );
}
}
/* Redraw the table */
oSettings._iDisplayLength = parseInt(iVal, 10);
_fnCalculateEnd( oSettings );
/* If we have space to show extra rows (backing up from the end point - then do so */
if ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() )
{
oSettings._iDisplayStart = oSettings.fnDisplayEnd() - oSettings._iDisplayLength;
if ( oSettings._iDisplayStart < 0 )
{
oSettings._iDisplayStart = 0;
}
}
if ( oSettings._iDisplayLength == -1 )
{
oSettings._iDisplayStart = 0;
}
_fnDraw( oSettings );
} );
does anyone here familiar with MyBB?
I want to display all images in a thread in the forums that I have chosen previously in a gallery slide.
[img]*URL_IMAGE_FILE*[/img]
of the slider is a slider that I mean the following.
http://community.mybb.com/attachment.php?aid=26307
that where: 17 and 18 there are IDs that I choose.
WHERE t.fid IN (17,18) AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
please correct the following code if there is an error.
// Slider Images
/***** Slider Gallery Thread End *****/
/* LATEST THREADS */
$query = $db->query("
SELECT t.*, p.message, a.aid, a.thumbnail
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid = t.firstpost)
LEFT JOIN ".TABLE_PREFIX."attachments a ON(a.pid=p.pid)
WHERE t.fid IN (17,18) AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
ORDER BY t.dateline DESC
LIMIT 1");
if(!$db->num_rows($query))
{
// Needs to output a nice "no posts here" box
$title = 'Error';
$message = 'No Message';
eval("\$tricks = \"".$templates->get("member_profile_no_content")."\";");
}
else
{
// Set up the parser options.
$parser_options = array(
"allow_html" => $forum['allowhtml'],
"allow_mycode" => $forum['allowmycode'],
"allow_smilies" => $forum['allowsmilies'],
"allow_imgcode" => $forum['allowimgcode'],
"allow_videocode" => $forum['allowvideocode'],
"filter_badwords" => 1
);
while($threads = $db->fetch_array($query))
{
$threads['threadlink'] = get_thread_link($threads['tid']);
if($threads['lastposteruid'] == 0)
{
$lastposterlink = $threads['lastposter'];
}
else
{
$lastposterlink = build_profile_link($threads['lastposter'], $threads['lastposteruid']);
}
$view_string = 'Views';
$reply_string = 'Replies';
if($threads['views'] == 1)
{
$view_string = 'Views';
}
if($threads['replies'] == 1)
{
$reply_string = 'Replies';
}
if ($thread['thumbnail'])
{
$thumbnail = '';
}
else
{
$thumbnail = '';
}
$threads['profilelink'] = build_profile_link($threads['username'], $threads['uid']);
$threads['reply'] = $lang->sprintf($lang->thread_views_stats, my_number_format($threads['replies']), $reply_string, my_number_format($threads['views']), $view_string);
$threads['date'] = my_date($mybb->settings['dateformat'], $threads['dateline']);
$threads['time'] = my_date($mybb->settings['timeformat'], $threads['dateline']);
$threads['lastpostlink'] = get_thread_link($threads['tid'], 0, "lastpost");
$threads['message'] = my_substr($threads['message'], 0, 150) . "...";
$threads['message'] = $parser->parse_message($threads['message'], $options);
eval("\$tricks .= \"".$templates->get("depan_slides")."\";");
}
}
/***** Slider Gallery Thread End *****/
What is the best way in C++03 to split a command line in to two strings: executable and arguments?
For example:
"\"c:\\Program Files\\MyFile.exe\" /a /b /c" => "c:\Program Files\MyFile.exe", "/a /b /c"
"c:\\Foo\\bar.exe -t \"myfile.txt\"" => "c:\Foo\bar.exe", "-t \"myfile.txt\""
"baz.exe \"quantum conundrum\"" => "baz.exe", "\"quantum conundrum\""
A good solution should handle both quotes and spaces.
boost is acceptable.
My current (working) solution:
void split_cmd( const std::string& cmd,
std::string* executable,
std::string* parameters )
{
std::string c( cmd );
size_t exec_end;
boost::trim_all( c );
if( c[ 0 ] == '\"' )
{
exec_end = c.find_first_of( '\"', 1 );
if( std::string::npos != exec_end )
{
*executable = c.substr( 1, exec_end - 1 );
*parameters = c.substr( exec_end + 1 );
}
else
{
*executable = c.substr( 1, exec_end );
std::string().swap( *parameters );
}
}
else
{
exec_end = c.find_first_of( ' ', 0 );
if( std::string::npos != exec_end )
{
*executable = c.substr( 0, exec_end );
*parameters = c.substr( exec_end + 1 );
}
else
{
*executable = c.substr( 0, exec_end );
std::string().swap( *parameters );
}
}
}
I trying to connect to iSCSI target via WMI (class WMI\MSIscsiInitiator_TargetClass, which is distributed with Microsoft software initiator), but always get a generic failure (80041001). Here is my code:
var mgmts = GetObject("winmgmts:\\\\.\\root\\WMI");
function login (path, login, passwd) {
var portal = mgmts.Get("MSIscsiInitiator_Portal").SpawnInstance_(),
target = mgmts.Get("MSIscsiInitiator_TargetClass"
).SpawnInstance_(),
args = target.Methods_("Login").InParameters.SpawnInstance_(),
options = mgmts.Get("MSIscsiInitiator_TargetLoginOptions"
).SpawnInstance_();
target.TargetName = path;
target.Put_();
with ( portal ) {
Address = '10.0.0.100';
Port = 3260;
Index = 1;
SymbolicName = 'default';
Put_();
};
args.TargetPortal = portal;
args.IsPersistent = false;
with ( options ) {
HeaderDigest = 1; // CRC32C
DataDigest = 1; // CRC32C
AuthType = 1; // CHAP
Username = login.split('');
Password = passwd.split('');
InformationSpecified = 0xE3; // 227 = 11100011 !! 0x67 = 1100111
if ( ! ( login && passwd ) ) {
AuthType = 0;
// 0000011;
InformationSpecified = InformationSpecified ^ 0x03;
};
DefaultTime2Retain = 0;
DefaultTime2Wait = 0;
LoginFlags = 10; // 1010
MaximumConnections = 0;
Version = 0;
};
args.LoginOptions = options;
return target.ExecMethod_("Login", args); // <- this line fails
}
using like this:
login('iqn.2004-04.com.qnap:ts-859proplus:iscsi.test.c620aa',
'test', 'verylongpassword');
What's wrong?
P.S: the same task with iscsicli.exe
var portal_parameter = '10.0.0.100 3260';
function login (path, login, passwd) {
shell.run('iscsicli AddTargetPortal' +
portal_parameter +
' * * * * * * * * * * * *',
0, true);
var auth = '1'; // CHAP
if ( ! ( login && passwd ) ) {
auth = '0'; // NO
login = '*';
passwd = '*';
};
shell.run('iscsicli LoginTarget ' +
path + ' T ' + // PNP
portal_parameter +
' * * * * 1 1 * * * ' +
login + ' ' + passwd + ' ' + auth + ' * 0',
0, true);
}
works (without result check), but I need WMI.