Issues (103)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

includes/admin/views/analytics-stats.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Define vars
4
 */
5
$datas = array();
6
$seen  = array();
7
$query = array( 'data_type' => 'any', 'limit' => -1 );
8
9
/* Select a specific popup */
10
if( 'all' != $show ) {
11
	$query['popup_id'] = intval( $show );
12
}
13
14
switch( $period ) {
15
16
	case 'today':
17
		$timeframe = strtotime( 'today' );
18
	break;
19
20
	case 'this_week':
21
22
		$timeframe = array(
23
			'from' => strtotime( 'last monday', time() ),
24
			'to'   => strtotime( 'next sunday', time() )
25
		);
26
27
	break;
28
29
	case 'last_week':
30
31
		$timeframe = array(
32
			'from' => strtotime( 'last monday -1 week' ),
33
			'to'   => strtotime( 'next sunday -1 week' )
34
		);
35
36
	break;
37
38
	case 'this_month':
39
40
		$timeframe = array(
41
			'from' => strtotime( 'first day of this month', time() ),
42
			'to'   => strtotime( 'last day of this month', time() )
43
		);
44
45
	break;
46
47
	case 'last_month':
48
49
		$timeframe = array(
50
			'from' => strtotime( 'first day of last month', time() ),
51
			'to'   => strtotime( 'last day of last month', time() )
52
		);
53
54
	break;
55
56
	case 'this_quarter':
57
58
		$quarters = array( 1, 4, 7, 10 );
59
		$month    = intval( date( 'm' ) );
60
61 View Code Duplication
		if( in_array( $month, $quarters ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
			$current = date( 'Y-m-d', time() );
63
		} else {
64
65
			/* Get first month of this quarter */
66
			while( !in_array( $month, $quarters) ) {
67
				$month = $month-1;
68
			}
69
70
			$current = date( 'Y' ) . '-' . $month . '-' . '01';
71
72
		}
73
74
		$current = strtotime( $current );
75
76
		$timeframe = array(
77
			'from' => strtotime( 'first day of this month', $current ),
78
			'to'   => strtotime( 'last day of this month', strtotime( '+2 months', $current ) )
79
		);
80
81
	break;
82
83
	case 'last_quarter':
84
85
		$quarters = array( 1, 4, 7, 10 );
86
		$month    = intval( date( 'm' ) ) - 3;
87
		$rewind   = false;
88
89 View Code Duplication
		if( in_array( $month, $quarters ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
			$current = date( 'Y-m-d', time() );
91
		} else {
92
93
			/* Get first month of this quarter */
94
			while( !in_array( $month, $quarters) ) {
95
96
				$month = $month-1;
97
98
				/* Rewind to last year after we passed January */
99
				if( 0 === $month )
100
					$month = 12;
101
			}
102
103
			$current = date( 'Y' ) . '-' . $month . '-' . '01';
104
105
		}
106
107
		/* Set the theorical current date */
108
		$current = false === $rewind ? strtotime( $current ) : strtotime( '-1 year', $current );
109
110
		$timeframe = array(
111
			'from' => strtotime( 'first day of this month', $current ),
112
			'to'   => strtotime( 'last day of this month', strtotime( '+2 months', $current ) )
113
		);
114
115
	break;
116
117
	case 'this_year':
118
119
		$timeframe = array(
120
			'from' => strtotime( 'first day of January', time() ),
121
			'to'   => strtotime( 'last day of December', time() )
122
		);
123
124
	break;
125
126
	case 'last_year':
127
128
		$timeframe = array(
129
			'from' => strtotime( 'first day of January last year', time() ),
130
			'to'   => strtotime( 'last day of December last year', time() )
131
		);
132
133
	break;
134
135
}
136
137
/* Set the period */
138
$query['period'] = $timeframe;
139
140
/* Get the datas */
141
$datas = wpbo_db_get_datas( $query, 'OBJECT' );
142
?>
143
<div class="postbox">
144
145
	<!-- <h3><span>Conversion Statistics per Popup</span></h3> -->
146
	<div class="inside-no-padding">
147
148
		<table class="form-table" id="wpbo-stats-general" data-timeframe="<?php echo htmlspecialchars( serialize( $timeframe ) ); ?>" data-popup="<?php echo $show; ?>" data-period="<?php echo $period; ?>">
149
			<thead>
150
				<tr>
151
					<th class="row-title"><?php _e( 'Popup Name', 'betteroptin' ); ?></th>
152
					<th><?php _e( 'Impressions', 'betteroptin' ); ?></th>
153
					<th><?php _e( 'Conversions', 'betteroptin' ); ?></th>
154
					<th><?php _e( '% Conversion', 'betteroptin' ); ?></th>
155
					<th><?php _e( 'Status', 'betteroptin' ); ?></th>
156
					<th data-bSortable="false"><?php _e( 'Settings', 'betteroptin' ); ?></th>
157
				</tr>
158
			</thead>
159
			<tbody>
160
				<?php
161
				if( is_array( $datas ) ) {
162
163
					foreach( $datas as $key => $data ) {
164
165
						if( in_array( $data->popup_id, $seen ) )
166
							continue;
167
168
						/* Mark this popup as parsed */
169
						array_push( $seen, $data->popup_id );
170
171
						$popup        = get_post( $data->popup_id );
172
						$impressions  = wpbo_db_get_datas( array( 'popup_id' => $data->popup_id, 'data_type' => 'impression', 'limit' => -1, 'period' => $timeframe ), 'ARRAY_A' );
173
						$conversions  = wpbo_db_get_datas( array( 'popup_id' => $data->popup_id, 'data_type' => 'conversion', 'limit' => -1, 'period' => $timeframe ), 'ARRAY_A' );
174
						$rate         = ( 0 === count( $conversions ) || 0 === count( $impressions ) ) ? 0 : ( 100 * count( $conversions ) ) / count( $impressions );
175
						$status       = 'publish' == $popup->post_status ? __( 'Active', 'betteroptin' ) : __( 'Inactive', 'betteroptin' );
176
						$status_class = 'publish' == $popup->post_status ? 'wpbo-stats-active' : 'wpbo-stats-inactive';
177
178
						/* Increment the global vars */
179
						$total_impressions = $total_impressions + count( $impressions );
180
						$total_conversions = $total_conversions + count( $conversions );
181
						?>
182
183
						<tr valign="top">
184
							<td scope="row"><a href="<?php echo add_query_arg( array( 'post' => $data->popup_id, 'action' => 'edit' ), admin_url( 'post.php' ) ); ?>"><?php echo $popup->post_title; ?></a> <em>(#<?php echo $data->popup_id; ?>)</em></td>
185
							<td><?php echo number_format( count( $impressions ), 0 ); ?></td>
186
							<td><?php echo number_format( count( $conversions ), 0 ); ?></td>
187
							<td><?php echo number_format( $rate, 2 ); ?>% <!-- <span class="wpbo-stats-variation">&#9660;</span> --></td>
188
							<td><span class="<?php echo $status_class; ?>"><?php echo $status; ?></span></td>
189
							<td><a href="<?php echo add_query_arg( array( 'post' => $data->popup_id, 'action' => 'edit' ), admin_url( 'post.php' ) ); ?>" class="button-secondary"><?php _e( 'Settings', 'betteroptin' ); ?></a></td>
190
						</tr>
191
192
					<?php }
193
194
				}
195
				?>
196
			</tbody>
197
		</table>
198
	</div> <!-- .inside -->
199
</div> <!-- .postbox -->