Пример #1
0
 /**
  * Custom install method
  * @param boolean True if installing from directory
  */
 function install($p_fromdir = null)
 {
     josSpoofCheck();
     global $mosConfig_absolute_path, $database;
     if (!$this->preInstallCheck($p_fromdir, 'mambot')) {
         return false;
     }
     $xmlDoc = $this->xmlDoc();
     $mosinstall =& $xmlDoc->documentElement;
     // Set some vars
     $e =& $mosinstall->getElementsByPath('name', 1);
     $this->elementName($e->getText());
     $folder = $mosinstall->getAttribute('group');
     $this->elementDir(mosPathName($mosConfig_absolute_path . '/mambots/' . $folder));
     if (!file_exists($this->elementDir()) && !mosMakePath($this->elementDir())) {
         $this->setError(1, 'Failed to create directory "' . $this->elementDir() . '"');
         return false;
     }
     if ($this->parseFiles('files', 'mambot', 'Não existem arquivos definidos como Plugin') === false) {
         return false;
     }
     // Insert mambot in DB
     $query = "SELECT id" . "\n FROM #__mambots" . "\n WHERE element = " . $database->Quote($this->elementName());
     $database->setQuery($query);
     if (!$database->query()) {
         $this->setError(1, 'Erro SQL: ' . $database->stderr(true));
         return false;
     }
     $id = $database->loadResult();
     if (!$id) {
         $row = new mosMambot($database);
         $row->name = $this->elementName();
         $row->ordering = 0;
         $row->folder = $folder;
         $row->iscore = 0;
         $row->access = 0;
         $row->client_id = 0;
         $row->element = $this->elementSpecial();
         if ($folder == 'editors') {
             $row->published = 1;
         }
         if (!$row->store()) {
             $this->setError(1, 'Erro SQL: ' . $row->getError());
             return false;
         }
     } else {
         $this->setError(1, 'O plugin "' . $this->elementName() . '" já existe!');
         return false;
     }
     if ($e =& $mosinstall->getElementsByPath('description', 1)) {
         $this->setError(0, $this->elementName() . '<p>' . $e->getText() . '</p>');
     }
     return $this->copySetupFile('front');
 }
Пример #2
0
 /**
  * Custom install method
  * @param boolean True if installing from directory
  */
 function install($p_fromdir = null)
 {
     global $mosConfig_absolute_path, $database;
     if (!$this->preInstallCheck($p_fromdir, 'mambot')) {
         return false;
     }
     $xml = $this->xmlDoc();
     $mosinstall =& $xml->documentElement;
     // Set some vars
     $e =& $xml->getElementsByPath('name', 1);
     $this->elementName($e->getText());
     $folder = $mosinstall->getAttribute('group');
     $this->elementDir(mosPathName($mosConfig_absolute_path . '/mambots/' . $folder));
     //if(!file_exists($this->elementDir()) && !mkdir($this->elementDir(),0777)) {
     if (!file_exists($this->elementDir()) && !mkdir($this->elementDir(), 0777)) {
         $this->setError(1, 'Failed to create directory "' . $this->elementDir() . '"');
         return false;
     }
     if ($this->parseFiles('files', 'mambot', 'No file is marked as mambot file') === false) {
         return false;
     }
     // Insert in module in DB
     $database->setQuery("SELECT id FROM #__mambots WHERE element = '" . $this->elementName() . "'");
     if (!$database->query()) {
         $this->setError(1, 'SQL error: ' . $database->stderr(true));
         return false;
     }
     $id = $database->loadResult();
     if (!$id) {
         $row = new mosMambot($database);
         $row->name = $this->elementName();
         $row->ordering = 0;
         $row->folder = $folder;
         $row->iscore = 0;
         $row->access = 0;
         $row->client_id = 0;
         $row->element = $this->elementSpecial();
         if (!$row->store()) {
             $this->setError(1, 'SQL error: ' . $row->getError());
             return false;
         }
     } else {
         $this->setError(1, 'Mambot "' . $this->elementName() . '" already exists!');
         return false;
     }
     if ($e =& $xml->getElementsByPath('description', 1)) {
         $this->setError(0, $this->elementName() . '<p>' . $e->getText() . '</p>');
     }
     return $this->copySetupFile('front');
 }
Пример #3
0
/**
* changes the access level of a record
* @param integer The increment to reorder by
*/
function accessMenu($uid, $access, $option, $client)
{
    global $database;
    switch ($access) {
        case 'accesspublic':
            $access = 0;
            break;
        case 'accessregistered':
            $access = 1;
            break;
        case 'accessspecial':
            $access = 2;
            break;
    }
    $row = new mosMambot($database);
    $row->load($uid);
    $row->access = $access;
    if (!$row->check()) {
        return $row->getError();
    }
    if (!$row->store()) {
        return $row->getError();
    }
    mosRedirect('index2.php?option=' . $option);
}
Пример #4
0
function installBots_11x()
{
    global $database;
    $error = '';
    $return = '<b>' . _ACA_INSTALL_BOT . '</b> : ';
    if (!is_dir(ACA_JPATH_ROOT . '/mambots/acajoom')) {
        if (!@mkdir(ACA_JPATH_ROOT . '/mambots/acajoom', 0755)) {
            $return .= '<br /> Error adding bot directory.';
        } else {
            @chmod(ACA_JPATH_ROOT . '/mambots/acajoom', 0755);
        }
    }
    $bot_files = array('acajoombot.php', 'acajoombot.xml', 'index.html');
    foreach ($bot_files as $bot_file) {
        if (is_file(ACA_JPATH_ROOT . '/mambots/acajoom/' . $bot_file)) {
            @unlink(WPATH_ADMIN . 'bots/' . $bot_file);
        } else {
            if (!@rename(WPATH_ADMIN . 'bots/' . $bot_file, ACA_JPATH_ROOT . '/mambots/acajoom/' . $bot_file)) {
                $error .= '<br />Error copying bot file ' . $bot_file . ' to bot directory.';
            }
        }
    }
    @chmod(ACA_JPATH_ROOT . '/mambots/acajoom', 0755);
    if (!@rmdir(WPATH_ADMIN . 'bots/')) {
        $error .= '<br /> Error deleting the temporary bot directory.';
    }
    ### Acajoom bot
    $bot_infos = array('Acajoom Content Bot', 'acajoombot');
    foreach ($bot_infos as $bot_info) {
        $query = "SELECT `id` FROM `#__mambots` WHERE `element` = 'acajoombot'";
        $database->setQuery($query);
        $database->query();
        $error .= $database->getErrorMsg();
        if (!empty($error)) {
            $error .= '<br /> Error getting bot information from bot table for "' . $bot_info[0] . '". Database error: <br />' . $error . '<br />';
        } else {
            $id = $database->loadResult();
            if (!$id) {
                $row = new mosMambot($database);
                $row->name = $bot_infos[0];
                $row->ordering = 0;
                $row->folder = 'acajoom';
                $row->iscore = 0;
                $row->access = 0;
                $row->client_id = 0;
                $row->element = $bot_infos[1];
                $row->published = 1;
                if (!$row->store()) {
                    $error .= '<br />Error adding bot information to bot table for "' . $bot_info[0] . '".';
                }
            }
        }
    }
    if (empty($error)) {
        $return .= acajoom::printM('green', _ACA_INSTALL_SUCCESS) . '<br />';
    } else {
        $return .= $error . acajoom::printM('red', _ACA_INSTALL_ERROR) . '<br />';
    }
    return $return;
}
Пример #5
0
function saveOrder(&$cid)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    $row = new mosMambot($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // if
            // remember to updateOrder this group
            $condition = "folder = " . $database->Quote($row->folder) . " AND ordering > -10000 AND ordering < 10000 AND client_id = " . (int) $row->client_id;
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            // if
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
        // if
    }
    // for
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // foreach
    $msg = 'Nova ordenação salva';
    mosRedirect('index2.php?option=com_mambots', $msg);
}