php – Design pattern where the backend and frontend code are in a file

Forgive me if this is a simple question but I couldn't find the answer for this anywhere online. What is the name of the design pattern in web development in which both the front-end and the back-end are integrated into a single file, with the back-end code that appears in line with the front-end code? end? Some examples:

$sql = "SELECT id, first, last FROM MyGuests";
$result = $conn->query($sql);

while($row = $result->fetch_assoc()) {
    echo "
id: ". $row("id") . " - ". $row("first"). " " . $row("last"); }

This is opposed to other design patterns such as web development driven by API or MVC.

Complements: Is there a WP add-on that accepts a reference code at the end of the purchase without discounting a product? And a real-time map locator?

Good day! I need your experience before making a purchase in accessories. I need TWO add-ons that achieve these two objectives: 1.) Electronic commerce that WILL ALLOW a special code (such as a coupon code BUT WILL NOT DISCOUNT the product). We need to track where it came from. We have affiliated stores that direct people to buy directly from us on our own website. We want to give a commission to the affiliated store that referred our product, etc., and we must track it respectfully with maximum integrity. This code represents your store where the reference was made. AND 2.) We need a store locator map on our website exactly as it appears here: https://www.acehardware.com/store-locator. Thanks everyone for your help. The technology gurus of my hosting company recommended me here.

How can I delete a final slash in this code?

I am using the Amasty Layered Navigation extension. In the past I added this line of code

 $matchedAlias = trim($matchedAlias, '/'); 

to the Router.php file in the extension. As they updated the extension, I can't add it to their previous location. The matchedAlias ​​variable no longer exists, so I need to trim something else. Does anyone know where I could try something here?

private function getSeoPartAndIdentifier($identifier, $request)
{
    $seoPart = '';
    $filterWord = $this->helper->getFilterWord();
    if ($filterWord) {
        if (strpos($identifier, '/' . $filterWord . '/') !== false) {
            $filterWordPosition = strpos($identifier, '/' . $filterWord . '/');
            $seoPart = substr(
                $identifier,
                $filterWordPosition + strlen('/' . $filterWord . '/')
            );
            $identifier = substr($identifier, 0, $filterWordPosition);
        } else {
            $this->checkSeoParams($request);
            $request->setMetaData(Data::SKIP_REQUEST_FLAG, true);
        }
    } else {
        $lastSlashPosition = strrpos($identifier, "/");
        $lastSlashPosition = ($lastSlashPosition === false) ? 0 : $lastSlashPosition;
        $seoPart = substr($identifier, $lastSlashPosition + 1);
        $identifier = substr($identifier, 0, $lastSlashPosition);
    }

    return ($seoPart, $identifier);
}

/**
 * @param $identifier
 * @param $request
 *
 * @return string
 */
private function removeSuffix($identifier, $request)
{
    if (trim($identifier, '/') && $this->getSeoSuffix()) {
        $suffixPosition = strrpos($identifier, $this->getSeoSuffix());

        if ($suffixPosition !== false
            && ($suffixPosition == strlen($identifier) - strlen($this->getSeoSuffix()))
        ) {
            $identifier = substr($identifier, 0, $suffixPosition);
            if (!$this->urlHelper->getAddSuffixSettingValue() && !$request->isAjax()) {
                $request->setMetaData(Data::SEO_REDIRECT_MISSED_SUFFIX_FLAG, true);
            }
        } elseif ($this->urlHelper->getAddSuffixSettingValue() && !$request->isAjax()) {
            $request->setMetaData(Data::SEO_REDIRECT_MISSED_SUFFIX_FLAG, true);
        }
    }

    return $identifier;
}

/**
 * @param RequestInterface $request
 * @param $identifier
 * @param array $params
 *
 * @return $this
 */
public function modifyRequest(RequestInterface $request, $identifier, $params = ())
{
    if (strlen($identifier)) {
        $request->setMetaData(Data::HAS_ROUTE_PARAMS, true);
        if ($this->isSuffixRemoved) {
            $identifier .= $this->getSeoSuffix();
        }

        $request->setPathInfo($identifier);
    }

    $request->setParams($params);
         $matchedAlias = trim($matchedAlias, '/');
    $request->setMetaData(Data::HAS_PARSED_PARAMS, true);

    return $this;
}

Java: I have completed a coding challenge for beginners, but I feel that my code is unnecessarily complicated

I am starting to learn programming. I had already coded some functions and other things in other languages, and when trying to complete this Python challenge

View post on imgur.com

I switched to Java.

I initially wanted to start learning Python, but the company where I just started an apprenticeship uses almost exclusively Java, so I thought I could also learn that language.

I tried to complete it using mainly trial and error and some google, I have not seen many guides so far, so find out what I need to code how it took me a few hours. Now my code basically does what it is supposed to do, but I feel that it is written unnecessarily complicated and could be much shorter.

As I still have not really understood the scope and accessibility of the methods, I could not reuse the code as I would have liked and needed to rewrite a lot.

public static void main(String() args)
{
    System.out.println("Please enter a word");
    Scanner consoleInput = new Scanner(System.in);
    String userInput = consoleInput.nextLine(); 



    System.out.println(GetVowels(userInput).size() + " words starting with wovels: " + GetVowels(userInput));
    System.out.println(GetConsonants(userInput).size() + " words starting with consonants: " + GetConsonants(userInput));
}

 static ArrayList GetVowels(String userInput){ 
    char() vowels = "aeiou".toCharArray(); 
    ArrayList possibleWords = new ArrayList(); 

    for(int i = 0; i < vowels.length; i++){ 
        int offset = 0; 
        while(userInput.indexOf(vowels(i), offset) >= 0){ 
            int wordStartingIndex = userInput.indexOf(vowels(i), offset); 
            for (int u = wordStartingIndex; u <= userInput.length(); u++)  
            {
                String maybeAWord = userInput.substring(wordStartingIndex, u); 
                if(maybeAWord.length() > 0 && possibleWords.indexOf(maybeAWord) < 0) 
                {
                    possibleWords.add(maybeAWord); 
                }
            }
            offset = userInput.indexOf(vowels(i), offset) +1; 
        }
    }
  return possibleWords;

}


static ArrayList GetConsonants(String userInput){
    char() vowels = "aeiou".toCharArray();
    ArrayList possibleWords = new ArrayList();
    ArrayList vowelIndexes = new ArrayList();
    ArrayList consonantIndexes = new ArrayList();


    for(int i = 0; i < vowels.length; i++) { 
        int offset = 0;
        while (userInput.indexOf(vowels(i), offset) >= 0)
        {
            vowelIndexes.add(userInput.indexOf(vowels(i), offset));
            offset = userInput.indexOf(vowels(i), offset) + 1;
        }

    }

    for(int i = 0; i < userInput.length(); i++)
    {
        if(vowelIndexes.indexOf(i) < 0)
        {
            int wordStartingIndex = i;
            int offset = wordStartingIndex;

            while(offset <= userInput.length())
            {
                String maybeAWord = userInput.substring(wordStartingIndex, offset);
                if(maybeAWord.length() > 0 && possibleWords.indexOf(maybeAWord) < 0)
                {
                   possibleWords.add(maybeAWord);
                }
                offset = offset + 1;
            }

        }

    }
    return possibleWords;
}

I absolutely do not expect anyone to rewrite part of my code in a more compact or efficient way, but I would appreciate some advice or suggestions on what I could write differently, how I could reuse some of the code I had to write several times, or just things that I should avoid in the future.

Thanks in advance!

How to make a certain piece of Javascript code on a certain website?

So, this was something I saw. This website YT -> MP3 had a bookmark that only Allow the bookmark to run only on the YouTube website. Then, I would download the MP3. I was wondering, could I do that and send data to another website? For example, if you were at www.microsoft.com, you could click on the bookmark and search for Google data related to Microsoft.

Issuance code of income statements

In V10 we can associate code with the utility of issuing receipts through the UtilEmissaoRecibos class. Can we do the same on the tax return screen?

php – code that appears as text

I am trying to insert a table but when I add it I get my code as text but it works hahaha.

Does anyone know what's wrong with my code that I can't find?

session_start ();

include & # 39; mysql_connect.php & # 39 ;;

include & # 39; season_info.php & # 39 ;;

if ($ _SESSION (& # 39; HoopsUser & # 39;)! = NULL)

{

if (isset($_GET('Sort')))

    {

        $sort = $_GET('Sort');

        if ($sort == 'Age')

        {

            $age = 'Age_Asc';

        }

        else

        {

            $age = 'Age';

        }

    }

    if (isset($_GET('Position')))

    {

        $position = $_GET('Position');

        $and = '&Position='.$position.'';

        {

            if ($position == 'Draft')

            {       



                $and = '&Position='.$position.'';

            }

            else if ($position == 'FA')

            {       



                $and = '&Position='.$position.'';

            }

            else if ($position == 'Prev')

            {       



            }

            else if ($position == 1)

            {



            }

            else if ($position == 2)

            {



            }

            else if ($position == 3)

            {



            }

            else if ($position == 4)

            {


            }

            else if ($position == 5)

            {



            }

        }

    }

    else

    {



    }

    echo '


        

    

' . "n";



$sql = 'SELECT *, freeagencycoach.ID AS ID FROM freeagencycoach INNER JOIN Staff ON freeagencycoach.Player = Staff.ID WHERE CurrentTeam = 0 AND User = ''.$_SESSION('HoopsUser').'' AND Year = '.$year.' AND Years > 0 AND Amount > 0';

$result = mysql_query($sql) or die(mysql_error());

$count = mysql_num_rows($result);

if ($count > 0)

{

    echo '

    
' . "n"; } while ($row = mysql_fetch_assoc($result)) { $player = '' . $row('Name') . ''; if (0 == ($x++ & 1)) { $sClass = 'odd'; } else { $sClass = 'even'; } $sql2 = 'SELECT Player, Pos FROM ContractRequests WHERE ID = '.$row('Player').''; $result2 = mysql_query($sql2) or die(mysql_error()); while ($row2 = mysql_fetch_assoc($result2)) { $player = '' . $row2('Player') . ', ' . $row2('Pos'); } if ($row('Years') == 99) { $contract = 'Max offer'; } else if ($row('Amount') == 0) { $contract = 'Min offer'; } else { $contract = '$'.number_format($row('Amount')).'/'.$row('Years').' yr(s)'; } echo ' ' . "n"; } if ($count > 0) { echo '
Current Offers
PLAYER OFFER CANCEL
'.$player.' '.$contract.' Withdraw
' . "n"; } if (isset($_GET('Position'))) { if ($_GET('Position') == 'Prev') { $prev_year = $year - 1; $where = 'INNER JOIN SeasonStats ON SeasonStats.ID = Player.ID WHERE SeasonStats.Season = '.$prev_year.' AND SeasonStats.Team = ''.$_SESSION('HoopsTeam').'' AND CurrentTeam = 'FA''; } else { $where = 'WHERE CurrentTeam = 'FA' AND PositionNumber = '.$_GET('Position').''; } } else { $where = 'WHERE CurrentTeam = 'FA''; } if (isset($_GET('Sort'))) { $sort = $_GET('Sort'); if ($sort == 'Age_Asc') { $sort = 'Player.Age'; $by = ''; } else if ($sort == 'FutureRating') { $sort = 'FutureRating'; $by = ''; } else if ($sort == 'Age') { $sort = 'Player.Age'; $by = 'DESC'; } else { $by = 'DESC'; } } else { $sort = 'Overall'; $by = 'DESC'; } { $rank++; $name = $row('FirstName') . ". " . $row('LastName'); $id = $row('ID'); $team = ''.$row('Abbr').''; $pos = $row('PositionNumber'); if ($row('PositionNumber') == 1) { $pos = 'C'; } else if ($row('PositionNumber') == 2) { $pos = 'PF'; } else if ($row('PositionNumber') == 3) { $pos = 'SF'; } else if ($row('PositionNumber') == 4) { $pos = 'SG'; } else if ($row('PositionNumber') == 5) { $pos = 'PG'; } $age = $row('Age'); $exp = $row('Experience'); $ovr = number_format($row('Overall'),0); $inches = $row('Height'); $ft = floor($inches/12); $in = $inches % 12; $ht = $ft . ''' . $in . '"'; $wt = $row('Weight'); $ins = $row('InsideScoring'); $jps = $row('JumpShot'); $ft = $row('FreeThrowShot'); $tp = $row('ThreePointShot'); $pas = $row('Passing'); $hnd = $row('Handling'); $orb = $row('OffensiveRebounding'); $drb = $row('DefensiveRebounding'); $psd = $row('PostDefense'); $prd = $row('PerimeterDefense'); $stl = $row('Stealing'); $blk = $row('ShotBlocking'); $jmp = $row('Jumping'); $qkn = $row('Quickness'); $sth = $row('Strength'); $sta = $row('Stamina'); $ovr = number_format($row('Overall'),0); $fut = $row('FutureRating'); if ($row('BirdYears') >= 3 && $_GET('Position') == 'Prev') { $bird_rights = 'BIRD'; } else { $bird_rights = ''; } if ($sort == 'Player.Age') { $class1 = ' class="sort_bold"'; } if ($sort == 'Overall') { $class2 = ' class="sort_bold"'; } if ($sort == 'InsideScoring') { $class3 = ' class="sort_bold"'; } if ($sort == 'JumpShot') { $class4 = ' class="sort_bold"'; } if ($sort == 'FreeThrowShot') { $class5 = ' class="sort_bold"'; } if ($sort == 'ThreePointShot') { $class6 = ' class="sort_bold"'; } if ($sort == 'Handling') { $class7 = ' class="sort_bold"'; } if ($sort == 'Passing') { $class8 = ' class="sort_bold"'; } if ($sort == 'OffensiveRebounding') { $class9 = ' class="sort_bold"'; } if ($sort == 'DefensiveRebounding') { $class10 = ' class="sort_bold"'; } if ($sort == 'PostDefense') { $class11 = ' class="sort_bold"'; } if ($sort == 'PerimeterDefense') { $class12 = ' class="sort_bold"'; } if ($sort == 'Stealing') { $class13 = ' class="sort_bold"'; } if ($sort == 'ShotBlocking') { $class14 = ' class="sort_bold"'; } if ($sort == 'Quickness') { $class15 = ' class="sort_bold"'; } if ($sort == 'Strength') { $class16 = ' class="sort_bold"'; } if ($sort == 'Jumping') { $class17 = ' class="sort_bold"'; } if ($sort == 'Stamina') { $class18 = ' class="sort_bold"'; } // InsideScoring*0.3+JumpShot*0.09+ThreePointShot*1.5+Handling*0.2+Passing*2+OffensiveRebounding*4+DefensiveRebounding*4+PostDefense+PerimeterDefense*3+Stealing+ShotBlocking*0.8+Quickness*0.7+Jumping*0.5+Strength if (0 == ($i++ & 1)) { $sClass = 'odd'; } else { $sClass = 'even'; } if ($sort == 'Player.Age') { $sort = 'Age'; } if ($row(''.$sort.'') != $last_stat) { $last_stat = $row(''.$sort.''); $rank = $i; } else { $rank = ' '; } echo ' '; if ($i % 20 == 0 && $i != 100 && $i != 250) { echo ' PLAYER AGE EXP CUR POT OVR INS JPS FT 3PS HND PAS ORB DRB PSD PRD STL BLK QKN STR JMP '; } } echo '
'; if ($_SESSION('HoopsUser') == 'admin') { echo $sql; }

}

another thing

{

$redirect = urlencode($_SERVER('REQUEST_URI'));

echo "";

echo '

Access Restricted
You must be logged in to access this page!

';

}

webforms – patch method sample code REST API

I am working on web services in drupal. I have created a sample module to obtain the method to expose the data through web services. I have not found any sample code for the patch method.
code to get the method:

namespace Drupaldemo_rest_apiPluginrestresource;

use DrupalrestPluginResourceBase;
use DrupalrestResourceResponse;

class DemoResource extends ResourceBase {

}
/**
 * Provides a Demo Resource
 *
 * @RestResource(
 *   id = "demo_resource",
 *   label = @Translation("Demo Resource"),
 *   uri_paths = {
 *     "canonical" = "/demo_rest_api/demo_resource"
 *   }
 * )
 */
class DemoResource extends ResourceBase {

}
/**
 * Provides a Demo Resource
 *
 * @RestResource(
 *   id = "demo_resource",
 *   label = @Translation("Demo Resource"),
 *   uri_paths = {
 *     "canonical" = "/demo_rest_api/demo_resource"
 *   }
 * )
 */
class DemoResource extends ResourceBase {

  /**
   * Responds to entity GET requests.
   * @return DrupalrestResourceResponse
   */
  public function get() {
    $response = ('message' => 'Hello, this is a rest service');
    return new ResourceResponse($response);
  }
}

I am new to drupal. I didn't find any examples for the patch method. Can anyone advertise or provide a sample code for the patch method?

PD: I didn't find any tags for web services.

Thanks in advance

What's wrong with this code (Multiple left union plus total union)? SQL ORACLE

When I fire this code, SQL returns the following error: ANY or ALL is required.

The code consists of a union of two tables made of the union of three tables.

The code:

SELECT DATE_BASE, LSCRV, ACTIVO, SUM(IMP_CMA) AS CREDIT, 
SUM(LIMIT) AS CONTADO, SUM(LIMIT_AVG_DISPO) AS 
LIMIT_AVG_DISPO, COUNT(*) AS CLIENTS
FROM
(
SELECT L.DATE_BASE, L.LSCRV,
CASE WHEN C.POSIC_ACTUAL = ('010','011','015') AND C.PRODUCT = 
('M','R') AND C.SAL_CLIENT > 0 THEN 1
WHEN C.PRODUCT = 'P' AND P.FCH_FINAN >= TO_CHAR(ADD_MONTHS(SYSDATE,-6), 
'YYYYMM') THEN 1
ELSE 0 END AS ACTIVOS,
C.IMP_CMA, C.LIMIT, C.LIMIT/NULLIF(C.IMP_CMA,0) AS 
LIMIT_AVG_DISPO
FROM L_SCRV L LEFT JOIN N5 C
ON SUBSTR(L.CLIENT, 1, 12) = C.CLIENT
LEFT JOIN OPE_DAY P ON L.CLIENT = TO_CHAR(P.CONTRACT, 1, 12)  
UNION ALL 
SELECT L.DATE_BASE, L.LSCRV, 
CASE WHEN C.POSIC_ACTUAL = ('010','011','015') and C.PRODUCT = 
('M','R') AND C.SAL_CLIENT > 0 THEN 1
WHEN C.PRODUCT = 'P' AND P.FCH_FINAN >= 
TO_CHAR(ADD_MONTHS(SYSDATE,-6),'YYYYMM') THEN 1
ELSE 0 END AS ACTIVOS, 
C.IMP_CMA, C.LIMIT, LIMIT/NULLIF(IMP_CMA,0) AS LIMIT_AVG_DISPO
FROM L_SCRV_H L LEFT JOIN 5H C
ON SUBSTR(L.CLIENT, 1, 12) = C.CLIENT AND L.DATE_BASE = 
TO_CHAR(C.DATE_BASE,'YYYYMM')
LEFT JOIN OPE_DAY P ON L.CLIENT = TO_CHAR(P.CONTRACT, 1, 12)
WHERE L.DATE_BASE >= '201601' AND TO_CHAR(C.DATE_BASE,'YYYYMM') >= 
'201601'
)
GROUP BY DATE_BASE, LSCRV, ACTIVO
ORDER BY DATE_BASE, LSCRV

What happens

Sorry if it is a fundamental mistake. Im new coding in SQL.

Thanks for the help!

object-oriented – Calculate the first n cousins: a revised Clean Code example for C ++

I am trying to improve the examples of Clean code* while being redeployed in C ++. This time is the example of the main Sieve of Eratosthenes computing on pages 71-74.

Below is the original adapted for C ++, without improvements:

.h

class PrimeGenerator { 
public:
    PrimeGenerator() = default;
    ~PrimeGenerator() = default;

    static std::vector generatePrimes(unsigned maxValue);

private:
    static void uncrossIntegersUpTo(unsigned maxValue);
    static void crossOutMultiples();
    static unsigned determineIterationLimit();
    static void crossOutMultiplesOf(unsigned i);
    static bool notCrossed(unsigned i);
    static void putUncrossedIntegersIntoResult();
    static unsigned numberOfUncrossedIntegers();

    static std::vector crossedOut;
    static std::vector result; 
};

.cpp

std::vector PrimeGenerator::crossedOut;
std::vector PrimeGenerator::result;

std::vector PrimeGenerator::generatePrimes(unsigned maxValue)
{
    if (maxValue < 2)
        return {};

    uncrossIntegersUpTo(maxValue);
    crossOutMultiples();
    putUncrossedIntegersIntoResult();
    return result;
}

void PrimeGenerator::uncrossIntegersUpTo(unsigned maxValue)
{
    crossedOut = std::vector(maxValue + 1, false);
    crossedOut(0) = true;
    crossedOut(1) = true;
}

void PrimeGenerator::crossOutMultiples()
{
    unsigned limit = determineIterationLimit();
    for (size_t i = 2; i <= limit; ++i)
    {
        if (notCrossed(i))
            crossOutMultiplesOf(i);
    }
}

unsigned PrimeGenerator::determineIterationLimit()
{
    // Every multiple in the array has a prime factor that
    // is less than or equal to the root of the array size,
    // so we don't have to cross out multiples of numbers
    // larger than that root.
    double iterationLimit = std::sqrt(crossedOut.size());
    return static_cast(iterationLimit);
}

void PrimeGenerator::crossOutMultiplesOf(unsigned i)
{
    for (size_t multiple = 2 * i; multiple < crossedOut.size(); multiple += i)
    {
        crossedOut(multiple) = true;
    }
}

bool PrimeGenerator::notCrossed(unsigned i)
{
    return !crossedOut(i);
}

void PrimeGenerator::putUncrossedIntegersIntoResult()
{
    result = std::vector(numberOfUncrossedIntegers());
    size_t j = 0;
    for (size_t i = 2; i < crossedOut.size(); ++i)
    {
        if (notCrossed(i))
            result(j++) = i;
    }
}

unsigned PrimeGenerator::numberOfUncrossedIntegers()
{
    unsigned count = 0;
    for (size_t i = 2; i < crossedOut.size(); ++i)
    {
        if (notCrossed(i))
            count++;
    }

    return count;
}

What we see here is a static class with static functions and members. We don't like these in C ++, so it seems that this code could best serve with a namespace and some free features. Let's try: my attempt at improvement comes next.

.h

namespace PrimeGenerator
{
    std::vector generatePrimes(unsigned maxValue);
}

.cpp

namespace {

std::vector uncrossIntegersUpTo(int maxValue)
{
    std::vector crossedOut(maxValue + 1, false);
    crossedOut(0) = true;
    crossedOut(1) = true;

    return crossedOut;
}

unsigned determineIterationLimit(size_t size)
{
    // Every multiple in the array has a prime factor that
    // is less than or equal to the root of the array size,
    // so we don't have to cross out multiples of numbers
    // larger than that root.
    double iterationLimit = std::sqrt(size);
    return static_cast(iterationLimit);
}

void crossOutMultiplesOf(unsigned i, std::vector& crossedOut)
{
    for (size_t multiple = 2 * i; multiple < crossedOut.size(); multiple += i)
    {
        crossedOut(multiple) = true;
    }
}

void crossOutMultiples(std::vector& crossedOut)
{
    unsigned limit = determineIterationLimit(crossedOut.size());
    for (size_t i = 2; i <= limit; ++i)
    {
        if (!crossedOut(i))
            crossOutMultiplesOf(i, crossedOut);
    }
}

std::vector putUncrossedIntegersIntoResult(const std::vector& crossedOut)
{
    std::vector result;
    for (size_t i = 2; i < crossedOut.size(); ++i)
    {
        if (!crossedOut(i))
            result.push_back(i);
    }

    return result;
}

}

namespace PrimeGenerator {

std::vector generatePrimes(unsigned maxValue)
{
    if (maxValue < 2)
        return {};

    auto crossedOut = uncrossIntegersUpTo(maxValue);
    crossOutMultiples(crossedOut);
    return putUncrossedIntegersIntoResult(crossedOut);
}

}

A quick summary of the changes:
- I deleted the class, leaving a single interface function in a PrimeGenerator namespace
- The numberOfUncrossedIntegers() the function didn't seem to make much sense, so I refactor putUncrossedIntegersIntoResult(...) Get rid of the first.
- notCrossed(...) Now I would need to have two parameters, so it stopped making sense either. He is gone now.

Now, I have two questions about my code. First, now we have to pass the crossedOut Vector around, which is a disadvantage compared to the previous design. Would you propose an alternative solution to mitigate this? Second, is there any additional place where I should have used size_t instead of unsigned?

Cheers!


* * Clean code: an agile software craft manualRobert C. Martin